]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Contributed profile entries 22/422/2
authorAntti Villberg <antti.villberg@semantum.fi>
Tue, 18 Apr 2017 13:14:34 +0000 (16:14 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 18 Apr 2017 20:13:37 +0000 (23:13 +0300)
refs #7148

Change-Id: I9fe9a7f6a3d6eb2d2bf3122d7960e220895cba63

bundles/org.simantics.diagram.ontology/graph.tg
bundles/org.simantics.diagram.ontology/graph/Diagram.pgraph
bundles/org.simantics.diagram.ontology/graph/DiagramProfiles.pgraph
bundles/org.simantics.diagram.ontology/src/org/simantics/diagram/stubs/DiagramResource.java
bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/request/ProfileEntryContributions.java [new file with mode: 0644]
bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/request/RuntimeProfileActiveEntryResources.java

index 45f65af2648849bca8358e73bfd74d919dc95ece..af8d84f4113d025ab1048262eaffa36f37784f40 100644 (file)
Binary files a/bundles/org.simantics.diagram.ontology/graph.tg and b/bundles/org.simantics.diagram.ontology/graph.tg differ
index 687e9ddbc3375be5f0d3251155508b94d0657bd3..9e006381dbad4f8eb2ecffa5e41b34d2fd6781b2 100644 (file)
@@ -125,3 +125,7 @@ DIA.diagramActivityCondition : L0.Template
             DIA.DiagramActivityCondition.test _ : STR.SCLValue
                 L0.SCLValue.expression %expression
                 L0.HasValueType "Resource -> <ReadGraph> String"
+
+DIA.ProfileEntryContribution <T L0.Entity
+  --> DIA.ProfileEntryContribution.HasEntry --> DIA.ProfileEntry <R L0.IsRelatedTo  
+                
\ No newline at end of file
index 6b659f5c782b8f0ff46733f9a4219be6ba4ae407..6413e8019f6cb6cd656066839f291e3e962eb30a 100644 (file)
@@ -83,4 +83,8 @@ DIA.HasTemplate <R L0.ConsistsOf
    L0.HasDomain DIA.ProfileEntry
    L0.HasRange DIA.ProfileEntry
 
+DIA.Groups : L0.Library
+
+DIA.Groups.DefinedElementGroup : DIA.TypeGroup
+  DIA.TypeGroup.HasType DIA.DefinedElement
 
index 473285ff0a90ade7f7c6694a142136b83bd8b8e1..abf4c488fe15802ffabf72249e616d8059124acb 100644 (file)
@@ -99,6 +99,8 @@ public class DiagramResource {
     public final Resource Functions_selectedProfile;
     public final Resource Group;
     public final Resource GroupStyleProfileEntry;
+    public final Resource Groups;
+    public final Resource Groups_DefinedElementGroup;
     public final Resource HasActivationContext;
     public final Resource HasActivationContext_Inverse;
     public final Resource HasActiveProfile;
@@ -254,6 +256,8 @@ public class DiagramResource {
     public final Resource PageDescription_Size_Inverse;
     public final Resource Profile;
     public final Resource ProfileEntry;
+    public final Resource ProfileEntryContribution;
+    public final Resource ProfileEntryContribution_HasEntry;
     public final Resource ProfileEntry_HasGroup;
     public final Resource ProfileEntry_HasGroup_Inverse;
     public final Resource ProfileEntry_HasPriority;
@@ -507,6 +511,8 @@ public class DiagramResource {
         public static final String Functions_selectedProfile = "http://www.simantics.org/Diagram-2.2/Functions/selectedProfile";
         public static final String Group = "http://www.simantics.org/Diagram-2.2/Group";
         public static final String GroupStyleProfileEntry = "http://www.simantics.org/Diagram-2.2/GroupStyleProfileEntry";
+        public static final String Groups = "http://www.simantics.org/Diagram-2.2/Groups";
+        public static final String Groups_DefinedElementGroup = "http://www.simantics.org/Diagram-2.2/Groups/DefinedElementGroup";
         public static final String HasActivationContext = "http://www.simantics.org/Diagram-2.2/HasActivationContext";
         public static final String HasActivationContext_Inverse = "http://www.simantics.org/Diagram-2.2/HasActivationContext/Inverse";
         public static final String HasActiveProfile = "http://www.simantics.org/Diagram-2.2/HasActiveProfile";
@@ -662,6 +668,8 @@ public class DiagramResource {
         public static final String PageDescription_Size_Inverse = "http://www.simantics.org/Diagram-2.2/PageDescription/Size/Inverse";
         public static final String Profile = "http://www.simantics.org/Diagram-2.2/Profile";
         public static final String ProfileEntry = "http://www.simantics.org/Diagram-2.2/ProfileEntry";
+        public static final String ProfileEntryContribution = "http://www.simantics.org/Diagram-2.2/ProfileEntryContribution";
+        public static final String ProfileEntryContribution_HasEntry = "http://www.simantics.org/Diagram-2.2/ProfileEntryContribution/HasEntry";
         public static final String ProfileEntry_HasGroup = "http://www.simantics.org/Diagram-2.2/ProfileEntry/HasGroup";
         public static final String ProfileEntry_HasGroup_Inverse = "http://www.simantics.org/Diagram-2.2/ProfileEntry/HasGroup/Inverse";
         public static final String ProfileEntry_HasPriority = "http://www.simantics.org/Diagram-2.2/ProfileEntry/HasPriority";
@@ -925,6 +933,8 @@ public class DiagramResource {
         Functions_selectedProfile = getResourceOrNull(graph, URIs.Functions_selectedProfile);
         Group = getResourceOrNull(graph, URIs.Group);
         GroupStyleProfileEntry = getResourceOrNull(graph, URIs.GroupStyleProfileEntry);
+        Groups = getResourceOrNull(graph, URIs.Groups);
+        Groups_DefinedElementGroup = getResourceOrNull(graph, URIs.Groups_DefinedElementGroup);
         HasActivationContext = getResourceOrNull(graph, URIs.HasActivationContext);
         HasActivationContext_Inverse = getResourceOrNull(graph, URIs.HasActivationContext_Inverse);
         HasActiveProfile = getResourceOrNull(graph, URIs.HasActiveProfile);
@@ -1080,6 +1090,8 @@ public class DiagramResource {
         PageDescription_Size_Inverse = getResourceOrNull(graph, URIs.PageDescription_Size_Inverse);
         Profile = getResourceOrNull(graph, URIs.Profile);
         ProfileEntry = getResourceOrNull(graph, URIs.ProfileEntry);
+        ProfileEntryContribution = getResourceOrNull(graph, URIs.ProfileEntryContribution);
+        ProfileEntryContribution_HasEntry = getResourceOrNull(graph, URIs.ProfileEntryContribution_HasEntry);
         ProfileEntry_HasGroup = getResourceOrNull(graph, URIs.ProfileEntry_HasGroup);
         ProfileEntry_HasGroup_Inverse = getResourceOrNull(graph, URIs.ProfileEntry_HasGroup_Inverse);
         ProfileEntry_HasPriority = getResourceOrNull(graph, URIs.ProfileEntry_HasPriority);
diff --git a/bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/request/ProfileEntryContributions.java b/bundles/org.simantics.scenegraph.profile/src/org/simantics/scenegraph/profile/request/ProfileEntryContributions.java
new file mode 100644 (file)
index 0000000..4c3cd57
--- /dev/null
@@ -0,0 +1,44 @@
+package org.simantics.scenegraph.profile.request;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.ResourceRead;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.Instances;
+import org.simantics.diagram.stubs.DiagramResource;
+
+public class ProfileEntryContributions extends ResourceRead<Collection<Resource>>{
+
+       protected ProfileEntryContributions(Resource runtimeDiagram) {
+               super(runtimeDiagram);
+       }
+
+       @Override
+       public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {
+
+               DiagramResource DIA = DiagramResource.getInstance(graph);
+
+               String indexURI = graph.getPossibleRelatedValue(resource, DIA.RuntimeDiagram_HasModelURI);
+               if (indexURI == null)
+                       return Collections.emptyList();
+
+               Resource index = graph.getPossibleResource(indexURI);
+               if (index == null)
+                       return Collections.emptyList();
+
+               Instances query = graph.adapt(DIA.ProfileEntryContribution, Instances.class);
+
+               ArrayList<Resource> result = new ArrayList<>();
+               for(Resource contribution : query.find(graph, index)) {
+                       result.add(graph.getSingleObject(contribution, DIA.ProfileEntryContribution_HasEntry));
+               }
+
+               return result;
+
+       }
+
+}
\ No newline at end of file
index 5686024b0c702176352e73d34e0475b84903a5e2..5c438533d8c84f818bb14172c478a12e64a60b6f 100644 (file)
@@ -36,6 +36,9 @@ public class RuntimeProfileActiveEntryResources extends ResourceRead<Collection<
         DiagramResource DIA = DiagramResource.getInstance(graph);
 
         ArrayList<Resource> result = new ArrayList<Resource>();
+        
+        result.addAll(graph.syncRequest(new ProfileEntryContributions(resource)));
+
         Resource activeProfile = graph.getPossibleObject(resource, DIA.RuntimeDiagram_HasRuntimeProfile);
         if (activeProfile == null) {
                
@@ -45,12 +48,14 @@ public class RuntimeProfileActiveEntryResources extends ResourceRead<Collection<
                activeProfile = available.iterator().next().getResource();
             
         }
-
+        
         Resource rootEntries = graph.getPossibleObject(activeProfile, DIA.HasEntries);
         if (rootEntries == null)
             return result;
         
-        return graph.syncRequest(new ProfileActiveEntryResources(activeProfile, rootEntries));
+        result.addAll(graph.syncRequest(new ProfileActiveEntryResources(activeProfile, rootEntries)));
+        
+        return result;
         
     }