diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/description/FieldEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/description/FieldEntity.java new file mode 100644 index 000000000..7ffdd64a8 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/description/FieldEntity.java @@ -0,0 +1,22 @@ +package eu.eudat.commons.types.description; + +public class FieldEntity { + private String key; + private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/types/description/PropertyDefinitionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/commons/types/description/PropertyDefinitionEntity.java new file mode 100644 index 000000000..c0623c4fe --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/commons/types/description/PropertyDefinitionEntity.java @@ -0,0 +1,15 @@ +package eu.eudat.commons.types.description; + +import java.util.List; + +public class PropertyDefinitionEntity { + private List fields; + + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/config/filepath/FilePathsConfiguration.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/filepath/FilePathsConfiguration.java similarity index 86% rename from dmp-backend/core/src/main/java/eu/eudat/commons/config/filepath/FilePathsConfiguration.java rename to dmp-backend/core/src/main/java/eu/eudat/configurations/filepath/FilePathsConfiguration.java index 47024f6c7..de056ab36 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/config/filepath/FilePathsConfiguration.java +++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/filepath/FilePathsConfiguration.java @@ -1,4 +1,4 @@ -package eu.eudat.commons.config.filepath; +package eu.eudat.configurations.filepath; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Configuration; diff --git a/dmp-backend/core/src/main/java/eu/eudat/commons/config/filepath/FilePathsProperties.java b/dmp-backend/core/src/main/java/eu/eudat/configurations/filepath/FilePathsProperties.java similarity index 96% rename from dmp-backend/core/src/main/java/eu/eudat/commons/config/filepath/FilePathsProperties.java rename to dmp-backend/core/src/main/java/eu/eudat/configurations/filepath/FilePathsProperties.java index 9c5f4ea22..cee98aaa2 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/commons/config/filepath/FilePathsProperties.java +++ b/dmp-backend/core/src/main/java/eu/eudat/configurations/filepath/FilePathsProperties.java @@ -1,4 +1,4 @@ -package eu.eudat.commons.config.filepath; +package eu.eudat.configurations.filepath; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java index 7f49b18f5..91005ea23 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionEntity.java @@ -6,65 +6,45 @@ import eu.eudat.commons.enums.IsActive; import eu.eudat.data.converters.DateToUTCConverter; import eu.eudat.data.converters.enums.DescriptionStatusConverter; import eu.eudat.data.converters.enums.IsActiveConverter; -import eu.eudat.data.old.*; 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.*; -import java.util.stream.Collectors; @Entity @Table(name = "\"Description\"") public class DescriptionEntity implements DataEntity { - public static Set getHints() { - return hints; - } - - private static final Set hints = new HashSet<>(Arrays.asList("datasetListingModel")); - @Id @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) private UUID id; public static final String _id = "id"; - @Column(name = "label", length = 250, nullable = false) + @Column(name = "label", length = DescriptionEntity._labelLength, nullable = false) private String label; + public static final int _labelLength = 250; public static final String _label = "label"; - @Column(name = "dmp", columnDefinition = "uuid") + @Column(name = "dmp", columnDefinition = "uuid", nullable = false) private UUID dmp; public static final String _dmp = "dmp"; - @Column(name = "uri", length = 250) - private String uri; - - public static final String _uri = "uri"; - @Column(name = "properties") private String properties; public static final String _properties = "properties"; - //TODO: (thgiannos) Previously 'DescriptionTemplate' - @Column(name = "profile", columnDefinition = "uuid") - private UUID profile; + @Column(name = "description_template", columnDefinition = "uuid", nullable = false) + private UUID descriptionTemplate; - public static final String _profile = "profile"; - - @Column(name = "reference") - private String reference; - - public static final String _reference = "reference"; + public static final String _descriptionTemplate = "descriptionTemplate"; @Column(name = "status", nullable = false) @Convert(converter = DescriptionStatusConverter.class) @@ -77,16 +57,6 @@ public class DescriptionEntity implements DataEntity { public static final String _description = "description"; - @Column(name = "dmp_section_index", nullable = false) - private Integer dmpSectionIndex; - - public static final String _dmpSectionIndex = "dmpSectionIndex"; - - @Column(name = "creator", columnDefinition = "uuid") - private UUID creator; - - public static final String _creator = "creator"; - @Column(name = "created_at", nullable = false) private Instant createdAt; @@ -109,6 +79,16 @@ public class DescriptionEntity implements DataEntity { public static final String _finalizedAt = "finalizedAt"; + @Column(name = "created_by", columnDefinition = "uuid", nullable = false) + private UUID createdBy; + + public static final String _createdBy = "createdBy"; + + @Column(name = "dmp_description_template", columnDefinition = "uuid", nullable = false) + private UUID dmpDescriptionTemplate; + + public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate"; + public UUID getId() { return id; } @@ -133,14 +113,6 @@ public class DescriptionEntity implements DataEntity { this.dmp = dmp; } - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - public String getProperties() { return properties; } @@ -149,20 +121,12 @@ public class DescriptionEntity implements DataEntity { this.properties = properties; } - public UUID getProfile() { - return profile; + public UUID getDescriptionTemplate() { + return descriptionTemplate; } - public void setProfile(UUID profile) { - this.profile = profile; - } - - public String getReference() { - return reference; - } - - public void setReference(String reference) { - this.reference = reference; + public void setDescriptionTemplate(UUID descriptionTemplate) { + this.descriptionTemplate = descriptionTemplate; } public DescriptionStatus getStatus() { @@ -181,22 +145,6 @@ public class DescriptionEntity implements DataEntity { this.description = description; } - public Integer getDmpSectionIndex() { - return dmpSectionIndex; - } - - public void setDmpSectionIndex(Integer dmpSectionIndex) { - this.dmpSectionIndex = dmpSectionIndex; - } - - public UUID getCreator() { - return creator; - } - - public void setCreator(UUID creator) { - this.creator = creator; - } - public Instant getCreatedAt() { return createdAt; } @@ -229,6 +177,22 @@ public class DescriptionEntity implements DataEntity { this.finalizedAt = finalizedAt; } + public UUID getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(UUID createdBy) { + this.createdBy = createdBy; + } + + public UUID getDmpDescriptionTemplate() { + return dmpDescriptionTemplate; + } + + public void setDmpDescriptionTemplate(UUID dmpDescriptionTemplate) { + this.dmpDescriptionTemplate = dmpDescriptionTemplate; + } + @Override public void update(DescriptionEntity entity) { // this.setUri(entity.getUri()); diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java index 0d8fafa31..b4f4cecef 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionReferenceEntity.java @@ -18,10 +18,10 @@ public class DescriptionReferenceEntity { public static final String _id = "id"; - @Column(name = "data") - private String data; - - public static final String _data = "data"; +// @Column(name = "data") +// private String data; +// +// public static final String _data = "data"; @Column(name = "description_id", columnDefinition = "uuid", nullable = false) private UUID descriptionId; @@ -59,14 +59,6 @@ public class DescriptionReferenceEntity { this.id = id; } - public String getData() { - return data; - } - - public void setData(String data) { - this.data = data; - } - public UUID getDescriptionId() { return descriptionId; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTagEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTagEntity.java new file mode 100644 index 000000000..cbb24f5d2 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/data/DescriptionTagEntity.java @@ -0,0 +1,97 @@ +package eu.eudat.data; + +import eu.eudat.commons.enums.IsActive; +import eu.eudat.data.converters.DateToUTCConverter; +import eu.eudat.data.converters.enums.IsActiveConverter; +import jakarta.persistence.*; + +import java.time.Instant; +import java.util.UUID; + +@Entity +@Table(name = "\"DescriptionTag\"") +public class DescriptionTagEntity { + + @Id + @Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)") + private UUID id; + + public static final String _id = "id"; + + @Column(name = "description", columnDefinition = "uuid", nullable = false) + private UUID description; + + public static final String _description = "description"; + + @Column(name = "tag", columnDefinition = "uuid", nullable = false) + private UUID tag; + + public static final String _tag = "tag"; + + @Column(name = "created_at") + @Convert(converter = DateToUTCConverter.class) + private Instant createdAt; + + public static final String _createdAt = "createdAt"; + + @Column(name = "updated_at") + @Convert(converter = DateToUTCConverter.class) + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + @Column(name = "is_active", nullable = false) + @Convert(converter = IsActiveConverter.class) + private IsActive isActive; + + public static final String _isActive = "isActive"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public UUID getDescription() { + return description; + } + + public void setDescription(UUID description) { + this.description = description; + } + + public UUID getTag() { + return tag; + } + + public void setTag(UUID tag) { + this.tag = tag; + } + + 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; + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/data/TagEntity.java b/dmp-backend/core/src/main/java/eu/eudat/data/TagEntity.java new file mode 100644 index 000000000..9f61b80cc --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/data/TagEntity.java @@ -0,0 +1,95 @@ +package eu.eudat.data; + + +import eu.eudat.commons.enums.DescriptionTemplateStatus; +import eu.eudat.commons.enums.IsActive; +import eu.eudat.data.converters.enums.DescriptionTemplateStatusConverter; +import eu.eudat.data.converters.enums.IsActiveConverter; +import eu.eudat.queryable.queryableentity.DataEntity; +import jakarta.persistence.*; +import org.hibernate.annotations.Type; + +import java.time.Instant; +import java.util.List; +import java.util.UUID; + + +@Entity +@Table(name = "\"Tag\"") +public class TagEntity { + @Id + @Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false) + private UUID id; + public static final String _id = "id"; + + @Column(name = "\"label\"", length = TagEntity._labelLength, nullable = false) + private String label; + public static final String _label = "label"; + public static final int _labelLength = 250; + + @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"; + + @Column(name = "\"created_by\"", nullable = false) + private UUID createdBy; + public static final String _createdBy = "createdBy"; + + 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 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; + } + + public UUID getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(UUID createdBy) { + this.createdBy = createdBy; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/Description.java b/dmp-backend/core/src/main/java/eu/eudat/model/Description.java index 68a3970b4..1de29c693 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/Description.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/Description.java @@ -2,6 +2,7 @@ package eu.eudat.model; import eu.eudat.commons.enums.DescriptionStatus; import eu.eudat.commons.enums.IsActive; +import eu.eudat.model.descriptionproperties.PropertyDefinition; import java.time.Instant; import java.util.List; @@ -21,21 +22,13 @@ public class Description { public static final String _dmp = "dmp"; - private String uri; - - public static final String _uri = "uri"; - - private String properties; + private PropertyDefinition properties; public static final String _properties = "properties"; - private UUID profile; + private DescriptionTemplate descriptionTemplate; - public static final String _profile = "profile"; - - private String reference; - - public static final String _reference = "reference"; + public static final String _descriptionTemplate = "descriptionTemplate"; private DescriptionStatus status; @@ -45,13 +38,9 @@ public class Description { public static final String _description = "description"; - private Integer dmpSectionIndex; + private UUID createdBy; - public static final String _dmpSectionIndex = "dmpSectionIndex"; - - private UUID creator; - - public static final String _creator = "creator"; + public static final String _createdBy = "createdBy"; private Instant createdAt; @@ -77,6 +66,14 @@ public class Description { public static final String _descriptionReferences = "descriptionReferences"; + private List descriptionTags; + + public static final String _descriptionTags = "descriptionTags"; + + private UUID dmpDescriptionTemplate; + + public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate"; + public UUID getId() { return id; } @@ -101,38 +98,14 @@ public class Description { this.dmp = dmp; } - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - - public String getProperties() { + public PropertyDefinition getProperties() { return properties; } - public void setProperties(String properties) { + public void setProperties(PropertyDefinition properties) { this.properties = properties; } - public UUID getProfile() { - return profile; - } - - public void setProfile(UUID profile) { - this.profile = profile; - } - - public String getReference() { - return reference; - } - - public void setReference(String reference) { - this.reference = reference; - } - public DescriptionStatus getStatus() { return status; } @@ -149,28 +122,12 @@ public class Description { this.description = description; } - public Integer getDmpSectionIndex() { - return dmpSectionIndex; + public UUID getCreatedBy() { + return createdBy; } - public void setDmpSectionIndex(Integer dmpSectionIndex) { - this.dmpSectionIndex = dmpSectionIndex; - } - - public UUID getCreator() { - return creator; - } - - public void setCreator(UUID creator) { - this.creator = creator; - } - - public Instant getCreatedAt() { - return createdAt; - } - - public void setCreatedAt(Instant createdAt) { - this.createdAt = createdAt; + public void setCreatedBy(UUID createdBy) { + this.createdBy = createdBy; } public Instant getUpdatedAt() { @@ -213,4 +170,35 @@ public class Description { this.descriptionReferences = descriptionReferences; } + public DescriptionTemplate getDescriptionTemplate() { + return descriptionTemplate; + } + + public void setDescriptionTemplate(DescriptionTemplate descriptionTemplate) { + this.descriptionTemplate = descriptionTemplate; + } + + public Instant getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(Instant createdAt) { + this.createdAt = createdAt; + } + + public UUID getDmpDescriptionTemplate() { + return dmpDescriptionTemplate; + } + + public void setDmpDescriptionTemplate(UUID dmpDescriptionTemplate) { + this.dmpDescriptionTemplate = dmpDescriptionTemplate; + } + + public List getDescriptionTags() { + return descriptionTags; + } + + public void setDescriptionTags(List descriptionTags) { + this.descriptionTags = descriptionTags; + } } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/DescriptionReference.java b/dmp-backend/core/src/main/java/eu/eudat/model/DescriptionReference.java index d06304b1b..11c57f6c3 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/DescriptionReference.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/DescriptionReference.java @@ -11,10 +11,6 @@ public class DescriptionReference { public static final String _id = "id"; - private String data; - - public static final String _data = "data"; - private Description description; public static final String _description = "description"; @@ -43,14 +39,6 @@ public class DescriptionReference { this.id = id; } - public String getData() { - return data; - } - - public void setData(String data) { - this.data = data; - } - public Description getDescription() { return description; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/DescriptionTag.java b/dmp-backend/core/src/main/java/eu/eudat/model/DescriptionTag.java new file mode 100644 index 000000000..84df25bf0 --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/DescriptionTag.java @@ -0,0 +1,82 @@ +package eu.eudat.model; + +import eu.eudat.commons.enums.IsActive; + +import java.time.Instant; +import java.util.UUID; + +public class DescriptionTag { + + private UUID id; + + public static final String _id = "id"; + + private Description description; + + public static final String _description = "description"; + + private Tag tag; + + public static final String _tag = "tag"; + + private Instant createdAt; + + public static final String _createdAt = "createdAt"; + + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + private IsActive isActive; + + public static final String _isActive = "isActive"; + + public UUID getId() { + return id; + } + + public void setId(UUID id) { + this.id = id; + } + + public Description getDescription() { + return description; + } + + public void setDescription(Description description) { + this.description = description; + } + + public Tag getTag() { + return tag; + } + + public void setTag(Tag tag) { + this.tag = tag; + } + + 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; + } + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/Tag.java b/dmp-backend/core/src/main/java/eu/eudat/model/Tag.java new file mode 100644 index 000000000..43bab127f --- /dev/null +++ b/dmp-backend/core/src/main/java/eu/eudat/model/Tag.java @@ -0,0 +1,95 @@ +package eu.eudat.model; + +import eu.eudat.commons.enums.DescriptionStatus; +import eu.eudat.commons.enums.IsActive; + +import java.time.Instant; +import java.util.List; +import java.util.UUID; + +public class Tag { + + private UUID id; + + public static final String _id = "id"; + + private String label; + + public static final String _label = "label"; + + private UUID createdBy; + + public static final String _createdBy = "createdBy"; + + private Instant createdAt; + + public static final String _createdAt = "createdAt"; + + private Instant updatedAt; + + public static final String _updatedAt = "updatedAt"; + + private IsActive isActive; + + public static final String _isActive = "isActive"; + + private String hash; + + public static final String _hash = "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 UUID getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(UUID createdBy) { + this.createdBy = createdBy; + } + + 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 String getHash() { + return hash; + } + + public void setHash(String hash) { + this.hash = hash; + } +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java index 59dc49387..6bc7f1978 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/builder/DescriptionBuilder.java @@ -70,24 +70,18 @@ public class DescriptionBuilder extends BaseBuilder fields; + +} diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java index e9d360f16..b3abc5dbe 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/mapper/deposit/DmpEntityDepositMapper.java @@ -72,7 +72,7 @@ public class DmpEntityDepositMapper { model.setLabel(entity.getLabel()); model.setDescription(entity.getDescription()); model.setProperties(entity.getProperties()); - DescriptionTemplateEntity descriptionTemplateEntity = getDescriptionTemplate(entity.getProfile()); + DescriptionTemplateEntity descriptionTemplateEntity = getDescriptionTemplate(entity.getDescriptionTemplate()); model.setProfileDefinition(descriptionTemplateEntity.getDefinition()); model.setFields(fromDefinitionAndProperties(descriptionTemplateEntity.getDefinition(), entity.getProperties())); return model; diff --git a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java index fc4e885e0..39f9ea214 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java +++ b/dmp-backend/core/src/main/java/eu/eudat/model/persist/DescriptionPersist.java @@ -15,20 +15,14 @@ public class DescriptionPersist { private UUID dmp; - private String uri; - private String properties; private UUID profile; - private String reference; - private DescriptionStatus status; private String description; - private Integer dmpSectionIndex; - private IsActive isActive; public UUID getId() { @@ -55,14 +49,6 @@ public class DescriptionPersist { this.dmp = dmp; } - public String getUri() { - return uri; - } - - public void setUri(String uri) { - this.uri = uri; - } - public String getProperties() { return properties; } @@ -79,14 +65,6 @@ public class DescriptionPersist { this.profile = profile; } - public String getReference() { - return reference; - } - - public void setReference(String reference) { - this.reference = reference; - } - public DescriptionStatus getStatus() { return status; } @@ -103,14 +81,6 @@ public class DescriptionPersist { this.description = description; } - public Integer getDmpSectionIndex() { - return dmpSectionIndex; - } - - public void setDmpSectionIndex(Integer dmpSectionIndex) { - this.dmpSectionIndex = dmpSectionIndex; - } - public IsActive getIsActive() { return isActive; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java index 4362d39b7..1f2e16933 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionQuery.java @@ -201,22 +201,16 @@ public class DescriptionQuery extends QueryBase { return DescriptionEntity._dmp; else if (item.match(Description._dmp)) return DescriptionEntity._dmp; - else if (item.match(Description._uri)) - return DescriptionEntity._uri; - else if (item.match(Description._properties)) + else if (item.prefix(Description._properties)) return DescriptionEntity._properties; - else if (item.match(Description._profile)) - return DescriptionEntity._profile; - else if (item.match(Description._reference)) - return DescriptionEntity._reference; + else if (item.prefix(Description._descriptionTemplate)) + return DescriptionEntity._descriptionTemplate; else if (item.match(Description._status)) return DescriptionEntity._status; else if (item.match(Description._description)) return DescriptionEntity._description; - else if (item.match(Description._dmpSectionIndex)) - return DescriptionEntity._dmpSectionIndex; - else if (item.match(Description._creator)) - return DescriptionEntity._creator; + else if (item.match(Description._createdBy)) + return DescriptionEntity._createdBy; else if (item.match(Description._createdAt)) return DescriptionEntity._createdAt; else if (item.match(Description._updatedAt)) @@ -225,6 +219,8 @@ public class DescriptionQuery extends QueryBase { return DescriptionEntity._isActive; else if (item.match(Description._finalizedAt)) return DescriptionEntity._finalizedAt; + else if (item.match(Description._dmpDescriptionTemplate)) + return DescriptionEntity._dmpDescriptionTemplate; else return null; } @@ -235,18 +231,16 @@ public class DescriptionQuery extends QueryBase { item.setId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._id, UUID.class)); item.setLabel(QueryBase.convertSafe(tuple, columns, DescriptionEntity._label, String.class)); item.setDmp(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmp, UUID.class)); - item.setUri(QueryBase.convertSafe(tuple, columns, DescriptionEntity._uri, String.class)); item.setProperties(QueryBase.convertSafe(tuple, columns, DescriptionEntity._properties, String.class)); - item.setProfile(QueryBase.convertSafe(tuple, columns, DescriptionEntity._profile, UUID.class)); - item.setReference(QueryBase.convertSafe(tuple, columns, DescriptionEntity._reference, String.class)); + item.setDescriptionTemplate(QueryBase.convertSafe(tuple, columns, DescriptionEntity._descriptionTemplate, UUID.class)); item.setStatus(QueryBase.convertSafe(tuple, columns, DescriptionEntity._status, DescriptionStatus.class)); item.setDescription(QueryBase.convertSafe(tuple, columns, DescriptionEntity._description, String.class)); - item.setDmpSectionIndex(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpSectionIndex, Integer.class)); - item.setCreator(QueryBase.convertSafe(tuple, columns, DescriptionEntity._creator, UUID.class)); + item.setDmpDescriptionTemplate(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdBy, UUID.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdAt, Instant.class)); item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._updatedAt, Instant.class)); item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionEntity._isActive, IsActive.class)); item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._finalizedAt, Instant.class)); + item.setDmpDescriptionTemplate(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpDescriptionTemplate, UUID.class)); return item; } diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java index 83d64142f..3141f5b2b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionReferenceQuery.java @@ -184,8 +184,6 @@ public class DescriptionReferenceQuery extends QueryBase columns) { DescriptionReferenceEntity item = new DescriptionReferenceEntity(); item.setId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._id, UUID.class)); - item.setData(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._data, String.class)); item.setDescriptionId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._descriptionId, UUID.class)); item.setReferenceId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._referenceId, UUID.class)); item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._createdAt, Instant.class)); diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTemplateQuery.java b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTemplateQuery.java index eb67bd54a..ff102c5ad 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTemplateQuery.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/DescriptionTemplateQuery.java @@ -27,6 +27,7 @@ public class DescriptionTemplateQuery extends QueryBase ids; + private Collection groupIds; private Collection isActives; diff --git a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateLookup.java b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateLookup.java index 1d4ff9ad2..281f2c74b 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateLookup.java +++ b/dmp-backend/core/src/main/java/eu/eudat/query/lookup/DescriptionTemplateLookup.java @@ -6,6 +6,7 @@ import eu.eudat.query.DescriptionTemplateQuery; import gr.cite.tools.data.query.Lookup; import gr.cite.tools.data.query.QueryFactory; +import java.util.Collection; import java.util.List; import java.util.UUID; @@ -14,6 +15,7 @@ public class DescriptionTemplateLookup extends Lookup { private String like; private List isActive; + private List groupIds; private List statuses; @@ -71,12 +73,22 @@ public class DescriptionTemplateLookup extends Lookup { this.typeIds = typeIds; } + public List getGroupIds() { + return groupIds; + } + + public void setGroupIds(List groupIds) { + this.groupIds = groupIds; + } + public DescriptionTemplateQuery enrich(QueryFactory queryFactory) { DescriptionTemplateQuery query = queryFactory.query(DescriptionTemplateQuery.class); if (this.like != null) query.like(this.like); if (this.isActive != null) query.isActive(this.isActive); + if (this.groupIds != null) + query.groupIds(this.groupIds); if (this.statuses != null) query.statuses(this.statuses); if (this.ids != null) diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java index ed576e6c3..22d89c4a8 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/description/DescriptionServiceImpl.java @@ -108,13 +108,10 @@ public class DescriptionServiceImpl implements DescriptionService { data.setLabel(model.getLabel()); data.setDmp(model.getDmp()); - data.setUri(model.getUri()); data.setProperties(model.getProperties()); - data.setProfile(model.getProfile()); - data.setReference(model.getReference()); + data.setDescriptionTemplate(model.getProfile()); data.setStatus(model.getStatus()); data.setDescription(model.getDescription()); - data.setDmpSectionIndex(model.getDmpSectionIndex()); data.setUpdatedAt(Instant.now()); if (isUpdate) this.entityManager.merge(data); diff --git a/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java b/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java index adef8b250..0432ba8aa 100644 --- a/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java +++ b/dmp-backend/core/src/main/java/eu/eudat/service/descriptiontemplate/DescriptionTemplateServiceImpl.java @@ -5,7 +5,7 @@ import eu.eudat.authorization.AuthorizationFlags; import eu.eudat.authorization.Permission; import eu.eudat.commons.JsonHandlingService; import eu.eudat.commons.XmlHandlingService; -import eu.eudat.commons.config.filepath.FilePathsProperties; +import eu.eudat.configurations.filepath.FilePathsProperties; import eu.eudat.commons.enums.DescriptionTemplateStatus; import eu.eudat.commons.enums.FieldType; import eu.eudat.commons.enums.IsActive; diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java index ef18a6652..8d827d91a 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/dao/entities/DatasetDaoImpl.java @@ -20,10 +20,7 @@ import jakarta.persistence.criteria.Join; import jakarta.persistence.criteria.JoinType; import javax.management.InvalidApplicationException; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.UUID; +import java.util.*; import java.util.concurrent.CompletableFuture; @Component("datasetDao") @@ -34,7 +31,7 @@ public class DatasetDaoImpl extends DatabaseAccess implements @Override public QueryableList getWithCriteria(DatasetCriteria criteria) { - QueryableList query = getDatabaseService().getQueryable(DescriptionEntity.getHints(), DescriptionEntity.class); + QueryableList query = getDatabaseService().getQueryable(new HashSet<>(Arrays.asList("datasetListingModel")), DescriptionEntity.class); if (criteria.getIsPublic() != null && criteria.getIsPublic()) { query.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true)); query.where((builder, root) -> builder.equal(root.get("status"), DescriptionStatus.Finalized)); @@ -91,7 +88,7 @@ public class DatasetDaoImpl extends DatabaseAccess implements } public QueryableList filterFromElastic(DatasetCriteria criteria, List ids) { - QueryableList query = getDatabaseService().getQueryable(DescriptionEntity.getHints(), DescriptionEntity.class); + QueryableList query = getDatabaseService().getQueryable(new HashSet<>(Arrays.asList("datasetListingModel")), DescriptionEntity.class); query.where(((builder, root) -> root.get("id").in(ids))); if (!criteria.getAllVersions()) @@ -113,13 +110,13 @@ public class DatasetDaoImpl extends DatabaseAccess implements @Override public DescriptionEntity find(UUID id, String hint) throws InvalidApplicationException { - return getDatabaseService().getQueryable(DescriptionEntity.getHints(), DescriptionEntity.class).withHint(hint) + return getDatabaseService().getQueryable(new HashSet<>(Arrays.asList("datasetListingModel")), DescriptionEntity.class).withHint(hint) .where((builder, root) -> builder.and(builder.notEqual(root.get(DescriptionEntity._isActive), IsActive.Inactive), builder.notEqual(root.get("status"), DescriptionStatus.Canceled), builder.equal((root.get("id")), id))).getSingle(); } @Override public DescriptionEntity isPublicDataset(UUID id) throws InvalidApplicationException { - QueryableList query = getDatabaseService().getQueryable(DescriptionEntity.getHints(), DescriptionEntity.class); + QueryableList query = getDatabaseService().getQueryable(new HashSet<>(Arrays.asList("datasetListingModel")), DescriptionEntity.class); query.where(((builder, root) -> builder.equal(root.get("id"), id))); return query.withHint("datasetListingModel").getSingle(); 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 b185a60a7..276770177 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 @@ -494,7 +494,7 @@ public class DataManagementPlanManager { } List descriptionEntityList = dmp1.getDataset().stream().filter(dataset -> dataset.getIsActive() != IsActive.Inactive).collect(Collectors.toList()); for (DescriptionEntity descriptionEntity : descriptionEntityList) { - if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> descriptionEntity.getProfile().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null) + if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> descriptionEntity.getDescriptionTemplate().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null) throw new Exception("Dataset Template for Dataset Description is missing from the DMP."); } if (dataManagementPlan.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue() && dmp1.getStatus().equals(DMP.DMPStatus.FINALISED.getValue())) @@ -1122,7 +1122,7 @@ public class DataManagementPlanManager { datasetElastic.setId(dataset1.getId().toString()); datasetElastic.setLabel(dataset1.getLabel()); datasetElastic.setDescription(dataset1.getDescription()); - datasetElastic.setTemplate(dataset1.getProfile()); + datasetElastic.setTemplate(dataset1.getDescriptionTemplate()); datasetElastic.setStatus(dataset1.getStatus().getValue()); datasetElastic.setDmp(dataset1.getDmp()); datasetElastic.setGroup(dmp.getGroupId()); @@ -1549,7 +1549,7 @@ public class DataManagementPlanManager { .filter(item -> item.getStatus() != DescriptionStatus.Canceled) .filter(item -> item.getIsActive() != IsActive.Inactive) .filter(item -> !isPublic && !isFinalized || item.getStatus() == DescriptionStatus.Finalized) - .filter(item -> item.getDmpSectionIndex().equals(section.getOrdinal() - 1)) + //.filter(item -> item.getDmpSectionIndex().equals(section.getOrdinal() - 1)) //TODO .sorted(Comparator.comparing(DescriptionEntity::getCreatedAt)) .forEach(datasetEntity -> { Map properties = new HashMap<>(); @@ -1600,7 +1600,7 @@ public class DataManagementPlanManager { //runDatasetTemplate1.setBold(true); //runDatasetTemplate1.setFontSize(12); XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun(); - runDatasetTemplate.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getProfile()).first().getLabel()); + runDatasetTemplate.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getDescriptionTemplate()).first().getLabel()); runDatasetTemplate.setColor("116a78"); //runDatasetTemplate.setBold(true); //runDatasetTemplate.setFontSize(12); @@ -1646,7 +1646,7 @@ public class DataManagementPlanManager { runDatasetDescription1.setText("Description: "); runDatasetDescription1.setColor("000000"); XWPFRun runDatasetDescription = datasetDescParagraph.createRun(); - runDatasetDescription.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getProfile()).first().getLabel()); + runDatasetDescription.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getDescriptionTemplate()).first().getLabel()); runDatasetDescription.setColor("116a78"); //wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0); @@ -1921,17 +1921,18 @@ public class DataManagementPlanManager { datasetElement.appendChild(datasetDescriptionElement); datasetDescriptionElement.setTextContent(descriptionEntity.getDescription()); - Element datasetDmpSectionIndex = xmlDoc.createElement("dmpSectionIndex"); - datasetElement.appendChild(datasetDmpSectionIndex); - datasetDmpSectionIndex.setTextContent(String.valueOf(descriptionEntity.getDmpSectionIndex())); + //TODO +// Element datasetDmpSectionIndex = xmlDoc.createElement("dmpSectionIndex"); +// datasetElement.appendChild(datasetDmpSectionIndex); +// datasetDmpSectionIndex.setTextContent(String.valueOf(descriptionEntity.getDmpSectionIndex())); Element datsetProfileElement = xmlDoc.createElement("profile-id"); datasetElement.appendChild(datsetProfileElement); - datsetProfileElement.setTextContent(descriptionEntity.getProfile().toString()); + datsetProfileElement.setTextContent(descriptionEntity.getDescriptionTemplate().toString()); Element datsetProfileLabelElement = xmlDoc.createElement("profile-label"); datasetElement.appendChild(datsetProfileLabelElement); - datsetProfileLabelElement.setTextContent(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntity.getProfile()).first().getLabel()); + datsetProfileLabelElement.setTextContent(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntity.getDescriptionTemplate()).first().getLabel()); DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); Map properties = new HashMap<>(); @@ -2231,11 +2232,12 @@ public class DataManagementPlanManager { for (DatasetImportModels das: dataManagementPlans.get(0).getDatasetImportModels()) { DescriptionEntity descriptionEntity = new DescriptionEntity(); descriptionEntity.setLabel(das.getName()); - descriptionEntity.setDmpSectionIndex(das.getDmpSectionIndex()); + //TODO +// descriptionEntity.setDmpSectionIndex(das.getDmpSectionIndex()); try { - descriptionEntity.setProfile(das.getProfile()); + descriptionEntity.setDescriptionTemplate(das.getProfile()); } catch (Exception ignored) { - descriptionEntity.setProfile(associatedProfiles.get(0).getDescriptionTemplateId()); + descriptionEntity.setDescriptionTemplate(associatedProfiles.get(0).getDescriptionTemplateId()); } descriptionEntity.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels())); descriptionEntity.setStatus(DescriptionStatus.Saved); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index be8734b07..a3b48c152 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -309,7 +309,7 @@ public class DatasetManager { // Creates the Criteria to get all version of DescriptionTemplate in question. DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria(); - UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getProfile()).first().getGroupId(); + UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplate()).first().getGroupId(); List uuidList = new LinkedList<>(); uuidList.add(profileId); profileCriteria.setGroupIds(uuidList); @@ -340,7 +340,7 @@ public class DatasetManager { DescriptionTemplateEntity profile = profiles.get(0); // Check if the dataset is on the latest Version. - boolean latestVersion = profile.getVersion().toString().equals(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getProfile()).first().getVersion()); + boolean latestVersion = profile.getVersion().toString().equals(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplate()).first().getVersion()); dataset.setIsProfileLatestVersion(latestVersion); eu.eudat.elastic.entities.Dataset datasetElastic; @@ -400,7 +400,7 @@ public class DatasetManager { } public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, DescriptionEntity descriptionEntityEntity) { - eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getProfile()).first()); + eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplate()).first()); datasetprofile.setStatus(dataset.getStatus().getValue()); if (descriptionEntityEntity.getProperties() != null) { JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties()); @@ -598,7 +598,7 @@ public class DatasetManager { PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, descriptionEntityEntity); visibilityRuleService.setProperties(properties); visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules()); - File file = xmlBuilder.build(pagedDatasetProfile, descriptionEntityEntity.getProfile(), visibilityRuleService, environment); + File file = xmlBuilder.build(pagedDatasetProfile, descriptionEntityEntity.getDescriptionTemplate(), visibilityRuleService, environment); FileEnvelope fileEnvelope = new FileEnvelope(); fileEnvelope.setFile(file); String label = descriptionEntityEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", ""); @@ -639,7 +639,7 @@ public class DatasetManager { } } UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build(); - descriptionEntity.setCreator(userInfo.getId()); + descriptionEntity.setDmpDescriptionTemplate(userInfo.getId()); createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), descriptionEntity); createExternalDatasetsIfTheyDontExist(descriptionEntity); @@ -652,7 +652,7 @@ public class DatasetManager { datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1)); } - descriptionEntity1.setProfile(datasetWizardModel.getProfile().getId()); + descriptionEntity1.setDescriptionTemplate(datasetWizardModel.getProfile().getId()); // datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1)); UUID dmpId = descriptionEntity1.getDmp(); DMP dmp1 = databaseRepository.getDmpDao().find(descriptionEntity1.getDmp()); @@ -737,7 +737,7 @@ public class DatasetManager { public String checkDatasetValidation(DescriptionEntity descriptionEntity) throws Exception { List datasetProfileValidators = new LinkedList<>(); - DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(descriptionEntity.getProfile()); + DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(descriptionEntity.getDescriptionTemplate()); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = builderFactory.newDocumentBuilder(); Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes())); @@ -759,7 +759,7 @@ public class DatasetManager { VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl(); visibilityRuleService.setProperties(obj.toMap()); - descriptionEntity.setProfile(profile.getId()); + descriptionEntity.setDescriptionTemplate(profile.getId()); PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), descriptionEntity); visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules()); @@ -1036,10 +1036,10 @@ public class DatasetManager { entity.setUpdatedAt(Instant.now()); DescriptionTemplateEntity profile = new DescriptionTemplateEntity(); profile.setId(UUID.fromString(datasetProfileId)); - entity.setProfile(profile.getId()); + entity.setDescriptionTemplate(profile.getId()); UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(this.userScope.getUserId()).build(); - entity.setCreator(userInfo.getId()); + entity.setDmpDescriptionTemplate(userInfo.getId()); updateTagsXmlImportDataset(apiContext.getOperationsContext().getElasticRepository().getDatasetRepository(), entity); createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), entity); @@ -1064,7 +1064,7 @@ public class DatasetManager { // Creates the Criteria to get all version of DescriptionTemplate in question. DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria(); - UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getProfile()).first().getGroupId(); + UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getDescriptionTemplate()).first().getGroupId(); List uuidList = new LinkedList<>(); uuidList.add(profileId); profileCriteria.setGroupIds(uuidList); @@ -1152,7 +1152,7 @@ public class DatasetManager { } public void getTagsFromProfile(DatasetWizardModel wizardModel, DescriptionEntity descriptionEntity) throws IOException, InvalidApplicationException { - descriptionEntity.setProfile(descriptionEntity.getProfile()); + descriptionEntity.setDescriptionTemplate(descriptionEntity.getDescriptionTemplate()); wizardModel.setDatasetProfileDefinition(this.getPagedProfile(wizardModel, descriptionEntity)); ObjectMapper mapper = new ObjectMapper(); String json = mapper.writeValueAsString(wizardModel.getDatasetProfileDefinition()); diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MetricsManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MetricsManager.java index 899980333..a3aa448f2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MetricsManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/MetricsManager.java @@ -412,7 +412,7 @@ public class MetricsManager { List descriptionTemplateEntities = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList(); DatasetCriteria datasetCriteria = new DatasetCriteria(); datasetCriteria.setDatasetTemplates(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getId).collect(Collectors.toList())); - return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getProfile()).stream().distinct().count(); + return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getDescriptionTemplate()).stream().distinct().count(); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/NotificationManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/NotificationManager.java index e6169b8db..9b4730f27 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/NotificationManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/NotificationManager.java @@ -6,7 +6,7 @@ import eu.eudat.data.old.UserInfo; import eu.eudat.commons.enums.old.notification.ActiveStatus; import eu.eudat.commons.enums.old.notification.NotifyState; import eu.eudat.logic.services.ApiContext; -import eu.eudat.logic.services.utilities.MailService; +import eu.eudat.service.mail.MailService; import eu.eudat.service.mail.SimpleMail; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/elastic/DatasetMapper.java b/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/elastic/DatasetMapper.java index 16788b972..8278b2b05 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/elastic/DatasetMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/elastic/DatasetMapper.java @@ -1,17 +1,12 @@ package eu.eudat.logic.mapper.elastic; import eu.eudat.data.DescriptionEntity; -import eu.eudat.data.dao.criteria.DataManagementPlanCriteria; -import eu.eudat.data.old.DMP; -import eu.eudat.elastic.criteria.DatasetCriteria; import eu.eudat.elastic.entities.Dataset; import eu.eudat.elastic.entities.Tag; import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.services.ApiContext; -import eu.eudat.logic.utilities.helpers.StreamDistinctBy; import java.util.*; -import java.util.stream.Collectors; public class DatasetMapper { @@ -24,7 +19,7 @@ public class DatasetMapper { } public Dataset toElastic(DescriptionEntity descriptionEntity, List tags) throws Exception { - if (descriptionEntity.getProfile() == null) { + if (descriptionEntity.getDescriptionTemplate() == null) { return null; } //TODO diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/prefilling/PrefillingMapper.java b/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/prefilling/PrefillingMapper.java index 0d21cb83c..6e675d5f2 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/prefilling/PrefillingMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/mapper/prefilling/PrefillingMapper.java @@ -53,7 +53,7 @@ public class PrefillingMapper { DatasetWizardModel datasetWizardModel = new DatasetWizardModel(); datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile)); DescriptionEntity descriptionEntity = new DescriptionEntity(); - descriptionEntity.setProfile(profile.getId()); + descriptionEntity.setDescriptionTemplate(profile.getId()); Map properties = new HashMap<>(); JsonNode parentNode = mapper.readTree(mapper.writeValueAsString(datasetManager.getPagedProfile(datasetWizardModel, descriptionEntity))); for (DefaultPrefillingMapping prefillingMapping: prefillingGet.getMappings()) { diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/config/configloaders/DefaultConfigLoader.java b/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/config/configloaders/DefaultConfigLoader.java index 1ed59ca4f..1718d9ad9 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/config/configloaders/DefaultConfigLoader.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/proxy/config/configloaders/DefaultConfigLoader.java @@ -2,9 +2,8 @@ package eu.eudat.logic.proxy.config.configloaders; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; -import eu.eudat.commons.config.filepath.FilePathsProperties; +import eu.eudat.configurations.filepath.FilePathsProperties; import eu.eudat.logic.proxy.config.ExternalUrls; -import eu.eudat.service.descriptiontemplate.Semantic; import eu.eudat.models.data.pid.PidLinks; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.slf4j.Logger; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailService.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailService.java index a97294464..d42049fec 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailService.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailService.java @@ -3,6 +3,7 @@ package eu.eudat.logic.services.utilities; import eu.eudat.data.dao.entities.EmailConfirmationDao; import eu.eudat.data.old.EmailConfirmation; import eu.eudat.data.old.UserInfo; +import eu.eudat.service.mail.MailService; import javax.management.InvalidApplicationException; import java.util.UUID; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailServiceImpl.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailServiceImpl.java index 419b900a0..114056365 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailServiceImpl.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/ConfirmationEmailServiceImpl.java @@ -7,6 +7,7 @@ import eu.eudat.commons.scope.user.UserScope; import eu.eudat.data.dao.entities.EmailConfirmationDao; import eu.eudat.data.old.EmailConfirmation; import eu.eudat.data.old.UserInfo; +import eu.eudat.service.mail.MailService; import eu.eudat.service.mail.SimpleMail; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationService.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationService.java index cb40ea5c7..56ba8f49b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationService.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationService.java @@ -8,6 +8,7 @@ import eu.eudat.data.old.Invitation; import eu.eudat.data.old.UserDMP; import eu.eudat.data.old.UserInfo; +import eu.eudat.service.mail.MailService; import jakarta.mail.MessagingException; import java.util.List; import java.util.concurrent.CompletableFuture; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationServiceImpl.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationServiceImpl.java index 94e74e166..96db56535 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationServiceImpl.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/InvitationServiceImpl.java @@ -8,6 +8,7 @@ import eu.eudat.data.old.Invitation; import eu.eudat.data.old.UserDMP; import eu.eudat.data.old.UserInfo; import eu.eudat.models.data.invitation.Properties; +import eu.eudat.service.mail.MailService; import eu.eudat.service.mail.SimpleMail; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/MailService.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/MailService.java deleted file mode 100644 index d901b77fd..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/MailService.java +++ /dev/null @@ -1,14 +0,0 @@ -package eu.eudat.logic.services.utilities; - -import eu.eudat.service.mail.SimpleMail; - -import jakarta.mail.MessagingException; - - -public interface MailService { - void sendSimpleMail(SimpleMail mail) throws MessagingException; - - String getMailTemplateContent(String resourceTemplate); - - String getMailTemplateSubject(); -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/MailServiceImpl.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/MailServiceImpl.java deleted file mode 100644 index 091a925c3..000000000 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/MailServiceImpl.java +++ /dev/null @@ -1,139 +0,0 @@ -package eu.eudat.logic.services.utilities; - -import eu.eudat.service.mail.SimpleMail; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationContext; -import org.springframework.core.env.Environment; -import org.springframework.core.io.Resource; -import org.springframework.mail.javamail.JavaMailSender; -import org.springframework.stereotype.Service; - -import jakarta.mail.BodyPart; -import jakarta.mail.Message; -import jakarta.mail.MessagingException; -import jakarta.mail.internet.MimeBodyPart; -import jakarta.mail.internet.MimeMessage; -import jakarta.mail.internet.MimeMultipart; -import java.io.*; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - - -@Service("mailService") -public class MailServiceImpl implements MailService { - private static final Logger logger = LoggerFactory.getLogger(MailServiceImpl.class); - - private Environment env; - - private JavaMailSender emailSender; - - private ApplicationContext applicationContext; - - @Autowired - public MailServiceImpl(Environment env, JavaMailSender emailSender, ApplicationContext applicationContext) { - this.env = env; - this.emailSender = emailSender; - this.applicationContext = applicationContext; - } - - @Override - public void sendSimpleMail(SimpleMail mail) throws MessagingException { - List imageSources = parseImages(mail.getContent()); - List cids = new ArrayList<>(); - if (!imageSources.isEmpty()) { - for (int i = 0; i < imageSources.size(); i++) { - cids.add(UUID.randomUUID().toString()); - } - mail.setContent(replaceImageSources(mail.getContent(), cids)); - } - MimeMultipart content = new MimeMultipart("related"); - BodyPart messageBodyPart = new MimeBodyPart(); - messageBodyPart.setContent(mail.getContent(), "text/html; charset=UTF-8"); - content.addBodyPart(messageBodyPart); - if (!imageSources.isEmpty()) { - for (int i =0; i < imageSources.size(); i++) { - MimeBodyPart imagePart = new MimeBodyPart(); - try { - imagePart.attachFile(applicationContext.getResource(imageSources.get(i)).getFile()); - imagePart.setContentID("<" + cids.get(i) + ">"); - imagePart.setDisposition(MimeBodyPart.INLINE); - content.addBodyPart(imagePart); - } catch (IOException | MessagingException e) { - logger.error(e.getMessage(), e); - } - } - } - MimeMessage message = this.emailSender.createMimeMessage(); - message.setSubject(mail.getSubject()); - message.setContent(content); - message.addRecipients(Message.RecipientType.TO, mail.getTo()); - message.setFrom(env.getProperty("mail.from")); - this.emailSender.send(message); - } - - public Environment getEnv() { - return env; - } - - @Override - public String getMailTemplateContent(String resourceTemplate) { - Resource resource = applicationContext.getResource(resourceTemplate); - try { - InputStream inputStream = resource.getInputStream(); - StringWriter writer = new StringWriter(); - IOUtils.copy(inputStream, writer, "UTF-8"); - inputStream.close(); - return writer.toString(); - } catch (IOException e) { - logger.error(e.getMessage(), e); - } - return ""; - } - - @Override - public String getMailTemplateSubject() { - return env.getProperty("mail.subject"); - } - - private List parseImages(String content) { - List imagePaths = new ArrayList<>(); - - int lastIndex = 0; - - while (lastIndex != -1) { - lastIndex = content.indexOf("img src=\"", lastIndex); - - if (lastIndex != -1) { - String imagePath = content.substring(lastIndex + 9, content.indexOf("\"", lastIndex + 9)); - if (!imagePath.contains("data:image/png;base64")) { - imagePaths.add(imagePath); - } - lastIndex++; - } - } - - return imagePaths; - } - - private String replaceImageSources(String content, List cids) { - - int lastIndex = 0; - int cidIndex = 0; - - while (lastIndex != -1) { - lastIndex = content.indexOf("img src=\"", lastIndex); - - if (lastIndex != -1) { - content = content.replace(content.substring(lastIndex + 9, content.indexOf("\"", lastIndex + 9)), "cid:" + cids.get(cidIndex)); - lastIndex ++; - cidIndex ++; - } - } - - return content; - } -} diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/UtilitiesService.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/UtilitiesService.java index 58e9c499b..2959f4433 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/UtilitiesService.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/UtilitiesService.java @@ -1,6 +1,7 @@ package eu.eudat.logic.services.utilities; import eu.eudat.logic.services.forms.VisibilityRuleService; +import eu.eudat.service.mail.MailService; /** * Created by ikalyvas on 3/1/2018. diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/UtilitiesServiceImpl.java b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/UtilitiesServiceImpl.java index 9bc943280..2e50c26fb 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/UtilitiesServiceImpl.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/services/utilities/UtilitiesServiceImpl.java @@ -2,6 +2,7 @@ package eu.eudat.logic.services.utilities; import eu.eudat.logic.services.forms.VisibilityRuleService; import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl; +import eu.eudat.service.mail.MailService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java index b2d626de8..9cc27739a 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/rda/mapper/DatasetRDAMapper.java @@ -11,7 +11,6 @@ import eu.eudat.logic.managers.DatasetManager; import eu.eudat.logic.services.ApiContext; import eu.eudat.logic.utilities.helpers.StreamDistinctBy; import eu.eudat.logic.utilities.json.JsonSearcher; -import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel; import eu.eudat.models.data.datasetwizard.DatasetWizardModel; import eu.eudat.models.rda.*; import org.json.JSONObject; @@ -52,7 +51,7 @@ public class DatasetRDAMapper { } rda.setTitle(descriptionEntity.getLabel()); rda.setDescription(descriptionEntity.getDescription()); - rda.setAdditionalProperty("template", descriptionEntity.getProfile()); + rda.setAdditionalProperty("template", descriptionEntity.getDescriptionTemplate()); try { JSONObject jObject = new JSONObject(descriptionEntity.getProperties()); Map templateIdsToValues = jObject.toMap(); @@ -289,10 +288,10 @@ public class DatasetRDAMapper { entity.setDescription(rda.getDescription()); try { DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString())); - entity.setProfile(profile.getId()); + entity.setDescriptionTemplate(profile.getId()); }catch(Exception e) { logger.warn(e.getMessage(), e); - entity.setProfile(defaultProfile.getId()); + entity.setDescriptionTemplate(defaultProfile.getId()); } try { Map properties = new HashMap<>();