X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2Futils%2FStructuralUtils.java;h=45ca49873021d57e44d788dddf1b979ea8a81259;hb=e7715622bee64fd2c8fe74d260a560e688720f75;hp=0b0214e61ccf798be797d09c751282e6cbb4bc3a;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git 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 0b0214e61..45ca49873 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 @@ -1,10 +1,9 @@ package org.simantics.structural2.utils; -import gnu.trove.set.hash.THashSet; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Set; import org.simantics.databoard.Bindings; @@ -16,6 +15,7 @@ import org.simantics.db.Statement; import org.simantics.db.WriteGraph; import org.simantics.db.common.CommentMetadata; import org.simantics.db.common.request.ObjectsWithType; +import org.simantics.db.common.request.PossibleTypedParent; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; import org.simantics.db.layer0.exception.MissingVariableException; @@ -31,6 +31,8 @@ import org.simantics.structural2.queries.Terminal; import org.simantics.structural2.variables.Connection; import org.simantics.utils.datastructures.Pair; +import gnu.trove.set.hash.THashSet; + /** * A utility class for manipulating structural models. * @@ -273,5 +275,21 @@ public class StructuralUtils { } return null; } + + public static boolean isImmutable(ReadGraph graph, Resource r) throws DatabaseException { + 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) + || graph.hasStatement(uc, STR.ComponentType_Locked))) + // Anything under a published container (shared library) is published as well + || Layer0Utils.isContainerPublished(graph, r) + ; + } + public static List structuralConnectionConnectionPoints(ReadGraph graph, Connection conn, Resource relationType) throws DatabaseException { + return new ArrayList(conn.getConnectionPoints(graph, relationType)); + } + }