import org.simantics.databoard.type.UnionType;
import org.simantics.databoard.type.VariantType;
import org.simantics.databoard.util.ObjectUtils;
+import org.simantics.datatypes.literal.GUID;
import org.simantics.db.ChangeSetIdentifier;
import org.simantics.db.Operation;
import org.simantics.db.ReadGraph;
return PrettyPrintTG.print(tg, ignoreIdentifiers);
}
+ /**
+ * Adds a random {@link GUID} as a value for <code>L0.identifier</code>
+ *
+ * @param graph
+ * @param component
+ * for which the identifier is added
+ * @throws DatabaseException
+ */
+ public static void addL0Identifier(WriteGraph graph, Resource component) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ graph.addLiteral(component, L0.identifier, L0.identifier_Inverse, L0.GUID, GUID.random(), GUID.BINDING);
+ }
}
Layer0 L0 = Layer0.getInstance(graph);
while(!todo.isEmpty()) {
Resource resource = todo.remove(todo.size()-1);
- graph.claimLiteral(resource, L0.identifier, L0.GUID, GUID.random(), GUID.BINDING);
+ Layer0Utils.addL0Identifier(graph, resource);
if(deep)
todo.addAll(graph.getObjects(resource, L0.ConsistsOf));
}
GUID existing = graph.getPossibleRelatedValue(r, L0.identifier, GUID.BINDING);
if(existing == null) {
- graph.addLiteral(r, L0.identifier, L0.identifier_Inverse, L0.GUID, GUID.random(), GUID.BINDING);
+ Layer0Utils.addL0Identifier(graph, r);
madeChanges = true;
}
import org.simantics.db.Resource;
import org.simantics.db.WriteGraph;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.util.Layer0Utils;
import org.simantics.diagram.synchronization.ISynchronizationContext;
import org.simantics.diagram.synchronization.SynchronizationException;
import org.simantics.diagram.synchronization.SynchronizationHints;
if (graph.hasStatement(sourceContainer, L0.ConsistsOf, source))
graph.claim(targetContainer, L0.ConsistsOf, copy);
- graph.claimLiteral(copy, L0.identifier, L0.identifier_Inverse, L0.GUID, GUID.random(), GUID.BINDING);
+ Layer0Utils.addL0Identifier(graph, copy);
if (context.get(SynchronizationHints.NO_RENAME) == null)
renameComponent(context, graph, source, copy, sourceContainer, targetContainer);
return copy;
import org.simantics.db.WriteGraph;
import org.simantics.db.common.utils.CommonDBUtils;
import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.util.Layer0Utils;
import org.simantics.layer0.Layer0;
import org.simantics.layer0.utils.direct.GraphUtils;
import org.simantics.mapping.constraint.instructions.TypedBracketInstruction.CreationInstruction;
Resource result = GraphUtils.create(g,
b.HasName, proposition
);
- g.addLiteral(result, b.identifier, b.identifier_Inverse, b.GUID, GUID.random(), GUID.BINDING);
+ Layer0Utils.addL0Identifier(g, result);
return result;
} catch (NamingException e1) {
throw new DatabaseException(e1);
for (Resource r : ids) {
if (!graph.hasStatement(r, L0.identifier)) {
CommonDBUtils.selectClusterSet(graph, r);
- graph.addLiteral(r, L0.identifier, L0.identifier_Inverse, L0.GUID, GUID.random(), GUID.BINDING);
+ Layer0Utils.addL0Identifier(graph, r);
}
}
Resource component = ir.perform(g);
g.claim(component, L0.HasName, Layer0Utils.literal(g, name));
g.claim(component, L0.HasLabel, Layer0Utils.literal(g, ""));
- g.addLiteral(component, L0.identifier, L0.identifier_Inverse, L0.GUID, GUID.random(), GUID.BINDING);
g.claim(parent, L0.ConsistsOf, component);
+ // Add identifier
+ Layer0Utils.addL0Identifier(g, component);
// Add comment to change set.
CommentMetadata cm = g.getMetadata(CommentMetadata.class);
g.addMetadata(cm.add("Created component " + component));