1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.db.layer0.request;
\r
14 import org.simantics.db.ReadGraph;
\r
15 import org.simantics.db.Resource;
\r
16 import org.simantics.db.common.request.PossibleIndexRoot;
\r
17 import org.simantics.db.common.request.ResourceRead;
\r
18 import org.simantics.db.exception.DatabaseException;
\r
19 import org.simantics.layer0.Layer0;
\r
20 import org.simantics.simulation.ontology.SimulationResource;
\r
22 public class PossibleActiveExperiment extends ResourceRead<Resource> {
\r
24 public PossibleActiveExperiment(Resource partOfModel) {
\r
29 public Resource perform(ReadGraph graph) throws DatabaseException {
\r
31 Resource model = graph.sync(new PossibleIndexRoot(resource));
\r
32 if(model == null) return null;
\r
34 Layer0 b = Layer0.getInstance(graph);
\r
35 SimulationResource SIMU = SimulationResource.getInstance(graph);
\r
36 Resource result = null;
\r
37 for(Resource config : graph.getObjects(model, b.ConsistsOf)) {
\r
38 if(graph.isInstanceOf(config, SIMU.Experiment)) {
\r
39 for(Resource run : graph.getObjects(config, b.ConsistsOf)) {
\r
40 if(graph.isInstanceOf(run, SIMU.Run)) {
\r
41 if(graph.hasStatement(run, SIMU.IsActive)) {
\r
42 if(result != null) return null;
\r