--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.db.layer0.request;\r
+\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.IndexRoots;\r
+import org.simantics.db.common.request.ResourceRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+\r
+public class PossibleModel extends ResourceRead<Resource> {\r
+\r
+ public PossibleModel(Resource resource) {\r
+ super(resource);\r
+ }\r
+\r
+ @Override\r
+ public Resource perform(ReadGraph graph) throws DatabaseException {\r
+\r
+ SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+ if (graph.isInstanceOf(resource, SIMU.Model))\r
+ return resource;\r
+\r
+ Collection<Resource> result = graph.sync(new IndexRoots(resource));\r
+ if(result.size() == 1) {\r
+ Resource res = result.iterator().next(); \r
+ if (graph.isInstanceOf(res, SIMU.Model))\r
+ return res;\r
+ }\r
+ return null;\r
+ \r
+// SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+// Layer0 L0 = Layer0.getInstance(graph);\r
+// \r
+// if (graph.isInstanceOf(resource, SIMU.Model))\r
+// return resource;\r
+// \r
+// Resource parent = graph.getPossibleObject(resource, L0.PartOf);\r
+// if (parent == null)\r
+// return null;\r
+// \r
+// else return graph.syncRequest(new PossibleModel(parent));\r
+\r
+ }\r
+\r
+}\r