1 package org.simantics.db.layer0.variable;
3 import java.util.Collection;
4 import java.util.Collections;
8 import org.simantics.databoard.binding.Binding;
9 import org.simantics.db.ReadGraph;
10 import org.simantics.db.Resource;
11 import org.simantics.db.WriteGraph;
12 import org.simantics.db.common.uri.UnescapedChildMapOfResource;
13 import org.simantics.db.exception.DatabaseException;
14 import org.simantics.db.layer0.exception.MissingVariableValueException;
15 import org.simantics.db.layer0.variable.RVI.RVIPart;
16 import org.simantics.db.layer0.variable.RVI.StringRVIPart;
17 import org.simantics.db.layer0.variable.Variables.Role;
19 public abstract class AbstractChildVariable extends AbstractVariable {
21 public AbstractChildVariable() {
25 public AbstractChildVariable(VariableNode node) {
30 public Role getRole(ReadGraph graph) throws DatabaseException {
35 public <T> T getValue(ReadGraph graph) throws DatabaseException {
36 throw new MissingVariableValueException("No value in child variable.");
40 public <T> T getValue(ReadGraph graph, Binding binding) throws DatabaseException {
41 throw new MissingVariableValueException("No value in child variable.");
45 public void setValue(WriteGraph graph, Object value, Binding binding)
46 throws DatabaseException {
47 throw new DatabaseException("Cannot write value to a child variable.");
52 public Resource getRepresents(ReadGraph graph) throws DatabaseException {
53 Variable parent = getParent(graph);
54 if(!(parent instanceof AbstractChildVariable))
56 Resource parentRepresents =
57 ((AbstractChildVariable)parent).getRepresentsForBrowsingChildResources(graph);
58 if(parentRepresents == null)
60 Resource result = graph.syncRequest(new UnescapedChildMapOfResource(parentRepresents))
62 // System.err.println("getRepresents " + getURI(graph) + " -> parent " + parentRepresents + " " + this + " => " + result + " " + getName(graph));
66 public Resource getRepresentsForBrowsingChildResources(ReadGraph graph) throws DatabaseException {
67 return getRepresents(graph);
71 public Variable getPossibleExtraProperty(ReadGraph graph, String name) throws DatabaseException {
76 public void collectExtraProperties(ReadGraph graph, Map<String, Variable> properties) throws DatabaseException {
80 protected Variable getPossibleDomainProperty(ReadGraph graph, String name) throws DatabaseException {
85 public Variable getPossibleChild(ReadGraph graph, String name) throws DatabaseException {
90 public Map<String, Variable> collectDomainProperties(ReadGraph graph, Map<String, Variable> map) throws DatabaseException {
95 public Collection<Variable> getChildren(ReadGraph graph) throws DatabaseException {
96 return Collections.emptyList();
100 public RVIPart getRVIPart(ReadGraph graph) throws DatabaseException {
101 return new StringRVIPart(Role.CHILD, getName(graph));
105 public Set<String> getClassifications(ReadGraph graph) throws DatabaseException {
106 return Collections.emptySet();