2018-03-21 11:57:56 +01:00
|
|
|
package eu.eudat.data.entities;
|
2017-09-14 12:37:36 +02:00
|
|
|
|
|
|
|
|
2018-10-02 16:33:58 +02:00
|
|
|
import eu.eudat.data.converters.DateToUTCConverter;
|
2018-03-21 11:16:32 +01:00
|
|
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
2018-02-16 11:34:02 +01:00
|
|
|
import org.hibernate.annotations.GenericGenerator;
|
|
|
|
import org.hibernate.annotations.Type;
|
|
|
|
|
|
|
|
import javax.persistence.*;
|
2017-11-02 17:17:56 +01:00
|
|
|
import java.util.Date;
|
2018-10-02 16:33:58 +02:00
|
|
|
import java.util.List;
|
2017-10-20 17:11:40 +02:00
|
|
|
import java.util.Set;
|
2017-09-14 12:37:36 +02:00
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
|
|
@Entity
|
2018-02-16 11:34:02 +01:00
|
|
|
@Table(name = "\"DatasetProfile\"")
|
2019-04-22 11:11:21 +02:00
|
|
|
public class DatasetProfile implements DataEntity<DatasetProfile,UUID>{
|
2018-02-16 11:34:02 +01:00
|
|
|
|
2019-02-06 12:10:44 +01:00
|
|
|
public enum Status {
|
2019-02-11 13:04:45 +01:00
|
|
|
SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99);
|
2019-02-06 12:10:44 +01:00
|
|
|
|
|
|
|
private short value;
|
|
|
|
|
|
|
|
private Status(short value) {
|
|
|
|
this.value = value;
|
|
|
|
}
|
|
|
|
public short getValue() {
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Status fromInteger(int value) {
|
|
|
|
switch (value) {
|
|
|
|
case 0:
|
2019-02-11 13:04:45 +01:00
|
|
|
return SAVED;
|
2019-02-06 12:10:44 +01:00
|
|
|
case 1:
|
2019-02-11 13:04:45 +01:00
|
|
|
return FINALIZED;
|
2019-02-06 12:10:44 +01:00
|
|
|
case 99:
|
|
|
|
return DELETED;
|
|
|
|
default:
|
|
|
|
throw new RuntimeException("Unsupported Dataset Profile Status");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
@Id
|
|
|
|
@GeneratedValue
|
2017-09-14 12:37:36 +02:00
|
|
|
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
|
|
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
2018-02-16 11:34:02 +01:00
|
|
|
private UUID id;
|
|
|
|
|
|
|
|
@Column(name = "\"Label\"")
|
|
|
|
private String label;
|
|
|
|
|
|
|
|
@OneToMany(fetch = FetchType.LAZY, mappedBy = "profile")
|
|
|
|
private Set<Dataset> dataset;
|
|
|
|
|
2018-06-27 12:29:21 +02:00
|
|
|
@Type(type = "eu.eudat.configurations.typedefinition.XMLType")
|
2018-02-16 11:34:02 +01:00
|
|
|
@Column(name = "\"Definition\"", columnDefinition = "xml", nullable = false)
|
|
|
|
private String definition;
|
|
|
|
|
|
|
|
@Column(name = "\"Status\"", nullable = false)
|
|
|
|
private Short status;
|
|
|
|
|
|
|
|
@Column(name = "\"Created\"")
|
2018-10-02 16:33:58 +02:00
|
|
|
@Convert(converter = DateToUTCConverter.class)
|
2018-02-16 11:34:02 +01:00
|
|
|
private Date created;
|
|
|
|
|
|
|
|
@Column(name = "\"Modified\"")
|
2018-10-02 16:33:58 +02:00
|
|
|
@Convert(converter = DateToUTCConverter.class)
|
2018-02-16 11:34:02 +01:00
|
|
|
private Date modified = new Date();
|
|
|
|
|
|
|
|
@Column(name = "\"Description\"")
|
|
|
|
private String description;
|
|
|
|
|
2019-03-26 15:30:33 +01:00
|
|
|
@Column(name = "\"GroupId\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
|
|
private UUID groupId;
|
|
|
|
|
|
|
|
@Column(name = "\"Version\"", nullable = false)
|
|
|
|
private Short version;
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
return description;
|
|
|
|
}
|
|
|
|
public void setDescription(String description) {
|
|
|
|
this.description = description;
|
|
|
|
}
|
2017-11-02 17:17:56 +01:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public Short getStatus() {
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
public void setStatus(Short status) {
|
|
|
|
this.status = status;
|
|
|
|
}
|
2017-11-02 17:17:56 +01:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public Date getCreated() {
|
|
|
|
return created;
|
|
|
|
}
|
|
|
|
public void setCreated(Date created) {
|
|
|
|
this.created = created;
|
|
|
|
}
|
2017-11-02 17:17:56 +01:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public Date getModified() {
|
|
|
|
return modified;
|
|
|
|
}
|
|
|
|
public void setModified(Date modified) {
|
|
|
|
this.modified = modified;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public UUID getId() {
|
|
|
|
return id;
|
|
|
|
}
|
2019-03-26 15:30:33 +01:00
|
|
|
public void setId(UUID id) { this.id = id;}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public String getLabel() {
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
public void setLabel(String label) {
|
|
|
|
this.label = label;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public String getDefinition() {
|
|
|
|
return definition;
|
|
|
|
}
|
|
|
|
public void setDefinition(String definition) {
|
|
|
|
this.definition = definition;
|
|
|
|
}
|
2017-10-20 17:11:40 +02:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
public Set<Dataset> getDataset() {
|
|
|
|
return dataset;
|
|
|
|
}
|
|
|
|
public void setDataset(Set<Dataset> dataset) {
|
|
|
|
this.dataset = dataset;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2019-03-26 15:30:33 +01:00
|
|
|
public UUID getGroupId() { return groupId; }
|
|
|
|
public void setGroupId(UUID groupId) { this.groupId = groupId;}
|
|
|
|
|
|
|
|
public Short getVersion() { return version; }
|
|
|
|
public void setVersion(Short version) { this.version = version; }
|
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
@Override
|
|
|
|
public String toString() {
|
2019-04-22 11:11:21 +02:00
|
|
|
return "DatasetProfileListingModel [id=" + id + ", label=" + label + ", dataset=" + dataset + ", definition=" + definition + ", version=" + version + "]";
|
2018-02-16 11:34:02 +01:00
|
|
|
}
|
2017-10-04 11:48:21 +02:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
@Override
|
|
|
|
public void update(DatasetProfile entity) {
|
|
|
|
}
|
2017-12-17 22:34:24 +01:00
|
|
|
|
2018-02-16 11:34:02 +01:00
|
|
|
@Override
|
2018-02-20 08:50:17 +01:00
|
|
|
public UUID getKeys() {
|
|
|
|
return this.id;
|
2018-02-16 11:34:02 +01:00
|
|
|
}
|
2018-10-02 16:33:58 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public DatasetProfile buildFromTuple(List<Tuple> tuple, String base) {
|
|
|
|
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
|
|
|
|
return this;
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
}
|