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=991a0500ce93dac89f4715fd301296b04d330863;hb=321607bdbd3ca800128d40b5511092f71cb66367;hp=604faa69ed63d99f944bfabac8686eea2437750f;hpb=85c1daf4b3d4a48613e0c61c359cb8aac2157f01;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 604faa69e..991a0500c 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 @@ -39,13 +39,16 @@ 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.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; import org.simantics.db.layer0.exception.PendingVariableException; -import org.simantics.db.layer0.exception.VariableException; import org.simantics.db.layer0.request.PossibleURI; import org.simantics.db.layer0.request.PropertyInfo; import org.simantics.db.layer0.request.PropertyInfoRequest; @@ -167,7 +170,7 @@ public class All { if(value == null) throw new MissingVariableValueException(variable.getPossibleURI(graph)); return value.getValue(binding); } catch (AdaptException e) { - throw new DatabaseException(e); + throw new AdaptionException("Could not get value for " + context.getURI(graph), e); } } @@ -267,7 +270,7 @@ public class All { try { modifier.apply(graph, context, value, Bindings.getBinding(value.getClass())); } catch (BindingConstructionException e) { - throw new DatabaseException(e); + throw new org.simantics.db.exception.BindingException("",e); } } @@ -609,7 +612,7 @@ public class All { Variable parent = context.getParent(graph); Resource container = parent.getPossibleRepresents(graph); if(container == null) - return null; + return null; Map methods = graph.syncRequest(new UnescapedMethodMapOfResource(container)); Resource predicate = methods.get(name); if(predicate != null) { @@ -625,6 +628,8 @@ public class All { public Map getVariables(ReadGraph graph, Variable context, Map map) throws DatabaseException { Variable parent = context.getParent(graph); Resource container = parent.getPossibleRepresents(graph); + if(container == null) + return Collections.emptyMap(); Map methods = graph.syncRequest(new UnescapedMethodMapOfResource(container)); for(Map.Entry entry : methods.entrySet()) { String name = entry.getKey(); @@ -1305,14 +1310,14 @@ public class All { } if (variable.parentResource == null) - throw new VariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ")."); + throw new InvalidVariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ")."); try { return graph.getRelatedValue2(variable.parentResource, variable.property.predicate, variable); } catch (NoSingleResultException e) { - throw new MissingVariableValueException(variable.getPossibleURI(graph)); + throw new MissingVariableValueException(variable.getPossibleURI(graph), e); } catch (DoesNotContainValueException e) { - throw new MissingVariableValueException(variable.getPossibleURI(graph)); + throw new MissingVariableValueException(variable.getPossibleURI(graph), e); } } @@ -1328,14 +1333,14 @@ public class All { } if (variable.parentResource == null) - throw new VariableException("Variable is not represented by any resource (URI=" + variable.getPossibleURI(graph) + ")."); + 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); } catch (NoSingleResultException e) { - throw new MissingVariableValueException(variable.getPossibleURI(graph)); + throw new MissingVariableValueException(variable.getPossibleURI(graph), e); } catch (DoesNotContainValueException e) { - throw new MissingVariableValueException(variable.getPossibleURI(graph)); + throw new MissingVariableValueException(variable.getPossibleURI(graph), e); } }