Adding 'description' entity (former 'dataset' entity)

This commit is contained in:
Thomas Georgios Giannos 2023-10-24 12:47:48 +03:00
parent a68668f07e
commit e3536285aa
8 changed files with 639 additions and 0 deletions

View File

@ -38,6 +38,11 @@ public final class Permission {
public static String EditDmpBlueprint = "EditDmpBlueprint";
public static String DeleteDmpBlueprint = "DeleteDmpBlueprint";
//Description
public static String BrowseDescription = "BrowseDescription";
public static String EditDescription = "EditDescription";
public static String DeleteDescription = "DeleteDescription";
//DescriptionTemplateType
public static String BrowseEntityDoi = "BrowseEntityDoi";
public static String EditEntityDoi = "EditEntityDoi";

View File

@ -0,0 +1,31 @@
package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DescriptionStatus implements DatabaseEnum<Short> {
Saved((short) 0),
Finalized((short) 1),
Canceled((short) 2);
private final Short value;
DescriptionStatus(Short value) {
this.value = value;
}
@JsonValue
public Short getValue() {
return value;
}
private static final Map<Short, DescriptionStatus> map = EnumUtils.getEnumValueMap(DescriptionStatus.class);
public static DescriptionStatus of(Short i) {
return map.get(i);
}
}

View File

@ -0,0 +1,219 @@
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 jakarta.persistence.Column;
import jakarta.persistence.Convert;
import jakarta.persistence.Id;
import java.time.Instant;
import java.util.UUID;
//@Entity
//@Table(name = "\"Description\"")
public class DescriptionEntity {
@Id
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
private UUID id;
public static final String _id = "id";
@Column(name = "label", length = 250, nullable = false)
private String label;
public static final String _label = "label";
@Column(name = "dmp", columnDefinition = "uuid")
private UUID dmp;
public static final String _dmp = "dmp";
@Column(name = "uri", length = 250)
private String uri;
public static final String _uri = "uri";
@Column(name = "properties")
private String properties;
public static final String _properties = "properties";
//TODO: (thgiannos) Previously 'DescriptionTemplate'
@Column(name = "profile", columnDefinition = "uuid")
private UUID profile;
public static final String _profile = "profile";
@Column(name = "reference")
private String reference;
public static final String _reference = "reference";
@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 = "dmp_section_index", nullable = false)
private Integer dmpSectionIndex;
public static final String _dmpSectionIndex = "dmpSectionIndex";
@Column(name = "creator", columnDefinition = "uuid")
private UUID creator;
public static final String _creator = "creator";
@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";
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 UUID getDmp() {
return dmp;
}
public void setDmp(UUID dmp) {
this.dmp = dmp;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public UUID getProfile() {
return profile;
}
public void setProfile(UUID profile) {
this.profile = profile;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
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 Integer getDmpSectionIndex() {
return dmpSectionIndex;
}
public void setDmpSectionIndex(Integer dmpSectionIndex) {
this.dmpSectionIndex = dmpSectionIndex;
}
public UUID getCreator() {
return creator;
}
public void setCreator(UUID creator) {
this.creator = creator;
}
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;
}
}

View File

@ -0,0 +1,11 @@
package eu.eudat.data.converters.enums;
import eu.eudat.commons.enums.DescriptionStatus;
import jakarta.persistence.Converter;
@Converter
public class DescriptionStatusConverter extends DatabaseEnumConverter<DescriptionStatus, Short>{
protected DescriptionStatus of(Short i) {
return DescriptionStatus.of(i);
}
}

View File

@ -0,0 +1,24 @@
package eu.eudat.event;
import java.util.UUID;
public class DescriptionTouchedEvent {
public DescriptionTouchedEvent() {
}
public DescriptionTouchedEvent(UUID id) {
this.id = id;
}
private UUID id;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
}

View File

@ -0,0 +1,191 @@
package eu.eudat.model;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive;
import java.time.Instant;
import java.util.UUID;
public class Description {
private UUID id;
public static final String _id = "id";
private String label;
public static final String _label = "label";
private UUID dmp;
public static final String _dmp = "dmp";
private String uri;
public static final String _uri = "uri";
private String properties;
public static final String _properties = "properties";
private UUID profile;
public static final String _profile = "profile";
private String reference;
public static final String _reference = "reference";
private DescriptionStatus status;
public static final String _status = "status";
private String description;
public static final String _description = "description";
private Integer dmpSectionIndex;
public static final String _dmpSectionIndex = "dmpSectionIndex";
private UUID creator;
public static final String _creator = "creator";
private Instant createdAt;
public static final String _createdAt = "createdAt";
private Instant updatedAt;
public static final String _updatedAt = "updatedAt";
private IsActive isActive;
public static final String _isActive = "isActive";
private Instant finalizedAt;
public static final String _finalizedAt = "finalizedAt";
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 UUID getDmp() {
return dmp;
}
public void setDmp(UUID dmp) {
this.dmp = dmp;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public UUID getProfile() {
return profile;
}
public void setProfile(UUID profile) {
this.profile = profile;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
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 Integer getDmpSectionIndex() {
return dmpSectionIndex;
}
public void setDmpSectionIndex(Integer dmpSectionIndex) {
this.dmpSectionIndex = dmpSectionIndex;
}
public UUID getCreator() {
return creator;
}
public void setCreator(UUID creator) {
this.creator = creator;
}
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;
}
}

View File

@ -0,0 +1,37 @@
package eu.eudat.model.censorship;
import eu.eudat.authorization.Permission;
import eu.eudat.convention.ConventionService;
import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.DataLogEntry;
import gr.cite.tools.logging.LoggerService;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.UUID;
@Component
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class DescriptionCensor extends BaseCensor {
private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionCensor.class));
protected final AuthorizationService authService;
public DescriptionCensor(ConventionService conventionService, AuthorizationService authService) {
super(conventionService);
this.authService = authService;
}
public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields));
if (fields == null || fields.isEmpty())
return;
this.authService.authorizeForce(Permission.BrowseDescription);
}
}

View File

@ -0,0 +1,121 @@
package eu.eudat.model.persist;
import eu.eudat.commons.enums.DescriptionStatus;
import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.validation.ValidId;
import java.util.UUID;
public class DescriptionPersist {
@ValidId(message = "{validation.invalidid}")
private UUID id;
private String label;
private UUID dmp;
private String uri;
private String properties;
private UUID profile;
private String reference;
private DescriptionStatus status;
private String description;
private Integer dmpSectionIndex;
private IsActive isActive;
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 UUID getDmp() {
return dmp;
}
public void setDmp(UUID dmp) {
this.dmp = dmp;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getProperties() {
return properties;
}
public void setProperties(String properties) {
this.properties = properties;
}
public UUID getProfile() {
return profile;
}
public void setProfile(UUID profile) {
this.profile = profile;
}
public String getReference() {
return reference;
}
public void setReference(String reference) {
this.reference = reference;
}
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 Integer getDmpSectionIndex() {
return dmpSectionIndex;
}
public void setDmpSectionIndex(Integer dmpSectionIndex) {
this.dmpSectionIndex = dmpSectionIndex;
}
public IsActive getIsActive() {
return isActive;
}
public void setIsActive(IsActive isActive) {
this.isActive = isActive;
}
}