From de0826b0258aa7301b5daf8aa58eb752db7e1a9c Mon Sep 17 00:00:00 2001 From: Reino Ruusu Date: Fri, 27 Mar 2020 15:17:30 +0200 Subject: [PATCH] Fix use of static ontology variables out of context gitlab #84 Change-Id: I94d17685f44e4bbfdaccaf9b3bfabefacb4e1c8e --- .../simantics/district/selection/ElementSelector.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java b/org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java index f015bddf..9015b711 100644 --- a/org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java +++ b/org.simantics.district.selection/src/org/simantics/district/selection/ElementSelector.java @@ -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(); -- 2.47.1