1 package org.simantics.db.layer0.variable;
3 import org.simantics.databoard.Bindings;
4 import org.simantics.db.ReadGraph;
5 import org.simantics.db.Resource;
6 import org.simantics.db.exception.DatabaseException;
7 import org.simantics.layer0.Layer0;
9 abstract public class NodeManagerVariableBuilder implements VariableBuilder {
12 public Variable buildChild(ReadGraph graph, Variable parent, VariableNode node, Resource child) throws DatabaseException {
13 Layer0 L0 = Layer0.getInstance(graph);
14 String childName = graph.getRelatedValue(child, L0.HasName, Bindings.STRING);
15 String sessionName = parent.getURI(graph) + "/" + childName;
16 return createChild(graph, parent, sessionName, child);
19 protected Variable createChild(ReadGraph graph, Variable parent, String sessionName, Resource child) throws DatabaseException {
20 NodeSupport<?> support = getNodeSupport(graph, sessionName);
21 return new StandardGraphChildVariable(parent, new VariableNode(support, getRoot(graph, support, sessionName)), child);
25 public Variable buildProperty(ReadGraph graph, Variable parent, VariableNode node, Resource subject, Resource predicate) throws DatabaseException {
26 throw new UnsupportedOperationException();
29 protected abstract NodeSupport<?> getNodeSupport(ReadGraph graph, String sessionName) throws DatabaseException;
30 protected abstract Object getRoot(ReadGraph graph, NodeSupport<?> support, String sessionName) throws DatabaseException;