BasicReference.java

package de.dlr.shepard.context.references.basicreference.entities;

import de.dlr.shepard.common.neo4j.entities.BasicEntity;
import de.dlr.shepard.common.util.Neo4jLabels;
import de.dlr.shepard.context.collection.entities.DataObject;
import de.dlr.shepard.context.version.entities.Version;
import de.dlr.shepard.context.version.entities.VersionableEntity;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.ToString;
import org.neo4j.ogm.annotation.Index;
import org.neo4j.ogm.annotation.Labels;
import org.neo4j.ogm.annotation.NodeEntity;
import org.neo4j.ogm.annotation.Relationship;
import org.neo4j.ogm.annotation.Relationship.Direction;

@NodeEntity
@Data
@ToString(callSuper = true, onlyExplicitlyIncluded = true)
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class BasicReference extends BasicEntity implements VersionableEntity {

  @Labels
  @NonNull
  private final List<String> labels = List.of(Neo4jLabels.VERSIONABLE_ENTITY);

  @Index
  private Long shepardId;

  @Relationship(type = Neo4jLabels.HAS_VERSION)
  protected Version version;

  @Relationship(type = Neo4jLabels.HAS_REFERENCE, direction = Direction.INCOMING)
  private DataObject dataObject;

  /**
   * For testing purposes only
   *
   * @param id identifies the entity
   */
  public BasicReference(long id) {
    super(id);
  }

  /**
   * Returns the name of the implemented class
   *
   * @return the simple class name
   */
  public String getType() {
    return this.getClass().getSimpleName();
  }

  @Override
  public long getNumericId() {
    return getShepardId();
  }
}