]> gerrit.simantics Code Review - simantics/district.git/commitdiff
Fix use of static ontology variables out of context 51/4051/1
authorReino Ruusu <reino.ruusu@semantum.fi>
Fri, 27 Mar 2020 13:17:30 +0000 (15:17 +0200)
committerReino Ruusu <reino.ruusu@semantum.fi>
Fri, 27 Mar 2020 13:17:30 +0000 (15:17 +0200)
gitlab #84

Change-Id: I94d17685f44e4bbfdaccaf9b3bfabefacb4e1c8e

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

index f015bddf0f2ccc0814788c956d59ff05064f90dd..9015b7117605674dd56bcaa9385e3116ccaedf43 100644 (file)
@@ -689,11 +689,14 @@ public class ElementSelector {
                
                Condition(ReadGraph graph, Resource r) throws DatabaseException {
                        this(r);
+                       ElementSelectionResource ES = ElementSelectionResource.getInstance(graph);
                        isInverse = graph.hasStatement(r, ES.Condition_IsInverse, r);
                }
                
                public abstract boolean match(ReadGraph graph, Resource r) throws DatabaseException;
                public Resource update(WriteGraph graph) throws DatabaseException {
+                       ElementSelectionResource ES = ElementSelectionResource.getInstance(graph);
+                       
                        assert(resource != null);
                        if (isInverse)
                                graph.claim(resource, ES.Condition_IsInverse, resource);
@@ -707,6 +710,7 @@ public class ElementSelector {
                public PropertyCondition(ReadGraph graph, Resource r) throws DatabaseException {
                        super(graph, r);
                        
+                       ElementSelectionResource ES = ElementSelectionResource.getInstance(graph);
                        this.propertyName = graph.getRelatedValue(resource, ES.PropertyCondition_HasPropertyName);
                        this.lowerLimit = graph.getPossibleRelatedValue(resource, ES.PropertyCondition_HasLowerLimit);
                        this.upperLimit = graph.getPossibleRelatedValue(resource, ES.PropertyCondition_HasUpperLimit);
@@ -768,6 +772,7 @@ public class ElementSelector {
                public RegionCondition(ReadGraph graph, Resource r) throws DatabaseException {
                        super(graph, r);
                        
+                       ElementSelectionResource ES = ElementSelectionResource.getInstance(graph);
                        DiagramRegionsResource DR = DiagramRegionsResource.getInstance(graph);
                        this.regionResource = graph.getPossibleObject(resource, ES.RegionCondition_HasRegion);
                        this.region = regionResource != null ? graph.getRelatedValue(regionResource, DR.Region_area) : null;
@@ -802,8 +807,9 @@ public class ElementSelector {
                
                @Override
                public Resource update(WriteGraph graph) throws DatabaseException {
-                       ElementSelectionResource ES = ElementSelectionResource.getInstance(graph);
                        Layer0 L0 = Layer0.getInstance(graph);
+                       ElementSelectionResource ES = ElementSelectionResource.getInstance(graph);
+                       DiagramRegionsResource DR = DiagramRegionsResource.getInstance(graph);
                        
                        if (resource == null) {
                                resource = graph.newResource();
@@ -815,7 +821,6 @@ public class ElementSelector {
                        graph.claim(resource, ES.RegionCondition_HasRegion, regionResource);
                        
                        // Re-read region data to match DB
-                       DiagramRegionsResource DR = DiagramRegionsResource.getInstance(graph);
                        this.region = regionResource != null ? graph.getRelatedValue(regionResource, DR.Region_area, Bindings.DOUBLE_ARRAY) : null;
                        this.path = createPathForRegion(region);
                        
@@ -927,8 +932,8 @@ public class ElementSelector {
                
                @Override
                public Resource update(WriteGraph graph) throws DatabaseException {
-                       ElementSelectionResource ES = ElementSelectionResource.getInstance(graph);
                        Layer0 L0 = Layer0.getInstance(graph);
+                       ElementSelectionResource ES = ElementSelectionResource.getInstance(graph);
                        
                        if (resource == null) {
                                resource = graph.newResource();