-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.ResourceRead;\r
-import org.simantics.db.common.utils.NameUtils;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.exception.NoSingleResultException;\r
-\r
-/**\r
- * Returns the active model or null if no single active model is available.\r
- */\r
-public class SingleActiveModel extends ResourceRead<Resource> {\r
-\r
- public SingleActiveModel(Resource project) {\r
- super(project);\r
- }\r
-\r
- @Override\r
- public Resource perform(ReadGraph graph) throws DatabaseException {\r
- Collection<Resource> actives = graph.syncRequest(new ActiveModels(resource));\r
- if (actives.size() == 1)\r
- return actives.iterator().next();\r
-\r
- if (actives.size() == 0) \r
- throw new NoSingleResultException("There are no active models."); \r
-\r
- throw new NoSingleResultException("There are many active models: " + NameUtils.getSafeName(graph, actives)); \r
- \r
- }\r
-\r
-}\r
+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.ResourceRead;
+import org.simantics.db.common.utils.NameUtils;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.exception.NoSingleResultException;
+
+/**
+ * Returns the active model or null if no single active model is available.
+ */
+public class SingleActiveModel extends ResourceRead<Resource> {
+
+ public SingleActiveModel(Resource project) {
+ super(project);
+ }
+
+ @Override
+ public Resource perform(ReadGraph graph) throws DatabaseException {
+ Collection<Resource> actives = graph.syncRequest(new ActiveModels(resource));
+ if (actives.size() == 1)
+ return actives.iterator().next();
+
+ if (actives.size() == 0)
+ throw new NoSingleResultException("There are no active models.");
+
+ throw new NoSingleResultException("There are many active models: " + NameUtils.getSafeName(graph, actives));
+
+ }
+
+}