1 package org.simantics.document.server;
6 import org.simantics.databoard.adapter.AdaptException;
7 import org.simantics.databoard.binding.Binding;
8 import org.simantics.db.ReadGraph;
9 import org.simantics.db.Resource;
10 import org.simantics.db.exception.DatabaseException;
11 import org.simantics.db.layer0.request.VariableRead;
12 import org.simantics.db.layer0.variable.Variable;
13 import org.simantics.db.service.CollectionSupport;
14 import org.simantics.structural2.scl.StructuralComponent;
16 public class VariableStructuralContext extends StructuralComponent<Variable> {
18 final private Variable selfVariable;
19 final private Variable variable;
21 public VariableStructuralContext(ReadGraph graph, Variable selfVariable) throws DatabaseException {
22 this.selfVariable = selfVariable;
23 this.variable = selfVariable.getParent(graph).getParent(graph);
27 public Resource getType(ReadGraph g) throws DatabaseException {
28 throw new UnsupportedOperationException();
31 static class MapRequest extends VariableRead<Map<Resource,Variable>> {
33 public MapRequest(Variable component) {
38 public Map<Resource, Variable> perform(ReadGraph graph) throws DatabaseException {
40 CollectionSupport cs = graph.getService(CollectionSupport.class);
41 Map<Resource, Variable> result = cs.createMap(Variable.class);
42 for(Variable property : variable.getProperties(graph)) {
43 Resource predicate = property.getPossiblePredicateResource(graph);
45 result.put(predicate, property);
54 public Object getValue(ReadGraph g, Resource attribute, Binding binding) throws DatabaseException, AdaptException {
56 Map<Resource,Variable> map = g.syncRequest(new MapRequest(variable));
57 Variable p = map.get(attribute);
60 return p.getValue(g, binding);
70 public boolean isParametrized(ReadGraph g) throws DatabaseException {
71 throw new UnsupportedOperationException();
75 public Variable getConnection(ReadGraph g, Resource connectionPoint) throws DatabaseException {
76 throw new UnsupportedOperationException();
79 @SuppressWarnings({ "unchecked", "rawtypes" })
81 public List getConnections(ReadGraph g, Resource connectionPoint) throws DatabaseException {
82 throw new UnsupportedOperationException();
86 public Resource getResource() {
87 throw new UnsupportedOperationException();
91 public StructuralComponent<Variable> getContext() {