1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.db.layer0.request;
14 import java.util.Collection;
16 import org.simantics.db.ReadGraph;
17 import org.simantics.db.Resource;
18 import org.simantics.db.common.request.IndexRoots;
19 import org.simantics.db.common.request.ResourceRead;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.simulation.ontology.SimulationResource;
23 public class PossibleModel extends ResourceRead<Resource> {
25 public PossibleModel(Resource resource) {
30 public Resource perform(ReadGraph graph) throws DatabaseException {
32 SimulationResource SIMU = SimulationResource.getInstance(graph);
33 if (graph.isInstanceOf(resource, SIMU.Model))
36 Collection<Resource> result = graph.sync(new IndexRoots(resource));
37 if(result.size() == 1) {
38 Resource res = result.iterator().next();
39 if (graph.isInstanceOf(res, SIMU.Model))
44 // SimulationResource SIMU = SimulationResource.getInstance(graph);
45 // Layer0 L0 = Layer0.getInstance(graph);
47 // if (graph.isInstanceOf(resource, SIMU.Model))
50 // Resource parent = graph.getPossibleObject(resource, L0.PartOf);
51 // if (parent == null)
54 // else return graph.syncRequest(new PossibleModel(parent));