argos/dmp-backend/data/src/main/java/eu/eudat/data/entities/Content.java

154 lines
3.5 KiB
Java
Raw Normal View History

2018-03-21 11:57:56 +01:00
package eu.eudat.data.entities;
2018-03-19 13:40:04 +01:00
2018-03-21 11:16:32 +01:00
import eu.eudat.queryable.queryableentity.DataEntity;
2018-03-19 13:40:04 +01:00
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
2018-10-02 16:33:58 +02:00
import java.util.List;
2018-03-19 13:40:04 +01:00
import java.util.UUID;
/**
* Created by ikalyvas on 3/15/2018.
*/
@Entity
@Table(name = "\"Content\"")
public class Content implements DataEntity<Content, UUID> {
public enum ParentType {
PROJECT(0);
private int value;
private ParentType(int value) {
this.value = value;
}
public int getValue() {
return value;
}
public static ParentType fromInteger(int value) {
switch (value) {
case 0:
return PROJECT;
default:
throw new RuntimeException("Unsupported Content Parent Type Status");
}
}
}
public enum LocationType {
EXTERNAL(0), INTERNAL(1);
private Integer value;
private LocationType(Integer value) {
this.value = value;
}
public Integer getValue() {
return value;
}
public static LocationType fromInteger(int value) {
switch (value) {
case 0:
return EXTERNAL;
case 1:
return INTERNAL;
default:
throw new RuntimeException("Unsupported Content Location Type");
}
}
}
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Filename\"", nullable = false)
private String label;
@Column(name = "\"Extension\"", nullable = false)
private String extension;
@Column(name = "\"ParentType\"", nullable = false)
private Integer parentType;
@Column(name = "\"Uri\"", nullable = false)
private String uri;
@Column(name = "\"LocationType\"", nullable = false)
private Integer locationType;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getExtension() {
return extension;
}
public void setExtension(String extension) {
this.extension = extension;
}
public Integer getParentType() {
return parentType;
}
public void setParentType(Integer parentType) {
this.parentType = parentType;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public Integer getLocationType() {
return locationType;
}
public void setLocationType(Integer locationType) {
this.locationType = locationType;
}
@Override
public void update(Content entity) {
this.extension = entity.getExtension();
this.label = entity.getLabel();
this.locationType = entity.getLocationType();
this.parentType = entity.getParentType();
this.uri = entity.getUri();
}
@Override
public UUID getKeys() {
return this.id;
}
2018-10-02 16:33:58 +02:00
@Override
public Content buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
2018-03-19 13:40:04 +01:00
}