]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Management of mapped component properties in queries 32/2632/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Wed, 30 Jan 2019 14:20:28 +0000 (16:20 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Wed, 30 Jan 2019 14:20:28 +0000 (16:20 +0200)
gitlab #28

TODO:
* UI for listing stored queries
* UI for defining/editing queries
* UI for executing queries

Change-Id: Ie1c3892d77313c452560f7015b387825a9d34e9e

org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java

index 9de46638032cc7baf9ce0b952beabe4cd2c4e56c..a45839c9325198907bc9c5f7ed2c1ed2a5f7039c 100644 (file)
@@ -21,6 +21,7 @@ import org.simantics.db.layer0.variable.RVI;
 import org.simantics.db.layer0.variable.Variable;
 import org.simantics.db.layer0.variable.Variables;
 import org.simantics.diagram.stubs.DiagramResource;
+import org.simantics.district.network.ontology.DistrictNetworkResource;
 import org.simantics.district.region.ontology.DiagramRegionsResource;
 import org.simantics.district.selection.ElementSelector.AggregateCondition.Type;
 import org.simantics.layer0.Layer0;
@@ -49,6 +50,7 @@ public class ElementSelector {
        static StructuralResource2 STR;
        static ModelingResources MOD;
        static DiagramResource DIA;
+       static DistrictNetworkResource DN;
        
        ElementSelector(ReadGraph graph, Resource resource) throws DatabaseException {
                super();
@@ -58,6 +60,7 @@ public class ElementSelector {
                STR = StructuralResource2.getInstance(graph);
                MOD = ModelingResources.getInstance(graph);
                DIA = DiagramResource.getInstance(graph);
+               DN = DistrictNetworkResource.getInstance(graph);
                
                this.resource = resource;
                this.count = -1;
@@ -353,6 +356,11 @@ public class ElementSelector {
                                if (value != null)
                                        return value.doubleValue();
                        }
+                       
+                       // No property found - try possible mapped element property as well
+                       Resource mappedElement = graph.getPossibleObject(element, DN.MappedComponent);
+                       if (mappedElement != null)
+                               return getPropertyValue(graph, mappedElement, propertyName);
                }
                catch (DatabaseException e) {
                }