]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/function/All.java
Fix handling of property variables with no predicate resource.
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / function / All.java
index 4e775e08a22e12597044218f138aef3cfcaf6637..f52148c2a6b2306d9c8d4b6c0ce9e31cb5e89efe 100644 (file)
@@ -139,7 +139,7 @@ public class All {
                                                return graph.getValue2(object, variable);
                                        } else {
                                                for (Pair<PropertyInfo, Resource> assertion : assertions.values()) {
-                                                       if (assertion.first.predicate.equals(variable.property.predicate)) {
+                                                       if (assertion.first.predicate.equals(variable.getPossiblePredicateResource(graph))) {
                                                                return graph.getValue2(assertion.second, variable);
                                                        }
                                                }
@@ -201,7 +201,7 @@ public class All {
                                                return graph.getValue2(object, variable, binding);
                                        } else {
                                                for (Pair<PropertyInfo, Resource> assertion : assertions.values()) {
-                                                       if (assertion.first.predicate.equals(variable.property.predicate)) {
+                                                       if (assertion.first.predicate.equals(variable.getPossiblePredicateResource(graph))) {
                                                                return graph.getValue2(assertion.second, variable, binding);
                                                        }
                                                }
@@ -1164,8 +1164,11 @@ public class All {
        if(property instanceof StandardGraphPropertyVariable) {
                StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)property;
                if (variable.parentResource != null) {
-                       Statement stm = graph.getPossibleStatement(variable.parentResource, variable.property.predicate);
-                       return stm != null && stm.isAsserted(variable.parentResource);
+                       Resource predicate = variable.getPossiblePredicateResource(graph);
+                       if (predicate != null) {
+                                       Statement stm = graph.getPossibleStatement(variable.parentResource, predicate);
+                                       return stm != null && stm.isAsserted(variable.parentResource);
+                       }
                        }
        }
        return Boolean.FALSE;
@@ -1313,7 +1316,7 @@ public class All {
                        throw new InvalidVariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ").");
 
                try {
-                       return graph.getRelatedValue2(variable.parentResource, variable.property.predicate, variable);
+                       return graph.getRelatedValue2(variable.parentResource, variable.getPredicateResource(graph), variable);
                } catch (NoSingleResultException e) {
                        throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
                } catch (DoesNotContainValueException e) {
@@ -1334,9 +1337,10 @@ public class All {
 
                if (variable.parentResource == null)
                        throw new MissingVariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ").", context.getPossibleRepresents(graph));
+               
 
                try {
-                       return graph.getRelatedValue2(variable.parentResource, variable.property.predicate, variable);
+                       return graph.getRelatedValue2(variable.parentResource, variable.getPredicateResource(graph), variable);
                } catch (NoSingleResultException e) {
                        throw new MissingVariableValueException(variable.getPossibleURI(graph), e);
                } catch (DoesNotContainValueException e) {