235 lines
6.5 KiB
Java
235 lines
6.5 KiB
Java
package eu.eudat.data;
|
|
|
|
|
|
import eu.eudat.commons.enums.DescriptionStatus;
|
|
import eu.eudat.commons.enums.IsActive;
|
|
import eu.eudat.data.converters.DateToUTCConverter;
|
|
import eu.eudat.data.converters.enums.DescriptionStatusConverter;
|
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
|
import eu.eudat.data.old.helpers.EntityBinder;
|
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
|
|
|
import jakarta.persistence.*;
|
|
|
|
import java.time.Instant;
|
|
import java.util.*;
|
|
|
|
|
|
@Entity
|
|
@Table(name = "\"Description\"")
|
|
public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
|
|
|
@Id
|
|
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
|
private UUID id;
|
|
|
|
public static final String _id = "id";
|
|
|
|
@Column(name = "label", length = DescriptionEntity._labelLength, nullable = false)
|
|
private String label;
|
|
public static final int _labelLength = 250;
|
|
|
|
public static final String _label = "label";
|
|
|
|
|
|
@Column(name = "properties")
|
|
private String properties;
|
|
|
|
public static final String _properties = "properties";
|
|
|
|
@Column(name = "status", nullable = false)
|
|
@Convert(converter = DescriptionStatusConverter.class)
|
|
private DescriptionStatus status;
|
|
|
|
public static final String _status = "status";
|
|
|
|
@Column(name = "description")
|
|
private String description;
|
|
|
|
public static final String _description = "description";
|
|
|
|
@Column(name = "created_at", nullable = false)
|
|
private Instant createdAt;
|
|
|
|
public static final String _createdAt = "createdAt";
|
|
|
|
@Column(name = "updated_at", nullable = false)
|
|
private Instant updatedAt;
|
|
|
|
public static final String _updatedAt = "updatedAt";
|
|
|
|
@Column(name = "is_active", nullable = false)
|
|
@Convert(converter = IsActiveConverter.class)
|
|
private IsActive isActive;
|
|
|
|
public static final String _isActive = "isActive";
|
|
|
|
@Column(name = "\"finalized_at\"")
|
|
@Convert(converter = DateToUTCConverter.class)
|
|
private Instant finalizedAt;
|
|
|
|
public static final String _finalizedAt = "finalizedAt";
|
|
|
|
@Column(name = "created_by", columnDefinition = "uuid", nullable = false)
|
|
private UUID createdById;
|
|
|
|
public static final String _createdById = "createdById";
|
|
|
|
@Column(name = "dmp_description_template", columnDefinition = "uuid", nullable = false)
|
|
private UUID dmpDescriptionTemplateId;
|
|
|
|
public static final String _dmpDescriptionTemplateId = "dmpDescriptionTemplateId";
|
|
|
|
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 getProperties() {
|
|
return properties;
|
|
}
|
|
|
|
public void setProperties(String properties) {
|
|
this.properties = properties;
|
|
}
|
|
|
|
public DescriptionStatus getStatus() {
|
|
return status;
|
|
}
|
|
|
|
public void setStatus(DescriptionStatus status) {
|
|
this.status = status;
|
|
}
|
|
|
|
public String getDescription() {
|
|
return description;
|
|
}
|
|
|
|
public void setDescription(String description) {
|
|
this.description = description;
|
|
}
|
|
|
|
public Instant getCreatedAt() {
|
|
return createdAt;
|
|
}
|
|
|
|
public void setCreatedAt(Instant createdAt) {
|
|
this.createdAt = createdAt;
|
|
}
|
|
|
|
public Instant getUpdatedAt() {
|
|
return updatedAt;
|
|
}
|
|
|
|
public void setUpdatedAt(Instant updatedAt) {
|
|
this.updatedAt = updatedAt;
|
|
}
|
|
|
|
public IsActive getIsActive() {
|
|
return isActive;
|
|
}
|
|
|
|
public void setIsActive(IsActive isActive) {
|
|
this.isActive = isActive;
|
|
}
|
|
|
|
public Instant getFinalizedAt() {
|
|
return finalizedAt;
|
|
}
|
|
|
|
public void setFinalizedAt(Instant finalizedAt) {
|
|
this.finalizedAt = finalizedAt;
|
|
}
|
|
|
|
public UUID getCreatedById() {
|
|
return createdById;
|
|
}
|
|
|
|
public void setCreatedById(UUID createdById) {
|
|
this.createdById = createdById;
|
|
}
|
|
|
|
public UUID getDmpDescriptionTemplateId() {
|
|
return dmpDescriptionTemplateId;
|
|
}
|
|
|
|
public void setDmpDescriptionTemplateId(UUID dmpDescriptionTemplateId) {
|
|
this.dmpDescriptionTemplateId = dmpDescriptionTemplateId;
|
|
}
|
|
|
|
@Override
|
|
public void update(DescriptionEntity entity) {
|
|
// this.setUri(entity.getUri());
|
|
// this.setDescription(entity.getDescription());
|
|
// this.setLabel(entity.getLabel());
|
|
// this.setProperties(entity.getProperties());
|
|
//
|
|
// if (entity.getDatasetDataRepositories() == null || entity.getDatasetDataRepositories().size() < 1) {
|
|
// if (this.getDatasetDataRepositories() != null) this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
|
|
// } else {
|
|
// if (this.getDatasetDataRepositories() != null) {
|
|
// this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
|
|
// } else {
|
|
// this.setDatasetDataRepositories(new HashSet<>());
|
|
// }
|
|
// this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
|
// }
|
|
//
|
|
// if (entity.getDatasetExternalDatasets() == null || entity.getDatasetExternalDatasets().size() < 1) {
|
|
// if (this.getDatasetExternalDatasets() != null) this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
|
|
// } else {
|
|
// if (this.getDatasetExternalDatasets() != null) {
|
|
// this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
|
|
// } else {
|
|
// this.setDatasetExternalDatasets(new HashSet<>());
|
|
// }
|
|
// this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
|
// }
|
|
//
|
|
// if (entity.getServices() == null || entity.getServices().size() < 1) {
|
|
// if (this.getServices() != null) this.getServices().removeAll(this.getServices());
|
|
// } else {
|
|
// if (this.getServices() != null) {
|
|
// this.getServices().removeAll(this.getServices());
|
|
// } else {
|
|
// this.setServices(new HashSet<>());
|
|
// }
|
|
// this.getServices().addAll(entity.getServices().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
|
// }
|
|
//
|
|
// this.setRegistries(entity.getRegistries());
|
|
//
|
|
// this.setDmp(entity.getDmp());
|
|
// this.setDmpSectionIndex(entity.getDmpSectionIndex());
|
|
// this.setStatus(entity.getStatus());
|
|
// this.setProfile(entity.getProfile());
|
|
// this.setModified(new Date());
|
|
// if (entity.getStatus().equals(Status.FINALISED.getValue())) this.setFinalizedAt(new Date());
|
|
// if (entity.getCreator() != null) this.creator = entity.getCreator();
|
|
}
|
|
|
|
@Override
|
|
public UUID getKeys() {
|
|
return this.id;
|
|
}
|
|
|
|
@Override
|
|
public DescriptionEntity buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
|
String currentBase = base.isEmpty() ? "" : base + ".";
|
|
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
|
|
return this;
|
|
}
|
|
}
|
|
|