X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.document.server%2Fsrc%2Forg%2Fsimantics%2Fdocument%2Fserver%2FVariableStructuralContext.java;h=b714253e2e86a8a576575e915eefd537023740a5;hp=e3f7e3778a4b1cbbc2cffe9650efbbcbf02c0389;hb=de86e08dadfd2733d23b3fe2817b27ae835d9f3b;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.document.server/src/org/simantics/document/server/VariableStructuralContext.java b/bundles/org.simantics.document.server/src/org/simantics/document/server/VariableStructuralContext.java index e3f7e3778..b714253e2 100644 --- a/bundles/org.simantics.document.server/src/org/simantics/document/server/VariableStructuralContext.java +++ b/bundles/org.simantics.document.server/src/org/simantics/document/server/VariableStructuralContext.java @@ -1,98 +1,95 @@ -package org.simantics.document.server; - -import java.util.List; -import java.util.Map; - -import org.simantics.databoard.adapter.AdaptException; -import org.simantics.databoard.binding.Binding; -import org.simantics.db.ReadGraph; -import org.simantics.db.Resource; -import org.simantics.db.exception.DatabaseException; -import org.simantics.db.layer0.request.VariableRead; -import org.simantics.db.layer0.variable.Variable; -import org.simantics.db.service.CollectionSupport; -import org.simantics.document.base.ontology.DocumentationResource; -import org.simantics.structural2.scl.StructuralComponent; - -public class VariableStructuralContext extends StructuralComponent { - - final private Variable selfVariable; - final private Variable variable; - final private DocumentationResource DOC; - - public VariableStructuralContext(ReadGraph graph, Variable selfVariable) throws DatabaseException { - this.selfVariable = selfVariable; - this.variable = selfVariable.getParent(graph).getParent(graph); - this.DOC = DocumentationResource.getInstance(graph); - } - - @Override - public Resource getType(ReadGraph g) throws DatabaseException { - throw new UnsupportedOperationException(); - } - - static class MapRequest extends VariableRead> { - - public MapRequest(Variable component) { - super(component); - } - - @Override - public Map perform(ReadGraph graph) throws DatabaseException { - - CollectionSupport cs = graph.getService(CollectionSupport.class); - Map result = cs.createMap(Variable.class); - for(Variable property : variable.getProperties(graph)) { - Resource predicate = property.getPossiblePredicateResource(graph); - if(predicate != null) - result.put(predicate, property); - } - return result; - - } - - } - - @Override - public Object getValue(ReadGraph g, Resource attribute, Binding binding) throws DatabaseException, AdaptException { - - Map map = g.syncRequest(new MapRequest(variable)); - Variable p = map.get(attribute); - if(p != null) { - if(binding != null) - return p.getValue(g, binding); - else - return p.getValue(g); - } - - return null; - - } - - @Override - public boolean isParametrized(ReadGraph g) throws DatabaseException { - throw new UnsupportedOperationException(); - } - - @Override - public Variable getConnection(ReadGraph g, Resource connectionPoint) throws DatabaseException { - throw new UnsupportedOperationException(); - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public List getConnections(ReadGraph g, Resource connectionPoint) throws DatabaseException { - throw new UnsupportedOperationException(); - } - - @Override - public Resource getResource() { - throw new UnsupportedOperationException(); - } - - @Override - public StructuralComponent getContext() { - return null; - } - -} +package org.simantics.document.server; + +import java.util.List; +import java.util.Map; + +import org.simantics.databoard.adapter.AdaptException; +import org.simantics.databoard.binding.Binding; +import org.simantics.db.ReadGraph; +import org.simantics.db.Resource; +import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.request.VariableRead; +import org.simantics.db.layer0.variable.Variable; +import org.simantics.db.service.CollectionSupport; +import org.simantics.structural2.scl.StructuralComponent; + +public class VariableStructuralContext extends StructuralComponent { + + final private Variable selfVariable; + final private Variable variable; + + public VariableStructuralContext(ReadGraph graph, Variable selfVariable) throws DatabaseException { + this.selfVariable = selfVariable; + this.variable = selfVariable.getParent(graph).getParent(graph); + } + + @Override + public Resource getType(ReadGraph g) throws DatabaseException { + throw new UnsupportedOperationException(); + } + + static class MapRequest extends VariableRead> { + + public MapRequest(Variable component) { + super(component); + } + + @Override + public Map perform(ReadGraph graph) throws DatabaseException { + + CollectionSupport cs = graph.getService(CollectionSupport.class); + Map result = cs.createMap(Variable.class); + for(Variable property : variable.getProperties(graph)) { + Resource predicate = property.getPossiblePredicateResource(graph); + if(predicate != null) + result.put(predicate, property); + } + return result; + + } + + } + + @Override + public Object getValue(ReadGraph g, Resource attribute, Binding binding) throws DatabaseException, AdaptException { + + Map map = g.syncRequest(new MapRequest(variable)); + Variable p = map.get(attribute); + if(p != null) { + if(binding != null) + return p.getValue(g, binding); + else + return p.getValue(g); + } + + return null; + + } + + @Override + public boolean isParametrized(ReadGraph g) throws DatabaseException { + throw new UnsupportedOperationException(); + } + + @Override + public Variable getConnection(ReadGraph g, Resource connectionPoint) throws DatabaseException { + throw new UnsupportedOperationException(); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public List getConnections(ReadGraph g, Resource connectionPoint) throws DatabaseException { + throw new UnsupportedOperationException(); + } + + @Override + public Resource getResource() { + throw new UnsupportedOperationException(); + } + + @Override + public StructuralComponent getContext() { + return null; + } + +}