1 package de.dlr.shepard.neo4Core.entities;
2
3 import de.dlr.shepard.util.Constants;
4 import de.dlr.shepard.util.HasId;
5 import java.util.Objects;
6 import lombok.Data;
7 import lombok.NoArgsConstructor;
8 import lombok.ToString;
9 import org.neo4j.ogm.annotation.GeneratedValue;
10 import org.neo4j.ogm.annotation.Id;
11 import org.neo4j.ogm.annotation.NodeEntity;
12 import org.neo4j.ogm.annotation.Relationship;
13
14 @NodeEntity
15 @Data
16 @NoArgsConstructor
17 public class SemanticAnnotation implements HasId {
18
19 @Id
20 @GeneratedValue
21 private Long id;
22
23 private String name;
24
25 private String propertyIRI;
26
27 private String valueIRI;
28
29 @ToString.Exclude
30 @Relationship(type = Constants.PROPERTY_REPOSITORY)
31 private SemanticRepository propertyRepository;
32
33 @ToString.Exclude
34 @Relationship(type = Constants.VALUE_REPOSITORY)
35 private SemanticRepository valueRepository;
36
37
38
39
40
41
42 public SemanticAnnotation(long id) {
43 this.id = id;
44 }
45
46 @Override
47 public int hashCode() {
48 final int prime = 31;
49 var result = Objects.hash(id, name, propertyIRI, valueIRI);
50 result = prime * result + HasId.hashcodeHelper(propertyRepository);
51 result = prime * result + HasId.hashcodeHelper(valueRepository);
52 return result;
53 }
54
55 @Override
56 public boolean equals(Object obj) {
57 if (this == obj) return true;
58 if (obj == null) return false;
59 if (!(obj instanceof SemanticAnnotation)) return false;
60 SemanticAnnotation other = (SemanticAnnotation) obj;
61 return (
62 Objects.equals(id, other.id) &&
63 Objects.equals(name, other.name) &&
64 Objects.equals(propertyIRI, other.propertyIRI) &&
65 Objects.equals(valueIRI, other.valueIRI) &&
66 HasId.equalsHelper(propertyRepository, other.propertyRepository) &&
67 HasId.equalsHelper(valueRepository, other.valueRepository)
68 );
69 }
70
71 @Override
72 public String getUniqueId() {
73 return id.toString();
74 }
75 }