]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.event/src/org/simantics/event/util/EventUtils.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.event / src / org / simantics / event / util / EventUtils.java
index c4b83aa994c3c3c9585b39f3a503fd28b9b95416..9f29cc7ab15da399c97a55c3485c0d0402b8b49f 100644 (file)
@@ -1,72 +1,72 @@
-package org.simantics.event.util;\r
-\r
-import java.util.List;\r
-import java.util.UUID;\r
-\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.PossibleTypedParent;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.event.ontology.EventResource;\r
-import org.simantics.layer0.Layer0;\r
-\r
-public class EventUtils {\r
-\r
-       public static final int MAX_EVENTS = 1000;\r
-       public static final int SLICE_SIZE = 64;\r
-       public static final int KEEPS_SLICES = (MAX_EVENTS / SLICE_SIZE) + 2;\r
-       public static final String MAX_SLICE_NAME = "" + (SLICE_SIZE-1);\r
-\r
-       public static Resource createLog(WriteGraph graph) throws DatabaseException {\r
-               Layer0 L0 = Layer0.getInstance(graph);\r
-               EventResource EVENT = EventResource.getInstance(graph);\r
-        Resource log = graph.newResource();\r
-        graph.claim(log, L0.InstanceOf, null, EVENT.EventLog);\r
-        graph.claimLiteral(log, L0.HasName, UUID.randomUUID().toString(), Bindings.STRING);\r
-        graph.claimLiteral(log, EVENT.HasModificationCounter, 0, Bindings.INTEGER);\r
-        return log;\r
-       }\r
-\r
-    /**\r
-     * Bumps the modification counter value of the event log of the specified\r
-     * events using {@link #bumpModificationCounter(WriteGraph, Resource)}.\r
-     * <p>\r
-     * The code assumes that all events are from the same log.\r
-     * \r
-     * @param graph\r
-     * @param forLogOfEvents\r
-     * @throws DatabaseException\r
-     */\r
-    public static void bumpModificationCounter(WriteGraph graph, List<Resource> forLogOfEvents) throws DatabaseException {\r
-        EventResource EVENT = EventResource.getInstance(graph);\r
-        for (Resource event : forLogOfEvents) {\r
-            Resource log = graph.syncRequest(new PossibleTypedParent(event, EVENT.EventLog));\r
-            if (log != null) {\r
-                bumpModificationCounter(graph, log);\r
-                return;\r
-            }\r
-        }\r
-    }\r
-\r
-    /**\r
-     * Bumps the modification counter of the specified event log by 1.\r
-     * \r
-     * @param graph\r
-     * @param eventLog\r
-     * @return new modification counter value\r
-     * @throws DatabaseException\r
-     */\r
-    public static int bumpModificationCounter(WriteGraph graph, Resource eventLog) throws DatabaseException {\r
-        EventResource EVENT = EventResource.getInstance(graph);\r
-        Resource counter = graph.getPossibleObject(eventLog, EVENT.HasModificationCounter);\r
-        if (counter != null) {\r
-            Integer c = graph.getValue(counter, Bindings.INTEGER);\r
-            c = c == null ? 1 : c+1;\r
-            graph.claimValue(counter, c, Bindings.INTEGER);\r
-            return c;\r
-        }\r
-        return 0;\r
-    }\r
-\r
-}\r
+package org.simantics.event.util;
+
+import java.util.List;
+import java.util.UUID;
+
+import org.simantics.databoard.Bindings;
+import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
+import org.simantics.db.common.request.PossibleTypedParent;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.event.ontology.EventResource;
+import org.simantics.layer0.Layer0;
+
+public class EventUtils {
+
+       public static final int MAX_EVENTS = 1000;
+       public static final int SLICE_SIZE = 64;
+       public static final int KEEPS_SLICES = (MAX_EVENTS / SLICE_SIZE) + 2;
+       public static final String MAX_SLICE_NAME = "" + (SLICE_SIZE-1);
+
+       public static Resource createLog(WriteGraph graph) throws DatabaseException {
+               Layer0 L0 = Layer0.getInstance(graph);
+               EventResource EVENT = EventResource.getInstance(graph);
+        Resource log = graph.newResource();
+        graph.claim(log, L0.InstanceOf, null, EVENT.EventLog);
+        graph.claimLiteral(log, L0.HasName, UUID.randomUUID().toString(), Bindings.STRING);
+        graph.claimLiteral(log, EVENT.HasModificationCounter, 0, Bindings.INTEGER);
+        return log;
+       }
+
+    /**
+     * Bumps the modification counter value of the event log of the specified
+     * events using {@link #bumpModificationCounter(WriteGraph, Resource)}.
+     * <p>
+     * The code assumes that all events are from the same log.
+     * 
+     * @param graph
+     * @param forLogOfEvents
+     * @throws DatabaseException
+     */
+    public static void bumpModificationCounter(WriteGraph graph, List<Resource> forLogOfEvents) throws DatabaseException {
+        EventResource EVENT = EventResource.getInstance(graph);
+        for (Resource event : forLogOfEvents) {
+            Resource log = graph.syncRequest(new PossibleTypedParent(event, EVENT.EventLog));
+            if (log != null) {
+                bumpModificationCounter(graph, log);
+                return;
+            }
+        }
+    }
+
+    /**
+     * Bumps the modification counter of the specified event log by 1.
+     * 
+     * @param graph
+     * @param eventLog
+     * @return new modification counter value
+     * @throws DatabaseException
+     */
+    public static int bumpModificationCounter(WriteGraph graph, Resource eventLog) throws DatabaseException {
+        EventResource EVENT = EventResource.getInstance(graph);
+        Resource counter = graph.getPossibleObject(eventLog, EVENT.HasModificationCounter);
+        if (counter != null) {
+            Integer c = graph.getValue(counter, Bindings.INTEGER);
+            c = c == null ? 1 : c+1;
+            graph.claimValue(counter, c, Bindings.INTEGER);
+            return c;
+        }
+        return 0;
+    }
+
+}