1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package eu.ehri.project.models.events;
21
22 import com.tinkerpop.blueprints.Vertex;
23 import com.tinkerpop.frames.Adjacency;
24 import com.tinkerpop.frames.Property;
25 import com.tinkerpop.frames.modules.javahandler.JavaHandler;
26 import com.tinkerpop.frames.modules.javahandler.JavaHandlerContext;
27 import com.tinkerpop.pipes.util.Pipeline;
28 import eu.ehri.project.definitions.Ontology;
29 import eu.ehri.project.models.EntityClass;
30 import eu.ehri.project.models.annotations.EntityType;
31 import eu.ehri.project.models.annotations.Mandatory;
32 import eu.ehri.project.models.base.Entity;
33 import eu.ehri.project.models.utils.JavaHandlerUtils;
34
35
36
37
38
39 @EntityType(EntityClass.SYSTEM)
40 public interface SystemEventQueue extends Entity {
41
42 String STREAM_START = Ontology.ACTIONER_HAS_LIFECYCLE_ACTION + "Stream";
43
44
45
46
47
48
49 @Mandatory
50 @Property(Ontology.EVENT_TIMESTAMP)
51 String getTimestamp();
52
53
54
55
56
57
58 @Adjacency(label = STREAM_START)
59 SystemEvent getLatestEvent();
60
61
62
63
64
65
66 @JavaHandler
67 Iterable<SystemEvent> getSystemEvents();
68
69 abstract class Impl implements JavaHandlerContext<Vertex>, SystemEventQueue {
70 public Iterable<SystemEvent> getSystemEvents() {
71 Pipeline<Vertex,Vertex> otherPipe = gremlin().as("n")
72 .out(Ontology.ACTIONER_HAS_LIFECYCLE_ACTION)
73 .loop("n", JavaHandlerUtils.noopLoopFunc, JavaHandlerUtils.noopLoopFunc);
74 return frameVertices(gremlin()
75 .out(STREAM_START).cast(Vertex.class)
76 .copySplit(gremlin(), otherPipe)
77 .exhaustMerge().cast(Vertex.class));
78 }
79 }
80 }