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.document.base.ontology.DocumentationResource;
15 import org.simantics.structural2.scl.StructuralComponent;
17 public class VariableStructuralContext extends StructuralComponent<Variable> {
19 final private Variable selfVariable;
20 final private Variable variable;
21 final private DocumentationResource DOC;
23 public VariableStructuralContext(ReadGraph graph, Variable selfVariable) throws DatabaseException {
24 this.selfVariable = selfVariable;
25 this.variable = selfVariable.getParent(graph).getParent(graph);
26 this.DOC = DocumentationResource.getInstance(graph);
30 public Resource getType(ReadGraph g) throws DatabaseException {
31 throw new UnsupportedOperationException();
34 static class MapRequest extends VariableRead<Map<Resource,Variable>> {
36 public MapRequest(Variable component) {
41 public Map<Resource, Variable> perform(ReadGraph graph) throws DatabaseException {
43 CollectionSupport cs = graph.getService(CollectionSupport.class);
44 Map<Resource, Variable> result = cs.createMap(Variable.class);
45 for(Variable property : variable.getProperties(graph)) {
46 Resource predicate = property.getPossiblePredicateResource(graph);
48 result.put(predicate, property);
57 public Object getValue(ReadGraph g, Resource attribute, Binding binding) throws DatabaseException, AdaptException {
59 Map<Resource,Variable> map = g.syncRequest(new MapRequest(variable));
60 Variable p = map.get(attribute);
63 return p.getValue(g, binding);
73 public boolean isParametrized(ReadGraph g) throws DatabaseException {
74 throw new UnsupportedOperationException();
78 public Variable getConnection(ReadGraph g, Resource connectionPoint) throws DatabaseException {
79 throw new UnsupportedOperationException();
82 @SuppressWarnings({ "unchecked", "rawtypes" })
84 public List getConnections(ReadGraph g, Resource connectionPoint) throws DatabaseException {
85 throw new UnsupportedOperationException();
89 public Resource getResource() {
90 throw new UnsupportedOperationException();
94 public StructuralComponent<Variable> getContext() {