diff --git a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java index e4a33b910..d032e5083 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java +++ b/dmp-backend/core/src/main/java/eu/eudat/authorization/Permission.java @@ -28,6 +28,11 @@ public final class Permission { public static String EditDescriptionTemplateType = "EditDescriptionTemplateType"; public static String DeleteDescriptionTemplateType = "DeleteDescriptionTemplateType"; + //DmpBlueprint + public static String BrowseDmpBlueprint = "BrowseDmpBlueprint"; + public static String EditDmpBlueprint = "EditDmpBlueprint"; + public static String DeleteDmpBlueprint = "DeleteDmpBlueprint"; + //DescriptionTemplateType public static String BrowseEntityDoi = "BrowseEntityDoi"; public static String EditEntityDoi = "EditEntityDoi"; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintExtraFieldType.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintExtraFieldType.java new file mode 100644 index 000000000..45d040f5b --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintExtraFieldType.java @@ -0,0 +1,31 @@ +package eu.eudat.commons.enums; + +import eu.eudat.data.converters.enums.DatabaseEnum; + +import java.util.Map; + +public enum DmpBlueprintExtraFieldType implements DatabaseEnum { + + 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 map = EnumUtils.getEnumValueMap(DmpBlueprintExtraFieldType.class); + + public static DmpBlueprintExtraFieldType of(Short i) { + return map.get(i); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintFieldCategory.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintFieldCategory.java new file mode 100644 index 000000000..88bcf3529 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintFieldCategory.java @@ -0,0 +1,26 @@ +package eu.eudat.commons.enums; + +import eu.eudat.data.converters.enums.DatabaseEnum; + +import java.util.Map; + +public enum DmpBlueprintFieldCategory implements DatabaseEnum { + System((short)0), + Extra((short)1); + + private final Short value; + + DmpBlueprintFieldCategory(Short value) { + this.value = value; + } + + public Short getValue() { + return value; + } + + private static final Map map = EnumUtils.getEnumValueMap(DmpBlueprintFieldCategory.class); + + public static DmpBlueprintFieldCategory of(Short i) { + return map.get(i); + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintStatus.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintStatus.java new file mode 100644 index 000000000..3f12347e1 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintStatus.java @@ -0,0 +1,28 @@ +package eu.eudat.commons.enums; + +import eu.eudat.data.converters.enums.DatabaseEnum; + +import java.util.Map; + +public enum DmpBlueprintStatus implements DatabaseEnum { + + Draft((short) 0), + Finalized((short) 1); + + private final Short value; + + DmpBlueprintStatus(Short value) { + this.value = value; + } + + public Short getValue() { + return value; + } + + private static final Map map = EnumUtils.getEnumValueMap(DmpBlueprintStatus.class); + + public static DmpBlueprintStatus of(Short i) { + return map.get(i); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintSystemFieldType.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintSystemFieldType.java new file mode 100644 index 000000000..087178474 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/DmpBlueprintSystemFieldType.java @@ -0,0 +1,35 @@ +package eu.eudat.commons.enums; + +import eu.eudat.data.converters.enums.DatabaseEnum; + +import java.util.Map; + +public enum DmpBlueprintSystemFieldType implements DatabaseEnum { + + Text((short)0), + HtmlText((short)1), + Researchers((short)2), + Organizations((short)3), + Language((short)4), + Contact((short)5), + Funder((short)6), + Grant((short)7), + Project((short)8), + License((short)9), + AccessRights((short)10); + private final Short value; + + DmpBlueprintSystemFieldType(Short value) { + this.value = value; + } + + public Short getValue() { + return value; + } + + private static final Map map = EnumUtils.getEnumValueMap(DmpBlueprintSystemFieldType.class); + + public static DmpBlueprintSystemFieldType of(Short i) { + return map.get(i); + } +} \ No newline at end of file diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/ExternalReferencesType.java b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/ExternalReferencesType.java index 982cd7a57..002c63117 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/enums/ExternalReferencesType.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/enums/ExternalReferencesType.java @@ -18,9 +18,7 @@ public enum ExternalReferencesType implements DatabaseEnum { Datasets((short) 10), Organizations((short) 11), Grants((short) 12), - Validators((short) 13), - Researcher((short) 14), - Prefillings((short) 15); + Researcher((short) 13); private final Short value; ExternalReferencesType(Short value) { diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DefinitionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DefinitionEntity.java new file mode 100644 index 000000000..a9e2f013f --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DefinitionEntity.java @@ -0,0 +1,50 @@ +package eu.eudat.commons.types.dmpblueprint; + +import eu.eudat.commons.types.xml.XmlBuilder; +import eu.eudat.commons.types.xml.XmlSerializable; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import java.util.LinkedList; +import java.util.List; + +public class DefinitionEntity implements XmlSerializable { + private List sections; + + public List getSections() { + return sections; + } + public void setSections(List sections) { + this.sections = sections; + } + + @Override + public Element toXml(Document doc) { + Element root = doc.createElement("root"); + Element sections = doc.createElement("sections"); + for (SectionEntity section : this.sections) { + sections.appendChild(section.toXml(doc)); + } + root.appendChild(sections); + return root; + } + + @Override + public DefinitionEntity fromXml(Element item) { + this.sections = new LinkedList<>(); + Element sections = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "sections"); + if (sections != null) { + NodeList sectionElements = sections.getChildNodes(); + for (int temp = 0; temp < sectionElements.getLength(); temp++) { + Node sectionElement = sectionElements.item(temp); + if (sectionElement.getNodeType() == Node.ELEMENT_NODE) { + this.sections.add(new SectionEntity().fromXml((Element) sectionElement)); + } + } + } + return this; + } + +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/DescriptionTemplate.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DescriptionTemplateEntity.java similarity index 89% rename from dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/DescriptionTemplate.java rename to dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DescriptionTemplateEntity.java index 0c8578333..52447f328 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/DescriptionTemplate.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/DescriptionTemplateEntity.java @@ -1,12 +1,12 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition; +package eu.eudat.commons.types.dmpblueprint; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; import java.util.UUID; -public class DescriptionTemplate implements XmlSerializable { +public class DescriptionTemplateEntity implements XmlSerializable { private UUID id; private UUID descriptionTemplateId; @@ -61,7 +61,7 @@ public class DescriptionTemplate implements XmlSerializable } @Override - public DescriptionTemplate fromXml(Element item) { + public DescriptionTemplateEntity fromXml(Element item) { this.id = UUID.fromString(item.getAttribute("id")); this.descriptionTemplateId = UUID.fromString(item.getAttribute("descriptionTemplateId")); this.label = item.getAttribute("label"); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/DmpProfileExternalAutoComplete.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/ExternalAutoCompleteEntity.java similarity index 84% rename from dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/DmpProfileExternalAutoComplete.java rename to dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/ExternalAutoCompleteEntity.java index 43beb8c9b..23f217552 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/DmpProfileExternalAutoComplete.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/ExternalAutoCompleteEntity.java @@ -1,10 +1,10 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition; +package eu.eudat.commons.types.dmpblueprint; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; -public class DmpProfileExternalAutoComplete implements XmlSerializable { +public class ExternalAutoCompleteEntity implements XmlSerializable { private String url; private String optionsRoot; private Boolean multiAutoComplete; @@ -56,7 +56,7 @@ public class DmpProfileExternalAutoComplete implements XmlSerializable { + private UUID id; + private DmpBlueprintFieldCategory category; + private String label; + private String placeholder; + private String description; + private Integer ordinal; + private boolean required; + + 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 isRequired() { + return required; + } + public void setRequired(boolean required) { + this.required = required; + } + protected abstract Element appendXmlChild(Element rootElement); + protected abstract FieldEntity fromXmlChild(Element item); + @Override + public Element toXml(Document doc) { + Element rootElement = doc.createElement("extraField"); + rootElement.setAttribute("id", this.getId().toString()); + rootElement.setAttribute("label", this.label); + rootElement.setAttribute("description", this.description); + rootElement.setAttribute("placeholder", this.placeholder); + rootElement.setAttribute("required", String.valueOf(this.required)); + rootElement.setAttribute("ordinal", String.valueOf(this.ordinal)); + this.appendXmlChild(rootElement); + return rootElement; + } + + @Override + public FieldEntity fromXml(Element item) { + this.id = UUID.fromString(item.getAttribute("id")); + this.label = item.getAttribute("label"); + this.description = item.getAttribute("description"); + this.placeholder = item.getAttribute("placeholder"); + this.required = Boolean.parseBoolean(item.getAttribute("required")); + this.ordinal = Integer.valueOf(item.getAttribute("ordinal")); + this.fromXmlChild(item); + return this; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/Section.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java similarity index 72% rename from dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/Section.java rename to dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java index 5a5da9a85..e91ecaacf 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/Section.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SectionEntity.java @@ -1,8 +1,8 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition; +package eu.eudat.commons.types.dmpblueprint; -import eu.eudat.logic.utilities.builders.XmlBuilder; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; +import eu.eudat.commons.enums.DmpBlueprintFieldCategory; +import eu.eudat.commons.types.xml.XmlBuilder; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -13,15 +13,15 @@ import java.util.List; import java.util.UUID; import java.util.stream.Collectors; -public class Section implements XmlSerializable
{ +public class SectionEntity implements XmlSerializable { private UUID id; private String label; private String description; private Integer ordinal; - private List fields; + private List fields; private Boolean hasTemplates; - private List descriptionTemplates; + private List descriptionTemplates; public UUID getId() { return id; @@ -51,10 +51,10 @@ public class Section implements XmlSerializable
{ this.ordinal = ordinal; } - public List getFields() { + public List getFields() { return fields; } - public void setFields(List fields) { + public void setFields(List fields) { this.fields = fields; } @@ -65,10 +65,10 @@ public class Section implements XmlSerializable
{ this.hasTemplates = hasTemplates; } - public List getDescriptionTemplates() { + public List getDescriptionTemplates() { return descriptionTemplates; } - public void setDescriptionTemplates(List descriptionTemplates) { + public void setDescriptionTemplates(List descriptionTemplates) { this.descriptionTemplates = descriptionTemplates; } @@ -80,22 +80,22 @@ public class Section implements XmlSerializable
{ rootElement.setAttribute("description", this.description); rootElement.setAttribute("ordinal", String.valueOf(this.ordinal)); rootElement.setAttribute("hasTemplates", String.valueOf(this.hasTemplates)); - List temp = this.fields.stream().filter(f -> f.getCategory().equals(FieldCategory.SYSTEM)).collect(Collectors.toList()); - List systemFieldsList = temp.stream().map(FieldModel::toSystemField).collect(Collectors.toList()); + List temp = this.fields.stream().filter(f -> f.getCategory().equals(DmpBlueprintFieldCategory.System)).collect(Collectors.toList()); + List systemFieldsList = temp.stream().map(x-> (SystemFieldEntity)x).collect(Collectors.toList()); Element systemFields = doc.createElement("systemFields"); - for (SystemField systemField : systemFieldsList) { + for (SystemFieldEntity systemField : systemFieldsList) { systemFields.appendChild(systemField.toXml(doc)); } rootElement.appendChild(systemFields); Element descriptionTemplates = doc.createElement("descriptionTemplates"); - for (DescriptionTemplate descriptionTemplate : this.descriptionTemplates) { + for (DescriptionTemplateEntity descriptionTemplate : this.descriptionTemplates) { descriptionTemplates.appendChild(descriptionTemplate.toXml(doc)); } rootElement.appendChild(descriptionTemplates); - temp = this.fields.stream().filter(f -> f.getCategory().equals(FieldCategory.EXTRA)).collect(Collectors.toList()); - List extraFieldList = temp.stream().map(FieldModel::toExtraField).collect(Collectors.toList()); + temp = this.fields.stream().filter(f -> f.getCategory().equals(DmpBlueprintFieldCategory.Extra)).collect(Collectors.toList()); + List extraFieldList = temp.stream().map(x-> (ExtraFieldEntity)x).collect(Collectors.toList()); Element extraFields = doc.createElement("extraFields"); - for (ExtraField extraField : extraFieldList) { + for (ExtraFieldEntity extraField : extraFieldList) { extraFields.appendChild(extraField.toXml(doc)); } rootElement.appendChild(extraFields); @@ -104,7 +104,7 @@ public class Section implements XmlSerializable
{ } @Override - public Section fromXml(Element item) { + public SectionEntity fromXml(Element item) { this.id = UUID.fromString(item.getAttribute("id")); this.label = item.getAttribute("label"); this.description = item.getAttribute("description"); @@ -117,8 +117,7 @@ public class Section implements XmlSerializable
{ for (int temp = 0; temp < systemFieldElements.getLength(); temp++) { Node systemFieldElement = systemFieldElements.item(temp); if (systemFieldElement.getNodeType() == Node.ELEMENT_NODE) { - SystemField systemField = new SystemField().fromXml((Element) systemFieldElement); - this.fields.add(new FieldModel().fromSystemField(systemField)); + this.fields.add(new SystemFieldEntity().fromXml((Element) systemFieldElement)); } } } @@ -129,7 +128,7 @@ public class Section implements XmlSerializable
{ for (int temp = 0; temp < descriptionTemplateElements.getLength(); temp++) { Node descriptionTemplateElement = descriptionTemplateElements.item(temp); if (descriptionTemplateElement.getNodeType() == Node.ELEMENT_NODE) { - this.descriptionTemplates.add(new DescriptionTemplate().fromXml((Element) descriptionTemplateElement)); + this.descriptionTemplates.add(new DescriptionTemplateEntity().fromXml((Element) descriptionTemplateElement)); } } } @@ -139,8 +138,7 @@ public class Section implements XmlSerializable
{ for (int temp = 0; temp < extraFieldElements.getLength(); temp++) { Node extraFieldElement = extraFieldElements.item(temp); if (extraFieldElement.getNodeType() == Node.ELEMENT_NODE) { - ExtraField extraField = new ExtraField().fromXml((Element) extraFieldElement); - this.fields.add(new FieldModel().fromExtraField(extraField)); + this.fields.add(new ExtraFieldEntity().fromXml((Element) extraFieldElement)); } } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SystemFieldEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SystemFieldEntity.java new file mode 100644 index 000000000..083c704c9 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/dmpblueprint/SystemFieldEntity.java @@ -0,0 +1,32 @@ +package eu.eudat.commons.types.dmpblueprint; + +import eu.eudat.commons.enums.DmpBlueprintSystemFieldType; +import eu.eudat.commons.types.xml.XmlSerializable; +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +import java.util.UUID; + +public class SystemFieldEntity extends FieldEntity { + + private DmpBlueprintSystemFieldType type; + + public DmpBlueprintSystemFieldType getType() { + return type; + } + public void setType(DmpBlueprintSystemFieldType type) { + this.type = type; + } + + @Override + public Element appendXmlChild(Element rootElement) { + rootElement.setAttribute("type", String.valueOf(this.type.getValue())); + return rootElement; + } + + @Override + public SystemFieldEntity fromXmlChild(Element item) { + this.type = DmpBlueprintSystemFieldType.of(Short.parseShort(item.getAttribute("type"))); + return this; + } +} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/builders/XmlBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/xml/XmlBuilder.java similarity index 98% rename from dmp-backend/web/src/main/java/eu/eudat/logic/utilities/builders/XmlBuilder.java rename to dmp-backend/core/src/main/java/eu/eudat/commons/types/xml/XmlBuilder.java index 8a2c2173c..6f02fd049 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/builders/XmlBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/xml/XmlBuilder.java @@ -1,4 +1,4 @@ -package eu.eudat.logic.utilities.builders; +package eu.eudat.commons.types.xml; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/interfaces/XmlSerializable.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/xml/XmlSerializable.java similarity index 78% rename from dmp-backend/web/src/main/java/eu/eudat/logic/utilities/interfaces/XmlSerializable.java rename to dmp-backend/core/src/main/java/eu/eudat/commons/types/xml/XmlSerializable.java index d293265c6..c974c82c2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/interfaces/XmlSerializable.java +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/xml/XmlSerializable.java @@ -1,4 +1,4 @@ -package eu.eudat.logic.utilities.interfaces; +package eu.eudat.commons.types.xml; import org.w3c.dom.Document; diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DmpBlueprintEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DmpBlueprintEntity.java new file mode 100644 index 000000000..a6b7d8111 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DmpBlueprintEntity.java @@ -0,0 +1,137 @@ +package eu.eudat.data; + + +import eu.eudat.commons.enums.DmpBlueprintStatus; +import eu.eudat.commons.enums.IsActive; +import eu.eudat.data.converters.DateToUTCConverter; +import eu.eudat.data.converters.enums.DescriptionTemplateTypeStatusConverter; +import eu.eudat.data.converters.enums.DmpBlueprintStatusConverter; +import eu.eudat.data.converters.enums.IsActiveConverter; +import eu.eudat.data.old.DMP; +import eu.eudat.data.old.helpers.EntityBinder; +import eu.eudat.queryable.queryableentity.DataEntity; +import org.hibernate.annotations.GenericGenerator; +import org.hibernate.annotations.Type; + +import jakarta.persistence.*; + +import java.time.Instant; +import java.util.Date; +import java.util.List; +import java.util.Set; +import java.util.UUID; + + +@Entity +@Table(name = "\"DmpBlueprint\"") +public class DmpBlueprintEntity implements DataEntity { + @Id + @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID id; + public static final String _id = "id"; + + @Column(name = "\"label\"") + private String label; + public static final String _label = "label"; + + @Type(eu.eudat.configurations.typedefinition.XMLType.class) + @Column(name = "\"definition\"", columnDefinition = "xml", nullable = true) + private String definition; + public static final String _definition = "definition"; + + + @Column(name = "\"status\"", nullable = false) + @Convert(converter = DmpBlueprintStatusConverter.class) + private DmpBlueprintStatus status; + public static final String _status = "status"; + + @Column(name = "is_active", nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; + public static final String _isActive = "isActive"; + + + @Column(name = "\"created_at\"", nullable = false) + private Instant createdAt = null; + public static final String _createdAt = "createdAt"; + + @Column(name = "\"updated_at\"", nullable = false) + private Instant updatedAt; + public static final String _updatedAt = "updatedAt"; + + 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 getDefinition() { + return definition; + } + + public void setDefinition(String definition) { + this.definition = definition; + } + + public DmpBlueprintStatus getStatus() { + return status; + } + + public void setStatus(DmpBlueprintStatus status) { + this.status = status; + } + + public IsActive getIsActive() { + return isActive; + } + + public void setIsActive(IsActive isActive) { + this.isActive = isActive; + } + + 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; + } + + @Override + public void update(DmpBlueprintEntity entity) { + this.updatedAt = Instant.now(); + this.definition = entity.getDefinition(); + this.label = entity.getLabel(); + this.status= entity.getStatus(); + } + + @Override + public UUID getKeys() { + return this.id; + } + + @Override + public DmpBlueprintEntity buildFromTuple(List tuple, List fields, String base) { + String currentBase = base.isEmpty() ? "" : base + "."; + if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); + return this; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/DmpBlueprintStatusConverter.java b/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/DmpBlueprintStatusConverter.java new file mode 100644 index 000000000..76f8fab0a --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/data/converters/enums/DmpBlueprintStatusConverter.java @@ -0,0 +1,12 @@ +package eu.eudat.data.converters.enums; + +import eu.eudat.commons.enums.DescriptionTemplateTypeStatus; +import eu.eudat.commons.enums.DmpBlueprintStatus; +import jakarta.persistence.Converter; + +@Converter +public class DmpBlueprintStatusConverter extends DatabaseEnumConverter { + public DmpBlueprintStatus of(Short i) { + return DmpBlueprintStatus.of(i); + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/old/DMP.java b/dmp-backend/core/src/main/java/eu/eudat/data/old/DMP.java index f11b96f13..ca1fa280b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/old/DMP.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/old/DMP.java @@ -1,6 +1,7 @@ package eu.eudat.data.old; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.EntityDoiEntity; import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.queryable.queryableentity.DataEntity; @@ -119,7 +120,7 @@ public class DMP implements DataEntity { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "\"Profile\"") - private DMPProfile profile; + private DmpBlueprintEntity profile; @ManyToOne(fetch = FetchType.LAZY) @@ -278,10 +279,10 @@ public class DMP implements DataEntity { this.associatedDmps = associatedDmps; } - public DMPProfile getProfile() { + public DmpBlueprintEntity getProfile() { return profile; } - public void setProfile(DMPProfile profile) { + public void setProfile(DmpBlueprintEntity profile) { this.profile = profile; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/old/DMPProfile.java b/dmp-backend/core/src/main/java/eu/eudat/data/old/DMPProfile.java deleted file mode 100644 index 78c30cc04..000000000 --- a/dmp-backend/core/src/main/java/eu/eudat/data/old/DMPProfile.java +++ /dev/null @@ -1,154 +0,0 @@ -package eu.eudat.data.old; - - -import eu.eudat.data.converters.DateToUTCConverter; -import eu.eudat.data.old.helpers.EntityBinder; -import eu.eudat.queryable.queryableentity.DataEntity; -import org.hibernate.annotations.GenericGenerator; -import org.hibernate.annotations.Type; - -import jakarta.persistence.*; -import java.util.Date; -import java.util.List; -import java.util.Set; -import java.util.UUID; - - -@Entity -@Table(name = "\"DMPProfile\"") -public class DMPProfile implements DataEntity { - - public enum Status { - SAVED((short) 0), FINALIZED((short) 1), DELETED((short) 99); - - private short value; - - private Status(short value) { - this.value = value; - } - - public short getValue() { - return value; - } - - public static Status fromInteger(int value) { - switch (value) { - case 0: - return SAVED; - case 1: - return FINALIZED; - case 99: - return DELETED; - default: - throw new RuntimeException("Unsupported Dmp Profile Status"); - } - } - } - - @Id - @GeneratedValue - @GenericGenerator(name = "uuid2", strategy = "uuid2") - @Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)") - private UUID id; - - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "profile") - private Set dmps; - - - @Column(name = "\"Label\"") - private String label; - - @Type(eu.eudat.configurations.typedefinition.XMLType.class) - @Column(name = "\"Definition\"", columnDefinition = "xml", nullable = true) - private String definition; - - - @Column(name = "\"Status\"", nullable = false) - private int status; - - - @Column(name = "\"Created\"") - @Convert(converter = DateToUTCConverter.class) - private Date created = null; - - @Column(name = "\"Modified\"") - @Convert(converter = DateToUTCConverter.class) - private Date modified = new Date(); - - public int getStatus() { - return status; - } - - public void setStatus(int status) { - this.status = status; - } - - 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; - } - - 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 getDefinition() { - return definition; - } - - public void setDefinition(String definition) { - this.definition = definition; - } - - public Set getDmps() { - return dmps; - } - - public void setDmps(Set dmps) { - this.dmps = dmps; - } - - @Override - public void update(DMPProfile entity) { - this.modified = new Date(); - this.definition = entity.getDefinition(); - this.label = entity.getLabel(); - this.status= entity.getStatus(); - } - - @Override - public UUID getKeys() { - return this.id; - } - - @Override - public DMPProfile buildFromTuple(List tuple,List fields, String base) { - String currentBase = base.isEmpty() ? "" : base + "."; - if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id"); - return this; - } -} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/DmpBlueprint.java b/dmp-backend/core/src/main/java/eu/eudat/model/DmpBlueprint.java new file mode 100644 index 000000000..53ca6fa82 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/DmpBlueprint.java @@ -0,0 +1,102 @@ +package eu.eudat.model; + +import eu.eudat.commons.enums.DmpBlueprintStatus; +import eu.eudat.commons.enums.IsActive; +import eu.eudat.model.dmpblueprintdefinition.Definition; + +import java.time.Instant; +import java.util.UUID; + +public class DmpBlueprint { + + public final static String _id = "id"; + private UUID id; + + public final static String _label= "label"; + private String label; + + public final static String _createdAt = "createdAt"; + private Definition definition; + + public final static String _definition = "definition"; + private Instant createdAt; + + public final static String _updatedAt = "updatedAt"; + private Instant updatedAt; + + public final static String _isActive = "isActive"; + private IsActive isActive; + + public final static String _status = "status"; + private DmpBlueprintStatus status; + + public final static String _hash = "hash"; + 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 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 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; + } + + public Definition getDefinition() { + return definition; + } + + public void setDefinition(Definition definition) { + this.definition = definition; + } +} + + + diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBlueprintBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBlueprintBuilder.java new file mode 100644 index 000000000..18496e4da --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DmpBlueprintBuilder.java @@ -0,0 +1,63 @@ +package eu.eudat.model.builder; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.types.dmpblueprint.DefinitionEntity; +import eu.eudat.commons.types.xml.XmlBuilder; +import eu.eudat.convention.ConventionService; +import eu.eudat.data.DmpBlueprintEntity; +import eu.eudat.model.DmpBlueprint; +import eu.eudat.model.dmpblueprintdefinition.Definition; +import gr.cite.tools.exception.MyApplicationException; +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.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.*; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DmpBlueprintBuilder extends BaseBuilder { + + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + @Autowired + public DmpBlueprintBuilder( + ConventionService conventionService + ) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(DmpBlueprintBuilder.class))); + } + + public DmpBlueprintBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + FieldSet definitionFields = fields.extractPrefixed(this.asPrefix(DmpBlueprint._definition)); +// new DefinitionEntity().fromXml(XmlBuilder.fromXml(entity.getDefinition()).getDocumentElement()); + List models = new ArrayList<>(); + for (DmpBlueprintEntity d : data) { + DmpBlueprint m = new DmpBlueprint(); + if (fields.hasField(this.asIndexer(DmpBlueprint._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(DmpBlueprint._label))) m.setLabel(d.getLabel()); + if (fields.hasField(this.asIndexer(DmpBlueprint._createdAt))) m.setCreatedAt(d.getCreatedAt()); + if (fields.hasField(this.asIndexer(DmpBlueprint._updatedAt))) m.setUpdatedAt(d.getUpdatedAt()); + if (fields.hasField(this.asIndexer(DmpBlueprint._isActive))) m.setIsActive(d.getIsActive()); + if (fields.hasField(this.asIndexer(DmpBlueprint._status))) m.setStatus(d.getStatus()); + if (fields.hasField(this.asIndexer(DmpBlueprint._hash))) m.setHash(this.hashValue(d.getUpdatedAt())); + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + return models; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/DefinitionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/DefinitionBuilder.java new file mode 100644 index 000000000..86e5b0a76 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/DefinitionBuilder.java @@ -0,0 +1,59 @@ +package eu.eudat.model.builder.dmpblueprintdefinition; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.types.dmpblueprint.DefinitionEntity; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.builder.BaseBuilder; +import eu.eudat.model.dmpblueprintdefinition.Definition; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.exception.MyApplicationException; +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.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.*; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DefinitionBuilder extends BaseBuilder { + + private final BuilderFactory builderFactory; + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + @Autowired + public DefinitionBuilder( + ConventionService conventionService, BuilderFactory builderFactory) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(DefinitionBuilder.class))); + this.builderFactory = builderFactory; + } + + public DefinitionBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + //Not Bulk Build because is XML no interaction with db + FieldSet sectionsFields = fields.extractPrefixed(this.asPrefix(Definition._sections)); + + List models = new ArrayList<>(); + for (DefinitionEntity d : data) { + Definition m = new Definition(); + if (!sectionsFields.isEmpty() && d.getSections() != null) m.setSections(this.builderFactory.builder(SectionBuilder.class).authorize(this.authorize).build(sectionsFields, d.getSections())); + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + return models; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/DescriptionTemplateBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/DescriptionTemplateBuilder.java new file mode 100644 index 000000000..2ae115b47 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/DescriptionTemplateBuilder.java @@ -0,0 +1,57 @@ +package eu.eudat.model.builder.dmpblueprintdefinition; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.types.dmpblueprint.DescriptionTemplateEntity; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.builder.BaseBuilder; +import eu.eudat.model.dmpblueprintdefinition.DescriptionTemplate; +import gr.cite.tools.exception.MyApplicationException; +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.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.*; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DescriptionTemplateBuilder extends BaseBuilder { + + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + @Autowired + public DescriptionTemplateBuilder( + ConventionService conventionService) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(DescriptionTemplateBuilder.class))); + } + + public DescriptionTemplateBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + List models = new ArrayList<>(); + for (DescriptionTemplateEntity d : data) { + DescriptionTemplate m = new DescriptionTemplate(); + if (fields.hasField(this.asIndexer(DescriptionTemplate._label))) m.setLabel(d.getLabel()); + if (fields.hasField(this.asIndexer(DescriptionTemplate._descriptionTemplateId))) m.setDescriptionTemplateId(d.getDescriptionTemplateId()); + if (fields.hasField(this.asIndexer(DescriptionTemplate._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(DescriptionTemplate._maxMultiplicity))) m.setMaxMultiplicity(d.getMaxMultiplicity()); + if (fields.hasField(this.asIndexer(DescriptionTemplate._minMultiplicity))) m.setMinMultiplicity(d.getMinMultiplicity()); + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + return models; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/ExtraFieldBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/ExtraFieldBuilder.java new file mode 100644 index 000000000..6ebcafe4a --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/ExtraFieldBuilder.java @@ -0,0 +1,32 @@ +package eu.eudat.model.builder.dmpblueprintdefinition; + +import eu.eudat.commons.types.dmpblueprint.ExtraFieldEntity; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.dmpblueprintdefinition.ExtraField; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class ExtraFieldBuilder extends FieldBuilder { + + @Autowired + public ExtraFieldBuilder( + ConventionService conventionService) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(ExtraFieldBuilder.class))); + } + + protected ExtraField getInstance() { + return new ExtraField(); + } + + protected ExtraField buildChild(FieldSet fields, ExtraFieldEntity data, ExtraField model) { + if (fields.hasField(this.asIndexer(ExtraField._type))) model.setType(data.getType()); + return model; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/FieldBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/FieldBuilder.java new file mode 100644 index 000000000..5683d7da5 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/FieldBuilder.java @@ -0,0 +1,68 @@ +package eu.eudat.model.builder.dmpblueprintdefinition; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.types.dmpblueprint.DescriptionTemplateEntity; +import eu.eudat.commons.types.dmpblueprint.ExtraFieldEntity; +import eu.eudat.commons.types.dmpblueprint.FieldEntity; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.builder.BaseBuilder; +import eu.eudat.model.dmpblueprintdefinition.DescriptionTemplate; +import eu.eudat.model.dmpblueprintdefinition.ExtraField; +import eu.eudat.model.dmpblueprintdefinition.Field; +import gr.cite.tools.exception.MyApplicationException; +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.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.*; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public abstract class FieldBuilder extends BaseBuilder { + + protected EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + @Autowired + public FieldBuilder( + ConventionService conventionService, + LoggerService logger) { + super(conventionService, logger); + } + + public FieldBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + protected abstract Model getInstance(); + + protected abstract Model buildChild(FieldSet fields, Entity data, Model model); + @Override + public List build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + List models = new ArrayList<>(); + for (Entity d : data) { + Model m = this.getInstance(); + if (fields.hasField(this.asIndexer(Model._label))) m.setLabel(d.getLabel()); + if (fields.hasField(this.asIndexer(Model._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(Model._category))) m.setCategory(d.getCategory()); + if (fields.hasField(this.asIndexer(Model._description))) m.setDescription(d.getDescription()); + if (fields.hasField(this.asIndexer(Model._placeholder))) m.setPlaceholder(d.getPlaceholder()); + if (fields.hasField(this.asIndexer(Model._ordinal))) m.setOrdinal(d.getOrdinal()); + if (fields.hasField(this.asIndexer(Model._required))) m.setRequired(d.isRequired()); + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + return models; + } +} + diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/SectionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/SectionBuilder.java new file mode 100644 index 000000000..652cf6282 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/SectionBuilder.java @@ -0,0 +1,77 @@ +package eu.eudat.model.builder.dmpblueprintdefinition; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.enums.DmpBlueprintFieldCategory; +import eu.eudat.commons.types.dmpblueprint.ExtraFieldEntity; +import eu.eudat.commons.types.dmpblueprint.FieldEntity; +import eu.eudat.commons.types.dmpblueprint.SectionEntity; +import eu.eudat.commons.types.dmpblueprint.SystemFieldEntity; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.builder.BaseBuilder; +import eu.eudat.model.dmpblueprintdefinition.Section; +import gr.cite.tools.data.builder.BuilderFactory; +import gr.cite.tools.exception.MyApplicationException; +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.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.util.*; +import java.util.stream.Collectors; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class SectionBuilder extends BaseBuilder { + + private final BuilderFactory builderFactory; + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + @Autowired + public SectionBuilder( + ConventionService conventionService, BuilderFactory builderFactory) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(SectionBuilder.class))); + this.builderFactory = builderFactory; + } + + public SectionBuilder authorize(EnumSet values) { + this.authorize = values; + return this; + } + + @Override + public List
build(FieldSet fields, List data) throws MyApplicationException { + this.logger.debug("building for {} items requesting {} fields", Optional.ofNullable(data).map(List::size).orElse(0), Optional.ofNullable(fields).map(FieldSet::getFields).map(Set::size).orElse(0)); + this.logger.trace(new DataLogEntry("requested fields", fields)); + if (fields == null || data == null || fields.isEmpty()) + return new ArrayList<>(); + + //Not Bulk Build because is XML no interaction with db + FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asPrefix(Section._descriptionTemplates)); + FieldSet fieldsFields = fields.extractPrefixed(this.asPrefix(Section._fields)); + + List
models = new ArrayList<>(); + for (SectionEntity d : data) { + Section m = new Section(); + if (fields.hasField(this.asIndexer(Section._id))) m.setId(d.getId()); + if (fields.hasField(this.asIndexer(Section._label))) m.setLabel(d.getLabel()); + if (fields.hasField(this.asIndexer(Section._description))) m.setDescription(d.getDescription()); + if (fields.hasField(this.asIndexer(Section._ordinal))) m.setOrdinal(d.getOrdinal()); + if (fields.hasField(this.asIndexer(Section._hasTemplates))) m.setHasTemplates(d.getHasTemplates()); + if (!descriptionTemplatesFields.isEmpty() && d.getDescriptionTemplates() != null) m.setDescriptionTemplates(this.builderFactory.builder(DescriptionTemplateBuilder.class).authorize(this.authorize).build(descriptionTemplatesFields, d.getDescriptionTemplates())); + if (!fieldsFields.isEmpty() && d.getFields() != null) { + List systemFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.System.equals(x.getCategory())).map(x-> (SystemFieldEntity)x).toList(); + List extraFieldEntities = d.getFields().stream().filter(x-> DmpBlueprintFieldCategory.Extra.equals(x.getCategory())).map(x-> (ExtraFieldEntity)x).toList(); + m.setFields(new ArrayList<>()); + m.getFields().addAll(this.builderFactory.builder(SystemFieldBuilder.class).authorize(this.authorize).build(fieldsFields, systemFieldEntities)); + m.getFields().addAll(this.builderFactory.builder(ExtraFieldBuilder.class).authorize(this.authorize).build(fieldsFields, extraFieldEntities)); + } + models.add(m); + } + this.logger.debug("build {} items", Optional.of(models).map(List::size).orElse(0)); + return models; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/SystemFieldBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/SystemFieldBuilder.java new file mode 100644 index 000000000..951ad38cd --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/dmpblueprintdefinition/SystemFieldBuilder.java @@ -0,0 +1,32 @@ +package eu.eudat.model.builder.dmpblueprintdefinition; + +import eu.eudat.commons.types.dmpblueprint.ExtraFieldEntity; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.dmpblueprintdefinition.ExtraField; +import gr.cite.tools.fieldset.FieldSet; +import gr.cite.tools.logging.LoggerService; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class SystemFieldBuilder extends FieldBuilder { + + @Autowired + public SystemFieldBuilder( + ConventionService conventionService) { + super(conventionService, new LoggerService(LoggerFactory.getLogger(SystemFieldBuilder.class))); + } + + protected ExtraField getInstance() { + return new ExtraField(); + } + + protected ExtraField buildChild(FieldSet fields, ExtraFieldEntity data, ExtraField model) { + if (fields.hasField(this.asIndexer(ExtraField._type))) model.setType(data.getType()); + return model; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DmpBlueprintCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DmpBlueprintCensor.java new file mode 100644 index 000000000..ddac38048 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/DmpBlueprintCensor.java @@ -0,0 +1,46 @@ +package eu.eudat.model.censorship; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.DmpBlueprint; +import eu.eudat.model.censorship.dmpblueprintdefinition.DefinitionCensor; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.censor.CensorFactory; +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 DmpBlueprintCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintCensor.class)); + + protected final AuthorizationService authService; + protected final CensorFactory censorFactory; + + public DmpBlueprintCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { + super(conventionService); + this.authService = authService; + this.censorFactory = censorFactory; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields.isEmpty()) + return; + + this.authService.authorizeForce(Permission.BrowseDmpBlueprint); + FieldSet definitionFields = fields.extractPrefixed(this.asIndexerPrefix(DmpBlueprint._definition)); + this.censorFactory.censor(DefinitionCensor.class).censor(definitionFields, userId); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/DefinitionCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/DefinitionCensor.java new file mode 100644 index 000000000..ae0df0d8c --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/DefinitionCensor.java @@ -0,0 +1,46 @@ +package eu.eudat.model.censorship.dmpblueprintdefinition; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +import eu.eudat.model.dmpblueprintdefinition.Definition; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.censor.CensorFactory; +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 DefinitionCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DefinitionCensor.class)); + + protected final AuthorizationService authService; + protected final CensorFactory censorFactory; + + public DefinitionCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { + super(conventionService); + this.authService = authService; + this.censorFactory = censorFactory; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields.isEmpty()) + return; + + this.authService.authorizeForce(Permission.BrowseDmpBlueprint); + FieldSet sectionsFields = fields.extractPrefixed(this.asIndexerPrefix(Definition._sections)); + this.censorFactory.censor(SectionCensor.class).censor(sectionsFields, userId); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/DescriptionTemplatesCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/DescriptionTemplatesCensor.java new file mode 100644 index 000000000..49c8c7bbf --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/DescriptionTemplatesCensor.java @@ -0,0 +1,39 @@ +package eu.eudat.model.censorship.dmpblueprintdefinition; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +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 DescriptionTemplatesCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DescriptionTemplatesCensor.class)); + + protected final AuthorizationService authService; + + public DescriptionTemplatesCensor(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.isEmpty()) + return; + + this.authService.authorizeForce(Permission.BrowseDmpBlueprint); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/FieldCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/FieldCensor.java new file mode 100644 index 000000000..305abb271 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/FieldCensor.java @@ -0,0 +1,39 @@ +package eu.eudat.model.censorship.dmpblueprintdefinition; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +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 FieldCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(FieldCensor.class)); + + protected final AuthorizationService authService; + + public FieldCensor(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.isEmpty()) + return; + + this.authService.authorizeForce(Permission.BrowseDmpBlueprint); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/SectionCensor.java b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/SectionCensor.java new file mode 100644 index 000000000..1e1e85c3b --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/censorship/dmpblueprintdefinition/SectionCensor.java @@ -0,0 +1,48 @@ +package eu.eudat.model.censorship.dmpblueprintdefinition; + +import eu.eudat.authorization.Permission; +import eu.eudat.convention.ConventionService; +import eu.eudat.model.censorship.BaseCensor; +import eu.eudat.model.dmpblueprintdefinition.Section; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.censor.CensorFactory; +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 SectionCensor extends BaseCensor { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(SectionCensor.class)); + + protected final AuthorizationService authService; + protected final CensorFactory censorFactory; + + public SectionCensor(ConventionService conventionService, + AuthorizationService authService, + CensorFactory censorFactory) { + super(conventionService); + this.authService = authService; + this.censorFactory = censorFactory; + } + + public void censor(FieldSet fields, UUID userId) { + logger.debug(new DataLogEntry("censoring fields", fields)); + if (fields.isEmpty()) + return; + + this.authService.authorizeForce(Permission.BrowseDmpBlueprint); + FieldSet fieldsFields = fields.extractPrefixed(this.asIndexerPrefix(Section._fields)); + this.censorFactory.censor(FieldCensor.class).censor(fieldsFields, userId); + FieldSet descriptionTemplatesFields = fields.extractPrefixed(this.asIndexerPrefix(Section._descriptionTemplates)); + this.censorFactory.censor(DescriptionTemplatesCensor.class).censor(descriptionTemplatesFields, userId); + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/deleter/DmpBlueprintDeleter.java b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/DmpBlueprintDeleter.java new file mode 100644 index 000000000..f0b980ef8 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/deleter/DmpBlueprintDeleter.java @@ -0,0 +1,79 @@ +package eu.eudat.model.deleter; + +import eu.eudat.commons.enums.IsActive; +import eu.eudat.data.DmpBlueprintEntity; +import eu.eudat.query.DmpBlueprintQuery; +import gr.cite.tools.data.deleter.Deleter; +import gr.cite.tools.data.deleter.DeleterFactory; +import gr.cite.tools.data.query.QueryFactory; +import gr.cite.tools.logging.LoggerService; +import gr.cite.tools.logging.MapLogEntry; +import jakarta.persistence.EntityManager; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import javax.management.InvalidApplicationException; +import java.time.Instant; +import java.util.List; +import java.util.Optional; +import java.util.UUID; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DmpBlueprintDeleter implements Deleter { + + private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintDeleter.class)); + + private final EntityManager entityManager; + + protected final QueryFactory queryFactory; + + protected final DeleterFactory deleterFactory; + + @Autowired + public DmpBlueprintDeleter( + EntityManager entityManager, + QueryFactory queryFactory, + DeleterFactory deleterFactory + ) { + this.entityManager = entityManager; + this.queryFactory = queryFactory; + this.deleterFactory = deleterFactory; + } + + public void deleteAndSaveByIds(List ids) throws InvalidApplicationException { + logger.debug(new MapLogEntry("collecting to delete").And("count", Optional.ofNullable(ids).map(List::size).orElse(0)).And("ids", ids)); + List data = this.queryFactory.query(DmpBlueprintQuery.class).ids(ids).collect(); + logger.trace("retrieved {} items", Optional.ofNullable(data).map(List::size).orElse(0)); + this.deleteAndSave(data); + } + + public void deleteAndSave(List data) throws InvalidApplicationException { + logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); + this.delete(data); + logger.trace("saving changes"); + this.entityManager.flush(); + logger.trace("changes saved"); + } + + public void delete(List data) throws InvalidApplicationException { + logger.debug("will delete {} items", Optional.ofNullable(data).map(List::size).orElse(0)); + if (data == null || data.isEmpty()) + return; + + Instant now = Instant.now(); + + for (DmpBlueprintEntity item : data) { + logger.trace("deleting item {}", item.getId()); + item.setIsActive(IsActive.Inactive); + item.setUpdatedAt(now); + logger.trace("updating item"); + this.entityManager.merge(item); + logger.trace("updated item"); + } + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Definition.java b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Definition.java new file mode 100644 index 000000000..8aab669c5 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Definition.java @@ -0,0 +1,17 @@ +package eu.eudat.model.dmpblueprintdefinition; + +import java.util.List; + +public class Definition { + + public final static String _sections = "sections"; + private List
sections; + + public List
getSections() { + return sections; + } + + public void setSections(List
sections) { + this.sections = sections; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/DescriptionTemplate.java b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/DescriptionTemplate.java new file mode 100644 index 000000000..dd859f706 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/DescriptionTemplate.java @@ -0,0 +1,61 @@ +package eu.eudat.model.dmpblueprintdefinition; + +import java.util.UUID; + +public class DescriptionTemplate { + + public final static String _id = "id"; + private UUID id; + + public final static String _descriptionTemplateId = "descriptionTemplateId"; + private UUID descriptionTemplateId; + + public final static String _label = "label"; + private String label; + + public final static String _minMultiplicity = "minMultiplicity"; + private Integer minMultiplicity; + + public final static String _maxMultiplicity = "maxMultiplicity"; + private Integer maxMultiplicity; + + 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; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/ExtraField.java b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/ExtraField.java new file mode 100644 index 000000000..ba5aca079 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/ExtraField.java @@ -0,0 +1,17 @@ +package eu.eudat.model.dmpblueprintdefinition; + +import eu.eudat.commons.enums.DmpBlueprintExtraFieldType; + +public class ExtraField extends Field { + + public final static String _type = "type"; + private DmpBlueprintExtraFieldType type; + + public DmpBlueprintExtraFieldType getType() { + return type; + } + + public void setType(DmpBlueprintExtraFieldType type) { + this.type = type; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Field.java b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Field.java new file mode 100644 index 000000000..791c37364 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Field.java @@ -0,0 +1,85 @@ +package eu.eudat.model.dmpblueprintdefinition; + +import eu.eudat.commons.enums.DmpBlueprintFieldCategory; + +import java.util.UUID; + +public abstract class Field { + + public final static String _id = "id"; + private UUID id; + + public final static String _category = "category"; + private DmpBlueprintFieldCategory category; + + public final static String _label = "label"; + private String label; + + public final static String _placeholder = "placeholder"; + private String placeholder; + + public final static String _description = "description"; + private String description; + + public final static String _ordinal = "ordinal"; + private Integer ordinal; + + public final static String _required = "required"; + private boolean required; + + 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 isRequired() { + return required; + } + + public void setRequired(boolean required) { + this.required = required; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Section.java b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Section.java new file mode 100644 index 000000000..c3de893f3 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/Section.java @@ -0,0 +1,93 @@ +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.UUID; + +public class Section { + + public final static String _id = "id"; + private UUID id; + + public final static String _description = "description"; + private String description; + + public final static String _label = "label"; + private String label; + + public final static String _ordinal = "ordinal"; + private Integer ordinal; + + public final static String _hasTemplates = "hasTemplates"; + private Boolean hasTemplates; + + public final static String _fields = "fields"; + private List fields; + + public final static String _descriptionTemplates = "descriptionTemplates"; + private List descriptionTemplates; + + 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 getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public List getDescriptionTemplates() { + return descriptionTemplates; + } + + public void setDescriptionTemplates(List descriptionTemplates) { + this.descriptionTemplates = descriptionTemplates; + } +} + + diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/SystemField.java b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/SystemField.java new file mode 100644 index 000000000..377c0db77 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/dmpblueprintdefinition/SystemField.java @@ -0,0 +1,17 @@ +package eu.eudat.model.dmpblueprintdefinition; + +import eu.eudat.commons.enums.DmpBlueprintSystemFieldType; + +public class SystemField extends Field { + + public final static String _type = "type"; + private DmpBlueprintSystemFieldType type; + + public DmpBlueprintSystemFieldType getType() { + return type; + } + + public void setType(DmpBlueprintSystemFieldType type) { + this.type = type; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DmpBlueprintQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DmpBlueprintQuery.java new file mode 100644 index 000000000..b59b12911 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DmpBlueprintQuery.java @@ -0,0 +1,196 @@ +package eu.eudat.query; + +import eu.eudat.authorization.AuthorizationFlags; +import eu.eudat.commons.enums.DmpBlueprintStatus; +import eu.eudat.commons.enums.IsActive; +import eu.eudat.commons.scope.user.UserScope; +import eu.eudat.data.DmpBlueprintEntity; +import eu.eudat.model.DmpBlueprint; +import gr.cite.commons.web.authz.service.AuthorizationService; +import gr.cite.tools.data.query.FieldResolver; +import gr.cite.tools.data.query.QueryBase; +import gr.cite.tools.data.query.QueryContext; +import jakarta.persistence.Tuple; +import jakarta.persistence.criteria.CriteriaBuilder; +import jakarta.persistence.criteria.Predicate; +import org.springframework.beans.factory.config.ConfigurableBeanFactory; +import org.springframework.context.annotation.Scope; +import org.springframework.stereotype.Component; + +import java.time.Instant; +import java.util.*; + +@Component +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +public class DmpBlueprintQuery extends QueryBase { + + private String like; + + private Collection ids; + + private Collection isActives; + + private Collection statuses; + + private Collection excludedIds; + + private EnumSet authorize = EnumSet.of(AuthorizationFlags.None); + + public DmpBlueprintQuery like(String value) { + this.like = value; + return this; + } + + public DmpBlueprintQuery ids(UUID value) { + this.ids = List.of(value); + return this; + } + + public DmpBlueprintQuery ids(UUID... value) { + this.ids = Arrays.asList(value); + return this; + } + + public DmpBlueprintQuery ids(Collection values) { + this.ids = values; + return this; + } + + public DmpBlueprintQuery isActive(IsActive value) { + this.isActives = List.of(value); + return this; + } + + public DmpBlueprintQuery isActive(IsActive... value) { + this.isActives = Arrays.asList(value); + return this; + } + + public DmpBlueprintQuery isActive(Collection values) { + this.isActives = values; + return this; + } + + public DmpBlueprintQuery statuses(DmpBlueprintStatus value) { + this.statuses = List.of(value); + return this; + } + + public DmpBlueprintQuery statuses(DmpBlueprintStatus... value) { + this.statuses = Arrays.asList(value); + return this; + } + + public DmpBlueprintQuery statuses(Collection values) { + this.statuses = values; + return this; + } + + public DmpBlueprintQuery excludedIds(Collection values) { + this.excludedIds = values; + return this; + } + + public DmpBlueprintQuery excludedIds(UUID value) { + this.excludedIds = List.of(value); + return this; + } + + public DmpBlueprintQuery excludedIds(UUID... value) { + this.excludedIds = Arrays.asList(value); + return this; + } + + public DmpBlueprintQuery authorize(EnumSet values) { + this.authorize = values; + return this; + } + + private final UserScope userScope; + + private final AuthorizationService authService; + + public DmpBlueprintQuery( + UserScope userScope, + AuthorizationService authService + ) { + this.userScope = userScope; + this.authService = authService; + } + + @Override + protected Class entityClass() { + return DmpBlueprintEntity.class; + } + + @Override + protected Boolean isFalseQuery() { + return this.isEmpty(this.ids) || this.isEmpty(this.isActives) || this.isEmpty(this.excludedIds) || this.isEmpty(this.statuses); + } + + @Override + protected Predicate applyFilters(QueryContext queryContext) { + List predicates = new ArrayList<>(); + if (this.ids != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._id)); + for (UUID item : this.ids) + inClause.value(item); + predicates.add(inClause); + } + if (this.like != null && !this.like.isEmpty()) { + predicates.add(queryContext.CriteriaBuilder.like(queryContext.Root.get(DmpBlueprintEntity._label), this.like)); + } + if (this.isActives != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._isActive)); + for (IsActive item : this.isActives) + inClause.value(item); + predicates.add(inClause); + } + + if (this.statuses != null) { + CriteriaBuilder.In inClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._status)); + for (DmpBlueprintStatus item : this.statuses) + inClause.value(item); + predicates.add(inClause); + } + if (this.excludedIds != null) { + CriteriaBuilder.In notInClause = queryContext.CriteriaBuilder.in(queryContext.Root.get(DmpBlueprintEntity._id)); + for (UUID item : this.excludedIds) + notInClause.value(item); + predicates.add(notInClause.not()); + } + if (!predicates.isEmpty()) { + Predicate[] predicatesArray = predicates.toArray(new Predicate[0]); + return queryContext.CriteriaBuilder.and(predicatesArray); + } else { + return null; + } + } + + @Override + protected DmpBlueprintEntity convert(Tuple tuple, Set columns) { + DmpBlueprintEntity item = new DmpBlueprintEntity(); + item.setId(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._id, UUID.class)); + item.setLabel(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._label, String.class)); + item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._createdAt, Instant.class)); + item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._updatedAt, Instant.class)); + item.setIsActive(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._isActive, IsActive.class)); + item.setDefinition(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._definition, String.class)); + item.setStatus(QueryBase.convertSafe(tuple, columns, DmpBlueprintEntity._status, DmpBlueprintStatus.class)); + return item; + } + + @Override + protected String fieldNameOf(FieldResolver item) { + if (item.match(DmpBlueprint._id)) return DmpBlueprintEntity._id; + else if (item.match(DmpBlueprint._label)) return DmpBlueprintEntity._label; + else if (item.match(DmpBlueprint._definition)) return DmpBlueprintEntity._definition; + else if (item.prefix(DmpBlueprint._definition)) return DmpBlueprintEntity._definition; + else if (item.match(DmpBlueprint._createdAt)) return DmpBlueprintEntity._createdAt; + else if (item.match(DmpBlueprint._updatedAt)) return DmpBlueprintEntity._updatedAt; + else if (item.match(DmpBlueprint._isActive)) return DmpBlueprintEntity._isActive; + else if (item.match(DmpBlueprint._status)) return DmpBlueprintEntity._status; + else return null; + } + +} diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java index 8af3c8281..9ffe48dc4 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanBlueprintCriteria.java @@ -1,15 +1,16 @@ package eu.eudat.data.dao.criteria; -import eu.eudat.data.old.DMPProfile; +import eu.eudat.commons.enums.DmpBlueprintStatus; +import eu.eudat.data.DmpBlueprintEntity; -public class DataManagementPlanBlueprintCriteria extends Criteria { +public class DataManagementPlanBlueprintCriteria extends Criteria { - private Integer status; + private DmpBlueprintStatus status; - public Integer getStatus() { + public DmpBlueprintStatus getStatus() { return status; } - public void setStatus(Integer status) { + public void setStatus(DmpBlueprintStatus status) { this.status = status; } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanCriteria.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanCriteria.java index 97cba9e23..c44b1b695 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanCriteria.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanCriteria.java @@ -1,7 +1,7 @@ package eu.eudat.data.dao.criteria; import eu.eudat.data.old.DMP; -import eu.eudat.data.old.DMPProfile; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.old.Grant; import java.util.Date; @@ -11,7 +11,7 @@ import java.util.UUID; public class DataManagementPlanCriteria extends Criteria { private Date periodStart; private Date periodEnd; - private DMPProfile profile; + private DmpBlueprintEntity profile; private List grants; private boolean allVersions; private List groupIds; @@ -39,10 +39,10 @@ public class DataManagementPlanCriteria extends Criteria { this.periodEnd = periodEnd; } - public DMPProfile getProfile() { + public DmpBlueprintEntity getProfile() { return profile; } - public void setProfile(DMPProfile profile) { + public void setProfile(DmpBlueprintEntity profile) { this.profile = profile; } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanProfileCriteria.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanProfileCriteria.java index 0e47f401b..56e4519d8 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanProfileCriteria.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/criteria/DataManagementPlanProfileCriteria.java @@ -1,9 +1,9 @@ package eu.eudat.data.dao.criteria; -import eu.eudat.data.old.DMPProfile; +import eu.eudat.data.DmpBlueprintEntity; /** * Created by ikalyvas on 3/21/2018. */ -public class DataManagementPlanProfileCriteria extends Criteria { +public class DataManagementPlanProfileCriteria extends Criteria { } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDao.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDao.java index bdef8642c..4963b13b2 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDao.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDao.java @@ -3,7 +3,7 @@ package eu.eudat.data.dao.entities; import eu.eudat.data.dao.DatabaseAccessLayer; import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria; import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria; -import eu.eudat.data.old.DMPProfile; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.queryable.QueryableList; import java.util.UUID; @@ -11,10 +11,10 @@ import java.util.UUID; /** * Created by ikalyvas on 3/21/2018. */ -public interface DMPProfileDao extends DatabaseAccessLayer { +public interface DMPProfileDao extends DatabaseAccessLayer { - QueryableList getWithCriteria(DataManagementPlanProfileCriteria criteria); + QueryableList getWithCriteria(DataManagementPlanProfileCriteria criteria); - QueryableList getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria); + QueryableList getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria); } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java index b8b811472..c9e1e5321 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DMPProfileDaoImpl.java @@ -1,10 +1,12 @@ package eu.eudat.data.dao.entities; +import eu.eudat.commons.enums.DmpBlueprintStatus; +import eu.eudat.commons.enums.IsActive; import eu.eudat.data.dao.DatabaseAccess; import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria; import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria; import eu.eudat.data.dao.databaselayer.service.DatabaseService; -import eu.eudat.data.old.DMPProfile; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.queryable.QueryableList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; @@ -18,69 +20,69 @@ import java.util.concurrent.CompletableFuture; * Created by ikalyvas on 3/21/2018. */ @Service("dmpProfileDao") -public class DMPProfileDaoImpl extends DatabaseAccess implements DMPProfileDao { +public class DMPProfileDaoImpl extends DatabaseAccess implements DMPProfileDao { @Autowired - public DMPProfileDaoImpl(DatabaseService databaseService) { + public DMPProfileDaoImpl(DatabaseService databaseService) { super(databaseService); } @Async @Override - public CompletableFuture createOrUpdateAsync(DMPProfile item) { + public CompletableFuture createOrUpdateAsync(DmpBlueprintEntity item) { return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item)); } @Override - public DMPProfile createOrUpdate(DMPProfile item) { - return this.getDatabaseService().createOrUpdate(item, DMPProfile.class); + public DmpBlueprintEntity createOrUpdate(DmpBlueprintEntity item) { + return this.getDatabaseService().createOrUpdate(item, DmpBlueprintEntity.class); } @Override - public DMPProfile find(UUID id) throws InvalidApplicationException { - return getDatabaseService().getQueryable(DMPProfile.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle(); + public DmpBlueprintEntity find(UUID id) throws InvalidApplicationException { + return getDatabaseService().getQueryable(DmpBlueprintEntity.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle(); } @Override - public DMPProfile find(UUID id, String hint) throws InvalidApplicationException { - return getDatabaseService().getQueryable(DMPProfile.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle(); + public DmpBlueprintEntity find(UUID id, String hint) throws InvalidApplicationException { + return getDatabaseService().getQueryable(DmpBlueprintEntity.class).where((builder, root) -> builder.equal((root.get("id")), id)).getSingle(); } @Override - public void delete(DMPProfile item) { + public void delete(DmpBlueprintEntity item) { this.getDatabaseService().delete(item); } @Override - public QueryableList asQueryable() { - return this.getDatabaseService().getQueryable(DMPProfile.class); + public QueryableList asQueryable() { + return this.getDatabaseService().getQueryable(DmpBlueprintEntity.class); } @Override - public QueryableList getWithCriteria(DataManagementPlanProfileCriteria criteria) { - QueryableList query = getDatabaseService().getQueryable(DMPProfile.class); + public QueryableList getWithCriteria(DataManagementPlanProfileCriteria criteria) { + QueryableList query = getDatabaseService().getQueryable(DmpBlueprintEntity.class); if (criteria.getLike() != null && !criteria.getLike().isEmpty()) query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%")); - query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue()))); + query.where(((builder, root) -> builder.notEqual(root.get(DmpBlueprintEntity._isActive), IsActive.Inactive))); return query; } @Override - public QueryableList getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria){ - QueryableList query = getDatabaseService().getQueryable(DMPProfile.class); + public QueryableList getWithCriteriaBlueprint(DataManagementPlanBlueprintCriteria criteria){ + QueryableList query = getDatabaseService().getQueryable(DmpBlueprintEntity.class); if (criteria.getLike() != null && !criteria.getLike().isEmpty()) query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + criteria.getLike().toUpperCase() + "%")); if (criteria.getStatus() != null) { - if (criteria.getStatus() == DMPProfile.Status.FINALIZED.getValue()) { - query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.FINALIZED.getValue())); - } else if (criteria.getStatus() == DMPProfile.Status.SAVED.getValue()) { - query.where((builder, root) -> builder.equal(root.get("status"), DMPProfile.Status.SAVED.getValue())); + if (criteria.getStatus().equals(DmpBlueprintStatus.Finalized)) { + query.where((builder, root) -> builder.equal(root.get(DmpBlueprintEntity._status), DmpBlueprintStatus.Finalized)); + } else if (criteria.getStatus().equals(DmpBlueprintStatus.Draft)) { + query.where((builder, root) -> builder.equal(root.get(DmpBlueprintEntity._status), DmpBlueprintStatus.Draft)); } } - query.where(((builder, root) -> builder.notEqual(root.get("status"), DMPProfile.Status.DELETED.getValue()))); + query.where(((builder, root) -> builder.notEqual(root.get(DmpBlueprintEntity._isActive), IsActive.Inactive))); return query; } } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/dmpblueprint/DataManagementPlanBlueprintTableRequest.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/dmpblueprint/DataManagementPlanBlueprintTableRequest.java index d3fac4120..2cb003859 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/dmpblueprint/DataManagementPlanBlueprintTableRequest.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/dmpblueprint/DataManagementPlanBlueprintTableRequest.java @@ -1,18 +1,18 @@ package eu.eudat.data.query.items.dmpblueprint; import eu.eudat.data.dao.criteria.DataManagementPlanBlueprintCriteria; -import eu.eudat.data.old.DMPProfile; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.query.PaginationService; import eu.eudat.data.query.definition.TableQuery; import eu.eudat.queryable.QueryableList; import java.util.UUID; -public class DataManagementPlanBlueprintTableRequest extends TableQuery { +public class DataManagementPlanBlueprintTableRequest extends TableQuery { @Override - public QueryableList applyCriteria() { - QueryableList query = this.getQuery(); + public QueryableList applyCriteria() { + QueryableList query = this.getQuery(); if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); if (this.getCriteria().getStatus() != null) @@ -21,7 +21,7 @@ public class DataManagementPlanBlueprintTableRequest extends TableQuery applyPaging(QueryableList items) { + public QueryableList applyPaging(QueryableList items) { return PaginationService.applyPaging(items, this); } } diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/dmpprofile/DataManagementPlanProfileCriteriaRequest.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/dmpprofile/DataManagementPlanProfileCriteriaRequest.java index 0382b2ce3..6ed3dedbc 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/dmpprofile/DataManagementPlanProfileCriteriaRequest.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/item/dmpprofile/DataManagementPlanProfileCriteriaRequest.java @@ -1,17 +1,17 @@ package eu.eudat.data.query.items.item.dmpprofile; import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria; -import eu.eudat.data.old.DMPProfile; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.query.definition.Query; import eu.eudat.queryable.QueryableList; /** * Created by ikalyvas on 3/21/2018. */ -public class DataManagementPlanProfileCriteriaRequest extends Query { +public class DataManagementPlanProfileCriteriaRequest extends Query { @Override - public QueryableList applyCriteria() { - QueryableList query = this.getQuery(); + public QueryableList applyCriteria() { + QueryableList query = this.getQuery(); if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) query.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%")); return query; diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dmpprofile/DataManagementPlanProfileTableRequest.java b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dmpprofile/DataManagementPlanProfileTableRequest.java index 9cad8dc8c..13563948f 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dmpprofile/DataManagementPlanProfileTableRequest.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/query/items/table/dmpprofile/DataManagementPlanProfileTableRequest.java @@ -1,7 +1,7 @@ package eu.eudat.data.query.items.table.dmpprofile; import eu.eudat.data.dao.criteria.DataManagementPlanProfileCriteria; -import eu.eudat.data.old.DMPProfile; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.query.PaginationService; import eu.eudat.data.query.definition.TableQuery; import eu.eudat.queryable.QueryableList; @@ -11,18 +11,18 @@ import java.util.UUID; /** * Created by ikalyvas on 3/21/2018. */ -public class DataManagementPlanProfileTableRequest extends TableQuery { +public class DataManagementPlanProfileTableRequest extends TableQuery { @Override - public QueryableList applyCriteria() { - QueryableList query = this.getQuery(); + public QueryableList applyCriteria() { + QueryableList query = this.getQuery(); if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty()) query.where((builder, root) -> builder.like(root.get("label"), "%" + this.getCriteria().getLike() + "%")); return query; } @Override - public QueryableList applyPaging(QueryableList items) { + public QueryableList applyPaging(QueryableList items) { return PaginationService.applyPaging(items, this); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java index e62f74c8c..69905de4b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/DMPProfileController.java @@ -2,7 +2,7 @@ package eu.eudat.controllers; import eu.eudat.authorization.Permission; import eu.eudat.data.dao.criteria.RequestItem; -import eu.eudat.data.old.DMPProfile; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.old.DescriptionTemplate; import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest; import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest; @@ -14,7 +14,6 @@ import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem; import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.helpers.responses.ResponseItem; import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel; -import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel; import eu.eudat.types.ApiMessageCode; import gr.cite.commons.web.authz.service.AuthorizationService; import org.springframework.beans.factory.annotation.Autowired; @@ -31,8 +30,6 @@ import javax.xml.xpath.XPathExpressionException; import java.io.IOException; import java.util.List; -import static eu.eudat.types.Authorities.ADMIN; - /** * Created by ikalyvas on 3/21/2018. */ @@ -51,34 +48,34 @@ public class DMPProfileController extends BaseController { this.authorizationService = authorizationService; } - @Transactional - @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") - public @ResponseBody - ResponseEntity> createOrUpdate(@RequestBody DataManagementPlanProfileListingModel dataManagementPlan) throws Exception { - this.authorizationService.authorizeForce(Permission.AdminRole); - - this.dataManagementProfileManager.createOrUpdate(dataManagementPlan); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created")); - } +// @Transactional +// @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") +// public @ResponseBody +// ResponseEntity> createOrUpdate(@RequestBody DataManagementPlanProfileListingModel dataManagementPlan) throws Exception { +// this.authorizationService.authorizeForce(Permission.AdminRole); +// +// this.dataManagementProfileManager.createOrUpdate(dataManagementPlan); +// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created")); +// } @Transactional @RequestMapping(method = RequestMethod.POST, value = {"/blueprint"}, consumes = "application/json", produces = "application/json") public @ResponseBody - ResponseEntity> createOrUpdateBlueprint(@RequestBody DataManagementPlanBlueprintListingModel dataManagementPlan) throws Exception { + ResponseEntity> createOrUpdateBlueprint(@RequestBody DataManagementPlanBlueprintListingModel dataManagementPlan) throws Exception { this.authorizationService.authorizeForce(Permission.AdminRole); this.dataManagementProfileManager.createOrUpdateBlueprint(dataManagementPlan); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created")); + return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created")); } - @RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json") - public @ResponseBody - ResponseEntity> getSingle(@PathVariable String id) throws IllegalAccessException, InstantiationException, InvalidApplicationException { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(id); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanProfileListingModel)); - } +// @RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json") +// public @ResponseBody +// ResponseEntity> getSingle(@PathVariable String id) throws IllegalAccessException, InstantiationException, InvalidApplicationException { +// this.authorizationService.authorizeForce(Permission.AuthenticatedRole); +// +// DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(id); +// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanProfileListingModel)); +// } @RequestMapping(method = RequestMethod.GET, value = {"/getSingleBlueprint/{id}"}, produces = "application/json") public @ResponseBody @@ -89,14 +86,14 @@ public class DMPProfileController extends BaseController { return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanBlueprintListingModel)); } - @RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json") - public @ResponseBody - ResponseEntity>> getPaged(@Valid @RequestBody DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest) throws Exception { - this.authorizationService.authorizeForce(Permission.AuthenticatedRole); - - DataTableData dataTable = this.dataManagementProfileManager.getPaged(dataManagementPlanProfileTableRequest); - return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); - } +// @RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json") +// public @ResponseBody +// ResponseEntity>> getPaged(@Valid @RequestBody DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest) throws Exception { +// this.authorizationService.authorizeForce(Permission.AuthenticatedRole); +// +// DataTableData dataTable = this.dataManagementProfileManager.getPaged(dataManagementPlanProfileTableRequest); +// return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable)); +// } @RequestMapping(method = RequestMethod.POST, value = {"/getPagedBlueprint"}, consumes = "application/json", produces = "application/json") public @ResponseBody @@ -155,9 +152,9 @@ public class DMPProfileController extends BaseController { .status(ApiMessageCode.SUCCESS_MESSAGE).message("")); } - @RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}) - public ResponseEntity getExternalAutocomplete(@RequestBody RequestItem lookupItem) throws XPathExpressionException, InvalidApplicationException { - List> items = this.dataManagementProfileManager.getExternalAutocomplete(lookupItem); - return ResponseEntity.status(HttpStatus.OK).body(items); - } +// @RequestMapping(method = RequestMethod.POST, value = {"/search/autocomplete"}) +// public ResponseEntity getExternalAutocomplete(@RequestBody RequestItem lookupItem) throws XPathExpressionException, InvalidApplicationException { +// List> items = this.dataManagementProfileManager.getExternalAutocomplete(lookupItem); +// return ResponseEntity.status(HttpStatus.OK).body(items); +// } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpBlueprintController.java b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpBlueprintController.java new file mode 100644 index 000000000..b32979b50 --- /dev/null +++ b/dmp-backend/web/src/main/java/eu/eudat/controllers/v2/DmpBlueprintController.java @@ -0,0 +1,130 @@ +//package eu.eudat.controllers.v2; +// +//import eu.eudat.audit.AuditableAction; +//import eu.eudat.authorization.AuthorizationFlags; +//import eu.eudat.data.DescriptionTemplateTypeEntity; +//import eu.eudat.model.DmpBlueprint; +//import eu.eudat.model.builder.DescriptionTemplateTypeBuilder; +//import eu.eudat.model.censorship.DescriptionTemplateTypeCensor; +//import eu.eudat.model.persist.DescriptionTemplateTypePersist; +//import eu.eudat.model.result.QueryResult; +//import eu.eudat.query.DescriptionTemplateTypeQuery; +//import eu.eudat.query.lookup.DescriptionTemplateTypeLookup; +//import eu.eudat.service.DescriptionTemplateTypeService; +//import gr.cite.tools.auditing.AuditService; +//import gr.cite.tools.data.builder.BuilderFactory; +//import gr.cite.tools.data.censor.CensorFactory; +//import gr.cite.tools.data.query.QueryFactory; +//import gr.cite.tools.exception.MyApplicationException; +//import gr.cite.tools.exception.MyForbiddenException; +//import gr.cite.tools.exception.MyNotFoundException; +//import gr.cite.tools.fieldset.FieldSet; +//import gr.cite.tools.logging.LoggerService; +//import gr.cite.tools.logging.MapLogEntry; +//import gr.cite.tools.validation.MyValidate; +//import org.slf4j.LoggerFactory; +//import org.springframework.context.MessageSource; +//import org.springframework.context.i18n.LocaleContextHolder; +//import org.springframework.transaction.annotation.Transactional; +//import org.springframework.web.bind.annotation.*; +// +//import javax.management.InvalidApplicationException; +//import java.util.*; +// +//@RestController +//@CrossOrigin +//@RequestMapping(path = "api/dmp-blueprint") +//public class DmpBlueprintController { +// +// private static final LoggerService logger = new LoggerService(LoggerFactory.getLogger(DmpBlueprintController.class)); +// +// private final BuilderFactory builderFactory; +// +// private final AuditService auditService; +// +// private final DescriptionTemplateTypeService descriptionTemplateTypeService; +// +// private final CensorFactory censorFactory; +// +// private final QueryFactory queryFactory; +// +// private final MessageSource messageSource; +// +// public DmpBlueprintController( +// BuilderFactory builderFactory, +// AuditService auditService, +// DescriptionTemplateTypeService descriptionTemplateTypeService, +// CensorFactory censorFactory, +// QueryFactory queryFactory, +// MessageSource messageSource) { +// this.builderFactory = builderFactory; +// this.auditService = auditService; +// this.descriptionTemplateTypeService = descriptionTemplateTypeService; +// this.censorFactory = censorFactory; +// this.queryFactory = queryFactory; +// this.messageSource = messageSource; +// } +// +// @PostMapping("query") +// public QueryResult Query(@RequestBody DescriptionTemplateTypeLookup lookup) throws MyApplicationException, MyForbiddenException { +// logger.debug("querying {}", DmpBlueprint.class.getSimpleName()); +// +// this.censorFactory.censor(DescriptionTemplateTypeCensor.class).censor(lookup.getProject(), null); +// +// DescriptionTemplateTypeQuery query = lookup.enrich(this.queryFactory).authorize(AuthorizationFlags.OwnerOrPermission); +// +// List data = query.collectAs(lookup.getProject()); +// List models = this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(lookup.getProject(), data); +// long count = (lookup.getMetadata() != null && lookup.getMetadata().getCountAll()) ? query.count() : models.size(); +// +// this.auditService.track(AuditableAction.DescriptionTemplateType_Query, "lookup", lookup); +// //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); +// +// return new QueryResult<>(models, count); +// } +// +// @GetMapping("{id}") +// public DmpBlueprint Get(@PathVariable("id") UUID id, FieldSet fieldSet, Locale locale) throws MyApplicationException, MyForbiddenException, MyNotFoundException { +// logger.debug(new MapLogEntry("retrieving" + DmpBlueprint.class.getSimpleName()).And("id", id).And("fields", fieldSet)); +// +// this.censorFactory.censor(DescriptionTemplateTypeCensor.class).censor(fieldSet, null); +// +// DescriptionTemplateTypeQuery query = this.queryFactory.query(DescriptionTemplateTypeQuery.class).authorize(AuthorizationFlags.OwnerOrPermission).ids(id); +// DmpBlueprint model = this.builderFactory.builder(DescriptionTemplateTypeBuilder.class).authorize(AuthorizationFlags.OwnerOrPermission).build(fieldSet, query.firstAs(fieldSet)); +// if (model == null) +// throw new MyNotFoundException(messageSource.getMessage("General_ItemNotFound", new Object[]{id, DmpBlueprint.class.getSimpleName()}, LocaleContextHolder.getLocale())); +// +// this.auditService.track(AuditableAction.DescriptionTemplateType_Lookup, Map.ofEntries( +// new AbstractMap.SimpleEntry("id", id), +// new AbstractMap.SimpleEntry("fields", fieldSet) +// )); +// //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); +// +// return model; +// } +// +// @PostMapping("persist") +// @Transactional +// public DmpBlueprint Persist(@MyValidate @RequestBody DescriptionTemplateTypePersist model, FieldSet fieldSet) throws MyApplicationException, MyForbiddenException, MyNotFoundException, InvalidApplicationException { +// logger.debug(new MapLogEntry("persisting" + DmpBlueprint.class.getSimpleName()).And("model", model).And("fieldSet", fieldSet)); +// DmpBlueprint persisted = this.descriptionTemplateTypeService.persist(model, fieldSet); +// +// this.auditService.track(AuditableAction.DescriptionTemplateType_Persist, Map.ofEntries( +// new AbstractMap.SimpleEntry("model", model), +// new AbstractMap.SimpleEntry("fields", fieldSet) +// )); +// //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); +// return persisted; +// } +// +// @DeleteMapping("{id}") +// @Transactional +// public void Delete(@PathVariable("id") UUID id) throws MyForbiddenException, InvalidApplicationException { +// logger.debug(new MapLogEntry("retrieving" + DmpBlueprint.class.getSimpleName()).And("id", id)); +// +// this.descriptionTemplateTypeService.deleteAndSave(id); +// +// this.auditService.track(AuditableAction.DescriptionTemplateType_Delete, "id", id); +// //this.auditService.trackIdentity(AuditableAction.IdentityTracking_Action); +// } +//} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/AdminManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/AdminManager.java index 8446d144c..da8bf7ebd 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/AdminManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/AdminManager.java @@ -10,7 +10,7 @@ import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyl import eu.eudat.models.data.admin.composite.DatasetProfile; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.utilities.builders.ModelBuilder; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.service.DescriptionTemplateTypeService; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java index af43c9f78..6bb30ac90 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementPlanManager.java @@ -5,8 +5,10 @@ import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.authorization.Permission; import eu.eudat.commons.scope.user.UserScope; import eu.eudat.commons.enums.EntityType; +import eu.eudat.commons.types.dmpblueprint.*; import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration; import eu.eudat.configurations.dynamicgrant.entities.Property; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.EntityDoiEntity; import eu.eudat.data.dao.criteria.*; import eu.eudat.data.dao.entities.*; @@ -41,7 +43,7 @@ import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl; import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; import eu.eudat.logic.utilities.documents.pdf.PDFUtils; import eu.eudat.logic.utilities.documents.types.ParagraphStyle; @@ -56,9 +58,8 @@ import eu.eudat.models.data.dmp.*; import eu.eudat.models.data.doi.DepositRequest; import eu.eudat.models.data.doi.Doi; import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.*; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType; +import eu.eudat.commons.enums.DmpBlueprintFieldCategory; +import eu.eudat.commons.enums.DmpBlueprintSystemFieldType; import eu.eudat.models.data.funder.FunderDMPEditorModel; import eu.eudat.models.data.grant.GrantDMPEditorModel; import eu.eudat.models.data.helpermodels.Tuple; @@ -68,7 +69,6 @@ import eu.eudat.models.data.project.ProjectDMPEditorModel; import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.models.data.userinfo.UserListingModel; import eu.eudat.queryable.QueryableList; -import eu.eudat.types.Authorities; import eu.eudat.types.MetricNames; import gr.cite.commons.web.authz.service.AuthorizationService; import org.apache.poi.xwpf.usermodel.XWPFDocument; @@ -500,8 +500,8 @@ public class DataManagementPlanManager { DMP newDmp = dataManagementPlan.toDataModel(); if(dataManagementPlan.getProfile() != null){ - DMPProfile dmpProfile = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().find(dataManagementPlan.getProfile().getId()); - newDmp.setProfile(dmpProfile); + DmpBlueprintEntity dmpBlueprint = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().find(dataManagementPlan.getProfile().getId()); + newDmp.setProfile(dmpBlueprint); } if (newDmp.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue()) { checkDmpValidationRules(newDmp); @@ -509,18 +509,18 @@ public class DataManagementPlanManager { UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); newDmp.setCreator(user); - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.ORGANIZATIONS)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Organizations)) { createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao()); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.RESEARCHERS)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Researchers)) { createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Funder)) { createFunderIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao()); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) { createGrantIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao()); - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Project)) { if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) { newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant())); } @@ -546,16 +546,16 @@ public class DataManagementPlanManager { } } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) { if (newDmp.getGrant() != null && newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) { checkIfUserCanEditGrant(newDmp, user); } assignGrandUserIfInternal(newDmp, user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Funder)) { assignFunderUserIfInternal(newDmp, user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Project)) { assignProjectUserIfInternal(newDmp, user); } @@ -565,7 +565,7 @@ public class DataManagementPlanManager { } } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) { if (newDmp.getGrant() != null) { apiContext.getOperationsContext().getDatabaseRepository().getGrantDao().createOrUpdate(newDmp.getGrant()); } @@ -665,16 +665,16 @@ public class DataManagementPlanManager { checkDmpValidationRules(tempDMP); } UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(this.userScope.getUserId()); - if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), SystemFieldType.ORGANIZATIONS)) { + if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), DmpBlueprintSystemFieldType.Organizations)) { createOrganisationsIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao()); } - if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), SystemFieldType.RESEARCHERS)) { + if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), DmpBlueprintSystemFieldType.Researchers)) { createResearchersIfTheyDontExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao(), user); } - if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), SystemFieldType.FUNDER)) { + if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), DmpBlueprintSystemFieldType.Funder)) { createFunderIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getFunderDao()); } - if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(tempDMP.getProfile(), DmpBlueprintSystemFieldType.Grant)) { createGrantIfItDoesntExist(tempDMP, apiContext.getOperationsContext().getDatabaseRepository().getGrantDao()); } @@ -714,18 +714,18 @@ public class DataManagementPlanManager { newDmp.setDmpProperties(oldDmp.getDmpProperties()); UserInfo user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build(); newDmp.setCreator(user); - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.ORGANIZATIONS)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Organizations)) { createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao()); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.RESEARCHERS)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Researchers)) { createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Funder)) { createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao()); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) { createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao()); - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Project)) { if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) { newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant())); } @@ -737,19 +737,19 @@ public class DataManagementPlanManager { newDmp.setVersion(oldDmp.getVersion() + 1); newDmp.setId(null); - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) { if (newDmp.getGrant() != null && newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) { checkIfUserCanEditGrant(newDmp, user); } assignGrandUserIfInternal(newDmp, user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Funder)) { assignFunderUserIfInternal(newDmp, user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Project)) { assignProjectUserIfInternal(newDmp, user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) { if (newDmp.getGrant() != null) { if (newDmp.getGrant().getStartdate() == null) { newDmp.getGrant().setStartdate(new Date()); @@ -803,18 +803,18 @@ public class DataManagementPlanManager { UserInfo user = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build(); newDmp.setCreator(user); - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.ORGANIZATIONS)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Organizations)) { createOrganisationsIfTheyDontExist(newDmp, databaseRepository.getOrganisationDao()); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.RESEARCHERS)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Researchers)) { createResearchersIfTheyDontExist(newDmp, databaseRepository.getResearcherDao(), user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Funder)) { createFunderIfItDoesntExist(newDmp, databaseRepository.getFunderDao()); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) { createGrantIfItDoesntExist(newDmp, databaseRepository.getGrantDao()); - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Project)) { if (newDmp.getProject() != null && newDmp.getGrant() != null && (newDmp.getProject().getLabel() == null || newDmp.getProject().getLabel().trim().isEmpty())) { newDmp.setProject(newDmp.getProject().projectFromGrant(newDmp.getGrant())); } @@ -826,19 +826,19 @@ public class DataManagementPlanManager { newDmp.setVersion(0); newDmp.setId(null); - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) { if (newDmp.getGrant() != null && newDmp.getGrant().getType().equals(Grant.GrantType.INTERNAL.getValue())) { checkIfUserCanEditGrant(newDmp, user); } assignGrandUserIfInternal(newDmp, user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.FUNDER)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Funder)) { assignFunderUserIfInternal(newDmp, user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.PROJECT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Project)) { assignProjectUserIfInternal(newDmp, user); } - if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(newDmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) { if (newDmp.getGrant() != null) { databaseRepository.getGrantDao().createOrUpdate(newDmp.getGrant()); } @@ -1111,7 +1111,7 @@ public class DataManagementPlanManager { datasetElastic.setStatus(dataset1.getStatus()); datasetElastic.setDmp(dataset1.getDmp().getId()); datasetElastic.setGroup(dataset1.getDmp().getGroupId()); - if(this.dataManagementProfileManager.fieldInBlueprint(dataset1.getDmp().getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(dataset1.getDmp().getProfile(), DmpBlueprintSystemFieldType.Grant)) { datasetElastic.setGrant(dataset1.getDmp().getGrant().getId()); } if (dataset1.getDmp().getUsers() != null) { @@ -1134,7 +1134,7 @@ public class DataManagementPlanManager { }).collect(Collectors.toList())); } datasetElastic.setPublic(dataset1.getDmp().isPublic()); - if(this.dataManagementProfileManager.fieldInBlueprint(dataset1.getDmp().getProfile(), SystemFieldType.GRANT)) { + if(this.dataManagementProfileManager.fieldInBlueprint(dataset1.getDmp().getProfile(), DmpBlueprintSystemFieldType.Grant)) { datasetElastic.setGrantStatus(dataset1.getDmp().getGrant().getStatus()); } @@ -1374,11 +1374,11 @@ public class DataManagementPlanManager { // // Space below Datasets. // XWPFParagraph parBreakDatasets = document.createParagraph(); - DMPProfile dmpProfile = dmpEntity.getProfile(); + DmpBlueprintEntity dmpProfile = dmpEntity.getProfile(); DataManagementPlanBlueprintListingModel dmpBlueprintModel = new DataManagementPlanBlueprintListingModel(); dmpBlueprintModel.fromDataModel(dmpProfile); - DataManagementPlanBlueprint dmpBlueprint = dmpBlueprintModel.getDefinition(); - for(Section section: dmpBlueprint.getSections()){ + DefinitionEntity dmpBlueprint = dmpBlueprintModel.getDefinition(); + for(SectionEntity section: dmpBlueprint.getSections()){ wordBuilder.addParagraphContent("Section " + section.getOrdinal(), document, ParagraphStyle.HEADER1, BigInteger.ZERO, 0); XWPFParagraph sectionInfoParagraph = document.createParagraph(); sectionInfoParagraph.setSpacingBetween(1.0); @@ -1397,10 +1397,10 @@ public class DataManagementPlanManager { runSectionDescriptionText.setColor("116a78"); wordBuilder.addParagraphContent("Section Fields", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0); - section.getFields().sort(Comparator.comparingInt(FieldModel::getOrdinal)); - for(FieldModel field: section.getFields()){ - if(field.getCategory() == FieldCategory.SYSTEM){ - SystemField systemField = field.toSystemField(); + section.getFields().sort(Comparator.comparingInt(FieldEntity::getOrdinal)); + for(FieldEntity field: section.getFields()){ + if(field.getCategory() == DmpBlueprintFieldCategory.System){ + SystemFieldEntity systemField = (SystemFieldEntity) field; XWPFParagraph systemFieldParagraph = document.createParagraph(); systemFieldParagraph.setSpacingBetween(1.0); XWPFRun runSyStemFieldTitle = systemFieldParagraph.createRun(); @@ -1425,62 +1425,62 @@ public class DataManagementPlanManager { runInput.setText("Input: "); runInput.setColor("000000"); switch (systemField.getType()) { - case TEXT: + case Text: XWPFRun runTitle = systemFieldInput.createRun(); runTitle.setText(dmpEntity.getLabel()); runTitle.setColor("116a78"); break; - case HTML_TEXT: + case HtmlText: XWPFRun runDescription = systemFieldInput.createRun(); runDescription.setText(dmpEntity.getDescription()); runDescription.setColor("116a78"); break; - case RESEARCHERS: + case Researchers: for(Researcher researcher: dmpEntity.getResearchers()){ XWPFRun runResearcher = systemFieldInput.createRun(); runResearcher.setText("• " + researcher.getLabel()); runResearcher.setColor("116a78"); } break; - case ORGANIZATIONS: + case Organizations: for(Organisation organisation: dmpEntity.getOrganisations()){ XWPFRun runOrganisation = systemFieldInput.createRun(); runOrganisation.setText("• " + organisation.getLabel()); runOrganisation.setColor("116a78"); } break; - case LANGUAGE: + case Language: XWPFRun runLanguage = systemFieldInput.createRun(); runLanguage.setText(objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class).get("language").toString()); runLanguage.setColor("116a78"); break; - case CONTACT: + case Contact: XWPFRun runContact = systemFieldInput.createRun(); runContact.setText(dmpEntity.getCreator().getName()); runContact.setColor("116a78"); break; - case FUNDER: + case Funder: if (dmpEntity.getGrant() != null && dmpEntity.getGrant().getFunder() != null) { XWPFRun runFunder = systemFieldInput.createRun(); runFunder.setText(dmpEntity.getGrant().getFunder().getLabel()); runFunder.setColor("116a78"); } break; - case GRANT: + case Grant: if (dmpEntity.getGrant() != null) { XWPFRun runGrant = systemFieldInput.createRun(); runGrant.setText(dmpEntity.getGrant().getLabel()); runGrant.setColor("116a78"); } break; - case PROJECT: + case Project: if (dmpEntity.getProject() != null ) { XWPFRun runProject = systemFieldInput.createRun(); runProject.setText(dmpEntity.getProject().getLabel()); runProject.setColor("116a78"); } break; - case LICENSE: + case License: Map extraProperties = objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class); if (extraProperties.containsKey("license")) { XWPFRun runLicense = systemFieldInput.createRun(); @@ -1488,7 +1488,7 @@ public class DataManagementPlanManager { runLicense.setColor("116a78"); } break; - case ACCESS_RIGHTS: + case AccessRights: Map extraPropertiesMap = objectMapper.readValue(dmpEntity.getExtraProperties(), HashMap.class); if (extraPropertiesMap.containsKey("visible")) { XWPFRun runAccessRights = systemFieldInput.createRun(); @@ -1499,8 +1499,8 @@ public class DataManagementPlanManager { } document.createParagraph(); } - else if(field.getCategory() == FieldCategory.EXTRA){ - ExtraField extraField = field.toExtraField(); + else if(field.getCategory() == DmpBlueprintFieldCategory.Extra){ + ExtraFieldEntity extraField = (ExtraFieldEntity)field; XWPFParagraph extraFieldParagraph = document.createParagraph(); extraFieldParagraph.setSpacingBetween(1.0); XWPFRun runExtraFieldLabel = extraFieldParagraph.createRun(); @@ -1523,7 +1523,7 @@ public class DataManagementPlanManager { if(!section.getDescriptionTemplates().isEmpty()){ wordBuilder.addParagraphContent("Section descriptions", document, ParagraphStyle.HEADER2, BigInteger.ZERO, 0); wordBuilder.addParagraphContent("Description Templates", document, ParagraphStyle.HEADER4, BigInteger.ZERO, 0); - for(eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate descriptionTemplate: section.getDescriptionTemplates()){ + for(DescriptionTemplateEntity descriptionTemplate: section.getDescriptionTemplates()){ XWPFParagraph templateParagraph = document.createParagraph(); XWPFRun runTemplateLabel = templateParagraph.createRun(); runTemplateLabel.setText("• " + descriptionTemplate.getLabel()); @@ -1740,14 +1740,14 @@ public class DataManagementPlanManager { dmpElement.appendChild(costs); } - DMPProfile dmpProfile = dmp.getProfile(); + DmpBlueprintEntity dmpBlueprint = dmp.getProfile(); Element dmpProfileElement = xmlDoc.createElement("dmpProfile"); Element dmpProfileName = xmlDoc.createElement("dmpProfileName"); - if (!(dmpProfile == null)) { - dmpProfileName.setTextContent(dmpProfile.getLabel()); + if (!(dmpBlueprint == null)) { + dmpProfileName.setTextContent(dmpBlueprint.getLabel()); dmpProfileElement.appendChild(dmpProfileName); Element dmpProfileId = xmlDoc.createElement("dmpProfileId"); - dmpProfileId.setTextContent(dmpProfile.getId().toString()); + dmpProfileId.setTextContent(dmpBlueprint.getId().toString()); dmpProfileElement.appendChild(dmpProfileId); // Element values = xmlDoc.createElement("values"); // values.setTextContent(dmpProfile.getDefinition()); @@ -1791,7 +1791,7 @@ public class DataManagementPlanManager { // Funder. Element funder = xmlDoc.createElement("funder"); - if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT) && this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.FUNDER)) { + if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), DmpBlueprintSystemFieldType.Grant) && this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), DmpBlueprintSystemFieldType.Funder)) { Element funderLabel = xmlDoc.createElement("label"); Element funderId = xmlDoc.createElement("id"); funderLabel.setTextContent(dmp.getGrant().getFunder().getLabel()); @@ -1809,7 +1809,7 @@ public class DataManagementPlanManager { dmpElement.appendChild(funder); // Grant. Element grant = xmlDoc.createElement("grant"); - if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.GRANT)) { + if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) { Element grantLabel = xmlDoc.createElement("label"); Element grantId = xmlDoc.createElement("id"); grantLabel.setTextContent(dmp.getGrant().getLabel()); @@ -1827,7 +1827,7 @@ public class DataManagementPlanManager { dmpElement.appendChild(grant); // Project. Element project = xmlDoc.createElement("project"); - if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), SystemFieldType.PROJECT)) { + if (this.dataManagementProfileManager.fieldInBlueprint(dmp.getProfile(), DmpBlueprintSystemFieldType.Project)) { Element projectId = xmlDoc.createElement("id"); Element projectLabel = xmlDoc.createElement("label"); Element projectDescription = xmlDoc.createElement("description"); @@ -1874,10 +1874,10 @@ public class DataManagementPlanManager { Element extraFields = xmlDoc.createElement("extraFields"); Map dmpProperties = new ObjectMapper().readValue(dmp.getProperties(), new TypeReference>() {}); - DataManagementPlanBlueprint blueprint = this.dataManagementProfileManager.getSingleBlueprint(dmp.getProfile().getId().toString()).getDefinition(); + DefinitionEntity blueprint = this.dataManagementProfileManager.getSingleBlueprint(dmp.getProfile().getId().toString()).getDefinition(); blueprint.getSections().forEach(section -> { section.getFields().forEach(fieldModel -> { - if (fieldModel.getCategory() == FieldCategory.EXTRA) { + if (fieldModel.getCategory() == DmpBlueprintFieldCategory.Extra) { Element extraField = xmlDoc.createElement("extraField"); Element extraFieldId = xmlDoc.createElement("id"); extraFieldId.setTextContent(fieldModel.getId().toString()); @@ -2090,7 +2090,7 @@ public class DataManagementPlanManager { } dm.setProperties(dmpPropertiesMap); - if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), SystemFieldType.FUNDER)) { + if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), DmpBlueprintSystemFieldType.Funder)) { eu.eudat.models.data.funder.Funder funder = new eu.eudat.models.data.funder.Funder(); FunderImportModels funderImport = dataManagementPlans.get(0).getFunderImportModels(); funder.setId(funderImport.getId()); @@ -2101,7 +2101,7 @@ public class DataManagementPlanManager { dm.setFunder(funderEditor); } - if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), SystemFieldType.GRANT)) { + if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), DmpBlueprintSystemFieldType.Grant)) { eu.eudat.models.data.grant.Grant grant = new eu.eudat.models.data.grant.Grant(); GrantImportModels grantImport = dataManagementPlans.get(0).getGrantImport(); grant.setId(grantImport.getId()); @@ -2114,7 +2114,7 @@ public class DataManagementPlanManager { dm.setGrant(grantEditor); } - if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), SystemFieldType.PROJECT)) { + if (this.dataManagementProfileManager.fieldInBlueprint(dmpProfileImportModel.getDmpProfileId().toString(), DmpBlueprintSystemFieldType.Project)) { eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project(); ProjectImportModels projectImport = dataManagementPlans.get(0).getProjectImportModels(); project.setId(projectImport.getId()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java index 42166d01b..62e6427a4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DataManagementProfileManager.java @@ -2,26 +2,29 @@ package eu.eudat.logic.managers; import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; +import eu.eudat.commons.enums.DmpBlueprintStatus; +import eu.eudat.commons.enums.IsActive; +import eu.eudat.commons.types.dmpblueprint.ExternalAutoCompleteEntity; +import eu.eudat.commons.types.dmpblueprint.FieldEntity; +import eu.eudat.commons.types.dmpblueprint.SectionEntity; +import eu.eudat.commons.types.dmpblueprint.SystemFieldEntity; import eu.eudat.data.dao.criteria.DataManagementPlanCriteria; import eu.eudat.data.dao.criteria.RequestItem; -import eu.eudat.data.old.DMPProfile; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.query.items.dmpblueprint.DataManagementPlanBlueprintTableRequest; -import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest; -import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest; import eu.eudat.exceptions.dmpblueprint.DmpBlueprintUsedException; import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; import eu.eudat.logic.utilities.documents.xml.dmpXml.ExportXmlBuilderDmpBlueprint; import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpBlueprint; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.*; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType; +import eu.eudat.commons.enums.DmpBlueprintFieldCategory; +import eu.eudat.commons.enums.DmpBlueprintSystemFieldType; import eu.eudat.models.data.helpermodels.Tuple; import eu.eudat.models.data.helpers.common.AutoCompleteLookupItem; import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel; -import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel; +//import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel; import eu.eudat.queryable.QueryableList; import eu.eudat.logic.services.ApiContext; import org.slf4j.Logger; @@ -64,29 +67,12 @@ public class DataManagementProfileManager { this.environment = environment; } - public DataTableData getPaged(DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest) throws Exception { - QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().getWithCriteria(dataManagementPlanProfileTableRequest.getCriteria()); - QueryableList pagedItems = PaginationManager.applyPaging(items, dataManagementPlanProfileTableRequest); - - DataTableData dataTable = new DataTableData(); - - CompletableFuture itemsFuture = pagedItems - .selectAsync(item -> new DataManagementPlanProfileListingModel().fromDataModel(item)).whenComplete((resultList, throwable) -> { - dataTable.setData(resultList); - }); - - CompletableFuture countFuture = items.countAsync().whenComplete((count, throwable) -> { - dataTable.setTotalCount(count); - }); - CompletableFuture.allOf(itemsFuture, countFuture).join(); - return dataTable; - } public DataTableData getPagedBlueprint(DataManagementPlanBlueprintTableRequest dataManagementPlanBlueprintTableRequest) throws Exception { - QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().getWithCriteriaBlueprint(dataManagementPlanBlueprintTableRequest.getCriteria()); - QueryableList pagedItems = PaginationManager.applyPaging(items, dataManagementPlanBlueprintTableRequest); + QueryableList items = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().getWithCriteriaBlueprint(dataManagementPlanBlueprintTableRequest.getCriteria()); + QueryableList pagedItems = PaginationManager.applyPaging(items, dataManagementPlanBlueprintTableRequest); DataTableData dataTable = new DataTableData<>(); @@ -97,32 +83,27 @@ public class DataManagementProfileManager { return dataTable; } - public DataManagementPlanProfileListingModel getSingle(String id) throws InstantiationException, IllegalAccessException, InvalidApplicationException { - DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id)); - DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = new DataManagementPlanProfileListingModel(); - dataManagementPlanProfileListingModel.fromDataModel(dmpProfile); - return dataManagementPlanProfileListingModel; - } + public DataManagementPlanBlueprintListingModel getSingleBlueprint(String id) throws InvalidApplicationException { - DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id)); + DmpBlueprintEntity dmpBlueprint = databaseRepository.getDmpProfileDao().find(UUID.fromString(id)); DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel = new DataManagementPlanBlueprintListingModel(); - dataManagementPlanBlueprintListingModel.fromDataModel(dmpProfile); + dataManagementPlanBlueprintListingModel.fromDataModel(dmpBlueprint); return dataManagementPlanBlueprintListingModel; } - public boolean fieldInBlueprint(String id, SystemFieldType type) throws InvalidApplicationException { - DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id)); - return this.fieldInBlueprint(dmpProfile, type); + public boolean fieldInBlueprint(String id, DmpBlueprintSystemFieldType type) throws InvalidApplicationException { + DmpBlueprintEntity dmpBlueprint = databaseRepository.getDmpProfileDao().find(UUID.fromString(id)); + return this.fieldInBlueprint(dmpBlueprint, type); } - public boolean fieldInBlueprint(DMPProfile dmpProfile, SystemFieldType type) { + public boolean fieldInBlueprint(DmpBlueprintEntity dmpProfile, DmpBlueprintSystemFieldType type) { DataManagementPlanBlueprintListingModel dmpBlueprint = new DataManagementPlanBlueprintListingModel(); dmpBlueprint.fromDataModel(dmpProfile); - for(Section section: dmpBlueprint.getDefinition().getSections()){ - for(FieldModel field: section.getFields()){ - if(field.getCategory().equals(FieldCategory.SYSTEM)){ - SystemField systemField = field.toSystemField(); + for(SectionEntity section: dmpBlueprint.getDefinition().getSections()){ + for(FieldEntity field: section.getFields()){ + if(field.getCategory().equals(DmpBlueprintFieldCategory.System)){ + SystemFieldEntity systemField = (SystemFieldEntity)field; if(systemField.getType().equals(type)){ return true; } @@ -132,29 +113,18 @@ public class DataManagementProfileManager { return false; } - public List getWithCriteria(DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException, InvalidApplicationException { - QueryableList items = databaseRepository.getDmpProfileDao().getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria()); - List datamanagementPlans = items.select(item -> new DataManagementPlanProfileListingModel().fromDataModel(item)); - return datamanagementPlans; - } - - public void createOrUpdate(DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel) throws Exception { - DMPProfile dmpProfile = dataManagementPlanProfileListingModel.toDataModel(); - apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile); - } - public void createOrUpdateBlueprint(DataManagementPlanBlueprintListingModel dataManagementPlanBlueprintListingModel) throws Exception { - DMPProfile dmpProfile = dataManagementPlanBlueprintListingModel.toDataModel(); - apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile); + DmpBlueprintEntity dmpBlueprint = dataManagementPlanBlueprintListingModel.toDataModel(); + apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpBlueprint); } public void inactivate(String id) throws InvalidApplicationException { - DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id)); + DmpBlueprintEntity dmpBlueprint = databaseRepository.getDmpProfileDao().find(UUID.fromString(id)); DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria(); - dataManagementPlanCriteria.setProfile(dmpProfile); - if (dmpProfile.getStatus() == DMPProfile.Status.SAVED.getValue() || databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).count() == 0) { - dmpProfile.setStatus(DMPProfile.Status.DELETED.getValue()); - databaseRepository.getDmpProfileDao().createOrUpdate(dmpProfile); + dataManagementPlanCriteria.setProfile(dmpBlueprint); + if (DmpBlueprintStatus.Draft.equals(dmpBlueprint.getStatus()) || databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).count() == 0) { + dmpBlueprint.setIsActive(IsActive.Inactive); + databaseRepository.getDmpProfileDao().createOrUpdate(dmpBlueprint); } else { throw new DmpBlueprintUsedException("This blueprint can not deleted, because DMPs are associated with it"); } @@ -208,29 +178,7 @@ public class DataManagementProfileManager { fos.close(); return convFile; } - - public List> getExternalAutocomplete(RequestItem lookupItem) throws XPathExpressionException, InvalidApplicationException { - DMPProfile dmpProfile = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().find(UUID.fromString(lookupItem.getCriteria().getProfileID())); - Field field = this.queryForField(dmpProfile.getDefinition(), lookupItem.getCriteria().getFieldID()); - DmpProfileExternalAutoComplete data = field.getExternalAutocomplete(); - return this.externalAutocompleteRequest(data, lookupItem.getCriteria().getLike()); - } - - private Field queryForField(String xml, String fieldId) throws XPathExpressionException { - Field field = new Field(); - Document document = XmlBuilder.fromXml(xml); - XPathFactory xpathFactory = XPathFactory.newInstance(); - XPath xpath = xpathFactory.newXPath(); - XPathExpression expr = xpath.compile("//field[@id='" + fieldId + "']"); - Element name = (Element) expr.evaluate(document, XPathConstants.NODE); - field.fromXml(name); - return field; - } - - private List> externalAutocompleteRequest(DmpProfileExternalAutoComplete data, String like) { - return externalAutocompleteRequest(data.getUrl(), data.getOptionsRoot(), data.getLabel(), data.getValue(), like); - } - + public static List> externalAutocompleteRequest(String url, String optionsRoot, String label, String value, String like) { List> result = new LinkedList<>(); RestTemplate restTemplate = new RestTemplate(); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java index 5ba065e23..703d8be11 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetProfileManager.java @@ -16,7 +16,7 @@ import eu.eudat.logic.proxy.config.entities.GeneralUrls; import eu.eudat.logic.proxy.fetching.RemoteFetcher; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.logic.utilities.documents.helpers.FileEnvelope; import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile; import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ImportXmlBuilderDatasetProfile; @@ -30,7 +30,6 @@ import eu.eudat.models.data.listingmodels.UserInfoListingModel; import eu.eudat.models.data.mail.SimpleMail; import eu.eudat.queryable.QueryableList; import eu.eudat.service.DescriptionTemplateTypeService; -import eu.eudat.types.Authorities; import eu.eudat.types.MetricNames; import gr.cite.commons.web.authz.service.AuthorizationService; import org.slf4j.Logger; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UserManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UserManager.java index 4109ec1cc..4a407abbc 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UserManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/UserManager.java @@ -14,7 +14,7 @@ import eu.eudat.data.query.items.table.userinfo.UserInfoTableRequestItem; import eu.eudat.logic.builders.entity.UserRoleBuilder; import eu.eudat.logic.builders.model.models.DataTableDataBuilder; import eu.eudat.logic.services.ApiContext; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.models.HintedModelFactory; import eu.eudat.models.data.dmp.DataManagementPlan; import eu.eudat.models.data.helpers.common.DataTableData; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java b/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java index 9b1828e4e..dbff82dd0 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/fetching/RemoteFetcher.java @@ -76,8 +76,6 @@ public class RemoteFetcher { case Funder: return configLoader.getExternalUrls().getFunders(); case Project: return configLoader.getExternalUrls().getProjects(); case Researcher: return configLoader.getExternalUrls().getResearchers(); - case Validators: return configLoader.getExternalUrls().getValidations(); -// case Prefillings: return configLoader.getExternalUrls().getPrefillings(); default: throw new IllegalArgumentException("Type not found" + externalType); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/security/repositorydeposit/mapper/DMPToDepositMapper.java b/dmp-backend/web/src/main/java/eu/eudat/logic/security/repositorydeposit/mapper/DMPToDepositMapper.java index ccb614755..e26ffbfdf 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/security/repositorydeposit/mapper/DMPToDepositMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/security/repositorydeposit/mapper/DMPToDepositMapper.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; import eu.eudat.data.old.*; import eu.eudat.depositinterface.models.*; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import jakarta.transaction.Transactional; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/ExportXmlBuilder.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/ExportXmlBuilder.java index ae8c43490..c34504d31 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/ExportXmlBuilder.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/ExportXmlBuilder.java @@ -1,17 +1,14 @@ package eu.eudat.logic.utilities.documents.xml; import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.exc.MismatchedInputException; import eu.eudat.logic.services.forms.VisibilityRuleService; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.models.data.components.commons.datafield.ExternalDatasetsData; import eu.eudat.models.data.user.components.datasetprofile.Field; import eu.eudat.models.data.user.components.datasetprofile.FieldSet; import eu.eudat.models.data.user.components.datasetprofile.Section; import eu.eudat.models.data.user.composite.DatasetProfilePage; import eu.eudat.models.data.user.composite.PagedDatasetProfile; -import org.json.JSONArray; -import org.json.JSONException; import org.springframework.core.env.Environment; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/datasetProfileXml/ExportXmlBuilderDatasetProfile.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/datasetProfileXml/ExportXmlBuilderDatasetProfile.java index a64fd0de5..b826f6322 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/datasetProfileXml/ExportXmlBuilderDatasetProfile.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/datasetProfileXml/ExportXmlBuilderDatasetProfile.java @@ -7,7 +7,7 @@ import eu.eudat.models.data.components.commons.datafield.*; import eu.eudat.models.data.user.components.datasetprofile.Field; import eu.eudat.models.data.user.components.datasetprofile.FieldSet; import eu.eudat.models.data.user.components.datasetprofile.Section; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import org.springframework.core.env.Environment; import org.w3c.dom.Document; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ExportXmlBuilderDmpBlueprint.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ExportXmlBuilderDmpBlueprint.java index 478a3127a..f3b9b3da1 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ExportXmlBuilderDmpBlueprint.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/ExportXmlBuilderDmpBlueprint.java @@ -1,9 +1,9 @@ package eu.eudat.logic.utilities.documents.xml.dmpXml; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.dmpblueprint.DefinitionEntity; +import eu.eudat.commons.types.xml.XmlBuilder; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section; +import eu.eudat.commons.types.dmpblueprint.SectionEntity; import eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel; import org.springframework.core.env.Environment; import org.w3c.dom.Document; @@ -35,9 +35,9 @@ public class ExportXmlBuilderDmpBlueprint { return xmlFile; } - public Element createDefinition(DataManagementPlanBlueprint dmpDefinition, Document doc) { + public Element createDefinition(DefinitionEntity dmpDefinition, Document doc) { Element sections = doc.createElement("sections"); - for (Section section : dmpDefinition.getSections()) { + for (SectionEntity section : dmpDefinition.getSections()) { sections.appendChild(section.toXml(doc)); } return sections; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DescriptionTemplate.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DescriptionTemplate.java index 4566a8c03..c3ea6a263 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DescriptionTemplate.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DescriptionTemplate.java @@ -1,7 +1,6 @@ package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; - +import eu.eudat.commons.types.dmpblueprint.DescriptionTemplateEntity; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlRootElement; import java.util.UUID; @@ -60,8 +59,8 @@ public class DescriptionTemplate { this.maxMultiplicity = maxMultiplicity; } - public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate toDmpBlueprintCompositeModel() { - eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate descriptionTemplate = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DescriptionTemplate(); + public DescriptionTemplateEntity toDmpBlueprintCompositeModel() { + DescriptionTemplateEntity descriptionTemplate = new DescriptionTemplateEntity(); descriptionTemplate.setId(UUID.fromString(this.id)); descriptionTemplate.setDescriptionTemplateId(UUID.fromString(this.descriptionTemplateId)); descriptionTemplate.setLabel(this.label); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprint.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprint.java index 3de7cbe6a..6af044d5d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprint.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprint.java @@ -1,9 +1,11 @@ package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; -import eu.eudat.data.old.DMPProfile; - +import eu.eudat.commons.enums.DmpBlueprintStatus; +import eu.eudat.data.DmpBlueprintEntity; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; + +import java.time.Instant; import java.util.Date; @XmlRootElement(name = "root") @@ -23,9 +25,9 @@ public class DmpBlueprint { public eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel toDmpProfileCompositeModel(String label) { eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel dmpProfileModel = new eu.eudat.models.data.listingmodels.DataManagementPlanBlueprintListingModel(); dmpProfileModel.setLabel(label); - dmpProfileModel.setStatus(DMPProfile.Status.SAVED.getValue()); - dmpProfileModel.setCreated(new Date()); - dmpProfileModel.setModified(new Date()); + dmpProfileModel.setStatus(DmpBlueprintStatus.Draft); + dmpProfileModel.setCreated(Instant.now()); + dmpProfileModel.setModified(Instant.now()); if (this.dmpBlueprintDefinition != null) { dmpProfileModel.setDefinition(this.dmpBlueprintDefinition.toDmpBlueprintCompositeModel()); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprintDefinition.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprintDefinition.java index 21f73e288..94199f733 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprintDefinition.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/DmpBlueprintDefinition.java @@ -1,5 +1,7 @@ package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; +import eu.eudat.commons.types.dmpblueprint.DefinitionEntity; +import eu.eudat.commons.types.dmpblueprint.SectionEntity; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; import java.util.LinkedList; @@ -19,9 +21,9 @@ public class DmpBlueprintDefinition { } - public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint toDmpBlueprintCompositeModel() { - eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint dmpBlueprint = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint(); - List dmpBlueprintSections = new LinkedList<>(); + public DefinitionEntity toDmpBlueprintCompositeModel() { + DefinitionEntity dmpBlueprint = new DefinitionEntity(); + List dmpBlueprintSections = new LinkedList<>(); if (this.sections != null && this.sections.getSections() != null) { for (Section section : this.sections.getSections()) { dmpBlueprintSections.add(section.toDmpBlueprintCompositeModel()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/ExtraField.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/ExtraField.java index d162dc343..2532f52af 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/ExtraField.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/ExtraField.java @@ -1,7 +1,10 @@ package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; +import eu.eudat.commons.enums.DmpBlueprintExtraFieldType; +import eu.eudat.commons.enums.DmpBlueprintFieldCategory; +import eu.eudat.commons.types.dmpblueprint.ExtraFieldEntity; +import eu.eudat.commons.types.dmpblueprint.FieldEntity; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlRootElement; import java.util.UUID; @@ -10,7 +13,7 @@ import java.util.UUID; public class ExtraField { private String id; - private int type; + private short type; private String label; private String placeholder; private String description; @@ -27,11 +30,11 @@ public class ExtraField { } @XmlAttribute(name = "type") - public int getType() { + public short getType() { return type; } - public void setType(int type) { + public void setType(short type) { this.type = type; } @@ -80,11 +83,11 @@ public class ExtraField { this.required = required; } - public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel toDmpBlueprintCompositeModel() { - eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel systemField = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel(); + public FieldEntity toDmpBlueprintCompositeModel() { + ExtraFieldEntity systemField = new ExtraFieldEntity(); systemField.setId(UUID.fromString(this.id)); - systemField.setCategory(FieldCategory.EXTRA); - systemField.setType(this.type); + systemField.setCategory(DmpBlueprintFieldCategory.Extra); + systemField.setType(DmpBlueprintExtraFieldType.of(this.type)); systemField.setLabel(this.label); systemField.setPlaceholder(this.placeholder); systemField.setDescription(this.description); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/Section.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/Section.java index ff9d989d7..b74c1e4e3 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/Section.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/Section.java @@ -1,5 +1,8 @@ package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; +import eu.eudat.commons.types.dmpblueprint.DescriptionTemplateEntity; +import eu.eudat.commons.types.dmpblueprint.FieldEntity; +import eu.eudat.commons.types.dmpblueprint.SectionEntity; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; @@ -91,14 +94,14 @@ public class Section { this.descriptionTemplates = descriptionTemplates; } - public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section toDmpBlueprintCompositeModel() { - eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section section = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Section(); + public SectionEntity toDmpBlueprintCompositeModel() { + SectionEntity section = new SectionEntity(); section.setId(UUID.fromString(this.id)); section.setLabel(this.label); section.setDescription(this.description); section.setOrdinal(this.ordinal); section.setHasTemplates(this.hasTemplates); - List dmpBlueprintFieldModels = new LinkedList<>(); + List dmpBlueprintFieldModels = new LinkedList<>(); if (this.systemFields != null && this.systemFields.getSystemFields() != null) { for (SystemField systemField : this.systemFields.getSystemFields()) { dmpBlueprintFieldModels.add(systemField.toDmpBlueprintCompositeModel()); @@ -110,7 +113,7 @@ public class Section { } } section.setFields(dmpBlueprintFieldModels); - List dmpBlueprintDescriptionTemplates = new LinkedList<>(); + List dmpBlueprintDescriptionTemplates = new LinkedList<>(); if (this.descriptionTemplates != null && this.descriptionTemplates.getDescriptionTemplates() != null) { for (DescriptionTemplate descriptionTemplate : this.descriptionTemplates.getDescriptionTemplates()) { dmpBlueprintDescriptionTemplates.add(descriptionTemplate.toDmpBlueprintCompositeModel()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/SystemField.java b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/SystemField.java index 4e7df5fe3..b5e7ca4eb 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/SystemField.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/utilities/documents/xml/dmpXml/dmpBlueprintModel/SystemField.java @@ -1,7 +1,10 @@ package eu.eudat.logic.utilities.documents.xml.dmpXml.dmpBlueprintModel; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; +import eu.eudat.commons.enums.DmpBlueprintFieldCategory; +import eu.eudat.commons.enums.DmpBlueprintSystemFieldType; +import eu.eudat.commons.types.dmpblueprint.FieldEntity; +import eu.eudat.commons.types.dmpblueprint.SystemFieldEntity; import jakarta.xml.bind.annotation.XmlAttribute; import jakarta.xml.bind.annotation.XmlRootElement; import java.util.UUID; @@ -10,7 +13,7 @@ import java.util.UUID; public class SystemField { private String id; - private int type; + private short type; private String label; private String placeholder; private String description; @@ -27,11 +30,11 @@ public class SystemField { } @XmlAttribute(name = "type") - public int getType() { + public short getType() { return type; } - public void setType(int type) { + public void setType(short type) { this.type = type; } @@ -80,11 +83,11 @@ public class SystemField { this.required = required; } - public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel toDmpBlueprintCompositeModel() { - eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel systemField = new eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.FieldModel(); + public FieldEntity toDmpBlueprintCompositeModel() { + SystemFieldEntity systemField = new SystemFieldEntity(); systemField.setId(UUID.fromString(this.id)); - systemField.setCategory(FieldCategory.SYSTEM); - systemField.setType(this.type); + systemField.setCategory(DmpBlueprintFieldCategory.System); + systemField.setType(DmpBlueprintSystemFieldType.of(this.type)); systemField.setLabel(this.label); systemField.setPlaceholder(this.placeholder); systemField.setDescription(this.description); diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/Rule.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/Rule.java index 2549a015b..f41aa62eb 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/Rule.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/Rule.java @@ -1,7 +1,7 @@ package eu.eudat.models.data.components.commons; import eu.eudat.models.data.entities.xmlmodels.modeldefinition.DatabaseModelDefinition; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/Visibility.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/Visibility.java index 0dd6f60e4..5e627f302 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/Visibility.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/Visibility.java @@ -1,6 +1,6 @@ package eu.eudat.models.data.components.commons; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java index d7e1b1371..4d6e2cb3f 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/ComboBoxData.java @@ -1,6 +1,6 @@ package eu.eudat.models.data.components.commons.datafield; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/FieldData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/FieldData.java index a992658bd..eafde3782 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/FieldData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/FieldData.java @@ -1,6 +1,6 @@ package eu.eudat.models.data.components.commons.datafield; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/RadioBoxData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/RadioBoxData.java index 5dd1d7166..f5389510b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/RadioBoxData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/RadioBoxData.java @@ -1,6 +1,6 @@ package eu.eudat.models.data.components.commons.datafield; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/UploadData.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/UploadData.java index a43153256..f7821dc3a 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/UploadData.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/components/commons/datafield/UploadData.java @@ -1,6 +1,6 @@ package eu.eudat.models.data.components.commons.datafield; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/AssociatedProfile.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/AssociatedProfile.java index 0fc98b443..7819a03bd 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/AssociatedProfile.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/AssociatedProfile.java @@ -1,7 +1,7 @@ package eu.eudat.models.data.dmp; import eu.eudat.data.old.DescriptionTemplate; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java index e2913fdf3..b3382f65d 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java @@ -2,6 +2,7 @@ package eu.eudat.models.data.dmp; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.old.*; import eu.eudat.models.DataModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; @@ -318,9 +319,9 @@ public class DataManagementPlan implements DataModel { public DMP toDataModel() throws Exception { DMP dataManagementPlanEntity = new DMP(); if (this.profile != null) { - DMPProfile dmpProfile = new DMPProfile(); - dmpProfile.setId(this.profile.getId()); - dataManagementPlanEntity.setProfile(dmpProfile); + DmpBlueprintEntity dmpBlueprint = new DmpBlueprintEntity(); + dmpBlueprint.setId(this.profile.getId()); + dataManagementPlanEntity.setProfile(dmpBlueprint); } dataManagementPlanEntity.setId(this.id); if (this.organisations != null && !this.organisations.isEmpty()) diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java index c7e6fae0f..66bea5320 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanEditorModel.java @@ -2,6 +2,7 @@ package eu.eudat.models.data.dmp; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; +import eu.eudat.data.DmpBlueprintEntity; import eu.eudat.data.old.*; import eu.eudat.models.DataModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; @@ -286,9 +287,9 @@ public class DataManagementPlanEditorModel implements DataModel { - - private List
sections; - - public List
getSections() { - return sections; - } - public void setSections(List
sections) { - this.sections = sections; - } - - @Override - public Element toXml(Document doc) { - Element root = doc.createElement("root"); - Element sections = doc.createElement("sections"); - for (Section section : this.sections) { - sections.appendChild(section.toXml(doc)); - } - root.appendChild(sections); - return root; - } - - @Override - public DataManagementPlanBlueprint fromXml(Element item) { - this.sections = new LinkedList<>(); - Element sections = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "sections"); - if (sections != null) { - NodeList sectionElements = sections.getChildNodes(); - for (int temp = 0; temp < sectionElements.getLength(); temp++) { - Node sectionElement = sectionElements.item(temp); - if (sectionElement.getNodeType() == Node.ELEMENT_NODE) { - this.sections.add(new Section().fromXml((Element) sectionElement)); - } - } - } - return this; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/DataManagementPlanProfile.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/DataManagementPlanProfile.java deleted file mode 100644 index 6fb10e15c..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/DataManagementPlanProfile.java +++ /dev/null @@ -1,54 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition; - -import eu.eudat.logic.utilities.builders.XmlBuilder; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import java.util.LinkedList; -import java.util.List; - -/** - * Created by ikalyvas on 3/21/2018. - */ -public class DataManagementPlanProfile implements XmlSerializable { - - private List fields; - - public List getFields() { - return fields; - } - - public void setFields(List fields) { - this.fields = fields; - } - - @Override - public Element toXml(Document doc) { - Element root = doc.createElement("root"); - Element fields = doc.createElement("fields"); - for (Field field : this.fields) { - fields.appendChild(field.toXml(doc)); - } - root.appendChild(fields); - return root; - } - - @Override - public DataManagementPlanProfile fromXml(Element item) { - this.fields = new LinkedList(); - Element fields = (Element) XmlBuilder.getNodeFromListByTagName(item.getChildNodes(), "fields"); - if (fields != null) { - NodeList fieldElements = fields.getChildNodes(); - for (int temp = 0; temp < fieldElements.getLength(); temp++) { - Node fieldElement = fieldElements.item(temp); - if (fieldElement.getNodeType() == Node.ELEMENT_NODE) { - this.fields.add(new Field().fromXml((Element) fieldElement)); - } - } - } - return this; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/ExtraField.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/ExtraField.java deleted file mode 100644 index f3ab20c59..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/ExtraField.java +++ /dev/null @@ -1,93 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition; - -import eu.eudat.logic.utilities.interfaces.XmlSerializable; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.ExtraFieldType; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import java.util.UUID; - -public class ExtraField implements XmlSerializable { - - private UUID id; - private String label; - private String description; - private String placeholder; - private ExtraFieldType type; - private Boolean required; - private Integer ordinal; - - 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 String getPlaceholder() { - return placeholder; - } - public void setPlaceholder(String placeholder) { - this.placeholder = placeholder; - } - - public ExtraFieldType getType() { - return type; - } - public void setType(ExtraFieldType type) { - this.type = type; - } - - public Boolean getRequired() { - return required; - } - public void setRequired(Boolean required) { - this.required = required; - } - - public Integer getOrdinal() { - return ordinal; - } - public void setOrdinal(Integer ordinal) { - this.ordinal = ordinal; - } - - @Override - public Element toXml(Document doc) { - Element rootElement = doc.createElement("extraField"); - rootElement.setAttribute("id", this.getId().toString()); - rootElement.setAttribute("label", this.label); - rootElement.setAttribute("description", this.description); - rootElement.setAttribute("placeholder", this.placeholder); - rootElement.setAttribute("type", String.valueOf(this.type.getValue())); - rootElement.setAttribute("required", String.valueOf(this.required)); - rootElement.setAttribute("ordinal", String.valueOf(this.ordinal)); - return rootElement; - } - - @Override - public ExtraField fromXml(Element item) { - this.id = UUID.fromString(item.getAttribute("id")); - this.label = item.getAttribute("label"); - this.description = item.getAttribute("description"); - this.placeholder = item.getAttribute("placeholder"); - this.type = ExtraFieldType.fromInteger(Integer.parseInt(item.getAttribute("type"))); - this.required = Boolean.parseBoolean(item.getAttribute("required")); - this.ordinal = Integer.valueOf(item.getAttribute("ordinal")); - return this; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/Field.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/Field.java deleted file mode 100644 index 0790e014e..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/Field.java +++ /dev/null @@ -1,101 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition; - -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileFieldDataType; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.DMPProfileType; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import java.util.UUID; - -/** - * Created by ikalyvas on 3/21/2018. - */ -public class Field implements XmlSerializable { - - private UUID id; - private DMPProfileType type; - private DMPProfileFieldDataType dataType; - private Boolean required; - private String label; - private Object value; - private DmpProfileExternalAutoComplete externalAutocomplete; - - public UUID getId() { - if (this.id == null) this.id = UUID.randomUUID(); - return id; - } - public void setId(UUID id) { - this.id = id; - } - - public Integer getType() { - return type.getValue(); - } - public void setType(DMPProfileType type) { - this.type = type; - } - - public Integer getDataType() { - return dataType.getValue(); - } - public void setDataType(DMPProfileFieldDataType dataType) { - this.dataType = dataType; - } - - public Boolean getRequired() { - return required; - } - public void setRequired(Boolean required) { - this.required = required; - } - - public String getLabel() { - return label; - } - public void setLabel(String label) { - this.label = label; - } - - public Object getValue() { - return value; - } - public void setValue(Object value) { - this.value = value; - } - - public DmpProfileExternalAutoComplete getExternalAutocomplete() { - return externalAutocomplete; - } - public void setExternalAutocomplete(DmpProfileExternalAutoComplete externalAutocomplete) { - this.externalAutocomplete = externalAutocomplete; - } - - @Override - public Element toXml(Document doc) { - Element rootElement = doc.createElement("field"); - rootElement.setAttribute("id", this.getId().toString()); - rootElement.setAttribute("type", this.type.getValue().toString()); - rootElement.setAttribute("datatype", "" + this.dataType.getValue().toString()); - rootElement.setAttribute("required", this.required.toString()); - rootElement.setAttribute("label", this.label); - if (this.externalAutocomplete != null) - rootElement.appendChild(this.externalAutocomplete.toXml(doc)); - - return rootElement; - } - - @Override - public eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.Field fromXml(Element item) { - this.id = UUID.fromString(item.getAttribute("id")); - this.label = item.getAttribute("label"); - this.dataType = DMPProfileFieldDataType.fromInteger(Integer.parseInt(item.getAttribute("datatype"))); - this.required = Boolean.valueOf(item.getAttribute("required")); - this.type = DMPProfileType.fromInteger(Integer.parseInt(item.getAttribute("type"))); - Element optionElement = (Element) item.getElementsByTagName("externalAutocomplete").item(0); - if (optionElement != null) { - this.externalAutocomplete = new DmpProfileExternalAutoComplete().fromXml(optionElement); - } - return this; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/FieldModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/FieldModel.java deleted file mode 100644 index b311d005f..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/FieldModel.java +++ /dev/null @@ -1,127 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition; - -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.ExtraFieldType; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.FieldCategory; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType; - -import java.util.UUID; - -public class FieldModel { - - private UUID id; - private FieldCategory category; - private Integer type; - private String label; - private String placeholder; - private String description; - private Integer ordinal; - private boolean required; - - public UUID getId() { - return id; - } - public void setId(UUID id) { - this.id = id; - } - - public FieldCategory getCategory() { - return category; - } - public void setCategory(FieldCategory category) { - this.category = category; - } - - public Integer getType() { - return type; - } - public void setType(Integer type) { - this.type = type; - } - - 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 isRequired() { - return required; - } - public void setRequired(boolean required) { - this.required = required; - } - - public SystemField toSystemField(){ - SystemField systemField = new SystemField(); - if (this.category == FieldCategory.SYSTEM) { - systemField.setId(this.id); - systemField.setType(SystemFieldType.fromInteger(this.type)); - systemField.setLabel(this.label); - systemField.setPlaceholder(this.placeholder); - systemField.setDescription(this.description); - systemField.setOrdinal(this.ordinal); - systemField.setRequired(this.required); - } - return systemField; - } - - public FieldModel fromSystemField(SystemField systemField){ - this.setId(systemField.getId()); - this.setCategory(FieldCategory.SYSTEM); - this.setType(systemField.getType().getType()); - this.setLabel(systemField.getLabel()); - this.setPlaceholder(systemField.getPlaceholder()); - this.setDescription(systemField.getDescription()); - this.setOrdinal(systemField.getOrdinal()); - this.setRequired(systemField.isRequired()); - return this; - } - - public ExtraField toExtraField(){ - ExtraField extraField = new ExtraField(); - if (this.category == FieldCategory.EXTRA) { - extraField.setId(this.id); - extraField.setType(ExtraFieldType.fromInteger(this.type)); - extraField.setLabel(this.label); - extraField.setPlaceholder(this.placeholder); - extraField.setDescription(this.description); - extraField.setOrdinal(this.ordinal); - extraField.setRequired(this.required); - } - return extraField; - } - - public FieldModel fromExtraField(ExtraField extraField){ - this.setId(extraField.getId()); - this.setCategory(FieldCategory.EXTRA); - this.setType(extraField.getType().getValue()); - this.setLabel(extraField.getLabel()); - this.setPlaceholder(extraField.getPlaceholder()); - this.setDescription(extraField.getDescription()); - this.setOrdinal(extraField.getOrdinal()); - this.setRequired(extraField.getRequired()); - return this; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/FieldValues.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/FieldValues.java deleted file mode 100644 index 28cef102f..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/FieldValues.java +++ /dev/null @@ -1,25 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition; - -/** - * Created by ikalyvas on 3/22/2018. - */ -public class FieldValues { - private String id; - private String value; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/SystemField.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/SystemField.java deleted file mode 100644 index 419a9ccd9..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/SystemField.java +++ /dev/null @@ -1,94 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition; - -import eu.eudat.logic.utilities.interfaces.XmlSerializable; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types.SystemFieldType; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -import java.util.UUID; - -public class SystemField implements XmlSerializable { - - private UUID id; - private SystemFieldType type; - private String label; - private String placeholder; - private String description; - private boolean required; - private Integer ordinal; - - public UUID getId() { - return id; - } - public void setId(UUID id) { - this.id = id; - } - - public SystemFieldType getType() { - return type; - } - public void setType(SystemFieldType type) { - this.type = type; - } - - 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 boolean isRequired() { - return required; - } - public void setRequired(boolean required) { - this.required = required; - } - - public Integer getOrdinal() { - return ordinal; - } - public void setOrdinal(Integer ordinal) { - this.ordinal = ordinal; - } - - - @Override - public Element toXml(Document doc) { - Element rootElement = doc.createElement("systemField"); - rootElement.setAttribute("id", this.getId().toString()); - rootElement.setAttribute("type", String.valueOf(this.type.getType())); - rootElement.setAttribute("label", this.label); - rootElement.setAttribute("placeholder", this.placeholder); - rootElement.setAttribute("description", this.description); - rootElement.setAttribute("required", String.valueOf(this.required)); - rootElement.setAttribute("ordinal", String.valueOf(this.ordinal)); - return rootElement; - } - - @Override - public SystemField fromXml(Element item) { - this.id = UUID.fromString(item.getAttribute("id")); - this.type = SystemFieldType.fromInteger(Integer.parseInt(item.getAttribute("type"))); - this.label = item.getAttribute("label"); - this.placeholder = item.getAttribute("placeholder"); - this.description = item.getAttribute("description"); - this.required = Boolean.parseBoolean(item.getAttribute("required")); - this.ordinal = Integer.valueOf(item.getAttribute("ordinal")); - return this; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/DMPProfileFieldDataType.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/DMPProfileFieldDataType.java deleted file mode 100644 index bf692f4ce..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/DMPProfileFieldDataType.java +++ /dev/null @@ -1,33 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types; - -/** - * Created by ikalyvas on 3/21/2018. - */ -public enum DMPProfileFieldDataType { - DATE(0), NUMBER(1), TEXT(2), EXTERNAL_AUTOCOMPLETE(3); - - private Integer value; - - private DMPProfileFieldDataType(Integer value) { - this.value = value; - } - - public Integer getValue() { - return value; - } - - public static DMPProfileFieldDataType fromInteger(Integer value) { - switch (value) { - case 0: - return DATE; - case 1: - return NUMBER; - case 2: - return TEXT; - case 3: - return EXTERNAL_AUTOCOMPLETE; - default: - throw new RuntimeException("Unsupported DMPProfileFieldData Type"); - } - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/DMPProfileType.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/DMPProfileType.java deleted file mode 100644 index dd5f8c5e0..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/DMPProfileType.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types; - -/** - * Created by ikalyvas on 3/21/2018. - */ -public enum DMPProfileType { - INPUT(0); - - private Integer value; - - DMPProfileType(Integer value) { - this.value = value; - } - - public Integer getValue() { - return value; - } - - public static DMPProfileType fromInteger(Integer value) { - switch (value) { - case 0: - return INPUT; - default: - throw new RuntimeException("Unsupported DMPProfile Type"); - } - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/ExtraFieldType.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/ExtraFieldType.java deleted file mode 100644 index 6aa7fc24e..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/ExtraFieldType.java +++ /dev/null @@ -1,30 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types; - -public enum ExtraFieldType { - TEXT(0), RICH_TEXT(1), DATE(2), NUMBER(3); - - private Integer value; - - private ExtraFieldType(Integer value) { - this.value = value; - } - - public Integer getValue() { - return value; - } - - public static ExtraFieldType fromInteger(Integer value) { - switch (value) { - case 0: - return TEXT; - case 1: - return RICH_TEXT; - case 2: - return DATE; - case 3: - return NUMBER; - default: - throw new RuntimeException("Unsupported ExtraFieldType Type"); - } - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/FieldCategory.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/FieldCategory.java deleted file mode 100644 index cec77366d..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/FieldCategory.java +++ /dev/null @@ -1,27 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types; - -public enum FieldCategory { - SYSTEM(0), - EXTRA(1); - - private Integer value; - - private FieldCategory(Integer value) { - this.value = value; - } - - public Integer getValue() { - return value; - } - - public static FieldCategory fromInteger(Integer value) { - switch (value) { - case 0: - return SYSTEM; - case 1: - return EXTRA; - default: - throw new RuntimeException("Unsupported FieldCategory Type"); - } - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/SystemFieldType.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/SystemFieldType.java deleted file mode 100644 index 306c999e8..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/entities/xmlmodels/dmpprofiledefinition/types/SystemFieldType.java +++ /dev/null @@ -1,55 +0,0 @@ -package eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.types; - -public enum SystemFieldType { - - TEXT(0), - HTML_TEXT(1), - RESEARCHERS(2), - ORGANIZATIONS(3), - LANGUAGE(4), - CONTACT(5), - FUNDER(6), - GRANT(7), - PROJECT(8), - LICENSE(9), - ACCESS_RIGHTS(10); - - private int type; - - SystemFieldType(int type) { - this.type = type; - } - - public int getType() { - return type; - } - - public static SystemFieldType fromInteger(int type) { - switch (type) { - case 0: - return TEXT; - case 1: - return HTML_TEXT; - case 2: - return RESEARCHERS; - case 3: - return ORGANIZATIONS; - case 4: - return LANGUAGE; - case 5: - return CONTACT; - case 6: - return FUNDER; - case 7: - return GRANT; - case 8: - return PROJECT; - case 9: - return LICENSE; - case 10: - return ACCESS_RIGHTS; - default: - throw new RuntimeException("Unsupported System Section Type"); - } - } -} \ No newline at end of file diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanBlueprintListingModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanBlueprintListingModel.java index b3a9a18ae..4844adf12 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanBlueprintListingModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/listingmodels/DataManagementPlanBlueprintListingModel.java @@ -1,22 +1,23 @@ package eu.eudat.models.data.listingmodels; -import eu.eudat.data.old.DMPProfile; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.enums.DmpBlueprintStatus; +import eu.eudat.commons.types.dmpblueprint.DefinitionEntity; +import eu.eudat.data.DmpBlueprintEntity; +import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.models.DataModel; -import eu.eudat.models.data.entities.xmlmodels.dmpprofiledefinition.DataManagementPlanBlueprint; import org.w3c.dom.Document; -import java.util.Date; +import java.time.Instant; import java.util.UUID; -public class DataManagementPlanBlueprintListingModel implements DataModel { +public class DataManagementPlanBlueprintListingModel implements DataModel { private UUID id; private String label; - private DataManagementPlanBlueprint definition; - private int status; - private Date created = null; - private Date modified = new Date(); + private DefinitionEntity definition; + private DmpBlueprintStatus status; + private Instant created = null; + private Instant modified = Instant.now(); public UUID getId() { return id; @@ -32,57 +33,60 @@ public class DataManagementPlanBlueprintListingModel implements DataModel { - - private UUID id; - - private String label; - - private DataManagementPlanProfile definition; - - private int status; - - private Date created = null; - - private Date modified = new Date(); - - 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 DataManagementPlanProfile getDefinition() { - return definition; - } - - public void setDefinition(DataManagementPlanProfile definition) { - this.definition = definition; - } - - public int getStatus() { - return status; - } - - public void setStatus(int status) { - this.status = status; - } - - 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; - } - - @Override - public DataManagementPlanProfileListingModel fromDataModel(DMPProfile entity) { - this.id = entity.getId(); - this.created = entity.getCreated(); - this.definition = new DataManagementPlanProfile().fromXml(XmlBuilder.fromXml(entity.getDefinition()).getDocumentElement()); - this.modified = entity.getModified(); - this.label = entity.getLabel(); - this.status = entity.getStatus(); - return this; - } - - @Override - public DMPProfile toDataModel() throws Exception { - Document document = XmlBuilder.getDocument(); - document.appendChild(this.definition.toXml(document)); - DMPProfile dmpProfile = new DMPProfile(); - dmpProfile.setCreated(this.created == null ? new Date() : this.created); - dmpProfile.setDefinition(XmlBuilder.generateXml(document)); - dmpProfile.setId(this.id); - dmpProfile.setLabel(this.label); - dmpProfile.setStatus(this.status); - dmpProfile.setModified(this.modified == null ? new Date() : this.modified); - return dmpProfile; - } - - @Override - public String getHint() { - return null; - } -} +//package eu.eudat.models.data.listingmodels; +// +//import eu.eudat.commons.enums.DmpBlueprintStatus; +//import eu.eudat.commons.types.dmpblueprint.DefinitionEntity; +//import eu.eudat.data.DmpBlueprintEntity; +//import eu.eudat.models.DataModel; +//import eu.eudat.commons.types.xml.XmlBuilder; +//import org.w3c.dom.Document; +// +//import java.time.Instant; +//import java.util.UUID; +// +///** +// * Created by ikalyvas on 3/21/2018. +// */ +//public class DataManagementPlanProfileListingModel implements DataModel { +// +// private UUID id; +// +// private String label; +// +// private DefinitionEntity definitionEntity; +// +// private DmpBlueprintStatus status; +// +// private Instant created = null; +// +// private Instant modified = Instant.now(); +// +// 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 DefinitionEntity getDefinition() { +// return definitionEntity; +// } +// +// public void setDefinition(DefinitionEntity definitionEntity) { +// this.definitionEntity = definitionEntity; +// } +// +// public DmpBlueprintStatus getStatus() { +// return status; +// } +// +// public void setStatus(DmpBlueprintStatus status) { +// this.status = status; +// } +// +// public Instant getCreated() { +// return created; +// } +// +// public void setCreated(Instant created) { +// this.created = created; +// } +// +// public Instant getModified() { +// return modified; +// } +// +// public void setModified(Instant modified) { +// this.modified = modified; +// } +// +// @Override +// public DataManagementPlanProfileListingModel fromDataModel(DmpBlueprintEntity entity) { +// this.id = entity.getId(); +// this.created = entity.getCreatedAt(); +// this.definitionEntity = new DefinitionEntity().fromXml(XmlBuilder.fromXml(entity.getDefinition()).getDocumentElement()); +// this.modified = entity.getUpdatedAt(); +// this.label = entity.getLabel(); +// this.status = entity.getStatus(); +// return this; +// } +// +// @Override +// public DmpBlueprintEntity toDataModel() throws Exception { +// Document document = XmlBuilder.getDocument(); +// document.appendChild(this.definitionEntity.toXml(document)); +// DmpBlueprintEntity dmpBlueprint = new DmpBlueprintEntity(); +// dmpBlueprint.setCreatedAt(this.created == null ? Instant.now() : this.created); +// dmpBlueprint.setDefinition(XmlBuilder.generateXml(document)); +// dmpBlueprint.setId(this.id); +// dmpBlueprint.setLabel(this.label); +// dmpBlueprint.setStatus(this.status); +// dmpBlueprint.setUpdatedAt(this.modified == null ? Instant.now() : this.modified); +// return dmpBlueprint; +// } +// +// @Override +// public String getHint() { +// return null; +// } +//} diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java index 44ed53d9e..dd34750d4 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/rda/DatasetRDAExportModel.java @@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.jayway.jsonpath.JsonPath; import eu.eudat.data.old.Dataset; import eu.eudat.logic.managers.DatasetManager; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import org.json.JSONArray; import org.json.JSONObject; import org.slf4j.Logger; diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/managers/DatasetPublicManager.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/managers/DatasetPublicManager.java index 5b3f92790..a218e4646 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/publicapi/managers/DatasetPublicManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/managers/DatasetPublicManager.java @@ -9,7 +9,7 @@ import eu.eudat.exceptions.security.ForbiddenException; import eu.eudat.logic.managers.PaginationManager; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.services.operations.DatabaseRepository; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.models.HintedModelFactory; import eu.eudat.models.data.helpers.common.DataTableData; import eu.eudat.models.data.user.composite.PagedDatasetProfile; diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java index f3232baa3..f25676782 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/associatedprofile/AssociatedProfilePublicModel.java @@ -1,7 +1,7 @@ package eu.eudat.publicapi.models.associatedprofile; import eu.eudat.data.old.DescriptionTemplate; -import eu.eudat.logic.utilities.interfaces.XmlSerializable; +import eu.eudat.commons.types.xml.XmlSerializable; import org.w3c.dom.Document; import org.w3c.dom.Element; diff --git a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java index 8f280c1ff..317e85ffb 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/publicapi/models/overviewmodels/DataManagementPlanPublicModel.java @@ -6,7 +6,7 @@ import eu.eudat.data.old.DMP; import eu.eudat.data.old.DMPDatasetProfile; import eu.eudat.data.old.Dataset; import eu.eudat.data.old.DescriptionTemplate; -import eu.eudat.logic.utilities.builders.XmlBuilder; +import eu.eudat.commons.types.xml.XmlBuilder; import eu.eudat.models.DataModel; import eu.eudat.models.data.user.composite.PagedDatasetProfile; import eu.eudat.publicapi.models.associatedprofile.AssociatedProfilePublicModel; diff --git a/dmp-backend/web/src/main/resources/config/permissions.yml b/dmp-backend/web/src/main/resources/config/permissions.yml index 7ee5a0dc9..b63b787da 100644 --- a/dmp-backend/web/src/main/resources/config/permissions.yml +++ b/dmp-backend/web/src/main/resources/config/permissions.yml @@ -88,6 +88,26 @@ permissions: clients: [ ] allowAnonymous: false allowAuthenticated: false + # DmpBlueprint + BrowseDmpBlueprint: + roles: + - Admin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + EditDmpBlueprint: + roles: + - Admin + clients: [ ] + allowAnonymous: false + allowAuthenticated: false + DeleteDmpBlueprint: + roles: + - Admin + claims: [ ] + clients: [ ] + allowAnonymous: false + allowAuthenticated: false # ViewPage Permissions ViewDescriptionTemplateTypePage: diff --git a/dmp-db-scema/updates/00.01.003_Align_Dmp_blueprint_table.sql b/dmp-db-scema/updates/00.01.003_Align_Dmp_blueprint_table.sql new file mode 100644 index 000000000..bf66b6146 --- /dev/null +++ b/dmp-db-scema/updates/00.01.003_Align_Dmp_blueprint_table.sql @@ -0,0 +1,26 @@ +ALTER TABLE public."DMPProfile" RENAME TO "DmpBlueprint"; + +ALTER TABLE public."DmpBlueprint" RENAME "ID" TO id; + +ALTER TABLE public."DmpBlueprint" RENAME "Label" TO label; + +ALTER TABLE public."DmpBlueprint" RENAME "Definition" TO definition; + +ALTER TABLE public."DmpBlueprint" RENAME "Status" TO status; + +ALTER TABLE public."DmpBlueprint" RENAME "Created" TO created_at; + +ALTER TABLE public."DmpBlueprint" ALTER COLUMN created_at TYPE timestamp without time zone ; + +ALTER TABLE public."DmpBlueprint" RENAME "Modified" TO updated_at; + +ALTER TABLE public."DmpBlueprint" ALTER COLUMN updated_at TYPE timestamp without time zone ; + +ALTER TABLE public."DmpBlueprint" ADD COLUMN is_active smallint; + +UPDATE public."DmpBlueprint" SET is_active = 1; + +UPDATE public."DmpBlueprint" SET is_active = 0 where status = 99; +UPDATE public."DmpBlueprint" SET status = 0 where is_active = 0; + +ALTER TABLE public."DmpBlueprint" ALTER COLUMN is_active SET NOT NULL; \ No newline at end of file