import org.simantics.layer0.Layer0;\r
import org.simantics.simulation.ontology.SimulationResource;\r
import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.datastructures.Pair;\r
\r
public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph {\r
\r
if(graph.isInstanceOf(config, SIMU.Experiment)) {\r
for(Resource run : graph.getObjects(config, l0.ConsistsOf)) {\r
if(graph.isInstanceOf(run, SIMU.Run)) {\r
-// System.out.println("found run " + run);\r
result.add(run);\r
}\r
}\r
}\r
}\r
-// System.out.println("Compute runs ends");\r
return result;\r
}\r
\r
final Layer0 l0 = Layer0.getInstance(graph);\r
final String experimentName = graph.getPossibleRelatedValue(run, l0.HasName, StringBindingDefault.INSTANCE);\r
\r
-// System.out.println("RealizationVirtualGraph new experiment " + experimentName);\r
-\r
RuntimeValuations vs = graph.getService(RuntimeValuations.class);\r
if(vs.supports(experimentName)) {\r
\r
-// System.out.println("RealizationVirtualGraph scheduling " + experimentName);\r
-\r
-\r
- graph.asyncRequest(new Read<Collection<Resource>>() {\r
+ graph.asyncRequest(new Read<Collection<Pair<String, Resource>>>() {\r
\r
@Override\r
- public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
- HashSet<Resource> result = new HashSet<Resource>();\r
+ public Collection<Pair<String, Resource>> perform(ReadGraph graph) throws DatabaseException {\r
+ HashSet<Pair<String, Resource>> result = new HashSet<Pair<String, Resource>>();\r
Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
for(Resource part : graph.getObjects(configuration, l0.ConsistsOf)) {\r
- result.add(part);\r
+ String partName = graph.getPossibleRelatedValue(part, l0.HasName, StringBindingDefault.INSTANCE);\r
+ result.add(new Pair<String, Resource>(partName, part));\r
}\r
return result;\r
}\r
- }, new SingleSetSyncListener<Resource>() {\r
+ }, new SingleSetSyncListener<Pair<String, Resource>>() {\r
\r
@Override\r
- public void add(ReadGraph graph, final Resource part) throws DatabaseException {\r
+ public void add(ReadGraph graph, final Pair<String, Resource> part) throws DatabaseException {\r
graph.getSession().asyncRequest(new WriteRequest(graph.getService(VirtualGraph.class)) {\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
int runNode = context.getIndex(run);\r
- String partName = graph.getPossibleRelatedValue(part, l0.HasName, StringBindingDefault.INSTANCE);\r
- if(partName != null) {\r
+ if(part.first != null) {\r
Resource partResource = graph.newResource();\r
int partNode = context.getIndex(partResource);\r
graph.claim(run, l0.ConsistsOf, null, partResource);\r
- undiscovered.put(partNode, new ResourceData(runNode, part, valuation, partName, experimentName, null));\r
+ undiscovered.put(partNode, new ResourceData(runNode, part.second, valuation, part.first, experimentName, null));\r
}\r
}\r
});\r
}\r
\r
@Override\r
- public void remove(ReadGraph graph, final Resource part) throws DatabaseException {\r
- \r
+ public void remove(ReadGraph graph, final Pair<String, Resource> part) throws DatabaseException {\r
graph.getSession().asyncRequest(new WriteRequest(graph.getService(VirtualGraph.class)) {\r
@Override\r
public void perform(WriteGraph graph) throws DatabaseException {\r
Integer key = null;\r
for(int k : undiscovered.keySet()) {\r
- if (undiscovered.get(k).structureResource.equals(part)) {\r
+ ResourceData rd = undiscovered.get(k);\r
+ if (rd.name.equals(part.first) && rd.structureResource.equals(part.second)) {\r
key = k;\r
break;\r
}\r
Resource r = context.getResource(key);\r
RemoverUtil.remove(graph, r);\r
undiscovered.remove(key);\r
- \r
}\r
}\r
});\r
}\r
\r
});\r
-\r
-/*\r
- graph.getSession().asyncRequest(new WriteRequest(graph.getService(VirtualGraph.class)) {\r
-\r
- @Override\r
- public void perform(WriteGraph graph) throws DatabaseException {\r
-\r
-// System.out.println("RealizationVirtualGraph about to serve " + experimentName);\r
-\r
- int runNode = context.getIndex(run);\r
-\r
- Resource configuration = graph.getPossibleObject(model, b.HasConfiguration);\r
- for(Resource part : graph.getObjects(configuration, b.ConsistsOf)) {\r
- String partName = graph.getPossibleRelatedValue(part, b.HasName, StringBindingDefault.INSTANCE);\r
- if(partName != null) {\r
- Resource partResource = graph.newResource();\r
- int partNode = context.getIndex(partResource);\r
- graph.claim(run, b.ConsistsOf, null, partResource);\r
- undiscovered.put(partNode, new ResourceData(runNode, part, valuation, partName, experimentName, null));\r
- }\r
- }\r
-\r
- }\r
- });\r
-*/\r
\r
}\r
\r