X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2Futils%2FStructuralUtils.java;h=d029f3ae7942db8592e2bc68241b30f5af17b2af;hp=0b0214e61ccf798be797d09c751282e6cbb4bc3a;hb=c160c0a55fb8aaacc9bcfa08b2bfbc4fdf0bf871;hpb=089832880807e21e696b5f321a81fa93473c07a9 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..d029f3ae7 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 @@ -16,6 +16,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; @@ -273,5 +274,17 @@ 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) + ; + } + }