1 package de.dlr.shepard.neo4Core.entities;
2
3 import de.dlr.shepard.influxDB.Timeseries;
4 import de.dlr.shepard.util.Constants;
5 import de.dlr.shepard.util.HasId;
6 import java.util.ArrayList;
7 import java.util.List;
8 import java.util.Objects;
9 import lombok.Data;
10 import lombok.NoArgsConstructor;
11 import lombok.ToString;
12 import org.neo4j.ogm.annotation.NodeEntity;
13 import org.neo4j.ogm.annotation.Relationship;
14
15 @NodeEntity
16 @Data
17 @NoArgsConstructor
18 public class TimeseriesReference extends BasicReference {
19
20 private long start;
21
22 private long end;
23
24 @Relationship(type = Constants.HAS_PAYLOAD)
25 private List<Timeseries> timeseries = new ArrayList<>();
26
27 @ToString.Exclude
28 @Relationship(type = Constants.IS_IN_CONTAINER)
29 private TimeseriesContainer timeseriesContainer;
30
31
32
33
34
35
36 public TimeseriesReference(long id) {
37 super(id);
38 }
39
40 public void addTimeseries(Timeseries timeseries) {
41 this.timeseries.add(timeseries);
42 }
43
44 @Override
45 public int hashCode() {
46 final int prime = 31;
47 int result = super.hashCode();
48 result = prime * result + Objects.hash(end, start, timeseries);
49 result = prime * result + HasId.hashcodeHelper(timeseriesContainer);
50 return result;
51 }
52
53 @Override
54 public boolean equals(Object obj) {
55 if (this == obj) return true;
56 if (!super.equals(obj)) return false;
57 if (!(obj instanceof TimeseriesReference)) return false;
58 TimeseriesReference other = (TimeseriesReference) obj;
59 return (
60 end == other.end &&
61 start == other.start &&
62 Objects.equals(timeseries, other.timeseries) &&
63 HasId.equalsHelper(timeseriesContainer, other.timeseriesContainer)
64 );
65 }
66 }