X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.structural2%2Fsrc%2Forg%2Fsimantics%2Fstructural2%2FFunctions.java;h=96b1c882098c7ea8dc7a622ac370bfd26402809a;hb=3d1f8e3dbccff974e2f4e0ea5f8bc61ad136e194;hp=f429fdc91d104fabcaf53d6fd6c5752bdb1699ad;hpb=81520c987689b19949edce7fea0ea76e367f4e95;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java b/bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java index f429fdc91..96b1c8820 100644 --- a/bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java +++ b/bundles/org.simantics.structural2/src/org/simantics/structural2/Functions.java @@ -180,7 +180,7 @@ public class Functions { @Override public Object getValue(ReadGraph graph, Variable context) throws DatabaseException { StandardGraphPropertyVariable variable = (StandardGraphPropertyVariable)context; - return new ConnectionImpl2(context.getParent(graph), variable.property.predicate); + return new ConnectionImpl(context.getParent(graph), variable.property.predicate); } @Override @@ -308,6 +308,82 @@ public class Functions { } + public static class StructuralChildMapOfResource extends ResourceRead> { + + public StructuralChildMapOfResource(Resource resource) { + super(resource); + } + + @Override + public Map perform(ReadGraph graph) throws DatabaseException { + StructuralResource2 STR = StructuralResource2.getInstance(graph); + Resource type = graph.getPossibleType(resource, STR.Component); + if(type != null) { + Resource definition = graph.getPossibleObject(type, STR.IsDefinedBy); + if(definition != null) { + Map map = graph.syncRequest(new UnescapedChildMapOfResource(definition)); + if (!map.isEmpty()) + return map; + } + } + Map directChildren = graph.syncRequest(new UnescapedChildMapOfResource(resource)); + return directChildren; + } + + } + + public static class StructuralChildMapOfResourceT extends ResourceRead> { + + public StructuralChildMapOfResourceT(Resource resource) { + super(resource); + } + + @Override + public Map perform(ReadGraph graph) throws DatabaseException { + StructuralResource2 STR = StructuralResource2.getInstance(graph); + Resource definition = graph.getPossibleObject(resource, STR.IsDefinedBy); + if(definition != null) { + Map map = graph.syncRequest(new UnescapedChildMapOfResource(definition)); + if (!map.isEmpty()) + return map; + } + return Collections.emptyMap(); + } + + } + + static class StructuralRunChildMapOfResource extends ResourceRead> { + + public StructuralRunChildMapOfResource(Resource resource) { + super(resource); + } + + public Map fromContext(ReadGraph graph, Resource context) throws DatabaseException { + return graph.sync(new StructuralChildMapOfResource(context)); + } + + @Override + public Map perform(ReadGraph graph) throws DatabaseException { + + Layer0 L0 = Layer0.getInstance(graph); + SimulationResource SIMU = SimulationResource.getInstance(graph); + Resource model = graph.sync(new PossibleIndexRoot(resource)); + if(graph.isInstanceOf(model, L0.RVIContext)) { + return fromContext(graph, model); + } + Resource configuration = graph.getPossibleObject(model, SIMU.HasConfiguration); + if(configuration != null) { + if(graph.isInstanceOf(configuration, L0.RVIContext)) { + return fromContext(graph, configuration); + } + } + + return Collections.emptyMap(); + + } + + } + private static class SubstructureRequest extends VariableRead> { public SubstructureRequest(Variable context) { super(context);