]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
StructuralUtils.isImmutable now takes L0.readOnly of input into account
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 24 Apr 2020 17:09:02 +0000 (20:09 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 24 Apr 2020 17:09:22 +0000 (20:09 +0300)
Introduced new utility method Layer0Utils.isMarkedReadOnly for easy
checking L0.readOnly value of a Resource.

gitlab #525

bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Layer0Utils.java
bundles/org.simantics.structural2/src/org/simantics/structural2/utils/StructuralUtils.java

index 830f7a6bb74776ece6a99b35eb3b9b51999cc10a..ad8676f813bdb83d4da1adde8aed547c31541ddb 100644 (file)
@@ -1202,6 +1202,10 @@ public class Layer0Utils {
 
     }
 
+    public static boolean isMarkedReadOnly(ReadGraph graph, Resource r) throws DatabaseException {
+        return Boolean.TRUE.equals( graph.getPossibleRelatedValue(r, graph.<Layer0>l0().readOnly, Bindings.BOOLEAN) );
+    }
+
     private static TransferableGraph1 makeTG(ReadGraph graph, Resource r) throws DatabaseException {
 
        SimanticsClipboardImpl cp = new SimanticsClipboardImpl();
index e27d92f29219a7f54963208286b5bd1936c0f485..aac19a7f176b663c9297e9e3b820e86e44392992 100644 (file)
@@ -308,11 +308,13 @@ public class StructuralUtils {
     }
 
     public static boolean isImmutable(ReadGraph graph, Resource r) throws DatabaseException {
+        // Marking a resource L0.readOnly also makes it immutable
+        if (graph.isImmutable(r) || Layer0Utils.isMarkedReadOnly(graph, r))
+            return true;
         StructuralResource2 STR = StructuralResource2.getInstance(graph);
         Resource uc = graph.syncRequest(new PossibleTypedParent(r, STR.ComponentType));
-        return graph.isImmutable(r)
-                // Anything under a published or locked user component is published as well
-                || (uc != null && (Layer0Utils.isPublished(graph, uc)
+        return  // Anything under a published or locked user component is published as well
+                (uc != null && (Layer0Utils.isPublished(graph, uc)
                          || graph.hasStatement(uc, STR.ComponentType_Locked)))
                 // Anything under a published container (shared library) is published as well
                 || Layer0Utils.isContainerPublished(graph, r)