]> gerrit.simantics Code Review - simantics/district.git/blobdiff - org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java
Management of mapped component properties in queries
[simantics/district.git] / 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) {
                }