View Javadoc
1   package de.dlr.shepard.context.references.basicreference.entities;
2   
3   import de.dlr.shepard.common.neo4j.entities.BasicEntity;
4   import de.dlr.shepard.common.util.Neo4jLabels;
5   import de.dlr.shepard.context.collection.entities.DataObject;
6   import de.dlr.shepard.context.version.entities.Version;
7   import de.dlr.shepard.context.version.entities.VersionableEntity;
8   import java.util.List;
9   import lombok.Data;
10  import lombok.EqualsAndHashCode;
11  import lombok.NoArgsConstructor;
12  import lombok.NonNull;
13  import lombok.ToString;
14  import org.neo4j.ogm.annotation.Index;
15  import org.neo4j.ogm.annotation.Labels;
16  import org.neo4j.ogm.annotation.NodeEntity;
17  import org.neo4j.ogm.annotation.Relationship;
18  import org.neo4j.ogm.annotation.Relationship.Direction;
19  
20  @NodeEntity
21  @Data
22  @ToString(callSuper = true, onlyExplicitlyIncluded = true)
23  @NoArgsConstructor
24  @EqualsAndHashCode(callSuper = true)
25  public class BasicReference extends BasicEntity implements VersionableEntity {
26  
27    @Labels
28    @NonNull
29    private final List<String> labels = List.of(Neo4jLabels.VERSIONABLE_ENTITY);
30  
31    @Index
32    private Long shepardId;
33  
34    @Relationship(type = Neo4jLabels.HAS_VERSION)
35    protected Version version;
36  
37    @Relationship(type = Neo4jLabels.HAS_REFERENCE, direction = Direction.INCOMING)
38    private DataObject dataObject;
39  
40    /**
41     * For testing purposes only
42     *
43     * @param id identifies the entity
44     */
45    public BasicReference(long id) {
46      super(id);
47    }
48  
49    /**
50     * Returns the name of the implemented class
51     *
52     * @return the simple class name
53     */
54    public String getType() {
55      return this.getClass().getSimpleName();
56    }
57  
58    @Override
59    public long getNumericId() {
60      return getShepardId();
61    }
62  }