import org.simantics.structural2.scl.CompileStructuralValueRequest;
import org.simantics.structural2.scl.procedural.CompileProceduralComponentTypeRequest;
import org.simantics.structural2.variables.Connection;
-import org.simantics.structural2.variables.ConnectionBrowser;
import org.simantics.structural2.variables.StandardProceduralChildVariable;
-import org.simantics.structural2.variables.VariableConnectionPointDescriptor;
import org.simantics.utils.datastructures.MapList;
import gnu.trove.map.hash.THashMap;
-import gnu.trove.set.hash.THashSet;
public class Functions {
};
- static class ConnectionImpl implements Connection {
-
- final private StandardGraphPropertyVariable connectionPoint;
-
- public ConnectionImpl(StandardGraphPropertyVariable connectionPoint) {
- this.connectionPoint = connectionPoint;
- }
-
- @Override
- public Collection<Variable> getConnectionPoints(ReadGraph graph, Resource relationType) throws DatabaseException {
- Set<Variable> result = new THashSet<Variable>();
- for(VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, connectionPoint.parent, connectionPoint.property.predicate, relationType)) {
- result.add(desc.getVariable(graph));
- }
- return result;
- }
-
- @Override
- public Collection<String> getConnectionPointURIs(ReadGraph graph, Resource relationType) throws DatabaseException {
- Set<String> result = new THashSet<String>();
- for(VariableConnectionPointDescriptor desc : ConnectionBrowser.flatten(graph, connectionPoint.parent, connectionPoint.property.predicate, relationType)) {
- result.add(desc.getURI(graph));
- }
- return result;
- }
-
- @Override
- public Collection<VariableConnectionPointDescriptor> getConnectionPointDescriptors(ReadGraph graph, Resource relationType) throws DatabaseException {
- return ConnectionBrowser.flatten(graph, connectionPoint.parent, connectionPoint.property.predicate, relationType);
- }
-
- }
-
@SCLValue(type="ValueAccessor")
public static final ValueAccessor connectionValueAccessor = new ValueAccessor() {
@Override
public Object getValue(ReadGraph graph, Variable context) throws DatabaseException {
StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context;
- return new ConnectionImpl(variable);
+ return new ConnectionImpl(variable.property.predicate);
}
@Override
public Variable getPossibleConnectionPointFromContext(ReadGraph graph, Variable variable, Resource context, String name) throws DatabaseException {
- Map<String, Resource> connectionPoints = graph.syncRequest(new ConnectionPointMapOfResource(graph, context), TransientCacheAsyncListener.<Map<String,Resource>>instance());
- Resource cp = connectionPoints.get(name);
+ Map<String, PropertyInfo> connectionPoints = graph.syncRequest(new ConnectionPointMapOfResource(graph, context), TransientCacheAsyncListener.<Map<String,PropertyInfo>>instance());
+ PropertyInfo cp = connectionPoints.get(name);
if(cp == null) return null;
- else return new StandardGraphPropertyVariable(graph, variable, cp);
+ else return new StandardGraphPropertyVariable(graph, variable, cp.predicate);
}
if(graph.isImmutable(context)) {
- Map<String, Resource> cps = graph.syncRequest(new ConnectionPointMapOfResource(graph, context), TransientCacheAsyncListener.<Map<String,Resource>>instance());
+ Map<String, PropertyInfo> cps = graph.syncRequest(new ConnectionPointMapOfResource(graph, context), TransientCacheAsyncListener.<Map<String,PropertyInfo>>instance());
if(cps.size() == 0) return map;
if(map == null) map = new THashMap<String,Variable>(cps.size());
- for(Map.Entry<String, Resource> entry : cps.entrySet()) {
+ for(Map.Entry<String, PropertyInfo> entry : cps.entrySet()) {
String name = entry.getKey();
- Resource cp = entry.getValue();
- if(needSynchronized && !graph.isInstanceOf(cp, STR.SynchronizedConnectionRelation)) continue;
- map.put(name, new StandardGraphPropertyVariable(graph, variable, cp));
+ PropertyInfo cp = entry.getValue();
+ if(needSynchronized && !graph.isInstanceOf(cp.predicate, STR.SynchronizedConnectionRelation)) continue;
+ map.put(name, new StandardGraphPropertyVariable(graph, variable, cp.predicate));
}
return map;
};
- static class StructuralChildMapOfResource extends ResourceRead<Map<String, Resource>> {
+ public static class StructuralChildMapOfResource extends ResourceRead<Map<String, Resource>> {
public StructuralChildMapOfResource(Resource resource) {
super(resource);
}
- static class StructuralChildMapOfResourceT extends ResourceRead<Map<String, Resource>> {
+ public static class StructuralChildMapOfResourceT extends ResourceRead<Map<String, Resource>> {
public StructuralChildMapOfResourceT(Resource resource) {
super(resource);