]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/ProfileUtils.java
Better support for ontological profiles
[simantics/platform.git] / bundles / org.simantics.scenegraph.profile / src / org / simantics / scenegraph / profile / ProfileUtils.java
index 88a69065be58d358294c0238f263a755ad38aa45..92326248f26007b4eccfda3772ff72d99c6155a5 100644 (file)
@@ -13,7 +13,7 @@ import org.simantics.db.common.request.PossibleIndexRoot;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.layer0.Layer0;
-import org.simantics.scenegraph.profile.request.ProfileActiveEntryResources;
+import org.simantics.simulation.ontology.SimulationResource;
 
 public class ProfileUtils {
 
@@ -43,9 +43,9 @@ public class ProfileUtils {
                        if(profile.equals(ref)) return state;
                }
                return null;
-               
+
        }
-       
+
        public static Resource claimProfileActivationState(WriteGraph graph, Resource runtimeDiagram, Resource runtimeProfile, Resource entry) throws DatabaseException {
                Layer0 L0 = Layer0.getInstance(graph);
                DiagramResource DIA = DiagramResource.getInstance(graph);
@@ -66,6 +66,19 @@ public class ProfileUtils {
                graph.claim(indexRoot, L0.ConsistsOf, state);
                return state;
        }
-       
-       
+
+       public static boolean isActive(ReadGraph graph, Resource runtimeDiagram, Resource profile, Resource entry) throws DatabaseException {
+               DiagramResource DIA = DiagramResource.getInstance(graph);
+               SimulationResource SIMU = SimulationResource.getInstance(graph);
+               if(graph.isInstanceOf(entry, DIA.ProfileEntry)) {
+                       if(graph.isImmutable(profile)) {
+                               Resource state = getPossibleProfileActivationState(graph, runtimeDiagram, profile);
+                               if(state != null && graph.hasStatement(state, SIMU.IsActive, entry)) return true;
+                       } else {
+                               if(graph.hasStatement(profile, SIMU.IsActive, entry)) return true;
+                       }
+               }
+               return false;
+       }
+
 }