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