1 package org.simantics.db.layer0.request;
\r
3 import java.util.ArrayList;
\r
4 import java.util.Collection;
\r
5 import java.util.Collections;
\r
7 import org.simantics.db.ReadGraph;
\r
8 import org.simantics.db.Resource;
\r
9 import org.simantics.db.common.request.ResourceRead;
\r
10 import org.simantics.db.exception.DatabaseException;
\r
11 import org.simantics.db.layer0.variable.Variable;
\r
12 import org.simantics.db.layer0.variable.Variables;
\r
13 import org.simantics.simulation.ontology.SimulationResource;
\r
15 public class ActiveRuns extends ResourceRead<Collection<Variable>> {
\r
17 public ActiveRuns(ReadGraph graph, Variable model) throws DatabaseException {
\r
18 super(model.getRepresents(graph));
\r
21 public ActiveRuns(Resource model) {
\r
26 public Collection<Variable> perform(ReadGraph graph) throws DatabaseException {
\r
28 Variable variable = Variables.getPossibleVariable(graph, resource);
\r
29 if (variable == null)
\r
30 return Collections.emptyList();
\r
32 Collection<Variable> result = new ArrayList<Variable>();
\r
33 SimulationResource SIMU = SimulationResource.getInstance(graph);
\r
35 for(Variable experiment : variable.getChildren(graph)) {
\r
36 Resource experimentType = experiment.getPossibleType(graph, SIMU.Experiment);
\r
37 if(experimentType == null) continue;
\r
38 for(Variable run : experiment.getChildren(graph)) {
\r
39 Resource runType = run.getPossibleType(graph);
\r
40 if(runType == null) continue;
\r
41 if(graph.isInheritedFrom(runType, SIMU.Run)) {
\r
42 Resource represents = run.getRepresents(graph);
\r
43 if(graph.hasStatement(represents, SIMU.IsActive)) result.add(run);
\r