-package org.simantics.db.layer0.variable;\r
-\r
-import java.util.Collection;\r
-import java.util.Collections;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.datatypes.literal.GUID;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;\r
-import org.simantics.db.exception.AssumptionException;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.exception.InvalidVariableException;\r
-import org.simantics.db.layer0.exception.VariableException;\r
-import org.simantics.db.layer0.function.All;\r
-import org.simantics.db.layer0.request.ClassificationsRequest;\r
-import org.simantics.db.layer0.request.VariableURI;\r
-import org.simantics.db.layer0.variable.RVI.RVIPart;\r
-import org.simantics.db.layer0.variable.RVI.ResourceRVIPart;\r
-import org.simantics.db.layer0.variable.RVI.StringRVIPart;\r
-import org.simantics.db.layer0.variable.Variables.Role;\r
-import org.simantics.layer0.Layer0;\r
-import org.simantics.simulator.variable.exceptions.NodeManagerException;\r
-\r
-public class StandardGraphChildVariable extends AbstractChildVariable {\r
-\r
- /*\r
- * Extension points\r
- * \r
- */\r
- public Variable getPossibleSpecialChild(ReadGraph graph, String name) throws DatabaseException {\r
- return null;\r
- }\r
-\r
- public Map<String, Variable> collectSpecialChildren(ReadGraph graph, Map<String, Variable> children) throws DatabaseException {\r
- return children;\r
- }\r
-\r
- /*\r
- * Standard implementation\r
- * \r
- */\r
- \r
- final protected Variable parent;\r
- final public Resource resource;\r
- \r
- transient private int hash;\r
- \r
- public StandardGraphChildVariable(Variable parent, VariableNode node, Resource resource) {\r
- super(node);\r
- this.parent = parent;\r
- this.resource = resource;\r
- }\r
-\r
- @Override\r
- public void validate(ReadGraph graph) throws DatabaseException {\r
- if(!graph.hasStatement(resource)) throw new InvalidVariableException("The resource has been removed: " + resource);\r
- }\r
- \r
- @Override\r
- protected Variable getPossibleDomainProperty(ReadGraph graph, String name) throws DatabaseException {\r
- VariableMap map = getPossiblePropertyVariableMap(graph);\r
- if(map == null) return null;\r
- try {\r
- return map.getVariable(graph, this, name);\r
- } catch (DatabaseException e) {\r
- return null;\r
- }\r
- }\r
-\r
- @Override\r
- public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException {\r
- VariableMap map = getPossibleChildVariableMap(graph);\r
- if(map == null) return getPossibleSpecialChild(graph, name);\r
- try {\r
- Variable result = map.getVariable(graph, this, name);\r
- if(result != null) return result;\r
- else return getPossibleSpecialChild(graph, name);\r
- } catch (DatabaseException e) {\r
- return null;\r
- }\r
- }\r
-\r
- @Override\r
- public Map<String, Variable> collectDomainProperties(ReadGraph graph, Map<String, Variable> properties) throws DatabaseException {\r
- VariableMap map = getPossiblePropertyVariableMap(graph);\r
- if(map == null) return properties;\r
- return map.getVariables(graph, this, properties);\r
- }\r
-\r
- @Override\r
- public Collection<Variable> getChildren(ReadGraph graph) throws DatabaseException {\r
- Map<String, Variable> result = null;\r
- VariableMap map = getPossibleChildVariableMap(graph);\r
- if(map != null) result = map.getVariables(graph, this, result);\r
- result = collectSpecialChildren(graph, result);\r
- if(result == null) return Collections.emptyList();\r
- else return result.values();\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public String getName(ReadGraph graph) throws DatabaseException {\r
- if(node != null) {\r
- return node.support.manager.getName(node.node);\r
- }\r
- String unescapedName = graph.getPossibleRelatedValue(resource, graph.getService(Layer0.class).HasName, Bindings.STRING);\r
- if(unescapedName == null) return "r" + resource.getResourceId();\r
- return unescapedName;\r
- }\r
-\r
- @Override\r
- public Variable getNameVariable(ReadGraph graph) throws DatabaseException {\r
- Resource resource = (Resource) getPossibleRepresents(graph);\r
- if (resource != null) {\r
- return new StandardGraphPropertyVariable(graph, this, null, resource, Layer0.getInstance(graph).HasName);\r
- }\r
- return super.getNameVariable(graph);\r
- }\r
- \r
- \r
- @Override\r
- public String getLabel(ReadGraph graph) throws DatabaseException {\r
- if(resource == null) return getName(graph);\r
- String label = graph.getPossibleRelatedValue2(resource, graph.getService(Layer0.class).HasLabel);\r
- return label != null ? label : getName(graph);\r
- }\r
-\r
- @Override\r
- final protected Variable getLabelVariable(ReadGraph graph) throws DatabaseException {\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- if(resource == null) return null;\r
- return new StandardGraphPropertyVariable(graph, this, L0.HasLabel);\r
- }\r
- \r
-// @Override\r
-// final public Object getSerialized(ReadGraph graph) throws DatabaseException {\r
-// Resource represents = getRepresents(graph);\r
-// if(represents != null) return represents;\r
-// else return getName(graph);\r
-// }\r
-\r
- @Override\r
- public Variable getParent(ReadGraph graph) throws DatabaseException {\r
- return parent;\r
- }\r
- \r
- @Override\r
- final public Resource getRepresents(ReadGraph graph) throws DatabaseException {\r
- if(resource == null)\r
- throw new VariableException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ").");\r
- return resource;\r
-// Layer0X L0X = Layer0X.getInstance(graph);\r
-// Resource represents = graph.getPossibleObject(resource, L0X.Represents);\r
-// if(represents != null) return represents;\r
-// else return resource;\r
- }\r
-\r
- @Override\r
- public Resource getPossibleRepresents(ReadGraph graph)\r
- throws DatabaseException {\r
- return resource;\r
- }\r
- \r
- @Override\r
- final public String getURI(ReadGraph graph) throws DatabaseException {\r
- \r
- try {\r
- if(parent == null) return "http:/";\r
- String parentURI = graph.syncRequest(new VariableURI(parent), TransientCacheAsyncListener.<String>instance());\r
- return parentURI + Role.CHILD.getIdentifier() + encodeString(getName(graph));\r
- } catch (AssumptionException e) {\r
- throw new InvalidVariableException(e);\r
- }\r
- }\r
-\r
- /**\r
- * All variables must have proper URIs, this is only for debugging purposes.\r
- * \r
- * @see org.simantics.db.layer0.variable.AbstractVariable#getPossibleURI(org.simantics.db.ReadGraph)\r
- */\r
- @Override\r
- public String getPossibleURI(ReadGraph graph) throws DatabaseException {\r
- try {\r
- return getURI(graph);\r
- } catch (DatabaseException e) {\r
- return "<no uri>";\r
- }\r
- }\r
-\r
- @Override\r
- public int hashCode() {\r
- if(hash == 0) {\r
- final int prime = 31;\r
- int result = 1;\r
- result = prime * result + (parent != null ? parent.hashCode() : 0);\r
- result = prime * result + (node != null ? node.hashCode() : 0);\r
- result = prime * result + (resource != null ? resource.hashCode() : 0);\r
- hash =result;\r
- }\r
- return hash;\r
- }\r
-\r
- @Override\r
- public boolean equals(Object obj) {\r
- if (this == obj)\r
- return true;\r
- if (obj == null)\r
- return false;\r
- if (getClass() != obj.getClass())\r
- return false;\r
- \r
- StandardGraphChildVariable other = (StandardGraphChildVariable) obj;\r
- \r
- if(node != null) { \r
- if(!node.equals(other.node)) return false;\r
- } else if (other.node != null) return false;\r
-\r
- if(resource != null) {\r
- if(!resource.equals(other.resource)) return false;\r
- } else if (other.resource != null) return false;\r
- \r
- if(parent != null) {\r
- if(!parent.equals(other.parent)) return false;\r
- } else if (other.parent != null) return false;\r
- \r
- return true;\r
- \r
- }\r
- \r
- @Override\r
- public <T> T adapt(ReadGraph graph, Class<T> clazz) throws DatabaseException {\r
- return graph.adapt(resource, clazz);\r
- }\r
-\r
- @Override\r
- public <T> T adaptPossible(ReadGraph graph, Class<T> clazz) throws DatabaseException {\r
- return graph.getPossibleAdapter(resource, clazz);\r
- }\r
-\r
- @Override\r
- public RVIPart getRVIPart(ReadGraph graph) throws DatabaseException {\r
- if(resource == null) return new StringRVIPart(Role.CHILD, getName(graph));\r
- Layer0 L0 = Layer0.getInstance(graph);\r
- GUID id = graph.getPossibleRelatedValue(resource, L0.identifier, GUID.BINDING);\r
- if(id != null)\r
- return new RVI.GuidRVIPart(Role.CHILD, resource, id.mostSignificant, id.leastSignificant);\r
- else\r
- return new ResourceRVIPart(Role.CHILD, resource);\r
- }\r
- \r
- public String getIdentifier() {\r
- return getClass().getSimpleName() + "[" + resource + "]";\r
- }\r
- \r
- protected VariableMap getPossiblePropertyVariableMap(ReadGraph graph) throws DatabaseException {\r
- if(resource == null) return All.standardChildDomainProperties;\r
- return graph.getPossibleRelatedValue2(resource, Layer0.getInstance(graph).domainProperties, this);\r
- }\r
-\r
- protected VariableMap getPossibleChildVariableMap(ReadGraph graph) throws DatabaseException {\r
- if(resource == null) return All.standardChildDomainChildren;\r
- return graph.getPossibleRelatedValue2(resource, Layer0.getInstance(graph).domainChildren, this);\r
- }\r
- \r
- @Override\r
- public Map<String, Variable> collectDomainProperties(ReadGraph graph, String classification, Map<String, Variable> properties) throws DatabaseException {\r
- VariableMap valueMap = getPossiblePropertyVariableMap(graph);\r
- if(valueMap == null) return properties;\r
- return valueMap.getVariables(graph, this, classification, properties);\r
- }\r
- \r
- @Override\r
- public Variable resolve(ReadGraph graph, RVIPart part) throws DatabaseException {\r
- Resource represents = getPossibleRepresents(graph);\r
- if (represents == null)\r
- return StandardRVIResolver.INSTANCE.getVariable(graph, this, part);\r
- RVIResolver resolver = graph.adapt(represents, RVIResolver.class);\r
- return resolver.getVariable(graph, this, part);\r
- } \r
-\r
- @Override\r
- public Variable resolvePossible(ReadGraph graph, RVIPart part) throws DatabaseException {\r
- try {\r
- return resolve(graph, part);\r
- } catch (DatabaseException e) {\r
- return null;\r
- }\r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- public Set<String> getClassifications(ReadGraph graph) throws DatabaseException {\r
- Resource represents = getPossibleRepresents(graph);\r
- Set<String> result = (represents != null) ? graph.syncRequest(new ClassificationsRequest(graph.getPrincipalTypes(represents))) : Collections.<String>emptySet();\r
- if (result.isEmpty()) {\r
- Resource type = getPossibleType(graph);\r
- if(type != null) result = graph.syncRequest(new ClassificationsRequest(Collections.singleton(type)));\r
- }\r
- if (result.isEmpty() && node != null) {\r
- try {\r
- result = node.support.manager.getClassifications(node.node);\r
- } catch(NodeManagerException e) {\r
- throw new DatabaseException(e);\r
- }\r
- }\r
- return result;\r
- }\r
-\r
- @Override\r
- public RVI getRVI(ReadGraph graph) throws DatabaseException {\r
- Resource represents = getPossibleRepresents(graph);\r
- if (represents == null)\r
- return StandardRVIResolver.INSTANCE.getRVI(graph, this);\r
- RVIResolver resolver = graph.adapt(represents, RVIResolver.class);\r
- return resolver.getRVI(graph, this);\r
- } \r
- \r
- @Override\r
- public RVI getPossibleRVI(ReadGraph graph) throws DatabaseException {\r
- Resource represents = getPossibleRepresents(graph);\r
- if (represents == null)\r
- return StandardRVIResolver.INSTANCE.getPossibleRVI(graph, this);\r
- RVIResolver resolver = graph.getPossibleAdapter(represents, RVIResolver.class);\r
- if(resolver == null) return null;\r
- return resolver.getPossibleRVI(graph, this);\r
- }\r
-\r
- @Override\r
- public Resource getPossiblePredicateResource(ReadGraph graph) throws DatabaseException {\r
- return null;\r
- }\r
- \r
-}\r
+package org.simantics.db.layer0.variable;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.datatypes.literal.GUID;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.common.procedure.adapter.TransientCacheAsyncListener;
+import org.simantics.db.exception.AssumptionException;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.exception.InvalidVariableException;
+import org.simantics.db.layer0.function.All;
+import org.simantics.db.layer0.request.ClassificationsRequest;
+import org.simantics.db.layer0.request.VariableURI;
+import org.simantics.db.layer0.variable.RVI.RVIPart;
+import org.simantics.db.layer0.variable.RVI.ResourceRVIPart;
+import org.simantics.db.layer0.variable.RVI.StringRVIPart;
+import org.simantics.db.layer0.variable.Variables.Role;
+import org.simantics.layer0.Layer0;
+import org.simantics.simulator.variable.exceptions.NodeManagerException;
+
+public class StandardGraphChildVariable extends AbstractChildVariable implements ProxyVariableSupport {
+
+ /*
+ * Extension points
+ *
+ */
+ public Variable getPossibleSpecialChild(ReadGraph graph, String name) throws DatabaseException {
+ return null;
+ }
+
+ public Map<String, Variable> collectSpecialChildren(ReadGraph graph, Map<String, Variable> children) throws DatabaseException {
+ return children;
+ }
+
+ /*
+ * Standard implementation
+ *
+ */
+
+ final protected Variable parent;
+ final public Resource resource;
+
+ transient private int hash;
+
+ public StandardGraphChildVariable(Variable parent, VariableNode node, Resource resource) {
+ super(node);
+ this.parent = parent;
+ this.resource = resource;
+ }
+
+ @Override
+ public void validate(ReadGraph graph) throws DatabaseException {
+ if(!graph.hasStatement(resource)) throw new InvalidVariableException("The resource has been removed: " + resource);
+ }
+
+ @Override
+ protected Variable getPossibleDomainProperty(ReadGraph graph, String name) throws DatabaseException {
+ VariableMap map = getPossiblePropertyVariableMap(graph);
+ if(map == null) return null;
+ try {
+ return map.getVariable(graph, this, name);
+ } catch (DatabaseException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException {
+ VariableMap map = getPossibleChildVariableMap(graph);
+ if(map == null) return getPossibleSpecialChild(graph, name);
+ try {
+ Variable result = map.getVariable(graph, this, name);
+ if(result != null) return result;
+ else return getPossibleSpecialChild(graph, name);
+ } catch (DatabaseException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public Map<String, Variable> collectDomainProperties(ReadGraph graph, Map<String, Variable> properties) throws DatabaseException {
+ VariableMap map = getPossiblePropertyVariableMap(graph);
+ if(map == null) return properties;
+ return map.getVariables(graph, this, properties);
+ }
+
+ @Override
+ public Collection<Variable> getChildren(ReadGraph graph) throws DatabaseException {
+ Map<String, Variable> result = null;
+ VariableMap map = getPossibleChildVariableMap(graph);
+ if(map != null) result = map.getVariables(graph, this, result);
+ result = collectSpecialChildren(graph, result);
+ if(result == null) return Collections.emptyList();
+ else return result.values();
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public String getName(ReadGraph graph) throws DatabaseException {
+ if(node != null) {
+ return node.support.manager.getName(node.node);
+ }
+ String unescapedName = graph.getPossibleRelatedValue(resource, graph.getService(Layer0.class).HasName, Bindings.STRING);
+ if(unescapedName == null) return VariableUtils.unnamedResourceName(resource);
+ return unescapedName;
+ }
+
+ @Override
+ public Variable getNameVariable(ReadGraph graph) throws DatabaseException {
+ Resource resource = (Resource) getPossibleRepresents(graph);
+ if (resource != null) {
+ return new StandardGraphPropertyVariable(graph, this, null, resource, Layer0.getInstance(graph).HasName);
+ }
+ return super.getNameVariable(graph);
+ }
+
+
+ @Override
+ public String getLabel(ReadGraph graph) throws DatabaseException {
+ if(resource == null) return getName(graph);
+ String label = graph.getPossibleRelatedValue2(resource, graph.getService(Layer0.class).HasLabel);
+ return label != null ? label : getName(graph);
+ }
+
+ @Override
+ final protected Variable getLabelVariable(ReadGraph graph) throws DatabaseException {
+ Layer0 L0 = Layer0.getInstance(graph);
+ if(resource == null) return null;
+ return new StandardGraphPropertyVariable(graph, this, L0.HasLabel);
+ }
+
+// @Override
+// final public Object getSerialized(ReadGraph graph) throws DatabaseException {
+// Resource represents = getRepresents(graph);
+// if(represents != null) return represents;
+// else return getName(graph);
+// }
+
+ @Override
+ public Variable getParent(ReadGraph graph) throws DatabaseException {
+ return parent;
+ }
+
+ @Override
+ final public Resource getRepresents(ReadGraph graph) throws DatabaseException {
+ if(resource == null)
+ throw new InvalidVariableException("Variable is not represented by any resource (URI=" + getPossibleURI(graph) + ").");
+ return resource;
+// Layer0X L0X = Layer0X.getInstance(graph);
+// Resource represents = graph.getPossibleObject(resource, L0X.Represents);
+// if(represents != null) return represents;
+// else return resource;
+ }
+
+ @Override
+ public Resource getPossibleRepresents(ReadGraph graph)
+ throws DatabaseException {
+ return resource;
+ }
+
+ @Override
+ final public String getURI(ReadGraph graph) throws DatabaseException {
+
+ try {
+ if(parent == null) return "http:/";
+ String parentURI = graph.syncRequest(new VariableURI(parent), TransientCacheAsyncListener.<String>instance());
+ return parentURI + Role.CHILD.getIdentifier() + encodeString(getName(graph));
+ } catch (AssumptionException e) {
+ throw new InvalidVariableException(e);
+ }
+ }
+
+ /**
+ * All variables must have proper URIs, this is only for debugging purposes.
+ *
+ * @see org.simantics.db.layer0.variable.AbstractVariable#getPossibleURI(org.simantics.db.ReadGraph)
+ */
+ @Override
+ public String getPossibleURI(ReadGraph graph) throws DatabaseException {
+ try {
+ return getURI(graph);
+ } catch (DatabaseException e) {
+ return "<no uri>";
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ if(hash == 0) {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (parent != null ? parent.hashCode() : 0);
+ result = prime * result + (node != null ? node.hashCode() : 0);
+ result = prime * result + (resource != null ? resource.hashCode() : 0);
+ hash =result;
+ }
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+
+ StandardGraphChildVariable other = (StandardGraphChildVariable) obj;
+
+ if(node != null) {
+ if(!node.equals(other.node)) return false;
+ } else if (other.node != null) return false;
+
+ if(resource != null) {
+ if(!resource.equals(other.resource)) return false;
+ } else if (other.resource != null) return false;
+
+ if(parent != null) {
+ if(!parent.equals(other.parent)) return false;
+ } else if (other.parent != null) return false;
+
+ return true;
+
+ }
+
+ @Override
+ public <T> T adapt(ReadGraph graph, Class<T> clazz) throws DatabaseException {
+ return graph.adapt(resource, clazz);
+ }
+
+ @Override
+ public <T> T adaptPossible(ReadGraph graph, Class<T> clazz) throws DatabaseException {
+ return graph.getPossibleAdapter(resource, clazz);
+ }
+
+ @Override
+ public RVIPart getRVIPart(ReadGraph graph) throws DatabaseException {
+ if(resource == null) return new StringRVIPart(Role.CHILD, getName(graph));
+ Layer0 L0 = Layer0.getInstance(graph);
+ GUID id = graph.getPossibleRelatedValue(resource, L0.identifier, GUID.BINDING);
+ if(id != null)
+ return new RVI.GuidRVIPart(Role.CHILD, resource, id.mostSignificant, id.leastSignificant);
+ else
+ return new ResourceRVIPart(Role.CHILD, resource);
+ }
+
+ public String getIdentifier() {
+ return getClass().getSimpleName() + "[" + resource + "]";
+ }
+
+ protected VariableMap getPossiblePropertyVariableMap(ReadGraph graph) throws DatabaseException {
+ if(resource == null) return All.standardChildDomainProperties;
+ Resource domainProperties = Layer0.getInstance(graph).domainProperties;
+ return graph.getPossibleRelatedValue2(resource, domainProperties,
+ new StandardGraphPropertyVariable(graph, this, domainProperties));
+ }
+
+ protected VariableMap getPossibleChildVariableMap(ReadGraph graph) throws DatabaseException {
+ if(resource == null) return All.standardChildDomainChildren;
+ Resource domainChildren = Layer0.getInstance(graph).domainChildren;
+ return graph.getPossibleRelatedValue2(resource, domainChildren,
+ new StandardGraphPropertyVariable(graph, this, domainChildren));
+ }
+
+ @Override
+ public Map<String, Variable> collectDomainProperties(ReadGraph graph, String classification, Map<String, Variable> properties) throws DatabaseException {
+ VariableMap valueMap = getPossiblePropertyVariableMap(graph);
+ if(valueMap == null) return properties;
+ return valueMap.getVariables(graph, this, classification, properties);
+ }
+
+ @Override
+ public Variable resolve(ReadGraph graph, RVIPart part) throws DatabaseException {
+ Resource represents = getPossibleRepresents(graph);
+ if (represents == null)
+ return StandardRVIResolver.INSTANCE.getVariable(graph, this, part);
+ RVIResolver resolver = graph.adapt(represents, RVIResolver.class);
+ return resolver.getVariable(graph, this, part);
+ }
+
+ @Override
+ public Variable resolvePossible(ReadGraph graph, RVIPart part) throws DatabaseException {
+ try {
+ return resolve(graph, part);
+ } catch (DatabaseException e) {
+ return null;
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public Set<String> getClassifications(ReadGraph graph) throws DatabaseException {
+ Resource represents = getPossibleRepresents(graph);
+ Set<String> result = (represents != null) ? graph.syncRequest(new ClassificationsRequest(graph.getPrincipalTypes(represents))) : Collections.<String>emptySet();
+ if (result.isEmpty()) {
+ Resource type = getPossibleType(graph);
+ if(type != null) result = graph.syncRequest(new ClassificationsRequest(Collections.singleton(type)));
+ }
+ if (result.isEmpty() && node != null) {
+ try {
+ result = node.support.manager.getClassifications(node.node);
+ } catch(NodeManagerException e) {
+ throw new DatabaseException(e);
+ }
+ }
+ return result;
+ }
+
+ @Override
+ public RVI getRVI(ReadGraph graph) throws DatabaseException {
+ Resource represents = getPossibleRepresents(graph);
+ if (represents == null)
+ return StandardRVIResolver.INSTANCE.getRVI(graph, this);
+ RVIResolver resolver = graph.adapt(represents, RVIResolver.class);
+ return resolver.getRVI(graph, this);
+ }
+
+ @Override
+ public RVI getPossibleRVI(ReadGraph graph) throws DatabaseException {
+ Resource represents = getPossibleRepresents(graph);
+ if (represents == null)
+ return StandardRVIResolver.INSTANCE.getPossibleRVI(graph, this);
+ RVIResolver resolver = graph.getPossibleAdapter(represents, RVIResolver.class);
+ if(resolver == null) return null;
+ return resolver.getPossibleRVI(graph, this);
+ }
+
+ @Override
+ public Resource getPossiblePredicateResource(ReadGraph graph) throws DatabaseException {
+ return null;
+ }
+
+ @Override
+ public Variable attachTo(ReadGraph graph, Variable parent) {
+ return new StandardGraphChildVariable(parent, node, resource);
+ }
+
+ @Override
+ public Variable attachToRenamed(ReadGraph graph, Variable parent, String name) {
+ return new StandardGraphChildVariable(parent, node, resource) {
+ @Override
+ public String getName(ReadGraph graph) throws DatabaseException {
+ return name;
+ }
+ };
+ }
+
+}