DmpBlueprint refacto

This commit is contained in:
Efstratios Giannopoulos 2023-10-23 15:58:33 +03:00
parent f4d84aa807
commit fe7d6f59b1
39 changed files with 634 additions and 133 deletions

View File

@ -1,5 +1,6 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
@ -15,6 +16,7 @@ public enum DescriptionTemplateTypeStatus implements DatabaseEnum<Short> {
this.value = value; this.value = value;
} }
@JsonValue
public Short getValue() { public Short getValue() {
return value; return value;
} }

View File

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

View File

@ -1,31 +0,0 @@
package eu.eudat.commons.enums;
import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map;
public enum DmpBlueprintExtraFieldType implements DatabaseEnum<Short> {
Text((short) 0),
RichTex((short) 1),
Date((short) 2),
Number((short) 3),
;
private final Short value;
DmpBlueprintExtraFieldType(Short value) {
this.value = value;
}
public Short getValue() {
return value;
}
private static final Map<Short, DmpBlueprintExtraFieldType> map = EnumUtils.getEnumValueMap(DmpBlueprintExtraFieldType.class);
public static DmpBlueprintExtraFieldType of(Short i) {
return map.get(i);
}
}

View File

@ -1,5 +1,6 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
@ -14,6 +15,7 @@ public enum DmpBlueprintFieldCategory implements DatabaseEnum<Short> {
this.value = value; this.value = value;
} }
@JsonValue
public Short getValue() { public Short getValue() {
return value; return value;
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
@ -15,6 +16,7 @@ public enum DmpBlueprintStatus implements DatabaseEnum<Short> {
this.value = value; this.value = value;
} }
@JsonValue
public Short getValue() { public Short getValue() {
return value; return value;
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
@ -23,6 +24,7 @@ public enum DmpBlueprintSystemFieldType implements DatabaseEnum<Short> {
this.value = value; this.value = value;
} }
@JsonValue
public Short getValue() { public Short getValue() {
return value; return value;
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
@ -15,6 +16,7 @@ public enum DmpStatus implements DatabaseEnum<Short> {
} }
@Override @Override
@JsonValue
public Short getValue() { public Short getValue() {
return null; return null;
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
@ -15,6 +16,7 @@ public enum EntityType implements DatabaseEnum<Short> {
} }
@Override @Override
@JsonValue
public Short getValue() { public Short getValue() {
return value; return value;
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
@ -25,6 +26,7 @@ public enum ExternalReferencesType implements DatabaseEnum<Short> {
this.value = value; this.value = value;
} }
@JsonValue
public Short getValue() { public Short getValue() {
return value; return value;
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
@ -15,6 +16,7 @@ public enum IsActive implements DatabaseEnum<Short> {
this.value = value; this.value = value;
} }
@JsonValue
public Short getValue() { public Short getValue() {
return value; return value;
} }

View File

@ -1,5 +1,6 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.HashMap; import java.util.HashMap;
@ -25,6 +26,7 @@ public enum ProviderType implements DatabaseEnum<Integer> {
this.value = value; this.value = value;
} }
@JsonValue
public Integer getValue() { return this.value; } public Integer getValue() { return this.value; }
private static final Map<Integer, ProviderType> map = EnumUtils.getEnumValueMap(ProviderType.class); private static final Map<Integer, ProviderType> map = EnumUtils.getEnumValueMap(ProviderType.class);

View File

@ -1,5 +1,6 @@
package eu.eudat.commons.enums; package eu.eudat.commons.enums;
import com.fasterxml.jackson.annotation.JsonValue;
import eu.eudat.data.converters.enums.DatabaseEnum; import eu.eudat.data.converters.enums.DatabaseEnum;
import java.util.Map; import java.util.Map;
@ -15,6 +16,7 @@ public enum UserSettingsType implements DatabaseEnum<Short> {
this.value = value; this.value = value;
} }
@JsonValue
public Short getValue() { public Short getValue() {
return value; return value;
} }

View File

@ -1,19 +1,16 @@
package eu.eudat.commons.types.dmpblueprint; package eu.eudat.commons.types.dmpblueprint;
import eu.eudat.commons.enums.DmpBlueprintExtraFieldType; import eu.eudat.commons.enums.DmpBlueprintExtraFieldDataType;
import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import java.util.UUID;
public class ExtraFieldEntity extends FieldEntity { public class ExtraFieldEntity extends FieldEntity {
private DmpBlueprintExtraFieldType type; private DmpBlueprintExtraFieldDataType type;
public DmpBlueprintExtraFieldType getType() { public DmpBlueprintExtraFieldDataType getType() {
return type; return type;
} }
public void setType(DmpBlueprintExtraFieldType type) { public void setType(DmpBlueprintExtraFieldDataType type) {
this.type = type; this.type = type;
} }
@ -25,7 +22,7 @@ public class ExtraFieldEntity extends FieldEntity {
@Override @Override
public ExtraFieldEntity fromXmlChild(Element item) { public ExtraFieldEntity fromXmlChild(Element item) {
this.type = DmpBlueprintExtraFieldType.of(Short.parseShort(item.getAttribute("type"))); this.type = DmpBlueprintExtraFieldDataType.of(Short.parseShort(item.getAttribute("type")));
return this; return this;
} }
} }

View File

@ -1,8 +1,6 @@
package eu.eudat.commons.types.dmpblueprint; package eu.eudat.commons.types.dmpblueprint;
import eu.eudat.commons.enums.DmpBlueprintExtraFieldType;
import eu.eudat.commons.enums.DmpBlueprintFieldCategory; import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
import eu.eudat.commons.types.xml.XmlSerializable; import eu.eudat.commons.types.xml.XmlSerializable;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;

View File

@ -30,9 +30,10 @@ public class DmpBlueprintEntity implements DataEntity<DmpBlueprintEntity, UUID>
private UUID id; private UUID id;
public static final String _id = "id"; public static final String _id = "id";
@Column(name = "\"label\"") @Column(name = "\"label\"", length = DmpBlueprintEntity._labelLength, nullable = false)
private String label; private String label;
public static final String _label = "label"; public static final String _label = "label";
public static final int _labelLength = 250;
@Type(eu.eudat.configurations.typedefinition.XMLType.class) @Type(eu.eudat.configurations.typedefinition.XMLType.class)
@Column(name = "\"definition\"", columnDefinition = "xml", nullable = true) @Column(name = "\"definition\"", columnDefinition = "xml", nullable = true)

View File

@ -1,5 +1,8 @@
package eu.eudat.data.converters.enums; package eu.eudat.data.converters.enums;
import com.fasterxml.jackson.annotation.JsonValue;
public interface DatabaseEnum<T> { public interface DatabaseEnum<T> {
@JsonValue
T getValue(); T getValue();
} }

View File

@ -28,7 +28,7 @@ public class DescriptionTemplateTypeCensor extends BaseCensor {
public void censor(FieldSet fields, UUID userId) { public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorizeForce(Permission.BrowseDescriptionTemplateType); this.authService.authorizeForce(Permission.BrowseDescriptionTemplateType);

View File

@ -35,7 +35,7 @@ public class DmpBlueprintCensor extends BaseCensor {
public void censor(FieldSet fields, UUID userId) { public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorizeForce(Permission.BrowseDmpBlueprint); this.authService.authorizeForce(Permission.BrowseDmpBlueprint);

View File

@ -28,7 +28,7 @@ public class EntityDoiCensor extends BaseCensor{
public void censor(FieldSet fields, UUID userId) { public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorizeForce(Permission.BrowseEntityDoi); this.authService.authorizeForce(Permission.BrowseEntityDoi);

View File

@ -35,7 +35,7 @@ public class DefinitionCensor extends BaseCensor {
public void censor(FieldSet fields, UUID userId) { public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorizeForce(Permission.BrowseDmpBlueprint); this.authService.authorizeForce(Permission.BrowseDmpBlueprint);

View File

@ -30,7 +30,7 @@ public class DescriptionTemplatesCensor extends BaseCensor {
public void censor(FieldSet fields, UUID userId) { public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorizeForce(Permission.BrowseDmpBlueprint); this.authService.authorizeForce(Permission.BrowseDmpBlueprint);

View File

@ -30,7 +30,7 @@ public class FieldCensor extends BaseCensor {
public void censor(FieldSet fields, UUID userId) { public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorizeForce(Permission.BrowseDmpBlueprint); this.authService.authorizeForce(Permission.BrowseDmpBlueprint);

View File

@ -35,7 +35,7 @@ public class SectionCensor extends BaseCensor {
public void censor(FieldSet fields, UUID userId) { public void censor(FieldSet fields, UUID userId) {
logger.debug(new DataLogEntry("censoring fields", fields)); logger.debug(new DataLogEntry("censoring fields", fields));
if (fields.isEmpty()) if (fields == null || fields.isEmpty())
return; return;
this.authService.authorizeForce(Permission.BrowseDmpBlueprint); this.authService.authorizeForce(Permission.BrowseDmpBlueprint);

View File

@ -1,17 +1,17 @@
package eu.eudat.model.dmpblueprintdefinition; package eu.eudat.model.dmpblueprintdefinition;
import eu.eudat.commons.enums.DmpBlueprintExtraFieldType; import eu.eudat.commons.enums.DmpBlueprintExtraFieldDataType;
public class ExtraField extends Field { public class ExtraField extends Field {
public final static String _type = "type"; public final static String _type = "type";
private DmpBlueprintExtraFieldType type; private DmpBlueprintExtraFieldDataType type;
public DmpBlueprintExtraFieldType getType() { public DmpBlueprintExtraFieldDataType getType() {
return type; return type;
} }
public void setType(DmpBlueprintExtraFieldType type) { public void setType(DmpBlueprintExtraFieldDataType type) {
this.type = type; this.type = type;
} }
} }

View File

@ -1,12 +1,6 @@
package eu.eudat.model.dmpblueprintdefinition; package eu.eudat.model.dmpblueprintdefinition;
import eu.eudat.commons.enums.DmpBlueprintExtraFieldType;
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
import eu.eudat.commons.types.dmpblueprint.DescriptionTemplateEntity;
import eu.eudat.commons.types.dmpblueprint.FieldEntity;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;

View File

@ -0,0 +1,78 @@
package eu.eudat.model.persist;
import eu.eudat.commons.enums.DmpBlueprintStatus;
import eu.eudat.commons.validation.FieldNotNullIfOtherSet;
import eu.eudat.commons.validation.ValidEnum;
import eu.eudat.commons.validation.ValidId;
import eu.eudat.data.DmpBlueprintEntity;
import eu.eudat.model.dmpblueprintdefinition.Definition;
import eu.eudat.model.persist.dmpblueprintdefinition.DefinitionPersist;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.util.UUID;
@FieldNotNullIfOtherSet(message = "{validation.hashempty}")
public class DmpBlueprintPersist {
@ValidId(message = "{validation.invalidid}")
private UUID id;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
@Size(max = DmpBlueprintEntity._labelLength, message = "{validation.largerthanmax}")
private String label = null;
@NotNull(message = "{validation.empty}")
@Valid
private DefinitionPersist definition = null;
@ValidEnum(message = "{validation.empty}")
private DmpBlueprintStatus status;
private String hash;
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 DefinitionPersist getDefinition() {
return definition;
}
public void setDefinition(DefinitionPersist definition) {
this.definition = definition;
}
public DmpBlueprintStatus getStatus() {
return status;
}
public void setStatus(DmpBlueprintStatus status) {
this.status = status;
}
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
}

View File

@ -0,0 +1,21 @@
package eu.eudat.model.persist.dmpblueprintdefinition;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import java.util.List;
public class DefinitionPersist {
@NotNull(message = "{validation.empty}")
@Valid
private List<SectionPersist> sections = null;
public List<SectionPersist> getSections() {
return sections;
}
public void setSections(List<SectionPersist> sections) {
this.sections = sections;
}
}

View File

@ -0,0 +1,67 @@
package eu.eudat.model.persist.dmpblueprintdefinition;
import eu.eudat.commons.validation.ValidId;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.UUID;
public class DescriptionTemplatePersist {
@NotNull(message = "{validation.empty}")
@ValidId(message = "{validation.invalidid}")
private UUID id = null;
@NotNull(message = "{validation.empty}")
@ValidId(message = "{validation.invalidid}")
private UUID descriptionTemplateId = null;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String label = null;
@NotNull(message = "{validation.empty}")
private Integer minMultiplicity = null;
@NotNull(message = "{validation.empty}")
private Integer maxMultiplicity = null;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public UUID getDescriptionTemplateId() {
return descriptionTemplateId;
}
public void setDescriptionTemplateId(UUID descriptionTemplateId) {
this.descriptionTemplateId = descriptionTemplateId;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public Integer getMinMultiplicity() {
return minMultiplicity;
}
public void setMinMultiplicity(Integer minMultiplicity) {
this.minMultiplicity = minMultiplicity;
}
public Integer getMaxMultiplicity() {
return maxMultiplicity;
}
public void setMaxMultiplicity(Integer maxMultiplicity) {
this.maxMultiplicity = maxMultiplicity;
}
}

View File

@ -0,0 +1,19 @@
package eu.eudat.model.persist.dmpblueprintdefinition;
import eu.eudat.commons.enums.DmpBlueprintExtraFieldDataType;
import eu.eudat.commons.validation.ValidEnum;
public class ExtraFieldPersist extends FieldPersist {
@ValidEnum(message = "{validation.empty}")
private DmpBlueprintExtraFieldDataType dataType;
public DmpBlueprintExtraFieldDataType getDataType() {
return dataType;
}
public void setDataType(DmpBlueprintExtraFieldDataType dataType) {
this.dataType = dataType;
}
}

View File

@ -0,0 +1,102 @@
package eu.eudat.model.persist.dmpblueprintdefinition;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
import eu.eudat.commons.validation.ValidEnum;
import eu.eudat.commons.validation.ValidId;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.UUID;
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "category")
@JsonSubTypes({
@JsonSubTypes.Type(value = SystemFieldPersist.class, name = "System"),
@JsonSubTypes.Type(value = ExtraFieldPersist.class, name = "Extra")
})
public abstract class FieldPersist {
@NotNull(message = "{validation.empty}")
@ValidId(message = "{validation.invalidid}")
private UUID id = null;
@ValidEnum(message = "{validation.empty}")
private DmpBlueprintFieldCategory category;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String label = null;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String placeholder = null;
private String description;
@NotNull(message = "{validation.empty}")
private Integer ordinal = null;
@NotNull(message = "{validation.empty}")
private Boolean required = null;
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public DmpBlueprintFieldCategory getCategory() {
return category;
}
public void setCategory(DmpBlueprintFieldCategory category) {
this.category = category;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getPlaceholder() {
return placeholder;
}
public void setPlaceholder(String placeholder) {
this.placeholder = placeholder;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getOrdinal() {
return ordinal;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public Boolean getRequired() {
return required;
}
public void setRequired(Boolean required) {
this.required = required;
}
}

View File

@ -0,0 +1,94 @@
package eu.eudat.model.persist.dmpblueprintdefinition;
import eu.eudat.commons.validation.ValidId;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import java.util.List;
import java.util.UUID;
public class SectionPersist {
@NotNull(message = "{validation.empty}")
@ValidId(message = "{validation.invalidid}")
private UUID id = null;
private String description;
@NotNull(message = "{validation.empty}")
@NotEmpty(message = "{validation.empty}")
private String label = null;
@NotNull(message = "{validation.empty}")
private Integer ordinal = null;
@NotNull(message = "{validation.empty}")
private Boolean hasTemplates = null;
@Valid
@NotNull(message = "{validation.empty}")
private List<FieldPersist> fields = null;
@Valid
private List<DescriptionTemplatePersist> descriptionTemplates = null;
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 getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Integer getOrdinal() {
return ordinal;
}
public void setOrdinal(Integer ordinal) {
this.ordinal = ordinal;
}
public Boolean getHasTemplates() {
return hasTemplates;
}
public void setHasTemplates(Boolean hasTemplates) {
this.hasTemplates = hasTemplates;
}
public List<FieldPersist> getFields() {
return fields;
}
public void setFields(List<FieldPersist> fields) {
this.fields = fields;
}
public List<DescriptionTemplatePersist> getDescriptionTemplates() {
return descriptionTemplates;
}
public void setDescriptionTemplates(List<DescriptionTemplatePersist> descriptionTemplates) {
this.descriptionTemplates = descriptionTemplates;
}
}

View File

@ -0,0 +1,17 @@
package eu.eudat.model.persist.dmpblueprintdefinition;
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
import eu.eudat.commons.validation.ValidEnum;
public class SystemFieldPersist extends FieldPersist {
@ValidEnum(message = "{validation.empty}")
private DmpBlueprintSystemFieldType systemFieldType;
public DmpBlueprintSystemFieldType getSystemFieldType() {
return systemFieldType;
}
public void setSystemFieldType(DmpBlueprintSystemFieldType systemFieldType) {
this.systemFieldType = systemFieldType;
}
}

View File

@ -1,6 +1,7 @@
package eu.eudat.service.dmpblueprint; package eu.eudat.service.dmpblueprint;
import eu.eudat.model.DmpBlueprint; import eu.eudat.model.DmpBlueprint;
import eu.eudat.model.persist.DmpBlueprintPersist;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyNotFoundException;
@ -12,7 +13,7 @@ import java.util.UUID;
public interface DmpBlueprintService { public interface DmpBlueprintService {
// DmpBlueprint persist(DmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException; DmpBlueprint persist(DmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException;
void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException; void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException;

View File

@ -2,19 +2,20 @@ package eu.eudat.service.dmpblueprint;
import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.AuthorizationFlags;
import eu.eudat.authorization.Permission; import eu.eudat.authorization.Permission;
import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
import eu.eudat.commons.enums.IsActive; import eu.eudat.commons.enums.IsActive;
import eu.eudat.commons.types.dmpblueprint.*;
import eu.eudat.commons.types.xml.XmlBuilder;
import eu.eudat.convention.ConventionService; import eu.eudat.convention.ConventionService;
import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.DmpBlueprintEntity;
import eu.eudat.errorcode.ErrorThesaurusProperties;
import eu.eudat.event.EventBroker;
import eu.eudat.model.DmpBlueprint; import eu.eudat.model.DmpBlueprint;
import eu.eudat.model.builder.DmpBlueprintBuilder; import eu.eudat.model.builder.DmpBlueprintBuilder;
import eu.eudat.model.deleter.DmpBlueprintDeleter; import eu.eudat.model.deleter.DmpBlueprintDeleter;
import eu.eudat.model.persist.DmpBlueprintPersist;
import eu.eudat.model.persist.dmpblueprintdefinition.*;
import gr.cite.commons.web.authz.service.AuthorizationService; import gr.cite.commons.web.authz.service.AuthorizationService;
import gr.cite.tools.data.builder.BuilderFactory; import gr.cite.tools.data.builder.BuilderFactory;
import gr.cite.tools.data.deleter.DeleterFactory; import gr.cite.tools.data.deleter.DeleterFactory;
import gr.cite.tools.data.query.QueryFactory;
import gr.cite.tools.exception.MyApplicationException; import gr.cite.tools.exception.MyApplicationException;
import gr.cite.tools.exception.MyForbiddenException; import gr.cite.tools.exception.MyForbiddenException;
import gr.cite.tools.exception.MyNotFoundException; import gr.cite.tools.exception.MyNotFoundException;
@ -24,14 +25,17 @@ import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import jakarta.persistence.EntityManager; import jakarta.persistence.EntityManager;
import org.jetbrains.annotations.NotNull;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
import org.springframework.context.i18n.LocaleContextHolder; import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.w3c.dom.Document;
import javax.management.InvalidApplicationException; import javax.management.InvalidApplicationException;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@ -50,15 +54,9 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
private final ConventionService conventionService; private final ConventionService conventionService;
private final ErrorThesaurusProperties errors;
private final MessageSource messageSource; private final MessageSource messageSource;
private final EventBroker eventBroker;
private final QueryFactory queryFactory;
private final JsonHandlingService jsonHandlingService;
@Autowired @Autowired
public DmpBlueprintServiceImpl( public DmpBlueprintServiceImpl(
@ -67,58 +65,128 @@ public class DmpBlueprintServiceImpl implements DmpBlueprintService {
DeleterFactory deleterFactory, DeleterFactory deleterFactory,
BuilderFactory builderFactory, BuilderFactory builderFactory,
ConventionService conventionService, ConventionService conventionService,
ErrorThesaurusProperties errors, MessageSource messageSource) {
MessageSource messageSource,
EventBroker eventBroker,
QueryFactory queryFactory,
JsonHandlingService jsonHandlingService) {
this.entityManager = entityManager; this.entityManager = entityManager;
this.authorizationService = authorizationService; this.authorizationService = authorizationService;
this.deleterFactory = deleterFactory; this.deleterFactory = deleterFactory;
this.builderFactory = builderFactory; this.builderFactory = builderFactory;
this.conventionService = conventionService; this.conventionService = conventionService;
this.errors = errors;
this.messageSource = messageSource; this.messageSource = messageSource;
this.eventBroker = eventBroker;
this.queryFactory = queryFactory;
this.jsonHandlingService = jsonHandlingService;
} }
// public DmpBlueprint persist(DmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException { public DmpBlueprint persist(DmpBlueprintPersist model, FieldSet fields) throws MyForbiddenException, MyValidationException, MyApplicationException, MyNotFoundException, InvalidApplicationException {
// logger.debug(new MapLogEntry("persisting data dmpBlueprint").And("model", model).And("fields", fields)); logger.debug(new MapLogEntry("persisting data").And("model", model).And("fields", fields));
//
// this.authorizationService.authorizeForce(Permission.EditDmpBlueprint); this.authorizationService.authorizeForce(Permission.EditDmpBlueprint);
//
// Boolean isUpdate = this.conventionService.isValidGuid(model.getId()); Boolean isUpdate = this.conventionService.isValidGuid(model.getId());
//
// DmpBlueprintEntity data; DmpBlueprintEntity data;
// if (isUpdate) { if (isUpdate) {
// data = this.entityManager.find(DmpBlueprintEntity.class, model.getId()); data = this.entityManager.find(DmpBlueprintEntity.class, model.getId());
// if (data == null) if (data == null)
// throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{model.getId(), DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale()));
// } else { } else {
// data = new DmpBlueprintEntity(); data = new DmpBlueprintEntity();
// data.setId(UUID.randomUUID()); data.setId(UUID.randomUUID());
// data.setIsActive(IsActive.Active); data.setIsActive(IsActive.Active);
// data.setCreatedAt(Instant.now()); data.setCreatedAt(Instant.now());
// } }
//
// data.setName(model.getName()); data.setLabel(model.getLabel());
// data.setStatus(model.getStatus()); data.setStatus(model.getStatus());
// data.setUpdatedAt(Instant.now()); data.setUpdatedAt(Instant.now());
// if (isUpdate)
// this.entityManager.merge(data); Document document = XmlBuilder.getDocument();
// else if (document == null) throw new InvalidApplicationException("Can not create document");
// this.entityManager.persist(data); document.appendChild(this.buildDefinitionEntity(model.getDefinition()).toXml(document));
// data.setDefinition(XmlBuilder.generateXml(document));
// this.entityManager.flush();
// if (isUpdate) this.entityManager.merge(data);
// this.eventBroker.emit(new DmpBlueprintTouchedEvent(data.getId())); else this.entityManager.persist(data);
// return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(BaseFieldSet.build(fields, DmpBlueprint._id), data);
// } this.entityManager.flush();
return this.builderFactory.builder(DmpBlueprintBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(BaseFieldSet.build(fields, DmpBlueprint._id), data);
}
private @NotNull DefinitionEntity buildDefinitionEntity(DefinitionPersist persist){
DefinitionEntity data = new DefinitionEntity();
if (persist == null) return data;
if (!this.conventionService.isListNullOrEmpty(persist.getSections())){
data.setSections(new ArrayList<>());
for (SectionPersist sectionPersist: persist.getSections()) {
data.getSections().add(this.buildSectionEntity(sectionPersist));
}
}
return data;
}
private @NotNull SectionEntity buildSectionEntity(SectionPersist persist){
SectionEntity data = new SectionEntity();
if (persist == null) return data;
data.setId(persist.getId());
data.setDescription(persist.getDescription());
data.setLabel(persist.getLabel());
data.setOrdinal(persist.getOrdinal());
data.setHasTemplates(persist.getHasTemplates());
if (!this.conventionService.isListNullOrEmpty(persist.getFields())){
data.setFields(new ArrayList<>());
for (FieldPersist fieldPersist: persist.getFields()) {
data.getFields().add(this.buildExtraFieldEntity(fieldPersist));
}
}
if (!this.conventionService.isListNullOrEmpty(persist.getDescriptionTemplates())){
data.setDescriptionTemplates(new ArrayList<>());
for (DescriptionTemplatePersist descriptionTemplatePersist: persist.getDescriptionTemplates()) {
data.getDescriptionTemplates().add(this.buildDescriptionTemplateEntity(descriptionTemplatePersist));
}
}
return data;
}
private @NotNull DescriptionTemplateEntity buildDescriptionTemplateEntity(DescriptionTemplatePersist persist){
DescriptionTemplateEntity data = new DescriptionTemplateEntity();
if (persist == null) return data;
data.setId(persist.getId());
data.setDescriptionTemplateId(persist.getDescriptionTemplateId());
data.setLabel(persist.getLabel());
data.setMaxMultiplicity(persist.getMaxMultiplicity());
data.setMinMultiplicity(persist.getMinMultiplicity());
return data;
}
private @NotNull FieldEntity buildExtraFieldEntity(FieldPersist persist){
if (persist == null) return new ExtraFieldEntity();
FieldEntity data;
if (DmpBlueprintFieldCategory.Extra.equals(persist.getCategory())){
ExtraFieldEntity dataTyped = new ExtraFieldEntity();
dataTyped.setType(((ExtraFieldPersist)persist).getDataType());
data = dataTyped;
} else {
SystemFieldEntity dataTyped = new SystemFieldEntity();
dataTyped.setType(((SystemFieldPersist)persist).getSystemFieldType());
data = dataTyped;
}
data.setId(persist.getId());
data.setCategory(persist.getCategory());
data.setLabel(persist.getLabel());
data.setPlaceholder(persist.getPlaceholder());
data.setDescription(persist.getDescription());
data.setOrdinal(persist.getOrdinal());
data.setRequired(persist.getRequired());
return data;
}
public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException { public void deleteAndSave(UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug("deleting dataset: {}", id); logger.debug("deleting : {}", id);
this.authorizationService.authorizeForce(Permission.DeleteDmpBlueprint); this.authorizationService.authorizeForce(Permission.DeleteDmpBlueprint);

View File

@ -6,6 +6,7 @@ import eu.eudat.data.DmpBlueprintEntity;
import eu.eudat.model.DmpBlueprint; import eu.eudat.model.DmpBlueprint;
import eu.eudat.model.builder.DmpBlueprintBuilder; import eu.eudat.model.builder.DmpBlueprintBuilder;
import eu.eudat.model.censorship.DmpBlueprintCensor; import eu.eudat.model.censorship.DmpBlueprintCensor;
import eu.eudat.model.persist.DmpBlueprintPersist;
import eu.eudat.model.result.QueryResult; import eu.eudat.model.result.QueryResult;
import eu.eudat.query.DmpBlueprintQuery; import eu.eudat.query.DmpBlueprintQuery;
import eu.eudat.query.lookup.DmpBlueprintLookup; import eu.eudat.query.lookup.DmpBlueprintLookup;
@ -20,6 +21,7 @@ import gr.cite.tools.exception.MyNotFoundException;
import gr.cite.tools.fieldset.FieldSet; import gr.cite.tools.fieldset.FieldSet;
import gr.cite.tools.logging.LoggerService; import gr.cite.tools.logging.LoggerService;
import gr.cite.tools.logging.MapLogEntry; import gr.cite.tools.logging.MapLogEntry;
import gr.cite.tools.validation.MyValidate;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource; import org.springframework.context.MessageSource;
@ -63,7 +65,7 @@ public class DmpBlueprintController {
} }
@PostMapping("query") @PostMapping("query")
public QueryResult<DmpBlueprint> Query(@RequestBody DmpBlueprintLookup lookup) throws MyApplicationException, MyForbiddenException { public QueryResult<DmpBlueprint> query(@RequestBody DmpBlueprintLookup lookup) throws MyApplicationException, MyForbiddenException {
logger.debug("querying {}", DmpBlueprint.class.getSimpleName()); logger.debug("querying {}", DmpBlueprint.class.getSimpleName());
this.censorFactory.censor(DmpBlueprintCensor.class).censor(lookup.getProject(), null); this.censorFactory.censor(DmpBlueprintCensor.class).censor(lookup.getProject(), null);
@ -81,7 +83,7 @@ public class DmpBlueprintController {
} }
@GetMapping("{id}") @GetMapping("{id}")
public DmpBlueprint Get(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException { public DmpBlueprint get(@PathVariable("id") UUID id, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException {
logger.debug(new MapLogEntry("retrieving" + DmpBlueprint.class.getSimpleName()).And("id", id).And("fields", fieldSet)); logger.debug(new MapLogEntry("retrieving" + DmpBlueprint.class.getSimpleName()).And("id", id).And("fields", fieldSet));
this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null); this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null);
@ -100,23 +102,25 @@ public class DmpBlueprintController {
return model; return model;
} }
// @PostMapping("persist") @PostMapping("persist")
// @Transactional @Transactional
// public DmpBlueprint Persist(@MyValidate @RequestBody DmpBlueprintPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException { public DmpBlueprint persist(@MyValidate @RequestBody DmpBlueprintPersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException {
// logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet));
// DmpBlueprint persisted = this.dmpBlueprintService.persist(model, fieldSet); this.censorFactory.censor(DmpBlueprintCensor.class).censor(fieldSet, null);
//
// this.auditService.track(AuditableAction.DmpBlueprint_Persist, Map.ofEntries( DmpBlueprint persisted = this.dmpBlueprintService.persist(model, fieldSet);
// new AbstractMap.SimpleEntry<String, Object>("model", model),
// new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet) this.auditService.track(AuditableAction.DmpBlueprint_Persist, Map.ofEntries(
// )); new AbstractMap.SimpleEntry<String, Object>("model", model),
// //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); new AbstractMap.SimpleEntry<String, Object>("fields", fieldSet)
// return persisted; ));
// } //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action);
return persisted;
}
@DeleteMapping("{id}") @DeleteMapping("{id}")
@Transactional @Transactional
public void Delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException { public void delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException {
logger.debug(new MapLogEntry("retrieving" + DmpBlueprint.class.getSimpleName()).And("id", id)); logger.debug(new MapLogEntry("retrieving" + DmpBlueprint.class.getSimpleName()).And("id", id));
this.dmpBlueprintService.deleteAndSave(id); this.dmpBlueprintService.deleteAndSave(id);

View File

@ -1,6 +1,6 @@
package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel;
import eu.eudat.commons.enums.DmpBlueprintExtraFieldType; import eu.eudat.commons.enums.DmpBlueprintExtraFieldDataType;
import eu.eudat.commons.enums.DmpBlueprintFieldCategory; import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
import eu.eudat.commons.types.dmpblueprint.ExtraFieldEntity; import eu.eudat.commons.types.dmpblueprint.ExtraFieldEntity;
@ -87,7 +87,7 @@ public class ExtraField {
ExtraFieldEntity systemField = new ExtraFieldEntity(); ExtraFieldEntity systemField = new ExtraFieldEntity();
systemField.setId(UUID.fromString(this.id)); systemField.setId(UUID.fromString(this.id));
systemField.setCategory(DmpBlueprintFieldCategory.Extra); systemField.setCategory(DmpBlueprintFieldCategory.Extra);
systemField.setType(DmpBlueprintExtraFieldType.of(this.type)); systemField.setType(DmpBlueprintExtraFieldDataType.of(this.type));
systemField.setLabel(this.label); systemField.setLabel(this.label);
systemField.setPlaceholder(this.placeholder); systemField.setPlaceholder(this.placeholder);
systemField.setDescription(this.description); systemField.setDescription(this.description);

View File

@ -8,4 +8,12 @@ project.startDate.overlapping=Period Start cannot overlap Period
dataset.public=Dataset Has Been Made Public dataset.public=Dataset Has Been Made Public
datamanagementplannewversion.version.notacceptable=There is already a newer version than the one you submitted datamanagementplannewversion.version.notacceptable=There is already a newer version than the one you submitted
datamanagementplannewversion.version.notnext=The version you submitted is not the Subsequent value datamanagementplannewversion.version.notnext=The version you submitted is not the Subsequent value
project.external.edit = Editing External Projects Is Not Allowed project.external.edit = Editing External Projects Is Not Allowed
validation.empty=Value cannot be empty
validation.hashempty=Hash must be set
validation.lowerthanmin=Value must be larger than {value}
validation.largerthanmax=Value must be less than {value}
validation.invalidid=Not valid id
General_ItemNotFound=Item {0} of type {1} not found
Validation_Required={0} is required

View File

@ -6,4 +6,11 @@ grantTableRequest.length.negative=Το μέγεθος του table δεν μπο
datasetprofile.label.null=Το ονομα του ορισμου ενος Dataset δεν μπορει να ειναι κενο datasetprofile.label.null=Το ονομα του ορισμου ενος Dataset δεν μπορει να ειναι κενο
project.startDate.overlapping=Η Αρχικη Περιοδος δεν μπορει να ειναι Μεγαλυτερη της τελικης project.startDate.overlapping=Η Αρχικη Περιοδος δεν μπορει να ειναι Μεγαλυτερη της τελικης
dataset.public=Το Dataset δημοσιοποιηθηκε σε ολους dataset.public=Το Dataset δημοσιοποιηθηκε σε ολους
project.external.edit = Δεν επιτρέπεται η επεξεργασία εξωτερικών Projects project.external.edit = Δεν επιτρέπεται η επεξεργασία εξωτερικών Projects
validation.empty=el-Value cannot be empty
validation.hashempty=el-Hash must be set
validation.lowerthanmin=el-Value must be larger than {value}
validation.largerthanmax=el-Value must be less than {value}
validation.invalidid=el-Not valid id
General_ItemNotFound=el-Item {0} of type {1} not found

View File

@ -1,4 +1,4 @@
export enum DmpBlueprintStatus { export enum DmpBlueprintStatus {
Draft = 'Draft', Draft = 'Draft',
Finalized = 'Finalized' Finalized = 'Finalized'
} }