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

116 lines
2.7 KiB
Java
Raw Normal View History

2018-03-21 11:57:56 +01:00
package eu.eudat.data.entities;
2018-01-17 13:03:51 +01: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-01-17 13:03:51 +01:00
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.Date;
2018-10-02 16:33:58 +02:00
import java.util.List;
2018-01-17 13:03:51 +01:00
import java.util.Set;
import java.util.UUID;
2018-02-01 10:08:06 +01:00
2018-01-17 13:03:51 +01:00
@Entity
2018-02-16 11:34:02 +01:00
@Table(name = "\"ExternalDataset\"")
2018-02-20 08:50:17 +01:00
public class ExternalDataset implements DataEntity<ExternalDataset,UUID> {
2018-01-17 13:03:51 +01:00
@Id
@Column(name = "\"Id\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@Column(name = "\"Label\"", nullable = false)
private String label;
@Column(name = "\"Abbreviation\"", nullable = false)
private String abbreviation;
@Column(name = "\"Reference\"", nullable = false)
private String reference;
@Column(name = "\"Created\"", nullable = false)
2018-10-02 16:33:58 +02:00
@Convert(converter = DateToUTCConverter.class)
2018-01-17 13:03:51 +01:00
private Date created;
@Column(name = "\"Modified\"", nullable = false)
2018-10-02 16:33:58 +02:00
@Convert(converter = DateToUTCConverter.class)
2018-01-17 13:03:51 +01:00
private Date modified;
2018-05-28 11:50:42 +02:00
@OneToMany(mappedBy = "externalDataset", cascade = CascadeType.ALL, orphanRemoval = true)
private Set<DatasetExternalDataset> datasets;
2018-01-17 13:03:51 +01:00
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 getAbbreviation() {
return abbreviation;
}
public void setAbbreviation(String abbreviation) {
this.abbreviation = abbreviation;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getModified() {
return modified;
}
public void setModified(Date modified) {
this.modified = modified;
}
2018-05-28 11:50:42 +02:00
public Set<DatasetExternalDataset> getDatasets() {
2018-01-17 13:03:51 +01:00
return datasets;
}
2018-05-28 11:50:42 +02:00
public void setDatasets(Set<DatasetExternalDataset> datasets) {
2018-01-17 13:03:51 +01:00
this.datasets = datasets;
}
@Override
public void update(ExternalDataset entity) {
this.label = entity.getLabel();
this.abbreviation = entity.getAbbreviation();
this.modified = new Date();
}
@Override
2018-02-20 08:50:17 +01:00
public UUID getKeys() {
return this.id;
2018-01-17 13:03:51 +01:00
}
2018-10-02 16:33:58 +02:00
@Override
public ExternalDataset buildFromTuple(List<Tuple> tuple, String base) {
this.id = UUID.fromString((String) tuple.get(0).get(base.isEmpty() ? base + "." + "id" : "id"));
return this;
}
2018-01-17 13:03:51 +01:00
}