View Javadoc
1   package de.dlr.shepard.migrations.neo4j;
2   
3   import static org.neo4j.cypherdsl.core.Cypher.node;
4   
5   import lombok.AllArgsConstructor;
6   import org.neo4j.cypherdsl.core.Cypher;
7   import org.neo4j.cypherdsl.core.Literal;
8   import org.neo4j.cypherdsl.core.Node;
9   
10  @AllArgsConstructor
11  class SampleNodeCreator {
12  
13    private String suffix;
14  
15    public Node timeseries() {
16      return timeseries("device");
17    }
18  
19    public Node timeseries(String device) {
20      return node("Timeseries").withProperties(
21        "measurement",
22        literal("measurement"),
23        "device",
24        literal(device),
25        "location",
26        literal("location"),
27        "symbolicName",
28        literal("symbolicName"),
29        "field",
30        literal("field")
31      );
32    }
33  
34    public Node timeseriesReference() {
35      return timeseriesReference("Timeseries Reference");
36    }
37  
38    public Node timeseriesReference(int index) {
39      return timeseriesReference("ref" + index);
40    }
41  
42    Node timeseriesReference(String name) {
43      return node("TimeseriesReference", "VersionableEntity", "BasicReference", "BasicEntity").withProperties(
44        "createdAt",
45        Cypher.literalOf(100),
46        "deleted",
47        Cypher.literalOf(false),
48        "end",
49        Cypher.literalOf(2000),
50        "name",
51        literal(name),
52        "shepardId",
53        Cypher.literalOf(5),
54        "start",
55        Cypher.literalOf(1000)
56      );
57    }
58  
59    public Node annotation() {
60      return node("SemanticAnnotation").withProperties("propertyName", literal("prop"), "valueName", literal("value"));
61    }
62  
63    public Node annotation(int propNum) {
64      return node("SemanticAnnotation").withProperties(
65        "propertyName",
66        literal("prop-" + propNum),
67        "valueName",
68        literal("value")
69      );
70    }
71  
72    public Node timeseriesContainer(int index) {
73      return timeseriesContainer("TimeseriesContainer " + index);
74    }
75  
76    public Node timeseriesContainer() {
77      return timeseriesContainer("TimeseriesContainer");
78    }
79  
80    public Node timeseriesContainer(String name) {
81      return node("TimeseriesContainer", "BasicEntity", "BasicContainer").withProperties(
82        "createdAt",
83        Cypher.literalOf(200),
84        "deleted",
85        Cypher.literalOf(false),
86        "name",
87        literal(name)
88      );
89    }
90  
91    public Literal<String> literal(String of) {
92      return Cypher.literalOf(of + " " + suffix);
93    }
94  }