1 package de.dlr.shepard.neo4Core.entities;
2
3 import java.util.ArrayList;
4 import java.util.List;
5
6 import org.neo4j.ogm.annotation.NodeEntity;
7 import org.neo4j.ogm.annotation.Relationship;
8
9 import de.dlr.shepard.util.Constants;
10 import de.dlr.shepard.util.HasId;
11 import lombok.Data;
12 import lombok.NoArgsConstructor;
13 import lombok.ToString;
14
15 @NodeEntity
16 @Data
17 @ToString(callSuper = true)
18 @NoArgsConstructor
19 public class Collection extends AbstractDataObject {
20
21 @Relationship(type = Constants.HAS_DATAOBJECT)
22 private List<DataObject> dataObjects = new ArrayList<>();
23
24 @ToString.Exclude
25 @Relationship(type = Constants.POINTS_TO, direction = Relationship.INCOMING)
26 private List<CollectionReference> incoming = new ArrayList<>();
27
28 @ToString.Exclude
29 @Relationship(type = Constants.HAS_PERMISSIONS)
30 private Permissions permissions;
31
32
33
34
35
36
37 public Collection(long id) {
38 super(id);
39 }
40
41
42
43
44
45
46 public void addDataObject(DataObject dataObject) {
47 dataObjects.add(dataObject);
48 }
49
50 @Override
51 public int hashCode() {
52 final int prime = 31;
53 int result = super.hashCode();
54 result = prime * result + HasId.hashcodeHelper(dataObjects);
55 result = prime * result + HasId.hashcodeHelper(incoming);
56 result = prime * result + HasId.hashcodeHelper(permissions);
57 return result;
58 }
59
60 @Override
61 public boolean equals(Object obj) {
62 if (this == obj)
63 return true;
64 if (!super.equals(obj))
65 return false;
66 if (!(obj instanceof Collection))
67 return false;
68 Collection other = (Collection) obj;
69 return HasId.equalsHelper(dataObjects, other.dataObjects) && HasId.equalsHelper(incoming, other.incoming)
70 && HasId.equalsHelper(permissions, other.permissions);
71 }
72
73 }