]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.event/src/org/simantics/event/util/AllEventLogs.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.event / src / org / simantics / event / util / AllEventLogs.java
diff --git a/bundles/org.simantics.event/src/org/simantics/event/util/AllEventLogs.java b/bundles/org.simantics.event/src/org/simantics/event/util/AllEventLogs.java
new file mode 100644 (file)
index 0000000..0346036
--- /dev/null
@@ -0,0 +1,35 @@
+package org.simantics.event.util;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.List;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.ResourceRead;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.event.ontology.EventResource;\r
+\r
+/**\r
+ * Request for getting all event logs from a model.\r
+ * \r
+ * @author Tuukka Lehtonen\r
+ */\r
+public class AllEventLogs extends ResourceRead<Collection<Resource>> {\r
+\r
+    public AllEventLogs(Resource model) {\r
+        super(model);\r
+    }\r
+\r
+    @Override\r
+    public Collection<Resource> perform(ReadGraph graph) throws DatabaseException {\r
+        EventResource EVENT = EventResource.getInstance(graph);\r
+        List<Resource> result = new ArrayList<Resource>();\r
+        for (Resource eventLog : graph.syncRequest(new ObjectsWithType(resource, EVENT.HasEventLog, EVENT.EventLog))) {\r
+            result.add(eventLog);\r
+        }\r
+        return result;\r
+    }\r
+\r
+}\r