description refactor
This commit is contained in:
parent
20873ca13e
commit
662c5ad7e8
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package eu.eudat.commons.types.description;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PropertyDefinitionEntity {
|
||||||
|
private List<FieldEntity> fields;
|
||||||
|
|
||||||
|
public List<FieldEntity> getFields() {
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFields(List<FieldEntity> fields) {
|
||||||
|
this.fields = fields;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
|
@ -1,4 +1,4 @@
|
||||||
package eu.eudat.commons.config.filepath;
|
package eu.eudat.configurations.filepath;
|
||||||
|
|
||||||
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
@ -6,65 +6,45 @@ import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
import eu.eudat.data.converters.DateToUTCConverter;
|
||||||
import eu.eudat.data.converters.enums.DescriptionStatusConverter;
|
import eu.eudat.data.converters.enums.DescriptionStatusConverter;
|
||||||
import eu.eudat.data.converters.enums.IsActiveConverter;
|
import eu.eudat.data.converters.enums.IsActiveConverter;
|
||||||
import eu.eudat.data.old.*;
|
|
||||||
import eu.eudat.data.old.helpers.EntityBinder;
|
import eu.eudat.data.old.helpers.EntityBinder;
|
||||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
|
||||||
import org.hibernate.annotations.Type;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"Description\"")
|
@Table(name = "\"Description\"")
|
||||||
public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
|
|
||||||
public static Set<String> getHints() {
|
|
||||||
return hints;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
|
|
||||||
|
|
||||||
@Id
|
@Id
|
||||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
public static final String _id = "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;
|
private String label;
|
||||||
|
public static final int _labelLength = 250;
|
||||||
|
|
||||||
public static final String _label = "label";
|
public static final String _label = "label";
|
||||||
|
|
||||||
@Column(name = "dmp", columnDefinition = "uuid")
|
@Column(name = "dmp", columnDefinition = "uuid", nullable = false)
|
||||||
private UUID dmp;
|
private UUID dmp;
|
||||||
|
|
||||||
public static final String _dmp = "dmp";
|
public static final String _dmp = "dmp";
|
||||||
|
|
||||||
@Column(name = "uri", length = 250)
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
public static final String _uri = "uri";
|
|
||||||
|
|
||||||
@Column(name = "properties")
|
@Column(name = "properties")
|
||||||
private String properties;
|
private String properties;
|
||||||
|
|
||||||
public static final String _properties = "properties";
|
public static final String _properties = "properties";
|
||||||
|
|
||||||
//TODO: (thgiannos) Previously 'DescriptionTemplate'
|
@Column(name = "description_template", columnDefinition = "uuid", nullable = false)
|
||||||
@Column(name = "profile", columnDefinition = "uuid")
|
private UUID descriptionTemplate;
|
||||||
private UUID profile;
|
|
||||||
|
|
||||||
public static final String _profile = "profile";
|
public static final String _descriptionTemplate = "descriptionTemplate";
|
||||||
|
|
||||||
@Column(name = "reference")
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
public static final String _reference = "reference";
|
|
||||||
|
|
||||||
@Column(name = "status", nullable = false)
|
@Column(name = "status", nullable = false)
|
||||||
@Convert(converter = DescriptionStatusConverter.class)
|
@Convert(converter = DescriptionStatusConverter.class)
|
||||||
|
@ -77,16 +57,6 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
|
|
||||||
public static final String _description = "description";
|
public static final String _description = "description";
|
||||||
|
|
||||||
@Column(name = "dmp_section_index", nullable = false)
|
|
||||||
private Integer dmpSectionIndex;
|
|
||||||
|
|
||||||
public static final String _dmpSectionIndex = "dmpSectionIndex";
|
|
||||||
|
|
||||||
@Column(name = "creator", columnDefinition = "uuid")
|
|
||||||
private UUID creator;
|
|
||||||
|
|
||||||
public static final String _creator = "creator";
|
|
||||||
|
|
||||||
@Column(name = "created_at", nullable = false)
|
@Column(name = "created_at", nullable = false)
|
||||||
private Instant createdAt;
|
private Instant createdAt;
|
||||||
|
|
||||||
|
@ -109,6 +79,16 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
|
|
||||||
public static final String _finalizedAt = "finalizedAt";
|
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() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -133,14 +113,6 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
this.dmp = dmp;
|
this.dmp = dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProperties() {
|
public String getProperties() {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
@ -149,20 +121,12 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getProfile() {
|
public UUID getDescriptionTemplate() {
|
||||||
return profile;
|
return descriptionTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfile(UUID profile) {
|
public void setDescriptionTemplate(UUID descriptionTemplate) {
|
||||||
this.profile = profile;
|
this.descriptionTemplate = descriptionTemplate;
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionStatus getStatus() {
|
public DescriptionStatus getStatus() {
|
||||||
|
@ -181,22 +145,6 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getDmpSectionIndex() {
|
|
||||||
return dmpSectionIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDmpSectionIndex(Integer dmpSectionIndex) {
|
|
||||||
this.dmpSectionIndex = dmpSectionIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getCreator() {
|
|
||||||
return creator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreator(UUID creator) {
|
|
||||||
this.creator = creator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instant getCreatedAt() {
|
public Instant getCreatedAt() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
@ -229,6 +177,22 @@ public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
this.finalizedAt = finalizedAt;
|
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
|
@Override
|
||||||
public void update(DescriptionEntity entity) {
|
public void update(DescriptionEntity entity) {
|
||||||
// this.setUri(entity.getUri());
|
// this.setUri(entity.getUri());
|
||||||
|
|
|
@ -18,10 +18,10 @@ public class DescriptionReferenceEntity {
|
||||||
|
|
||||||
public static final String _id = "id";
|
public static final String _id = "id";
|
||||||
|
|
||||||
@Column(name = "data")
|
// @Column(name = "data")
|
||||||
private String data;
|
// private String data;
|
||||||
|
//
|
||||||
public static final String _data = "data";
|
// public static final String _data = "data";
|
||||||
|
|
||||||
@Column(name = "description_id", columnDefinition = "uuid", nullable = false)
|
@Column(name = "description_id", columnDefinition = "uuid", nullable = false)
|
||||||
private UUID descriptionId;
|
private UUID descriptionId;
|
||||||
|
@ -59,14 +59,6 @@ public class DescriptionReferenceEntity {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(String data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getDescriptionId() {
|
public UUID getDescriptionId() {
|
||||||
return descriptionId;
|
return descriptionId;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package eu.eudat.model;
|
||||||
|
|
||||||
import eu.eudat.commons.enums.DescriptionStatus;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.model.descriptionproperties.PropertyDefinition;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -21,21 +22,13 @@ public class Description {
|
||||||
|
|
||||||
public static final String _dmp = "dmp";
|
public static final String _dmp = "dmp";
|
||||||
|
|
||||||
private String uri;
|
private PropertyDefinition properties;
|
||||||
|
|
||||||
public static final String _uri = "uri";
|
|
||||||
|
|
||||||
private String properties;
|
|
||||||
|
|
||||||
public static final String _properties = "properties";
|
public static final String _properties = "properties";
|
||||||
|
|
||||||
private UUID profile;
|
private DescriptionTemplate descriptionTemplate;
|
||||||
|
|
||||||
public static final String _profile = "profile";
|
public static final String _descriptionTemplate = "descriptionTemplate";
|
||||||
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
public static final String _reference = "reference";
|
|
||||||
|
|
||||||
private DescriptionStatus status;
|
private DescriptionStatus status;
|
||||||
|
|
||||||
|
@ -45,13 +38,9 @@ public class Description {
|
||||||
|
|
||||||
public static final String _description = "description";
|
public static final String _description = "description";
|
||||||
|
|
||||||
private Integer dmpSectionIndex;
|
private UUID createdBy;
|
||||||
|
|
||||||
public static final String _dmpSectionIndex = "dmpSectionIndex";
|
public static final String _createdBy = "createdBy";
|
||||||
|
|
||||||
private UUID creator;
|
|
||||||
|
|
||||||
public static final String _creator = "creator";
|
|
||||||
|
|
||||||
private Instant createdAt;
|
private Instant createdAt;
|
||||||
|
|
||||||
|
@ -77,6 +66,14 @@ public class Description {
|
||||||
|
|
||||||
public static final String _descriptionReferences = "descriptionReferences";
|
public static final String _descriptionReferences = "descriptionReferences";
|
||||||
|
|
||||||
|
private List<DescriptionTag> descriptionTags;
|
||||||
|
|
||||||
|
public static final String _descriptionTags = "descriptionTags";
|
||||||
|
|
||||||
|
private UUID dmpDescriptionTemplate;
|
||||||
|
|
||||||
|
public static final String _dmpDescriptionTemplate = "dmpDescriptionTemplate";
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
@ -101,38 +98,14 @@ public class Description {
|
||||||
this.dmp = dmp;
|
this.dmp = dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUri() {
|
public PropertyDefinition getProperties() {
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProperties() {
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProperties(String properties) {
|
public void setProperties(PropertyDefinition properties) {
|
||||||
this.properties = 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() {
|
public DescriptionStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -149,28 +122,12 @@ public class Description {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getDmpSectionIndex() {
|
public UUID getCreatedBy() {
|
||||||
return dmpSectionIndex;
|
return createdBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmpSectionIndex(Integer dmpSectionIndex) {
|
public void setCreatedBy(UUID createdBy) {
|
||||||
this.dmpSectionIndex = dmpSectionIndex;
|
this.createdBy = createdBy;
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getCreator() {
|
|
||||||
return creator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreator(UUID creator) {
|
|
||||||
this.creator = creator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Instant getCreatedAt() {
|
|
||||||
return createdAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCreatedAt(Instant createdAt) {
|
|
||||||
this.createdAt = createdAt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant getUpdatedAt() {
|
public Instant getUpdatedAt() {
|
||||||
|
@ -213,4 +170,35 @@ public class Description {
|
||||||
this.descriptionReferences = descriptionReferences;
|
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<DescriptionTag> getDescriptionTags() {
|
||||||
|
return descriptionTags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescriptionTags(List<DescriptionTag> descriptionTags) {
|
||||||
|
this.descriptionTags = descriptionTags;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,10 +11,6 @@ public class DescriptionReference {
|
||||||
|
|
||||||
public static final String _id = "id";
|
public static final String _id = "id";
|
||||||
|
|
||||||
private String data;
|
|
||||||
|
|
||||||
public static final String _data = "data";
|
|
||||||
|
|
||||||
private Description description;
|
private Description description;
|
||||||
|
|
||||||
public static final String _description = "description";
|
public static final String _description = "description";
|
||||||
|
@ -43,14 +39,6 @@ public class DescriptionReference {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getData() {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setData(String data) {
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Description getDescription() {
|
public Description getDescription() {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -70,24 +70,18 @@ public class DescriptionBuilder extends BaseBuilder<Description, DescriptionEnti
|
||||||
m.setId(d.getId());
|
m.setId(d.getId());
|
||||||
if (fields.hasField(this.asIndexer(Description._label)))
|
if (fields.hasField(this.asIndexer(Description._label)))
|
||||||
m.setLabel(d.getLabel());
|
m.setLabel(d.getLabel());
|
||||||
if (fields.hasField(this.asIndexer(Description._uri)))
|
// if (fields.hasField(this.asIndexer(Description._properties)))
|
||||||
m.setUri(d.getUri());
|
// m.setProperties(d.getProperties());
|
||||||
if (fields.hasField(this.asIndexer(Description._properties)))
|
// if (fields.hasField(this.asIndexer(Description._profile)))
|
||||||
m.setProperties(d.getProperties());
|
// m.setProfile(d.getDescriptionTemplate());
|
||||||
if (fields.hasField(this.asIndexer(Description._profile)))
|
|
||||||
m.setProfile(d.getProfile());
|
|
||||||
if (fields.hasField(this.asIndexer(Description._reference)))
|
|
||||||
m.setReference(d.getReference());
|
|
||||||
if (fields.hasField(this.asIndexer(Description._status)))
|
if (fields.hasField(this.asIndexer(Description._status)))
|
||||||
m.setStatus(d.getStatus());
|
m.setStatus(d.getStatus());
|
||||||
if (fields.hasField(this.asIndexer(Description._description)))
|
if (fields.hasField(this.asIndexer(Description._description)))
|
||||||
m.setDescription(d.getDescription());
|
m.setDescription(d.getDescription());
|
||||||
if (fields.hasField(this.asIndexer(Description._creator)))
|
// if (fields.hasField(this.asIndexer(Description._creator)))
|
||||||
m.setCreator(d.getCreator());
|
// m.setCreatedBy(d.getDmpDescriptionTemplate());
|
||||||
if (fields.hasField(this.asIndexer(Description._dmpSectionIndex)))
|
// if (fields.hasField(this.asIndexer(Description._createdAt)))
|
||||||
m.setDmpSectionIndex(d.getDmpSectionIndex());
|
// m.setCreatedAt(d.getCreatedAt());
|
||||||
if (fields.hasField(this.asIndexer(Description._createdAt)))
|
|
||||||
m.setCreatedAt(d.getCreatedAt());
|
|
||||||
if (fields.hasField(this.asIndexer(Description._updatedAt)))
|
if (fields.hasField(this.asIndexer(Description._updatedAt)))
|
||||||
m.setUpdatedAt(d.getUpdatedAt());
|
m.setUpdatedAt(d.getUpdatedAt());
|
||||||
if (fields.hasField(this.asIndexer(Description._isActive)))
|
if (fields.hasField(this.asIndexer(Description._isActive)))
|
||||||
|
|
|
@ -67,8 +67,6 @@ public class DescriptionReferenceBuilder extends BaseBuilder<DescriptionReferenc
|
||||||
DescriptionReference m = new DescriptionReference();
|
DescriptionReference m = new DescriptionReference();
|
||||||
if (fields.hasField(this.asIndexer(DescriptionReference._id)))
|
if (fields.hasField(this.asIndexer(DescriptionReference._id)))
|
||||||
m.setId(d.getId());
|
m.setId(d.getId());
|
||||||
if (fields.hasField(this.asIndexer(DescriptionReference._data)))
|
|
||||||
m.setData(d.getData());
|
|
||||||
if (fields.hasField(this.asIndexer(DescriptionReference._createdAt)))
|
if (fields.hasField(this.asIndexer(DescriptionReference._createdAt)))
|
||||||
m.setCreatedAt(d.getCreatedAt());
|
m.setCreatedAt(d.getCreatedAt());
|
||||||
if (fields.hasField(this.asIndexer(DescriptionReference._updatedAt)))
|
if (fields.hasField(this.asIndexer(DescriptionReference._updatedAt)))
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package eu.eudat.model.descriptionproperties;
|
||||||
|
|
||||||
|
|
||||||
|
public class Field {
|
||||||
|
|
||||||
|
public final static String _id = "id";
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
public final static String _value = "value";
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package eu.eudat.model.descriptionproperties;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PropertyDefinition {
|
||||||
|
|
||||||
|
public final static String _fields = "fields";
|
||||||
|
private List<Field> fields;
|
||||||
|
|
||||||
|
}
|
|
@ -72,7 +72,7 @@ public class DmpEntityDepositMapper {
|
||||||
model.setLabel(entity.getLabel());
|
model.setLabel(entity.getLabel());
|
||||||
model.setDescription(entity.getDescription());
|
model.setDescription(entity.getDescription());
|
||||||
model.setProperties(entity.getProperties());
|
model.setProperties(entity.getProperties());
|
||||||
DescriptionTemplateEntity descriptionTemplateEntity = getDescriptionTemplate(entity.getProfile());
|
DescriptionTemplateEntity descriptionTemplateEntity = getDescriptionTemplate(entity.getDescriptionTemplate());
|
||||||
model.setProfileDefinition(descriptionTemplateEntity.getDefinition());
|
model.setProfileDefinition(descriptionTemplateEntity.getDefinition());
|
||||||
model.setFields(fromDefinitionAndProperties(descriptionTemplateEntity.getDefinition(), entity.getProperties()));
|
model.setFields(fromDefinitionAndProperties(descriptionTemplateEntity.getDefinition(), entity.getProperties()));
|
||||||
return model;
|
return model;
|
||||||
|
|
|
@ -15,20 +15,14 @@ public class DescriptionPersist {
|
||||||
|
|
||||||
private UUID dmp;
|
private UUID dmp;
|
||||||
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
private String properties;
|
private String properties;
|
||||||
|
|
||||||
private UUID profile;
|
private UUID profile;
|
||||||
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
private DescriptionStatus status;
|
private DescriptionStatus status;
|
||||||
|
|
||||||
private String description;
|
private String description;
|
||||||
|
|
||||||
private Integer dmpSectionIndex;
|
|
||||||
|
|
||||||
private IsActive isActive;
|
private IsActive isActive;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
|
@ -55,14 +49,6 @@ public class DescriptionPersist {
|
||||||
this.dmp = dmp;
|
this.dmp = dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProperties() {
|
public String getProperties() {
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
@ -79,14 +65,6 @@ public class DescriptionPersist {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DescriptionStatus getStatus() {
|
public DescriptionStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -103,14 +81,6 @@ public class DescriptionPersist {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getDmpSectionIndex() {
|
|
||||||
return dmpSectionIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDmpSectionIndex(Integer dmpSectionIndex) {
|
|
||||||
this.dmpSectionIndex = dmpSectionIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IsActive getIsActive() {
|
public IsActive getIsActive() {
|
||||||
return isActive;
|
return isActive;
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,22 +201,16 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
return DescriptionEntity._dmp;
|
return DescriptionEntity._dmp;
|
||||||
else if (item.match(Description._dmp))
|
else if (item.match(Description._dmp))
|
||||||
return DescriptionEntity._dmp;
|
return DescriptionEntity._dmp;
|
||||||
else if (item.match(Description._uri))
|
else if (item.prefix(Description._properties))
|
||||||
return DescriptionEntity._uri;
|
|
||||||
else if (item.match(Description._properties))
|
|
||||||
return DescriptionEntity._properties;
|
return DescriptionEntity._properties;
|
||||||
else if (item.match(Description._profile))
|
else if (item.prefix(Description._descriptionTemplate))
|
||||||
return DescriptionEntity._profile;
|
return DescriptionEntity._descriptionTemplate;
|
||||||
else if (item.match(Description._reference))
|
|
||||||
return DescriptionEntity._reference;
|
|
||||||
else if (item.match(Description._status))
|
else if (item.match(Description._status))
|
||||||
return DescriptionEntity._status;
|
return DescriptionEntity._status;
|
||||||
else if (item.match(Description._description))
|
else if (item.match(Description._description))
|
||||||
return DescriptionEntity._description;
|
return DescriptionEntity._description;
|
||||||
else if (item.match(Description._dmpSectionIndex))
|
else if (item.match(Description._createdBy))
|
||||||
return DescriptionEntity._dmpSectionIndex;
|
return DescriptionEntity._createdBy;
|
||||||
else if (item.match(Description._creator))
|
|
||||||
return DescriptionEntity._creator;
|
|
||||||
else if (item.match(Description._createdAt))
|
else if (item.match(Description._createdAt))
|
||||||
return DescriptionEntity._createdAt;
|
return DescriptionEntity._createdAt;
|
||||||
else if (item.match(Description._updatedAt))
|
else if (item.match(Description._updatedAt))
|
||||||
|
@ -225,6 +219,8 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
return DescriptionEntity._isActive;
|
return DescriptionEntity._isActive;
|
||||||
else if (item.match(Description._finalizedAt))
|
else if (item.match(Description._finalizedAt))
|
||||||
return DescriptionEntity._finalizedAt;
|
return DescriptionEntity._finalizedAt;
|
||||||
|
else if (item.match(Description._dmpDescriptionTemplate))
|
||||||
|
return DescriptionEntity._dmpDescriptionTemplate;
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -235,18 +231,16 @@ public class DescriptionQuery extends QueryBase<DescriptionEntity> {
|
||||||
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._id, UUID.class));
|
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionEntity._id, UUID.class));
|
||||||
item.setLabel(QueryBase.convertSafe(tuple, columns, DescriptionEntity._label, String.class));
|
item.setLabel(QueryBase.convertSafe(tuple, columns, DescriptionEntity._label, String.class));
|
||||||
item.setDmp(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmp, UUID.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.setProperties(QueryBase.convertSafe(tuple, columns, DescriptionEntity._properties, String.class));
|
||||||
item.setProfile(QueryBase.convertSafe(tuple, columns, DescriptionEntity._profile, UUID.class));
|
item.setDescriptionTemplate(QueryBase.convertSafe(tuple, columns, DescriptionEntity._descriptionTemplate, UUID.class));
|
||||||
item.setReference(QueryBase.convertSafe(tuple, columns, DescriptionEntity._reference, String.class));
|
|
||||||
item.setStatus(QueryBase.convertSafe(tuple, columns, DescriptionEntity._status, DescriptionStatus.class));
|
item.setStatus(QueryBase.convertSafe(tuple, columns, DescriptionEntity._status, DescriptionStatus.class));
|
||||||
item.setDescription(QueryBase.convertSafe(tuple, columns, DescriptionEntity._description, String.class));
|
item.setDescription(QueryBase.convertSafe(tuple, columns, DescriptionEntity._description, String.class));
|
||||||
item.setDmpSectionIndex(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpSectionIndex, Integer.class));
|
item.setDmpDescriptionTemplate(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdBy, UUID.class));
|
||||||
item.setCreator(QueryBase.convertSafe(tuple, columns, DescriptionEntity._creator, UUID.class));
|
|
||||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdAt, Instant.class));
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._createdAt, Instant.class));
|
||||||
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._updatedAt, Instant.class));
|
item.setUpdatedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._updatedAt, Instant.class));
|
||||||
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionEntity._isActive, IsActive.class));
|
item.setIsActive(QueryBase.convertSafe(tuple, columns, DescriptionEntity._isActive, IsActive.class));
|
||||||
item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._finalizedAt, Instant.class));
|
item.setFinalizedAt(QueryBase.convertSafe(tuple, columns, DescriptionEntity._finalizedAt, Instant.class));
|
||||||
|
item.setDmpDescriptionTemplate(QueryBase.convertSafe(tuple, columns, DescriptionEntity._dmpDescriptionTemplate, UUID.class));
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -184,8 +184,6 @@ public class DescriptionReferenceQuery extends QueryBase<DescriptionReferenceEnt
|
||||||
protected String fieldNameOf(FieldResolver item) {
|
protected String fieldNameOf(FieldResolver item) {
|
||||||
if (item.match(DescriptionReference._id))
|
if (item.match(DescriptionReference._id))
|
||||||
return DescriptionReferenceEntity._id;
|
return DescriptionReferenceEntity._id;
|
||||||
if (item.match(DescriptionReference._data))
|
|
||||||
return DescriptionReferenceEntity._data;
|
|
||||||
if (item.match(DescriptionReference._description))
|
if (item.match(DescriptionReference._description))
|
||||||
return DescriptionReferenceEntity._descriptionId;
|
return DescriptionReferenceEntity._descriptionId;
|
||||||
else if (item.prefix(DescriptionReference._description))
|
else if (item.prefix(DescriptionReference._description))
|
||||||
|
@ -208,7 +206,6 @@ public class DescriptionReferenceQuery extends QueryBase<DescriptionReferenceEnt
|
||||||
protected DescriptionReferenceEntity convert(Tuple tuple, Set<String> columns) {
|
protected DescriptionReferenceEntity convert(Tuple tuple, Set<String> columns) {
|
||||||
DescriptionReferenceEntity item = new DescriptionReferenceEntity();
|
DescriptionReferenceEntity item = new DescriptionReferenceEntity();
|
||||||
item.setId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._id, UUID.class));
|
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.setDescriptionId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._descriptionId, UUID.class));
|
||||||
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._referenceId, UUID.class));
|
item.setReferenceId(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._referenceId, UUID.class));
|
||||||
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._createdAt, Instant.class));
|
item.setCreatedAt(QueryBase.convertSafe(tuple, columns, DescriptionReferenceEntity._createdAt, Instant.class));
|
||||||
|
|
|
@ -27,6 +27,7 @@ public class DescriptionTemplateQuery extends QueryBase<DescriptionTemplateEntit
|
||||||
private String like;
|
private String like;
|
||||||
|
|
||||||
private Collection<UUID> ids;
|
private Collection<UUID> ids;
|
||||||
|
|
||||||
private Collection<UUID> groupIds;
|
private Collection<UUID> groupIds;
|
||||||
|
|
||||||
private Collection<IsActive> isActives;
|
private Collection<IsActive> isActives;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
import gr.cite.tools.data.query.Lookup;
|
import gr.cite.tools.data.query.Lookup;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ public class DescriptionTemplateLookup extends Lookup {
|
||||||
private String like;
|
private String like;
|
||||||
|
|
||||||
private List<IsActive> isActive;
|
private List<IsActive> isActive;
|
||||||
|
private List<UUID> groupIds;
|
||||||
|
|
||||||
private List<DescriptionTemplateStatus> statuses;
|
private List<DescriptionTemplateStatus> statuses;
|
||||||
|
|
||||||
|
@ -71,12 +73,22 @@ public class DescriptionTemplateLookup extends Lookup {
|
||||||
this.typeIds = typeIds;
|
this.typeIds = typeIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<UUID> getGroupIds() {
|
||||||
|
return groupIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupIds(List<UUID> groupIds) {
|
||||||
|
this.groupIds = groupIds;
|
||||||
|
}
|
||||||
|
|
||||||
public DescriptionTemplateQuery enrich(QueryFactory queryFactory) {
|
public DescriptionTemplateQuery enrich(QueryFactory queryFactory) {
|
||||||
DescriptionTemplateQuery query = queryFactory.query(DescriptionTemplateQuery.class);
|
DescriptionTemplateQuery query = queryFactory.query(DescriptionTemplateQuery.class);
|
||||||
if (this.like != null)
|
if (this.like != null)
|
||||||
query.like(this.like);
|
query.like(this.like);
|
||||||
if (this.isActive != null)
|
if (this.isActive != null)
|
||||||
query.isActive(this.isActive);
|
query.isActive(this.isActive);
|
||||||
|
if (this.groupIds != null)
|
||||||
|
query.groupIds(this.groupIds);
|
||||||
if (this.statuses != null)
|
if (this.statuses != null)
|
||||||
query.statuses(this.statuses);
|
query.statuses(this.statuses);
|
||||||
if (this.ids != null)
|
if (this.ids != null)
|
||||||
|
|
|
@ -108,13 +108,10 @@ public class DescriptionServiceImpl implements DescriptionService {
|
||||||
|
|
||||||
data.setLabel(model.getLabel());
|
data.setLabel(model.getLabel());
|
||||||
data.setDmp(model.getDmp());
|
data.setDmp(model.getDmp());
|
||||||
data.setUri(model.getUri());
|
|
||||||
data.setProperties(model.getProperties());
|
data.setProperties(model.getProperties());
|
||||||
data.setProfile(model.getProfile());
|
data.setDescriptionTemplate(model.getProfile());
|
||||||
data.setReference(model.getReference());
|
|
||||||
data.setStatus(model.getStatus());
|
data.setStatus(model.getStatus());
|
||||||
data.setDescription(model.getDescription());
|
data.setDescription(model.getDescription());
|
||||||
data.setDmpSectionIndex(model.getDmpSectionIndex());
|
|
||||||
data.setUpdatedAt(Instant.now());
|
data.setUpdatedAt(Instant.now());
|
||||||
if (isUpdate)
|
if (isUpdate)
|
||||||
this.entityManager.merge(data);
|
this.entityManager.merge(data);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.JsonHandlingService;
|
import eu.eudat.commons.JsonHandlingService;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
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.DescriptionTemplateStatus;
|
||||||
import eu.eudat.commons.enums.FieldType;
|
import eu.eudat.commons.enums.FieldType;
|
||||||
import eu.eudat.commons.enums.IsActive;
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
|
|
@ -20,10 +20,7 @@ import jakarta.persistence.criteria.Join;
|
||||||
import jakarta.persistence.criteria.JoinType;
|
import jakarta.persistence.criteria.JoinType;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Component("datasetDao")
|
@Component("datasetDao")
|
||||||
|
@ -34,7 +31,7 @@ public class DatasetDaoImpl extends DatabaseAccess<DescriptionEntity> implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<DescriptionEntity> getWithCriteria(DatasetCriteria criteria) {
|
public QueryableList<DescriptionEntity> getWithCriteria(DatasetCriteria criteria) {
|
||||||
QueryableList<DescriptionEntity> query = getDatabaseService().getQueryable(DescriptionEntity.getHints(), DescriptionEntity.class);
|
QueryableList<DescriptionEntity> query = getDatabaseService().getQueryable(new HashSet<>(Arrays.asList("datasetListingModel")), DescriptionEntity.class);
|
||||||
if (criteria.getIsPublic() != null && criteria.getIsPublic()) {
|
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("dmp").get("isPublic"), true));
|
||||||
query.where((builder, root) -> builder.equal(root.get("status"), DescriptionStatus.Finalized));
|
query.where((builder, root) -> builder.equal(root.get("status"), DescriptionStatus.Finalized));
|
||||||
|
@ -91,7 +88,7 @@ public class DatasetDaoImpl extends DatabaseAccess<DescriptionEntity> implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<DescriptionEntity> filterFromElastic(DatasetCriteria criteria, List<UUID> ids) {
|
public QueryableList<DescriptionEntity> filterFromElastic(DatasetCriteria criteria, List<UUID> ids) {
|
||||||
QueryableList<DescriptionEntity> query = getDatabaseService().getQueryable(DescriptionEntity.getHints(), DescriptionEntity.class);
|
QueryableList<DescriptionEntity> query = getDatabaseService().getQueryable(new HashSet<>(Arrays.asList("datasetListingModel")), DescriptionEntity.class);
|
||||||
|
|
||||||
query.where(((builder, root) -> root.get("id").in(ids)));
|
query.where(((builder, root) -> root.get("id").in(ids)));
|
||||||
if (!criteria.getAllVersions())
|
if (!criteria.getAllVersions())
|
||||||
|
@ -113,13 +110,13 @@ public class DatasetDaoImpl extends DatabaseAccess<DescriptionEntity> implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DescriptionEntity find(UUID id, String hint) throws InvalidApplicationException {
|
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();
|
.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
|
@Override
|
||||||
public DescriptionEntity isPublicDataset(UUID id) throws InvalidApplicationException {
|
public DescriptionEntity isPublicDataset(UUID id) throws InvalidApplicationException {
|
||||||
QueryableList<DescriptionEntity> query = getDatabaseService().getQueryable(DescriptionEntity.getHints(), DescriptionEntity.class);
|
QueryableList<DescriptionEntity> query = getDatabaseService().getQueryable(new HashSet<>(Arrays.asList("datasetListingModel")), DescriptionEntity.class);
|
||||||
query.where(((builder, root) -> builder.equal(root.get("id"), id)));
|
query.where(((builder, root) -> builder.equal(root.get("id"), id)));
|
||||||
|
|
||||||
return query.withHint("datasetListingModel").getSingle();
|
return query.withHint("datasetListingModel").getSingle();
|
||||||
|
|
|
@ -494,7 +494,7 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
List<DescriptionEntity> descriptionEntityList = dmp1.getDataset().stream().filter(dataset -> dataset.getIsActive() != IsActive.Inactive).collect(Collectors.toList());
|
List<DescriptionEntity> descriptionEntityList = dmp1.getDataset().stream().filter(dataset -> dataset.getIsActive() != IsActive.Inactive).collect(Collectors.toList());
|
||||||
for (DescriptionEntity descriptionEntity : descriptionEntityList) {
|
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.");
|
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()))
|
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.setId(dataset1.getId().toString());
|
||||||
datasetElastic.setLabel(dataset1.getLabel());
|
datasetElastic.setLabel(dataset1.getLabel());
|
||||||
datasetElastic.setDescription(dataset1.getDescription());
|
datasetElastic.setDescription(dataset1.getDescription());
|
||||||
datasetElastic.setTemplate(dataset1.getProfile());
|
datasetElastic.setTemplate(dataset1.getDescriptionTemplate());
|
||||||
datasetElastic.setStatus(dataset1.getStatus().getValue());
|
datasetElastic.setStatus(dataset1.getStatus().getValue());
|
||||||
datasetElastic.setDmp(dataset1.getDmp());
|
datasetElastic.setDmp(dataset1.getDmp());
|
||||||
datasetElastic.setGroup(dmp.getGroupId());
|
datasetElastic.setGroup(dmp.getGroupId());
|
||||||
|
@ -1549,7 +1549,7 @@ public class DataManagementPlanManager {
|
||||||
.filter(item -> item.getStatus() != DescriptionStatus.Canceled)
|
.filter(item -> item.getStatus() != DescriptionStatus.Canceled)
|
||||||
.filter(item -> item.getIsActive() != IsActive.Inactive)
|
.filter(item -> item.getIsActive() != IsActive.Inactive)
|
||||||
.filter(item -> !isPublic && !isFinalized || item.getStatus() == DescriptionStatus.Finalized)
|
.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))
|
.sorted(Comparator.comparing(DescriptionEntity::getCreatedAt))
|
||||||
.forEach(datasetEntity -> {
|
.forEach(datasetEntity -> {
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
@ -1600,7 +1600,7 @@ public class DataManagementPlanManager {
|
||||||
//runDatasetTemplate1.setBold(true);
|
//runDatasetTemplate1.setBold(true);
|
||||||
//runDatasetTemplate1.setFontSize(12);
|
//runDatasetTemplate1.setFontSize(12);
|
||||||
XWPFRun runDatasetTemplate = datasetTemplateParagraph.createRun();
|
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.setColor("116a78");
|
||||||
//runDatasetTemplate.setBold(true);
|
//runDatasetTemplate.setBold(true);
|
||||||
//runDatasetTemplate.setFontSize(12);
|
//runDatasetTemplate.setFontSize(12);
|
||||||
|
@ -1646,7 +1646,7 @@ public class DataManagementPlanManager {
|
||||||
runDatasetDescription1.setText("Description: ");
|
runDatasetDescription1.setText("Description: ");
|
||||||
runDatasetDescription1.setColor("000000");
|
runDatasetDescription1.setColor("000000");
|
||||||
XWPFRun runDatasetDescription = datasetDescParagraph.createRun();
|
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");
|
runDatasetDescription.setColor("116a78");
|
||||||
//wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
//wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.HTML, BigInteger.ZERO, 0);
|
||||||
|
|
||||||
|
@ -1921,17 +1921,18 @@ public class DataManagementPlanManager {
|
||||||
datasetElement.appendChild(datasetDescriptionElement);
|
datasetElement.appendChild(datasetDescriptionElement);
|
||||||
datasetDescriptionElement.setTextContent(descriptionEntity.getDescription());
|
datasetDescriptionElement.setTextContent(descriptionEntity.getDescription());
|
||||||
|
|
||||||
Element datasetDmpSectionIndex = xmlDoc.createElement("dmpSectionIndex");
|
//TODO
|
||||||
datasetElement.appendChild(datasetDmpSectionIndex);
|
// Element datasetDmpSectionIndex = xmlDoc.createElement("dmpSectionIndex");
|
||||||
datasetDmpSectionIndex.setTextContent(String.valueOf(descriptionEntity.getDmpSectionIndex()));
|
// datasetElement.appendChild(datasetDmpSectionIndex);
|
||||||
|
// datasetDmpSectionIndex.setTextContent(String.valueOf(descriptionEntity.getDmpSectionIndex()));
|
||||||
|
|
||||||
Element datsetProfileElement = xmlDoc.createElement("profile-id");
|
Element datsetProfileElement = xmlDoc.createElement("profile-id");
|
||||||
datasetElement.appendChild(datsetProfileElement);
|
datasetElement.appendChild(datsetProfileElement);
|
||||||
datsetProfileElement.setTextContent(descriptionEntity.getProfile().toString());
|
datsetProfileElement.setTextContent(descriptionEntity.getDescriptionTemplate().toString());
|
||||||
|
|
||||||
Element datsetProfileLabelElement = xmlDoc.createElement("profile-label");
|
Element datsetProfileLabelElement = xmlDoc.createElement("profile-label");
|
||||||
datasetElement.appendChild(datsetProfileLabelElement);
|
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();
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
@ -2231,11 +2232,12 @@ public class DataManagementPlanManager {
|
||||||
for (DatasetImportModels das: dataManagementPlans.get(0).getDatasetImportModels()) {
|
for (DatasetImportModels das: dataManagementPlans.get(0).getDatasetImportModels()) {
|
||||||
DescriptionEntity descriptionEntity = new DescriptionEntity();
|
DescriptionEntity descriptionEntity = new DescriptionEntity();
|
||||||
descriptionEntity.setLabel(das.getName());
|
descriptionEntity.setLabel(das.getName());
|
||||||
descriptionEntity.setDmpSectionIndex(das.getDmpSectionIndex());
|
//TODO
|
||||||
|
// descriptionEntity.setDmpSectionIndex(das.getDmpSectionIndex());
|
||||||
try {
|
try {
|
||||||
descriptionEntity.setProfile(das.getProfile());
|
descriptionEntity.setDescriptionTemplate(das.getProfile());
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
descriptionEntity.setProfile(associatedProfiles.get(0).getDescriptionTemplateId());
|
descriptionEntity.setDescriptionTemplate(associatedProfiles.get(0).getDescriptionTemplateId());
|
||||||
}
|
}
|
||||||
descriptionEntity.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels()));
|
descriptionEntity.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels()));
|
||||||
descriptionEntity.setStatus(DescriptionStatus.Saved);
|
descriptionEntity.setStatus(DescriptionStatus.Saved);
|
||||||
|
|
|
@ -309,7 +309,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
// Creates the Criteria to get all version of DescriptionTemplate in question.
|
// Creates the Criteria to get all version of DescriptionTemplate in question.
|
||||||
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
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<UUID> uuidList = new LinkedList<>();
|
List<UUID> uuidList = new LinkedList<>();
|
||||||
uuidList.add(profileId);
|
uuidList.add(profileId);
|
||||||
profileCriteria.setGroupIds(uuidList);
|
profileCriteria.setGroupIds(uuidList);
|
||||||
|
@ -340,7 +340,7 @@ public class DatasetManager {
|
||||||
DescriptionTemplateEntity profile = profiles.get(0);
|
DescriptionTemplateEntity profile = profiles.get(0);
|
||||||
|
|
||||||
// Check if the dataset is on the latest Version.
|
// 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);
|
dataset.setIsProfileLatestVersion(latestVersion);
|
||||||
|
|
||||||
eu.eudat.elastic.entities.Dataset datasetElastic;
|
eu.eudat.elastic.entities.Dataset datasetElastic;
|
||||||
|
@ -400,7 +400,7 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, DescriptionEntity descriptionEntityEntity) {
|
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());
|
datasetprofile.setStatus(dataset.getStatus().getValue());
|
||||||
if (descriptionEntityEntity.getProperties() != null) {
|
if (descriptionEntityEntity.getProperties() != null) {
|
||||||
JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
|
JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
|
||||||
|
@ -598,7 +598,7 @@ public class DatasetManager {
|
||||||
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, descriptionEntityEntity);
|
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, descriptionEntityEntity);
|
||||||
visibilityRuleService.setProperties(properties);
|
visibilityRuleService.setProperties(properties);
|
||||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
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 fileEnvelope = new FileEnvelope();
|
||||||
fileEnvelope.setFile(file);
|
fileEnvelope.setFile(file);
|
||||||
String label = descriptionEntityEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
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();
|
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);
|
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), descriptionEntity);
|
||||||
createExternalDatasetsIfTheyDontExist(descriptionEntity);
|
createExternalDatasetsIfTheyDontExist(descriptionEntity);
|
||||||
|
@ -652,7 +652,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
||||||
}
|
}
|
||||||
descriptionEntity1.setProfile(datasetWizardModel.getProfile().getId());
|
descriptionEntity1.setDescriptionTemplate(datasetWizardModel.getProfile().getId());
|
||||||
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
||||||
UUID dmpId = descriptionEntity1.getDmp();
|
UUID dmpId = descriptionEntity1.getDmp();
|
||||||
DMP dmp1 = databaseRepository.getDmpDao().find(descriptionEntity1.getDmp());
|
DMP dmp1 = databaseRepository.getDmpDao().find(descriptionEntity1.getDmp());
|
||||||
|
@ -737,7 +737,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
public String checkDatasetValidation(DescriptionEntity descriptionEntity) throws Exception {
|
public String checkDatasetValidation(DescriptionEntity descriptionEntity) throws Exception {
|
||||||
List<String> datasetProfileValidators = new LinkedList<>();
|
List<String> 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();
|
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
|
||||||
DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
DocumentBuilder builder = builderFactory.newDocumentBuilder();
|
||||||
Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes()));
|
Document xmlDocument = builder.parse(new ByteArrayInputStream(profile.getDefinition().getBytes()));
|
||||||
|
@ -759,7 +759,7 @@ public class DatasetManager {
|
||||||
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
||||||
visibilityRuleService.setProperties(obj.toMap());
|
visibilityRuleService.setProperties(obj.toMap());
|
||||||
|
|
||||||
descriptionEntity.setProfile(profile.getId());
|
descriptionEntity.setDescriptionTemplate(profile.getId());
|
||||||
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), descriptionEntity);
|
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), descriptionEntity);
|
||||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||||
|
|
||||||
|
@ -1036,10 +1036,10 @@ public class DatasetManager {
|
||||||
entity.setUpdatedAt(Instant.now());
|
entity.setUpdatedAt(Instant.now());
|
||||||
DescriptionTemplateEntity profile = new DescriptionTemplateEntity();
|
DescriptionTemplateEntity profile = new DescriptionTemplateEntity();
|
||||||
profile.setId(UUID.fromString(datasetProfileId));
|
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();
|
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);
|
updateTagsXmlImportDataset(apiContext.getOperationsContext().getElasticRepository().getDatasetRepository(), entity);
|
||||||
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), 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.
|
// Creates the Criteria to get all version of DescriptionTemplate in question.
|
||||||
DatasetProfileCriteria profileCriteria = new DatasetProfileCriteria();
|
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<UUID> uuidList = new LinkedList<>();
|
List<UUID> uuidList = new LinkedList<>();
|
||||||
uuidList.add(profileId);
|
uuidList.add(profileId);
|
||||||
profileCriteria.setGroupIds(uuidList);
|
profileCriteria.setGroupIds(uuidList);
|
||||||
|
@ -1152,7 +1152,7 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getTagsFromProfile(DatasetWizardModel wizardModel, DescriptionEntity descriptionEntity) throws IOException, InvalidApplicationException {
|
public void getTagsFromProfile(DatasetWizardModel wizardModel, DescriptionEntity descriptionEntity) throws IOException, InvalidApplicationException {
|
||||||
descriptionEntity.setProfile(descriptionEntity.getProfile());
|
descriptionEntity.setDescriptionTemplate(descriptionEntity.getDescriptionTemplate());
|
||||||
wizardModel.setDatasetProfileDefinition(this.getPagedProfile(wizardModel, descriptionEntity));
|
wizardModel.setDatasetProfileDefinition(this.getPagedProfile(wizardModel, descriptionEntity));
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String json = mapper.writeValueAsString(wizardModel.getDatasetProfileDefinition());
|
String json = mapper.writeValueAsString(wizardModel.getDatasetProfileDefinition());
|
||||||
|
|
|
@ -412,7 +412,7 @@ public class MetricsManager {
|
||||||
List<DescriptionTemplateEntity> descriptionTemplateEntities = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList();
|
List<DescriptionTemplateEntity> descriptionTemplateEntities = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(criteria).withFields(Collections.singletonList("id")).toList();
|
||||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||||
datasetCriteria.setDatasetTemplates(descriptionTemplateEntities.stream().map(DescriptionTemplateEntity::getId).collect(Collectors.toList()));
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.ActiveStatus;
|
||||||
import eu.eudat.commons.enums.old.notification.NotifyState;
|
import eu.eudat.commons.enums.old.notification.NotifyState;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
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 eu.eudat.service.mail.SimpleMail;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
|
@ -1,17 +1,12 @@
|
||||||
package eu.eudat.logic.mapper.elastic;
|
package eu.eudat.logic.mapper.elastic;
|
||||||
|
|
||||||
import eu.eudat.data.DescriptionEntity;
|
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.Dataset;
|
||||||
import eu.eudat.elastic.entities.Tag;
|
import eu.eudat.elastic.entities.Tag;
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class DatasetMapper {
|
public class DatasetMapper {
|
||||||
|
|
||||||
|
@ -24,7 +19,7 @@ public class DatasetMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset toElastic(DescriptionEntity descriptionEntity, List<Tag> tags) throws Exception {
|
public Dataset toElastic(DescriptionEntity descriptionEntity, List<Tag> tags) throws Exception {
|
||||||
if (descriptionEntity.getProfile() == null) {
|
if (descriptionEntity.getDescriptionTemplate() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
//TODO
|
//TODO
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class PrefillingMapper {
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||||
datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
||||||
DescriptionEntity descriptionEntity = new DescriptionEntity();
|
DescriptionEntity descriptionEntity = new DescriptionEntity();
|
||||||
descriptionEntity.setProfile(profile.getId());
|
descriptionEntity.setDescriptionTemplate(profile.getId());
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
JsonNode parentNode = mapper.readTree(mapper.writeValueAsString(datasetManager.getPagedProfile(datasetWizardModel, descriptionEntity)));
|
JsonNode parentNode = mapper.readTree(mapper.writeValueAsString(datasetManager.getPagedProfile(datasetWizardModel, descriptionEntity)));
|
||||||
for (DefaultPrefillingMapping prefillingMapping: prefillingGet.getMappings()) {
|
for (DefaultPrefillingMapping prefillingMapping: prefillingGet.getMappings()) {
|
||||||
|
|
|
@ -2,9 +2,8 @@ package eu.eudat.logic.proxy.config.configloaders;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
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.logic.proxy.config.ExternalUrls;
|
||||||
import eu.eudat.service.descriptiontemplate.Semantic;
|
|
||||||
import eu.eudat.models.data.pid.PidLinks;
|
import eu.eudat.models.data.pid.PidLinks;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.logic.services.utilities;
|
||||||
import eu.eudat.data.dao.entities.EmailConfirmationDao;
|
import eu.eudat.data.dao.entities.EmailConfirmationDao;
|
||||||
import eu.eudat.data.old.EmailConfirmation;
|
import eu.eudat.data.old.EmailConfirmation;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
import eu.eudat.service.mail.MailService;
|
||||||
|
|
||||||
import javax.management.InvalidApplicationException;
|
import javax.management.InvalidApplicationException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.dao.entities.EmailConfirmationDao;
|
import eu.eudat.data.dao.entities.EmailConfirmationDao;
|
||||||
import eu.eudat.data.old.EmailConfirmation;
|
import eu.eudat.data.old.EmailConfirmation;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
import eu.eudat.service.mail.MailService;
|
||||||
import eu.eudat.service.mail.SimpleMail;
|
import eu.eudat.service.mail.SimpleMail;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.data.old.Invitation;
|
||||||
|
|
||||||
import eu.eudat.data.old.UserDMP;
|
import eu.eudat.data.old.UserDMP;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
|
import eu.eudat.service.mail.MailService;
|
||||||
import jakarta.mail.MessagingException;
|
import jakarta.mail.MessagingException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
|
@ -8,6 +8,7 @@ import eu.eudat.data.old.Invitation;
|
||||||
import eu.eudat.data.old.UserDMP;
|
import eu.eudat.data.old.UserDMP;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.models.data.invitation.Properties;
|
import eu.eudat.models.data.invitation.Properties;
|
||||||
|
import eu.eudat.service.mail.MailService;
|
||||||
import eu.eudat.service.mail.SimpleMail;
|
import eu.eudat.service.mail.SimpleMail;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
|
@ -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();
|
|
||||||
}
|
|
|
@ -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<String> imageSources = parseImages(mail.getContent());
|
|
||||||
List<String> 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<String> parseImages(String content) {
|
|
||||||
List<String> 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<String> 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;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.logic.services.utilities;
|
package eu.eudat.logic.services.utilities;
|
||||||
|
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
|
import eu.eudat.service.mail.MailService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 3/1/2018.
|
* Created by ikalyvas on 3/1/2018.
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.logic.services.utilities;
|
||||||
|
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||||
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
|
import eu.eudat.logic.services.forms.VisibilityRuleServiceImpl;
|
||||||
|
import eu.eudat.service.mail.MailService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ import eu.eudat.logic.managers.DatasetManager;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
import eu.eudat.logic.utilities.helpers.StreamDistinctBy;
|
||||||
import eu.eudat.logic.utilities.json.JsonSearcher;
|
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.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.rda.*;
|
import eu.eudat.models.rda.*;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -52,7 +51,7 @@ public class DatasetRDAMapper {
|
||||||
}
|
}
|
||||||
rda.setTitle(descriptionEntity.getLabel());
|
rda.setTitle(descriptionEntity.getLabel());
|
||||||
rda.setDescription(descriptionEntity.getDescription());
|
rda.setDescription(descriptionEntity.getDescription());
|
||||||
rda.setAdditionalProperty("template", descriptionEntity.getProfile());
|
rda.setAdditionalProperty("template", descriptionEntity.getDescriptionTemplate());
|
||||||
try {
|
try {
|
||||||
JSONObject jObject = new JSONObject(descriptionEntity.getProperties());
|
JSONObject jObject = new JSONObject(descriptionEntity.getProperties());
|
||||||
Map<String, Object> templateIdsToValues = jObject.toMap();
|
Map<String, Object> templateIdsToValues = jObject.toMap();
|
||||||
|
@ -289,10 +288,10 @@ public class DatasetRDAMapper {
|
||||||
entity.setDescription(rda.getDescription());
|
entity.setDescription(rda.getDescription());
|
||||||
try {
|
try {
|
||||||
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(rda.getAdditionalProperties().get("template").toString()));
|
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) {
|
}catch(Exception e) {
|
||||||
logger.warn(e.getMessage(), e);
|
logger.warn(e.getMessage(), e);
|
||||||
entity.setProfile(defaultProfile.getId());
|
entity.setDescriptionTemplate(defaultProfile.getId());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
|
|
Loading…
Reference in New Issue