From 026c8cdb249c17fc85fb8a53c41f21f0d20376fc Mon Sep 17 00:00:00 2001 From: lempinen Date: Tue, 28 Sep 2010 14:42:11 +0000 Subject: [PATCH] HistoryRealization names stay up-to-date in experiments git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@18113 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../HistoryRealizationVirtualGraph.java | 58 +++++-------------- 1 file changed, 13 insertions(+), 45 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/HistoryRealizationVirtualGraph.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/HistoryRealizationVirtualGraph.java index d637d8a8..d015a1c3 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/HistoryRealizationVirtualGraph.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/HistoryRealizationVirtualGraph.java @@ -21,6 +21,7 @@ import org.simantics.db.request.Read; import org.simantics.layer0.Layer0; import org.simantics.simulation.ontology.SimulationResource; import org.simantics.sysdyn.SysdynResource; +import org.simantics.utils.datastructures.Pair; public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph { @@ -43,13 +44,11 @@ public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph { if(graph.isInstanceOf(config, SIMU.Experiment)) { for(Resource run : graph.getObjects(config, l0.ConsistsOf)) { if(graph.isInstanceOf(run, SIMU.Run)) { -// System.out.println("found run " + run); result.add(run); } } } } -// System.out.println("Compute runs ends"); return result; } @@ -61,53 +60,48 @@ public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph { final Layer0 l0 = Layer0.getInstance(graph); final String experimentName = graph.getPossibleRelatedValue(run, l0.HasName, StringBindingDefault.INSTANCE); -// System.out.println("RealizationVirtualGraph new experiment " + experimentName); - RuntimeValuations vs = graph.getService(RuntimeValuations.class); if(vs.supports(experimentName)) { -// System.out.println("RealizationVirtualGraph scheduling " + experimentName); - - - graph.asyncRequest(new Read>() { + graph.asyncRequest(new Read>>() { @Override - public Collection perform(ReadGraph graph) throws DatabaseException { - HashSet result = new HashSet(); + public Collection> perform(ReadGraph graph) throws DatabaseException { + HashSet> result = new HashSet>(); Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration); for(Resource part : graph.getObjects(configuration, l0.ConsistsOf)) { - result.add(part); + String partName = graph.getPossibleRelatedValue(part, l0.HasName, StringBindingDefault.INSTANCE); + result.add(new Pair(partName, part)); } return result; } - }, new SingleSetSyncListener() { + }, new SingleSetSyncListener>() { @Override - public void add(ReadGraph graph, final Resource part) throws DatabaseException { + public void add(ReadGraph graph, final Pair part) throws DatabaseException { graph.getSession().asyncRequest(new WriteRequest(graph.getService(VirtualGraph.class)) { @Override public void perform(WriteGraph graph) throws DatabaseException { int runNode = context.getIndex(run); - String partName = graph.getPossibleRelatedValue(part, l0.HasName, StringBindingDefault.INSTANCE); - if(partName != null) { + if(part.first != null) { Resource partResource = graph.newResource(); int partNode = context.getIndex(partResource); graph.claim(run, l0.ConsistsOf, null, partResource); - undiscovered.put(partNode, new ResourceData(runNode, part, valuation, partName, experimentName, null)); + undiscovered.put(partNode, new ResourceData(runNode, part.second, valuation, part.first, experimentName, null)); } } }); } @Override - public void remove(ReadGraph graph, final Resource part) throws DatabaseException { - + public void remove(ReadGraph graph, final Pair part) throws DatabaseException { graph.getSession().asyncRequest(new WriteRequest(graph.getService(VirtualGraph.class)) { @Override public void perform(WriteGraph graph) throws DatabaseException { Integer key = null; for(int k : undiscovered.keySet()) { - if (undiscovered.get(k).structureResource.equals(part)) { + ResourceData rd = undiscovered.get(k); + if (rd.name.equals(part.first) && rd.structureResource.equals(part.second)) { key = k; break; } @@ -116,7 +110,6 @@ public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph { Resource r = context.getResource(key); RemoverUtil.remove(graph, r); undiscovered.remove(key); - } } }); @@ -128,31 +121,6 @@ public class HistoryRealizationVirtualGraph extends RealizationVirtualGraph { } }); - -/* - graph.getSession().asyncRequest(new WriteRequest(graph.getService(VirtualGraph.class)) { - - @Override - public void perform(WriteGraph graph) throws DatabaseException { - -// System.out.println("RealizationVirtualGraph about to serve " + experimentName); - - int runNode = context.getIndex(run); - - Resource configuration = graph.getPossibleObject(model, b.HasConfiguration); - for(Resource part : graph.getObjects(configuration, b.ConsistsOf)) { - String partName = graph.getPossibleRelatedValue(part, b.HasName, StringBindingDefault.INSTANCE); - if(partName != null) { - Resource partResource = graph.newResource(); - int partNode = context.getIndex(partResource); - graph.claim(run, b.ConsistsOf, null, partResource); - undiscovered.put(partNode, new ResourceData(runNode, part, valuation, partName, experimentName, null)); - } - } - - } - }); -*/ } -- 2.47.1