X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.db.layer0%2Fsrc%2Forg%2Fsimantics%2Fdb%2Flayer0%2Fvariable%2FStandardGraphResourcePropertyVariable.java;h=6fa5127db65112153c8858617874d6506d82d570;hb=1ecae6e1ad40507badb8807fb14bb67b4adf199c;hp=aedfcb5ae0692c815c7060b8353b7f4bda35b181;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphResourcePropertyVariable.java b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphResourcePropertyVariable.java index aedfcb5ae..6fa5127db 100644 --- a/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphResourcePropertyVariable.java +++ b/bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/variable/StandardGraphResourcePropertyVariable.java @@ -1,47 +1,50 @@ -package org.simantics.db.layer0.variable; - -import org.simantics.databoard.binding.Binding; -import org.simantics.databoard.type.Datatype; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.exception.NoSingleResultException; -import org.simantics.db.layer0.exception.MissingVariableValueException; -import org.simantics.db.layer0.exception.VariableException; - -public class StandardGraphResourcePropertyVariable extends StandardGraphPropertyVariable { - - public StandardGraphResourcePropertyVariable(ReadGraph graph, Variable parent, Resource parentResource, Resource property) throws DatabaseException { - super(graph, parent, null, parentResource, property); - } - - @Override - public T getValue(ReadGraph graph) throws DatabaseException { - if (parentResource == null) - throw new VariableException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ")."); - try { - return (T)graph.getSingleObject(parentResource, property.predicate); - } catch (NoSingleResultException e) { - System.err.println("No object for " + parentResource + " " + property); - throw new MissingVariableValueException(getPossibleURI(graph)); - } - } - - @Override - public T getValue(ReadGraph graph, Binding binding) throws DatabaseException { - if (parentResource == null) - throw new VariableException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ")."); - try { - return (T)graph.getSingleObject(parentResource, property.predicate); - } catch (NoSingleResultException e) { - System.err.println("No object for " + parentResource + " " + property); - throw new MissingVariableValueException(getPossibleURI(graph)); - } - } - - @Override - public Datatype getDatatype(ReadGraph graph) throws DatabaseException { - return null; - } - -} +package org.simantics.db.layer0.variable; + +import org.simantics.databoard.binding.Binding; +import org.simantics.databoard.type.Datatype; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.exception.NoSingleResultException; +import org.simantics.db.layer0.exception.MissingVariableValueException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class StandardGraphResourcePropertyVariable extends StandardGraphPropertyVariable { + + private static final Logger LOGGER = LoggerFactory.getLogger(StandardGraphResourcePropertyVariable.class); + + public StandardGraphResourcePropertyVariable(ReadGraph graph, Variable parent, Resource parentResource, Resource property) throws DatabaseException { + super(graph, parent, null, parentResource, property); + } + + @Override + public T getValue(ReadGraph graph) throws DatabaseException { + if (parentResource == null) + throw new MissingVariableValueException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ")."); + try { + return (T)graph.getSingleObject(parentResource, property.predicate); + } catch (NoSingleResultException e) { + LOGGER.error("No object for " + parentResource + " " + property); + throw new MissingVariableValueException(getPossibleURI(graph), e); + } + } + + @Override + public T getValue(ReadGraph graph, Binding binding) throws DatabaseException { + if (parentResource == null) + throw new MissingVariableValueException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ")."); + try { + return (T)graph.getSingleObject(parentResource, property.predicate); + } catch (NoSingleResultException e) { + LOGGER.error("No object for " + parentResource + " " + property); + throw new MissingVariableValueException(getPossibleURI(graph), e); + } + } + + @Override + public Datatype getDatatype(ReadGraph graph) throws DatabaseException { + return null; + } + +}