X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.event%2Fsrc%2Forg%2Fsimantics%2Fevent%2Futil%2FEventUtils.java;fp=bundles%2Forg.simantics.event%2Fsrc%2Forg%2Fsimantics%2Fevent%2Futil%2FEventUtils.java;h=bb85be21fe878143cb864547df0576043625efc3;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.event/src/org/simantics/event/util/EventUtils.java b/bundles/org.simantics.event/src/org/simantics/event/util/EventUtils.java new file mode 100644 index 000000000..bb85be21f --- /dev/null +++ b/bundles/org.simantics.event/src/org/simantics/event/util/EventUtils.java @@ -0,0 +1,29 @@ +package org.simantics.event.util; + +import java.util.UUID; + +import org.simantics.databoard.Bindings; +import org.simantics.db.Resource; +import org.simantics.db.WriteGraph; +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; + } + +}