package org.simantics.structural2.scl; import java.util.List; import org.simantics.databoard.Bindings; 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.variable.Variable; import org.simantics.layer0.Layer0; import org.simantics.structural.stubs.StructuralResource2; import org.simantics.structural2.scl.StructuralComponent; public class VariableStructuralContext extends StructuralComponent { final public Variable variable; public VariableStructuralContext(ReadGraph graph, Variable selfVariable) throws DatabaseException { this.variable = selfVariable.getParent(graph).getParent(graph); } public VariableStructuralContext(Variable variable) throws DatabaseException { this.variable = variable; } @Override public Resource getType(ReadGraph g) throws DatabaseException { throw new UnsupportedOperationException(); } @Override public Object getValue(ReadGraph g, Resource attribute, Binding binding) throws DatabaseException, AdaptException { Layer0 L0 = Layer0.getInstance(g); StructuralResource2 STR = StructuralResource2.getInstance(g); if(STR.input.equals(attribute)) { return variable.getPropertyValue(g, "input"); } String name = g.getRelatedValue(attribute, L0.HasName, Bindings.STRING); return variable.getPropertyValue(g, name); } @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() { throw new UnsupportedOperationException(); } }