X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Ffunction%2FAll.java;h=f52148c2a6b2306d9c8d4b6c0ce9e31cb5e89efe;hb=15af8a20abe8b2ba24b52c9da8bce6c92351dc43;hp=991a0500ce93dac89f4715fd301296b04d330863;hpb=321607bdbd3ca800128d40b5511092f71cb66367;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/function/All.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/function/All.java index 991a0500c..f52148c2a 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/function/All.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/function/All.java @@ -38,13 +38,13 @@ import org.simantics.db.common.utils.Functions; import org.simantics.db.common.utils.ListUtils; import org.simantics.db.common.utils.Logger; import org.simantics.db.common.utils.NameUtils; +import org.simantics.db.common.utils.NearestOwnerFinder; import org.simantics.db.common.validation.L0Validations; import org.simantics.db.exception.AdaptionException; import org.simantics.db.exception.DatabaseException; import org.simantics.db.exception.DoesNotContainValueException; import org.simantics.db.exception.NoSingleResultException; import org.simantics.db.exception.RuntimeDatabaseException; -import org.simantics.db.exception.VariableException; import org.simantics.db.layer0.exception.InvalidVariableException; import org.simantics.db.layer0.exception.MissingVariableException; import org.simantics.db.layer0.exception.MissingVariableValueException; @@ -139,7 +139,7 @@ public class All { return graph.getValue2(object, variable); } else { for (Pair 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 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); } } @@ -570,9 +570,9 @@ public class All { // Process graph properties for(Resource predicate : predicates) { - PropertyInfo info = graph.isImmutable(predicate) ? - graph.syncRequest(new PropertyInfoRequest(predicate), TransientCacheAsyncListener.instance()) : - graph.syncRequest(new PropertyInfoRequest(predicate)); + PropertyInfo info = //graph.isImmutable(predicate) ? + graph.syncRequest(new PropertyInfoRequest(predicate), TransientCacheAsyncListener.instance());// : + //graph.syncRequest(new PropertyInfoRequest(predicate)); if(!info.isHasProperty) continue; @@ -992,7 +992,7 @@ public class All { public static PropertyInfo getPossiblePropertyInfoFromContext(ReadGraph graph, Variable variable, Resource context, String name) throws DatabaseException { if(context == null) return null; - Map predicates = graph.syncRequest(new UnescapedPropertyMapOfResource(context)); + Map predicates = graph.syncRequest(new UnescapedPropertyMapOfResource(context), TransientCacheListener.instance()); return predicates.get(name); } @@ -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) { @@ -1504,7 +1508,7 @@ public class All { ClusteringSupport cs = graph.getService(ClusteringSupport.class); if(cs.isClusterSet(resource) && !base.equals(resource)) return resource; - Resource nearest = CommonDBUtils.getNearestOwner(graph, Collections.singletonList(resource)); + Resource nearest = NearestOwnerFinder.getNearestOwner(graph, resource); if(nearest == null) return null; return getPossibleNearestClusterSet(graph, base, nearest);