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