]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.structural2/src/org/simantics/structural2/utils/StructuralUtils.java
Merge commit '31664b6'
[simantics/platform.git] / bundles / org.simantics.structural2 / src / org / simantics / structural2 / utils / StructuralUtils.java
index 0b0214e61ccf798be797d09c751282e6cbb4bc3a..45ca49873021d57e44d788dddf1b979ea8a81259 100644 (file)
@@ -1,10 +1,9 @@
 package org.simantics.structural2.utils;\r
 \r
-import gnu.trove.set.hash.THashSet;\r
-\r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
 import java.util.HashMap;\r
+import java.util.List;\r
 import java.util.Set;\r
 \r
 import org.simantics.databoard.Bindings;\r
@@ -16,6 +15,7 @@ import org.simantics.db.Statement;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.CommentMetadata;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.PossibleTypedParent;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.exception.MissingVariableException;\r
@@ -31,6 +31,8 @@ import org.simantics.structural2.queries.Terminal;
 import org.simantics.structural2.variables.Connection;\r
 import org.simantics.utils.datastructures.Pair;\r
 \r
+import gnu.trove.set.hash.THashSet;\r
+\r
 /**\r
  * A utility class for manipulating structural models.\r
  * \r
@@ -273,5 +275,21 @@ public class StructuralUtils {
        }\r
        return null;\r
     }\r
+\r
+    public static boolean isImmutable(ReadGraph graph, Resource r) throws DatabaseException {\r
+        StructuralResource2 STR = StructuralResource2.getInstance(graph);\r
+        Resource uc = graph.syncRequest(new PossibleTypedParent(r, STR.ComponentType));\r
+        return graph.isImmutable(r)\r
+                // Anything under a published or locked user component is published as well\r
+                || (uc != null && (Layer0Utils.isPublished(graph, uc)\r
+                         || graph.hasStatement(uc, STR.ComponentType_Locked)))\r
+                // Anything under a published container (shared library) is published as well\r
+                || Layer0Utils.isContainerPublished(graph, r)\r
+                ;\r
+    }\r
     \r
+    public static List<Variable> structuralConnectionConnectionPoints(ReadGraph graph, Connection conn, Resource relationType) throws DatabaseException {\r
+       return new ArrayList<Variable>(conn.getConnectionPoints(graph, relationType));\r
+    }\r
+\r
 }\r