From: Tuukka Lehtonen Date: Mon, 3 Jul 2017 20:46:20 +0000 (+0300) Subject: Fixed changes made in commit 3a10ce85. X-Git-Tag: v1.31.0~278 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F75%2F675%2F2;p=simantics%2Fplatform.git Fixed changes made in commit 3a10ce85. refs #7339 Change-Id: Ib47a5eb67c83a716d82526a5f61c303d9e34f235 --- diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java index beec63aa1..3da57809a 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java @@ -1394,10 +1394,17 @@ public class Layer0Utils { * @param graph * @param component * for which the identifier is added + * @param add + * true to invoke addLiteral, false to + * invoke claimLiteral * @throws DatabaseException */ - public static void addL0Identifier(WriteGraph graph, Resource component) throws DatabaseException { + public static void claimNewIdentifier(WriteGraph graph, Resource component, boolean add) throws DatabaseException { Layer0 L0 = Layer0.getInstance(graph); - graph.addLiteral(component, L0.identifier, L0.identifier_Inverse, L0.GUID, GUID.random(), GUID.BINDING); + GUID guid = GUID.random(); + if (add) + graph.addLiteral(component, L0.identifier, L0.identifier_Inverse, L0.GUID, guid, GUID.BINDING); + else + graph.claimLiteral(component, L0.identifier, L0.identifier_Inverse, L0.GUID, guid, GUID.BINDING); } } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java index 753a90292..385947d0c 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java @@ -2260,7 +2260,7 @@ public class ModelingUtils { Layer0 L0 = Layer0.getInstance(graph); while(!todo.isEmpty()) { Resource resource = todo.remove(todo.size()-1); - Layer0Utils.addL0Identifier(graph, resource); + Layer0Utils.claimNewIdentifier(graph, resource, false); if(deep) todo.addAll(graph.getObjects(resource, L0.ConsistsOf)); } @@ -2291,7 +2291,7 @@ public class ModelingUtils { GUID existing = graph.getPossibleRelatedValue(r, L0.identifier, GUID.BINDING); if(existing == null) { - Layer0Utils.addL0Identifier(graph, r); + Layer0Utils.claimNewIdentifier(graph, r, true); madeChanges = true; } diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/ComponentCopyAdvisor.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/ComponentCopyAdvisor.java index 96aa3f134..6b4e59d17 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/ComponentCopyAdvisor.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/ComponentCopyAdvisor.java @@ -17,7 +17,6 @@ import java.util.Map; import org.simantics.Simantics; import org.simantics.databoard.Bindings; -import org.simantics.datatypes.literal.GUID; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.exception.DatabaseException; @@ -74,7 +73,7 @@ public class ComponentCopyAdvisor extends GraphCopyAdvisor { if (graph.hasStatement(sourceContainer, L0.ConsistsOf, source)) graph.claim(targetContainer, L0.ConsistsOf, copy); - Layer0Utils.addL0Identifier(graph, copy); + Layer0Utils.claimNewIdentifier(graph, copy, false); if (context.get(SynchronizationHints.NO_RENAME) == null) renameComponent(context, graph, source, copy, sourceContainer, targetContainer); return copy; diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/NamingCreationInstruction.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/NamingCreationInstruction.java index 3330587b9..0796e6879 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/NamingCreationInstruction.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/mapping/NamingCreationInstruction.java @@ -14,7 +14,6 @@ package org.simantics.modeling.mapping; import gnu.trove.map.hash.TIntIntHashMap; import gnu.trove.set.hash.TIntHashSet; -import org.simantics.datatypes.literal.GUID; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.common.utils.CommonDBUtils; @@ -55,7 +54,7 @@ public class NamingCreationInstruction extends CreationInstruction { Resource result = GraphUtils.create(g, b.HasName, proposition ); - Layer0Utils.addL0Identifier(g, result); + Layer0Utils.claimNewIdentifier(g, result, true); return result; } catch (NamingException e1) { throw new DatabaseException(e1); diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/utils/OntologicalRequirementEnforceRequest.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/utils/OntologicalRequirementEnforceRequest.java index 905305bc3..dd547ffe3 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/utils/OntologicalRequirementEnforceRequest.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/utils/OntologicalRequirementEnforceRequest.java @@ -2,7 +2,6 @@ package org.simantics.modeling.utils; import java.util.Collection; -import org.simantics.datatypes.literal.GUID; import org.simantics.db.Resource; import org.simantics.db.WriteGraph; import org.simantics.db.common.CommentMetadata; @@ -113,7 +112,7 @@ public class OntologicalRequirementEnforceRequest extends WriteRequest { for (Resource r : ids) { if (!graph.hasStatement(r, L0.identifier)) { CommonDBUtils.selectClusterSet(graph, r); - Layer0Utils.addL0Identifier(graph, r); + Layer0Utils.claimNewIdentifier(graph, r, true); } } diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/utils/StructuralUtils.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/utils/StructuralUtils.java index 9b9dc6cb6..9a77d100f 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/utils/StructuralUtils.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/utils/StructuralUtils.java @@ -7,7 +7,6 @@ import java.util.List; import java.util.Set; import org.simantics.databoard.Bindings; -import org.simantics.datatypes.literal.GUID; import org.simantics.db.ReadGraph; import org.simantics.db.RequestProcessor; import org.simantics.db.Resource; @@ -142,8 +141,7 @@ public class StructuralUtils { g.claim(component, L0.HasName, Layer0Utils.literal(g, name)); g.claim(component, L0.HasLabel, Layer0Utils.literal(g, "")); g.claim(parent, L0.ConsistsOf, component); - // Add identifier - Layer0Utils.addL0Identifier(g, component); + Layer0Utils.claimNewIdentifier(g, component, true); // Add comment to change set. CommentMetadata cm = g.getMetadata(CommentMetadata.class); g.addMetadata(cm.add("Created component " + component));