argos/dmp-migration-tool/data/src/main/java/eu/old/eudat/data/entities/DatasetRegistry.java

97 lines
2.2 KiB
Java

package eu.old.eudat.data.entities;
import eu.old.eudat.queryable.queryableentity.DataEntity;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Type;
import jakarta.persistence.*;
import java.io.Serializable;
import java.util.List;
import java.util.UUID;
@Entity
@Table(name = "\"DatasetRegistry\"")
public class DatasetRegistry implements DataEntity<DatasetRegistry, UUID> {
@Id
@GeneratedValue
@GenericGenerator(name = "uuid2", strategy = "uuid2")
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
private UUID id;
@ManyToOne
@JoinColumn(name = "\"Dataset\"", nullable = false)
private Dataset dataset;
@ManyToOne
@JoinColumn(name = "\"Registry\"", nullable = false)
private Registry registry;
@Column(name = "\"Role\"")
private Integer role;
@Column(name = "\"Data\"")
private String data;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public Dataset getDataset() {
return dataset;
}
public void setDataset(Dataset dataset) {
this.dataset = dataset;
}
public Registry getRegistry() {
return registry;
}
public void setRegistry(Registry registry) {
this.registry = registry;
}
public Integer getRole() {
return role;
}
public void setRole(Integer role) {
this.role = role;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
@Override
public void update(DatasetRegistry entity) {
this.dataset = entity.getDataset();
this.registry = entity.getRegistry();
this.role = entity.getRole();
}
@Override
public UUID getKeys() {
return this.id;
}
@Override
public DatasetRegistry buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
String currentBase = base.isEmpty() ? "" : base + ".";
if(fields.contains(currentBase + "id")) this.id = UUID.fromString((String) tuple.get(0).get(currentBase + "id"));
return this;
}
}