description refactor
This commit is contained in:
parent
9cf91aab50
commit
81528dfe55
|
@ -1,217 +1,295 @@
|
||||||
package eu.eudat.data;
|
package eu.eudat.data;
|
||||||
|
|
||||||
|
|
||||||
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.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.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.UUID;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "\"Description\"")
|
@Table(name = "\"Description\"")
|
||||||
public class DescriptionEntity {
|
public class DescriptionEntity implements DataEntity<DescriptionEntity, UUID> {
|
||||||
|
|
||||||
@Id
|
public static Set<String> getHints() {
|
||||||
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
return hints;
|
||||||
private UUID id;
|
}
|
||||||
|
|
||||||
public static final String _id = "id";
|
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
|
||||||
|
|
||||||
@Column(name = "label", length = 250, nullable = false)
|
@Id
|
||||||
private String label;
|
@Column(name = "id", columnDefinition = "uuid", updatable = false, nullable = false)
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
public static final String _label = "label";
|
public static final String _id = "id";
|
||||||
|
|
||||||
@Column(name = "dmp", columnDefinition = "uuid")
|
@Column(name = "label", length = 250, nullable = false)
|
||||||
private UUID dmp;
|
private String label;
|
||||||
|
|
||||||
public static final String _dmp = "dmp";
|
public static final String _label = "label";
|
||||||
|
|
||||||
@Column(name = "uri", length = 250)
|
@Column(name = "dmp", columnDefinition = "uuid")
|
||||||
private String uri;
|
private UUID dmp;
|
||||||
|
|
||||||
public static final String _uri = "uri";
|
public static final String _dmp = "dmp";
|
||||||
|
|
||||||
@Column(name = "properties")
|
@Column(name = "uri", length = 250)
|
||||||
private String properties;
|
private String uri;
|
||||||
|
|
||||||
public static final String _properties = "properties";
|
public static final String _uri = "uri";
|
||||||
|
|
||||||
//TODO: (thgiannos) Previously 'DescriptionTemplate'
|
@Column(name = "properties")
|
||||||
@Column(name = "profile", columnDefinition = "uuid")
|
private String properties;
|
||||||
private UUID profile;
|
|
||||||
|
|
||||||
public static final String _profile = "profile";
|
public static final String _properties = "properties";
|
||||||
|
|
||||||
@Column(name = "reference")
|
//TODO: (thgiannos) Previously 'DescriptionTemplate'
|
||||||
private String reference;
|
@Column(name = "profile", columnDefinition = "uuid")
|
||||||
|
private UUID profile;
|
||||||
|
|
||||||
public static final String _reference = "reference";
|
public static final String _profile = "profile";
|
||||||
|
|
||||||
@Column(name = "status", nullable = false)
|
@Column(name = "reference")
|
||||||
@Convert(converter = DescriptionStatusConverter.class)
|
private String reference;
|
||||||
private DescriptionStatus status;
|
|
||||||
|
|
||||||
public static final String _status = "status";
|
public static final String _reference = "reference";
|
||||||
|
|
||||||
@Column(name = "description")
|
@Column(name = "status", nullable = false)
|
||||||
private String description;
|
@Convert(converter = DescriptionStatusConverter.class)
|
||||||
|
private DescriptionStatus status;
|
||||||
|
|
||||||
public static final String _description = "description";
|
public static final String _status = "status";
|
||||||
|
|
||||||
@Column(name = "dmp_section_index", nullable = false)
|
@Column(name = "description")
|
||||||
private Integer dmpSectionIndex;
|
private String description;
|
||||||
|
|
||||||
public static final String _dmpSectionIndex = "dmpSectionIndex";
|
public static final String _description = "description";
|
||||||
|
|
||||||
@Column(name = "creator", columnDefinition = "uuid")
|
@Column(name = "dmp_section_index", nullable = false)
|
||||||
private UUID creator;
|
private Integer dmpSectionIndex;
|
||||||
|
|
||||||
public static final String _creator = "creator";
|
public static final String _dmpSectionIndex = "dmpSectionIndex";
|
||||||
|
|
||||||
@Column(name = "created_at", nullable = false)
|
@Column(name = "creator", columnDefinition = "uuid")
|
||||||
private Instant createdAt;
|
private UUID creator;
|
||||||
|
|
||||||
public static final String _createdAt = "createdAt";
|
public static final String _creator = "creator";
|
||||||
|
|
||||||
@Column(name = "updated_at", nullable = false)
|
@Column(name = "created_at", nullable = false)
|
||||||
private Instant updatedAt;
|
private Instant createdAt;
|
||||||
|
|
||||||
public static final String _updatedAt = "updatedAt";
|
public static final String _createdAt = "createdAt";
|
||||||
|
|
||||||
@Column(name = "is_active", nullable = false)
|
@Column(name = "updated_at", nullable = false)
|
||||||
@Convert(converter = IsActiveConverter.class)
|
private Instant updatedAt;
|
||||||
private IsActive isActive;
|
|
||||||
|
|
||||||
public static final String _isActive = "isActive";
|
public static final String _updatedAt = "updatedAt";
|
||||||
|
|
||||||
@Column(name = "\"finalized_at\"")
|
@Column(name = "is_active", nullable = false)
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
@Convert(converter = IsActiveConverter.class)
|
||||||
private Instant finalizedAt;
|
private IsActive isActive;
|
||||||
|
|
||||||
public static final String _finalizedAt = "finalizedAt";
|
public static final String _isActive = "isActive";
|
||||||
|
|
||||||
public UUID getId() {
|
@Column(name = "\"finalized_at\"")
|
||||||
return id;
|
@Convert(converter = DateToUTCConverter.class)
|
||||||
}
|
private Instant finalizedAt;
|
||||||
|
|
||||||
public void setId(UUID id) {
|
public static final String _finalizedAt = "finalizedAt";
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLabel() {
|
public UUID getId() {
|
||||||
return label;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLabel(String label) {
|
public void setId(UUID id) {
|
||||||
this.label = label;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getDmp() {
|
public String getLabel() {
|
||||||
return dmp;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmp(UUID dmp) {
|
public void setLabel(String label) {
|
||||||
this.dmp = dmp;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUri() {
|
public UUID getDmp() {
|
||||||
return uri;
|
return dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUri(String uri) {
|
public void setDmp(UUID dmp) {
|
||||||
this.uri = uri;
|
this.dmp = dmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProperties() {
|
public String getUri() {
|
||||||
return properties;
|
return uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProperties(String properties) {
|
public void setUri(String uri) {
|
||||||
this.properties = properties;
|
this.uri = uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getProfile() {
|
public String getProperties() {
|
||||||
return profile;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfile(UUID profile) {
|
public void setProperties(String properties) {
|
||||||
this.profile = profile;
|
this.properties = properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getReference() {
|
public UUID getProfile() {
|
||||||
return reference;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReference(String reference) {
|
public void setProfile(UUID profile) {
|
||||||
this.reference = reference;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DescriptionStatus getStatus() {
|
public String getReference() {
|
||||||
return status;
|
return reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStatus(DescriptionStatus status) {
|
public void setReference(String reference) {
|
||||||
this.status = status;
|
this.reference = reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDescription() {
|
public DescriptionStatus getStatus() {
|
||||||
return description;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setStatus(DescriptionStatus status) {
|
||||||
this.description = description;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getDmpSectionIndex() {
|
public String getDescription() {
|
||||||
return dmpSectionIndex;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDmpSectionIndex(Integer dmpSectionIndex) {
|
public void setDescription(String description) {
|
||||||
this.dmpSectionIndex = dmpSectionIndex;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getCreator() {
|
public Integer getDmpSectionIndex() {
|
||||||
return creator;
|
return dmpSectionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreator(UUID creator) {
|
public void setDmpSectionIndex(Integer dmpSectionIndex) {
|
||||||
this.creator = creator;
|
this.dmpSectionIndex = dmpSectionIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant getCreatedAt() {
|
public UUID getCreator() {
|
||||||
return createdAt;
|
return creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreatedAt(Instant createdAt) {
|
public void setCreator(UUID creator) {
|
||||||
this.createdAt = createdAt;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant getUpdatedAt() {
|
public Instant getCreatedAt() {
|
||||||
return updatedAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpdatedAt(Instant updatedAt) {
|
public void setCreatedAt(Instant createdAt) {
|
||||||
this.updatedAt = updatedAt;
|
this.createdAt = createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IsActive getIsActive() {
|
public Instant getUpdatedAt() {
|
||||||
return isActive;
|
return updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsActive(IsActive isActive) {
|
public void setUpdatedAt(Instant updatedAt) {
|
||||||
this.isActive = isActive;
|
this.updatedAt = updatedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Instant getFinalizedAt() {
|
public IsActive getIsActive() {
|
||||||
return finalizedAt;
|
return isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFinalizedAt(Instant finalizedAt) {
|
public void setIsActive(IsActive isActive) {
|
||||||
this.finalizedAt = finalizedAt;
|
this.isActive = isActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Instant getFinalizedAt() {
|
||||||
|
return finalizedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFinalizedAt(Instant finalizedAt) {
|
||||||
|
this.finalizedAt = finalizedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(DescriptionEntity entity) {
|
||||||
|
// this.setUri(entity.getUri());
|
||||||
|
// this.setDescription(entity.getDescription());
|
||||||
|
// this.setLabel(entity.getLabel());
|
||||||
|
// this.setProperties(entity.getProperties());
|
||||||
|
//
|
||||||
|
// if (entity.getDatasetDataRepositories() == null || entity.getDatasetDataRepositories().size() < 1) {
|
||||||
|
// if (this.getDatasetDataRepositories() != null) this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
|
||||||
|
// } else {
|
||||||
|
// if (this.getDatasetDataRepositories() != null) {
|
||||||
|
// this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
|
||||||
|
// } else {
|
||||||
|
// this.setDatasetDataRepositories(new HashSet<>());
|
||||||
|
// }
|
||||||
|
// this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (entity.getDatasetExternalDatasets() == null || entity.getDatasetExternalDatasets().size() < 1) {
|
||||||
|
// if (this.getDatasetExternalDatasets() != null) this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
|
||||||
|
// } else {
|
||||||
|
// if (this.getDatasetExternalDatasets() != null) {
|
||||||
|
// this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
|
||||||
|
// } else {
|
||||||
|
// this.setDatasetExternalDatasets(new HashSet<>());
|
||||||
|
// }
|
||||||
|
// this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (entity.getServices() == null || entity.getServices().size() < 1) {
|
||||||
|
// if (this.getServices() != null) this.getServices().removeAll(this.getServices());
|
||||||
|
// } else {
|
||||||
|
// if (this.getServices() != null) {
|
||||||
|
// this.getServices().removeAll(this.getServices());
|
||||||
|
// } else {
|
||||||
|
// this.setServices(new HashSet<>());
|
||||||
|
// }
|
||||||
|
// this.getServices().addAll(entity.getServices().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// this.setRegistries(entity.getRegistries());
|
||||||
|
//
|
||||||
|
// this.setDmp(entity.getDmp());
|
||||||
|
// this.setDmpSectionIndex(entity.getDmpSectionIndex());
|
||||||
|
// this.setStatus(entity.getStatus());
|
||||||
|
// this.setProfile(entity.getProfile());
|
||||||
|
// this.setModified(new Date());
|
||||||
|
// if (entity.getStatus().equals(Status.FINALISED.getValue())) this.setFinalizedAt(new Date());
|
||||||
|
// if (entity.getCreator() != null) this.creator = entity.getCreator();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getKeys() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DescriptionEntity buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||||
|
String currentBase = base.isEmpty() ? "" : base + ".";
|
||||||
|
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.data.old;
|
package eu.eudat.data.old;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
import eu.eudat.data.converters.DateToUTCConverter;
|
||||||
|
@ -103,7 +104,7 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
private Integer version;
|
private Integer version;
|
||||||
|
|
||||||
@OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
|
@OneToMany(mappedBy = "dmp", fetch = FetchType.LAZY)
|
||||||
private Set<Dataset> dataset;
|
private Set<DescriptionEntity> descriptionEntity;
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.LAZY)
|
||||||
|
@ -286,11 +287,11 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Dataset> getDataset() {
|
public Set<DescriptionEntity> getDataset() {
|
||||||
return dataset;
|
return descriptionEntity;
|
||||||
}
|
}
|
||||||
public void setDataset(Set<Dataset> dataset) {
|
public void setDataset(Set<DescriptionEntity> descriptionEntity) {
|
||||||
this.dataset = dataset;
|
this.descriptionEntity = descriptionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Organisation> getOrganisations() {
|
public Set<Organisation> getOrganisations() {
|
||||||
|
@ -395,7 +396,7 @@ public class DMP implements DataEntity<DMP, UUID> {
|
||||||
@Override
|
@Override
|
||||||
public DMP buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
public DMP buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
||||||
this.id = tuple.get(0).get(base.isEmpty() ? "id" : base + "." + "id", UUID.class);
|
this.id = tuple.get(0).get(base.isEmpty() ? "id" : base + "." + "id", UUID.class);
|
||||||
this.dataset = tuple.stream().map(x -> new Dataset().buildFromTuple(tuple, fields ,base.isEmpty() ? "dataset" : base + "." + "dataset")).collect(Collectors.toSet());
|
this.descriptionEntity = tuple.stream().map(x -> new DescriptionEntity().buildFromTuple(tuple, fields ,base.isEmpty() ? "dataset" : base + "." + "dataset")).collect(Collectors.toSet());
|
||||||
this.creator = tuple.stream().map(x -> new UserInfo().buildFromTuple(tuple, fields , base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0);
|
this.creator = tuple.stream().map(x -> new UserInfo().buildFromTuple(tuple, fields , base.isEmpty() ? "creator" : base + "." + "creator")).collect(Collectors.toList()).get(0);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,360 +0,0 @@
|
||||||
package eu.eudat.data.old;
|
|
||||||
|
|
||||||
|
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
|
||||||
import eu.eudat.data.old.helpers.EntityBinder;
|
|
||||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
|
||||||
import org.hibernate.annotations.Type;
|
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name = "\"Dataset\"")
|
|
||||||
@NamedEntityGraphs({
|
|
||||||
@NamedEntityGraph(
|
|
||||||
name = "datasetListingModel",
|
|
||||||
attributeNodes = {/*@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"),
|
|
||||||
@NamedAttributeNode(value = "datasetExternalDatasets", subgraph = "datasetExternalDatasets"), @NamedAttributeNode("registries"),*/
|
|
||||||
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode(value = "profile", subgraph = "profile"), @NamedAttributeNode("creator")},
|
|
||||||
subgraphs = {
|
|
||||||
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("grant"), @NamedAttributeNode("organisations")}),
|
|
||||||
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}),
|
|
||||||
@NamedSubgraph(name = "datasetExternalDatasets", attributeNodes = {@NamedAttributeNode("externalDataset")}),
|
|
||||||
@NamedSubgraph(name = "profile", attributeNodes = {@NamedAttributeNode("label")})
|
|
||||||
}),
|
|
||||||
|
|
||||||
@NamedEntityGraph(
|
|
||||||
name = "datasetWizardModel",
|
|
||||||
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode("datasetDataRepositories"), @NamedAttributeNode("datasetExternalDatasets"), @NamedAttributeNode("registries"),
|
|
||||||
@NamedAttributeNode("dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")}),
|
|
||||||
@NamedEntityGraph(
|
|
||||||
name = "datasetRecentActivity",
|
|
||||||
attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp")},
|
|
||||||
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("users")})),
|
|
||||||
@NamedEntityGraph(
|
|
||||||
name = "datasetDataRepositories",
|
|
||||||
attributeNodes = {@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("creator")},
|
|
||||||
subgraphs = @NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users")})),
|
|
||||||
@NamedEntityGraph(
|
|
||||||
name = "recentDatasetModel",
|
|
||||||
attributeNodes = {@NamedAttributeNode("services"), @NamedAttributeNode(value = "datasetDataRepositories", subgraph = "datasetDataRepositories"),
|
|
||||||
@NamedAttributeNode(value = "datasetExternalDatasets", subgraph = "datasetExternalDatasets"), @NamedAttributeNode("registries"),
|
|
||||||
@NamedAttributeNode(value = "dmp", subgraph = "dmp"), @NamedAttributeNode("profile"), @NamedAttributeNode("creator")},
|
|
||||||
subgraphs = {
|
|
||||||
@NamedSubgraph(name = "dmp", attributeNodes = {@NamedAttributeNode("creator"), @NamedAttributeNode("users"), @NamedAttributeNode("grant"), @NamedAttributeNode("organisations")}),
|
|
||||||
@NamedSubgraph(name = "datasetDataRepositories", attributeNodes = {@NamedAttributeNode("dataRepository")}),
|
|
||||||
@NamedSubgraph(name = "datasetExternalDatasets", attributeNodes = {@NamedAttributeNode("externalDataset")})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
public class Dataset implements DataEntity<Dataset, UUID> {
|
|
||||||
|
|
||||||
public static Set<String> getHints() {
|
|
||||||
return hints;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final Set<String> hints = new HashSet<>(Arrays.asList("datasetListingModel"));
|
|
||||||
|
|
||||||
public enum Status {
|
|
||||||
SAVED((short) 0), FINALISED((short) 1), CANCELED((short) 2), DELETED((short) 99),;
|
|
||||||
|
|
||||||
private short value;
|
|
||||||
|
|
||||||
private Status(short value) {
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public short getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Status fromInteger(int value) {
|
|
||||||
switch (value) {
|
|
||||||
case 0:
|
|
||||||
return SAVED;
|
|
||||||
case 1:
|
|
||||||
return FINALISED;
|
|
||||||
case 2:
|
|
||||||
return CANCELED;
|
|
||||||
case 99:
|
|
||||||
return DELETED;
|
|
||||||
default:
|
|
||||||
throw new RuntimeException("Unsupported Dataset Status");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
||||||
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "\"Label\"", nullable = false)
|
|
||||||
private String label;
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
// @Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
|
||||||
@JoinColumn(name = "\"DMP\"", nullable = false)
|
|
||||||
private DMP dmp;
|
|
||||||
|
|
||||||
@Column(name = "\"DmpSectionIndex\"")
|
|
||||||
private Integer dmpSectionIndex;
|
|
||||||
|
|
||||||
@Column(name = "\"Uri\"")
|
|
||||||
private String uri;
|
|
||||||
|
|
||||||
@Type(eu.eudat.configurations.typedefinition.XMLType.class)
|
|
||||||
@Column(name = "\"Properties\"", columnDefinition = "xml")
|
|
||||||
private String properties;
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
//@Cascade(value=org.hibernate.annotations.CascadeType.ALL)
|
|
||||||
@JoinColumn(name = "\"Profile\"")
|
|
||||||
private DescriptionTemplateEntity profile;
|
|
||||||
|
|
||||||
@Type(eu.eudat.configurations.typedefinition.XMLType.class)
|
|
||||||
@Column(name = "\"Reference\"", columnDefinition = "xml")
|
|
||||||
private String reference;
|
|
||||||
|
|
||||||
@OneToMany(fetch = FetchType.LAZY)
|
|
||||||
@JoinTable(name = "\"DatasetRegistry\"",
|
|
||||||
joinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")},
|
|
||||||
inverseJoinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")}
|
|
||||||
)
|
|
||||||
private Set<Registry> registries;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
private Set<DatasetDataRepository> datasetDataRepositories;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
private Set<DatasetService> services;
|
|
||||||
|
|
||||||
@OneToMany(mappedBy = "dataset", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
||||||
private Set<DatasetExternalDataset> datasetExternalDatasets;
|
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
|
||||||
private Short status;
|
|
||||||
|
|
||||||
|
|
||||||
@Column(name = "\"Created\"", nullable = false)
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date created = null;
|
|
||||||
|
|
||||||
@Column(name = "\"Modified\"", nullable = false)
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date modified = new Date();
|
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "\"Creator\"")
|
|
||||||
private UserInfo creator;
|
|
||||||
|
|
||||||
@Column(name = "\"Description\"")
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
@Column(name= "\"FinalizedAt\"")
|
|
||||||
@Convert(converter = DateToUTCConverter.class)
|
|
||||||
private Date finalizedAt;
|
|
||||||
|
|
||||||
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public void setDescription(String description) {
|
|
||||||
this.description = description;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public UserInfo getCreator() {
|
|
||||||
return creator;
|
|
||||||
}
|
|
||||||
public void setCreator(UserInfo creator) {
|
|
||||||
this.creator = creator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Short getStatus() {
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
public void setStatus(Short status) {
|
|
||||||
this.status = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Date getCreated() {
|
|
||||||
return created;
|
|
||||||
}
|
|
||||||
public void setCreated(Date created) {
|
|
||||||
this.created = created;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Date getModified() {
|
|
||||||
return modified;
|
|
||||||
}
|
|
||||||
public void setModified(Date modified) {
|
|
||||||
this.modified = modified;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Set<Registry> getRegistries() {
|
|
||||||
return registries;
|
|
||||||
}
|
|
||||||
public void setRegistries(Set<Registry> registries) {
|
|
||||||
this.registries = registries;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<DatasetService> getServices() {
|
|
||||||
return services;
|
|
||||||
}
|
|
||||||
public void setServices(Set<DatasetService> services) {
|
|
||||||
this.services = services;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 DMP getDmp() {
|
|
||||||
return dmp;
|
|
||||||
}
|
|
||||||
public void setDmp(DMP dmp) {
|
|
||||||
this.dmp = dmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getDmpSectionIndex() {
|
|
||||||
return dmpSectionIndex;
|
|
||||||
}
|
|
||||||
public void setDmpSectionIndex(Integer dmpSectionIndex) {
|
|
||||||
this.dmpSectionIndex = dmpSectionIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUri() {
|
|
||||||
return uri;
|
|
||||||
}
|
|
||||||
public void setUri(String uri) {
|
|
||||||
this.uri = uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getProperties() {
|
|
||||||
return properties;
|
|
||||||
}
|
|
||||||
public void setProperties(String properties) {
|
|
||||||
this.properties = properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public DescriptionTemplateEntity getProfile() {
|
|
||||||
return profile;
|
|
||||||
}
|
|
||||||
public void setProfile(DescriptionTemplateEntity profile) {
|
|
||||||
this.profile = profile;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public Set<DatasetDataRepository> getDatasetDataRepositories() {
|
|
||||||
return datasetDataRepositories;
|
|
||||||
}
|
|
||||||
public void setDatasetDataRepositories(Set<DatasetDataRepository> datasetDataRepositories) {
|
|
||||||
this.datasetDataRepositories = datasetDataRepositories;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getReference() {
|
|
||||||
return reference;
|
|
||||||
}
|
|
||||||
public void setReference(String reference) {
|
|
||||||
this.reference = reference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<DatasetExternalDataset> getDatasetExternalDatasets() {
|
|
||||||
return datasetExternalDatasets;
|
|
||||||
}
|
|
||||||
public void setDatasetExternalDatasets(Set<DatasetExternalDataset> datasetExternalDatasets) {
|
|
||||||
this.datasetExternalDatasets = datasetExternalDatasets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getFinalizedAt() {
|
|
||||||
return finalizedAt;
|
|
||||||
}
|
|
||||||
public void setFinalizedAt(Date finalizedAt) {
|
|
||||||
this.finalizedAt = finalizedAt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Dataset entity) {
|
|
||||||
this.setUri(entity.getUri());
|
|
||||||
this.setDescription(entity.getDescription());
|
|
||||||
this.setLabel(entity.getLabel());
|
|
||||||
this.setProperties(entity.getProperties());
|
|
||||||
|
|
||||||
if (entity.getDatasetDataRepositories() == null || entity.getDatasetDataRepositories().size() < 1) {
|
|
||||||
if (this.getDatasetDataRepositories() != null) this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
|
|
||||||
} else {
|
|
||||||
if (this.getDatasetDataRepositories() != null) {
|
|
||||||
this.getDatasetDataRepositories().removeAll(this.getDatasetDataRepositories());
|
|
||||||
} else {
|
|
||||||
this.setDatasetDataRepositories(new HashSet<>());
|
|
||||||
}
|
|
||||||
this.getDatasetDataRepositories().addAll(entity.getDatasetDataRepositories().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.getDatasetExternalDatasets() == null || entity.getDatasetExternalDatasets().size() < 1) {
|
|
||||||
if (this.getDatasetExternalDatasets() != null) this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
|
|
||||||
} else {
|
|
||||||
if (this.getDatasetExternalDatasets() != null) {
|
|
||||||
this.getDatasetExternalDatasets().removeAll(this.getDatasetExternalDatasets());
|
|
||||||
} else {
|
|
||||||
this.setDatasetExternalDatasets(new HashSet<>());
|
|
||||||
}
|
|
||||||
this.getDatasetExternalDatasets().addAll(entity.getDatasetExternalDatasets().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity.getServices() == null || entity.getServices().size() < 1) {
|
|
||||||
if (this.getServices() != null) this.getServices().removeAll(this.getServices());
|
|
||||||
} else {
|
|
||||||
if (this.getServices() != null) {
|
|
||||||
this.getServices().removeAll(this.getServices());
|
|
||||||
} else {
|
|
||||||
this.setServices(new HashSet<>());
|
|
||||||
}
|
|
||||||
this.getServices().addAll(entity.getServices().stream().peek(item -> item.setDataset(this)).collect(Collectors.toList()));
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setRegistries(entity.getRegistries());
|
|
||||||
|
|
||||||
this.setDmp(entity.getDmp());
|
|
||||||
this.setDmpSectionIndex(entity.getDmpSectionIndex());
|
|
||||||
this.setStatus(entity.getStatus());
|
|
||||||
this.setProfile(entity.getProfile());
|
|
||||||
this.setModified(new Date());
|
|
||||||
if (entity.getStatus().equals(Status.FINALISED.getValue())) this.setFinalizedAt(new Date());
|
|
||||||
if (entity.getCreator() != null) this.creator = entity.getCreator();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UUID getKeys() {
|
|
||||||
return this.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dataset buildFromTuple(List<Tuple> tuple, List<String> fields, String base) {
|
|
||||||
String currentBase = base.isEmpty() ? "" : base + ".";
|
|
||||||
if (fields.contains(currentBase + "id")) this.id = EntityBinder.fromTuple(tuple, currentBase + "id");
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.data.old;
|
package eu.eudat.data.old;
|
||||||
|
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
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.GenericGenerator;
|
||||||
|
@ -24,7 +25,7 @@ public class DatasetDataRepository implements DataEntity<DatasetDataRepository,
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "\"Dataset\"", nullable = false)
|
@JoinColumn(name = "\"Dataset\"", nullable = false)
|
||||||
private Dataset dataset;
|
private DescriptionEntity descriptionEntity;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "\"DataRepository\"", nullable = false)
|
@JoinColumn(name = "\"DataRepository\"", nullable = false)
|
||||||
|
@ -44,12 +45,12 @@ public class DatasetDataRepository implements DataEntity<DatasetDataRepository,
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset getDataset() {
|
public DescriptionEntity getDataset() {
|
||||||
return dataset;
|
return descriptionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataset(Dataset dataset) {
|
public void setDataset(DescriptionEntity descriptionEntity) {
|
||||||
this.dataset = dataset;
|
this.descriptionEntity = descriptionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataRepository getDataRepository() {
|
public DataRepository getDataRepository() {
|
||||||
|
@ -78,7 +79,7 @@ public class DatasetDataRepository implements DataEntity<DatasetDataRepository,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(DatasetDataRepository entity) {
|
public void update(DatasetDataRepository entity) {
|
||||||
this.dataset = entity.getDataset();
|
this.descriptionEntity = entity.getDataset();
|
||||||
this.dataRepository = entity.getDataRepository();
|
this.dataRepository = entity.getDataRepository();
|
||||||
this.role = entity.getRole();
|
this.role = entity.getRole();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.data.old;
|
package eu.eudat.data.old;
|
||||||
|
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
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.GenericGenerator;
|
||||||
|
@ -21,7 +22,7 @@ public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "\"Dataset\"", nullable = false)
|
@JoinColumn(name = "\"Dataset\"", nullable = false)
|
||||||
private Dataset dataset;
|
private DescriptionEntity descriptionEntity;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "\"ExternalDataset\"", nullable = false)
|
@JoinColumn(name = "\"ExternalDataset\"", nullable = false)
|
||||||
|
@ -42,12 +43,12 @@ public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset getDataset() {
|
public DescriptionEntity getDataset() {
|
||||||
return dataset;
|
return descriptionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataset(Dataset dataset) {
|
public void setDataset(DescriptionEntity descriptionEntity) {
|
||||||
this.dataset = dataset;
|
this.descriptionEntity = descriptionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExternalDataset getExternalDataset() {
|
public ExternalDataset getExternalDataset() {
|
||||||
|
@ -76,7 +77,7 @@ public class DatasetExternalDataset implements DataEntity<DatasetExternalDataset
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(DatasetExternalDataset entity) {
|
public void update(DatasetExternalDataset entity) {
|
||||||
this.dataset = entity.getDataset();
|
this.descriptionEntity = entity.getDataset();
|
||||||
this.externalDataset = entity.getExternalDataset();
|
this.externalDataset = entity.getExternalDataset();
|
||||||
this.role = entity.getRole();
|
this.role = entity.getRole();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.data.old;
|
package eu.eudat.data.old;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.queryable.queryableentity.DataEntity;
|
import eu.eudat.queryable.queryableentity.DataEntity;
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ public class DatasetService implements DataEntity<DatasetService, UUID> {
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "\"Dataset\"", nullable = false)
|
@JoinColumn(name = "\"Dataset\"", nullable = false)
|
||||||
private Dataset dataset;
|
private DescriptionEntity descriptionEntity;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "\"Service\"", nullable = false)
|
@JoinColumn(name = "\"Service\"", nullable = false)
|
||||||
|
@ -43,12 +44,12 @@ public class DatasetService implements DataEntity<DatasetService, UUID> {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset getDataset() {
|
public DescriptionEntity getDataset() {
|
||||||
return dataset;
|
return descriptionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataset(Dataset dataset) {
|
public void setDataset(DescriptionEntity descriptionEntity) {
|
||||||
this.dataset = dataset;
|
this.descriptionEntity = descriptionEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Service getService() {
|
public Service getService() {
|
||||||
|
@ -77,7 +78,7 @@ public class DatasetService implements DataEntity<DatasetService, UUID> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(DatasetService entity) {
|
public void update(DatasetService entity) {
|
||||||
this.dataset = entity.getDataset();
|
this.descriptionEntity = entity.getDataset();
|
||||||
this.service = entity.getService();
|
this.service = entity.getService();
|
||||||
this.role = entity.getRole();
|
this.role = entity.getRole();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.data.old;
|
package eu.eudat.data.old;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.converters.DateToUTCConverter;
|
import eu.eudat.data.converters.DateToUTCConverter;
|
||||||
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;
|
||||||
|
@ -42,7 +43,7 @@ public class Registry implements DataEntity<Registry, UUID> {
|
||||||
joinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")},
|
joinColumns = {@JoinColumn(name = "\"Registry\"", referencedColumnName = "\"ID\"")},
|
||||||
inverseJoinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")}
|
inverseJoinColumns = {@JoinColumn(name = "\"Dataset\"", referencedColumnName = "\"ID\"")}
|
||||||
)
|
)
|
||||||
private Set<Dataset> datasets;
|
private Set<DescriptionEntity> descriptionEntities;
|
||||||
|
|
||||||
@Column(name = "\"Status\"", nullable = false)
|
@Column(name = "\"Status\"", nullable = false)
|
||||||
private Short status;
|
private Short status;
|
||||||
|
@ -123,11 +124,11 @@ public class Registry implements DataEntity<Registry, UUID> {
|
||||||
this.definition = definition;
|
this.definition = definition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Dataset> getDatasets() {
|
public Set<DescriptionEntity> getDatasets() {
|
||||||
return datasets;
|
return descriptionEntities;
|
||||||
}
|
}
|
||||||
public void setDatasets(Set<Dataset> datasets) {
|
public void setDatasets(Set<DescriptionEntity> descriptionEntities) {
|
||||||
this.datasets = datasets;
|
this.descriptionEntities = descriptionEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserInfo getCreationUser() {
|
public UserInfo getCreationUser() {
|
||||||
|
|
|
@ -3,14 +3,12 @@ package eu.eudat.model.builder;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.convention.ConventionService;
|
import eu.eudat.convention.ConventionService;
|
||||||
import eu.eudat.data.DescriptionEntity;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DmpEntity;
|
|
||||||
import eu.eudat.model.Description;
|
import eu.eudat.model.Description;
|
||||||
import eu.eudat.model.DescriptionReference;
|
import eu.eudat.model.DescriptionReference;
|
||||||
import eu.eudat.model.Dmp;
|
import eu.eudat.model.Dmp;
|
||||||
import eu.eudat.model.DmpReference;
|
import eu.eudat.model.DmpReference;
|
||||||
import eu.eudat.query.DescriptionReferenceQuery;
|
import eu.eudat.query.DescriptionReferenceQuery;
|
||||||
import eu.eudat.query.DmpQuery;
|
import eu.eudat.query.DmpQuery;
|
||||||
import eu.eudat.query.DmpReferenceQuery;
|
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import gr.cite.tools.exception.MyApplicationException;
|
import gr.cite.tools.exception.MyApplicationException;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.elastic.entities.Tag;
|
import eu.eudat.elastic.entities.Tag;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -8,7 +8,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
public class DatasetCriteria extends Criteria<Dataset> {
|
public class DatasetCriteria extends Criteria<DescriptionEntity> {
|
||||||
private Integer status;
|
private Integer status;
|
||||||
private Date periodStart;
|
private Date periodStart;
|
||||||
private Date periodEnd;
|
private Date periodEnd;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package eu.eudat.data.dao.criteria;
|
package eu.eudat.data.dao.criteria;
|
||||||
|
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.elastic.entities.Tag;
|
import eu.eudat.elastic.entities.Tag;
|
||||||
import eu.eudat.types.grant.GrantStateType;
|
import eu.eudat.types.grant.GrantStateType;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import java.util.UUID;
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 10/2/2018.
|
* Created by ikalyvas on 10/2/2018.
|
||||||
*/
|
*/
|
||||||
public class DatasetPublicCriteria extends Criteria<Dataset>{
|
public class DatasetPublicCriteria extends Criteria<DescriptionEntity>{
|
||||||
private GrantStateType grantStatus;
|
private GrantStateType grantStatus;
|
||||||
private List<UUID> grants;
|
private List<UUID> grants;
|
||||||
private List<UUID> datasetProfile;
|
private List<UUID> datasetProfile;
|
||||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
|
@ -10,14 +10,14 @@ import javax.management.InvalidApplicationException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface DatasetDao extends DatabaseAccessLayer<Dataset, UUID> {
|
public interface DatasetDao extends DatabaseAccessLayer<DescriptionEntity, UUID> {
|
||||||
|
|
||||||
QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria);
|
QueryableList<DescriptionEntity> getWithCriteria(DatasetCriteria criteria);
|
||||||
|
|
||||||
QueryableList<Dataset> filterFromElastic(DatasetCriteria criteria, List<UUID> ids);
|
QueryableList<DescriptionEntity> filterFromElastic(DatasetCriteria criteria, List<UUID> ids);
|
||||||
|
|
||||||
QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal, List<Integer> roles);
|
QueryableList<DescriptionEntity> getAuthenticated(QueryableList<DescriptionEntity> query, UserInfo principal, List<Integer> roles);
|
||||||
|
|
||||||
Dataset isPublicDataset(UUID id) throws InvalidApplicationException;
|
DescriptionEntity isPublicDataset(UUID id) throws InvalidApplicationException;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,10 +1,12 @@
|
||||||
package eu.eudat.data.dao.entities;
|
package eu.eudat.data.dao.entities;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.dao.DatabaseAccess;
|
import eu.eudat.data.dao.DatabaseAccess;
|
||||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||||
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
import eu.eudat.data.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
|
@ -25,17 +27,17 @@ import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Component("datasetDao")
|
@Component("datasetDao")
|
||||||
public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDao {
|
public class DatasetDaoImpl extends DatabaseAccess<DescriptionEntity> implements DatasetDao {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DatasetDaoImpl(DatabaseService<Dataset> databaseService) { super(databaseService); }
|
public DatasetDaoImpl(DatabaseService<DescriptionEntity> databaseService) { super(databaseService); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
|
public QueryableList<DescriptionEntity> getWithCriteria(DatasetCriteria criteria) {
|
||||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
|
QueryableList<DescriptionEntity> query = getDatabaseService().getQueryable(DescriptionEntity.getHints(), 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"), Dataset.Status.FINALISED.getValue()));
|
query.where((builder, root) -> builder.equal(root.get("status"), DescriptionStatus.Finalized));
|
||||||
/*query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
|
/*query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
|
||||||
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
|
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
|
||||||
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));*/
|
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));*/
|
||||||
|
@ -83,13 +85,13 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
||||||
if (criteria.hasDoi()) {
|
if (criteria.hasDoi()) {
|
||||||
query.where((builder, root) -> builder.not(builder.isNull(root.join("dmp").join("dois").get("id"))));
|
query.where((builder, root) -> builder.not(builder.isNull(root.join("dmp").join("dois").get("id"))));
|
||||||
}
|
}
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get(DescriptionEntity._isActive), IsActive.Inactive));
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.CANCELED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get("status"), DescriptionStatus.Canceled));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QueryableList<Dataset> filterFromElastic(DatasetCriteria criteria, List<UUID> ids) {
|
public QueryableList<DescriptionEntity> filterFromElastic(DatasetCriteria criteria, List<UUID> ids) {
|
||||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
|
QueryableList<DescriptionEntity> query = getDatabaseService().getQueryable(DescriptionEntity.getHints(), 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())
|
||||||
|
@ -99,32 +101,32 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset createOrUpdate(Dataset item) {
|
public DescriptionEntity createOrUpdate(DescriptionEntity item) {
|
||||||
return getDatabaseService().createOrUpdate(item, Dataset.class);
|
return getDatabaseService().createOrUpdate(item, DescriptionEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset find(UUID id) throws InvalidApplicationException {
|
public DescriptionEntity find(UUID id) throws InvalidApplicationException {
|
||||||
return getDatabaseService().getQueryable(Dataset.class)
|
return getDatabaseService().getQueryable(DescriptionEntity.class)
|
||||||
.where((builder, root) -> builder.and(builder.notEqual(root.get("status"),Dataset.Status.DELETED.getValue()), builder.notEqual(root.get("status"),Dataset.Status.CANCELED.getValue()), 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 Dataset find(UUID id, String hint) throws InvalidApplicationException {
|
public DescriptionEntity find(UUID id, String hint) throws InvalidApplicationException {
|
||||||
return getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class).withHint(hint)
|
return getDatabaseService().getQueryable(DescriptionEntity.getHints(), DescriptionEntity.class).withHint(hint)
|
||||||
.where((builder, root) -> builder.and(builder.notEqual(root.get("status"),Dataset.Status.DELETED.getValue()), builder.notEqual(root.get("status"),Dataset.Status.CANCELED.getValue()), 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 Dataset isPublicDataset(UUID id) throws InvalidApplicationException {
|
public DescriptionEntity isPublicDataset(UUID id) throws InvalidApplicationException {
|
||||||
QueryableList<Dataset> query = getDatabaseService().getQueryable(Dataset.getHints(), Dataset.class);
|
QueryableList<DescriptionEntity> query = getDatabaseService().getQueryable(DescriptionEntity.getHints(), 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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> getAuthenticated(QueryableList<Dataset> query, UserInfo principal, List<Integer> roles) {
|
public QueryableList<DescriptionEntity> getAuthenticated(QueryableList<DescriptionEntity> query, UserInfo principal, List<Integer> roles) {
|
||||||
if (roles != null && !roles.isEmpty()) {
|
if (roles != null && !roles.isEmpty()) {
|
||||||
query.where((builder, root) -> {
|
query.where((builder, root) -> {
|
||||||
Join userJoin = root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT);
|
Join userJoin = root.join("dmp", JoinType.LEFT).join("users", JoinType.LEFT);
|
||||||
|
@ -138,17 +140,17 @@ public class DatasetDaoImpl extends DatabaseAccess<Dataset> implements DatasetDa
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Dataset item) {
|
public void delete(DescriptionEntity item) {
|
||||||
this.getDatabaseService().delete(item);
|
this.getDatabaseService().delete(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> asQueryable() {
|
public QueryableList<DescriptionEntity> asQueryable() {
|
||||||
return this.getDatabaseService().getQueryable(Dataset.class);
|
return this.getDatabaseService().getQueryable(DescriptionEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Async
|
@Async
|
||||||
public CompletableFuture<Dataset> createOrUpdateAsync(Dataset item) {
|
public CompletableFuture<DescriptionEntity> createOrUpdateAsync(DescriptionEntity item) {
|
||||||
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
return CompletableFuture.supplyAsync(() -> this.createOrUpdate(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package eu.eudat.data.query.items.table.dataset;
|
package eu.eudat.data.query.items.table.dataset;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.dao.criteria.DatasetPublicCriteria;
|
import eu.eudat.data.dao.criteria.DatasetPublicCriteria;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
import eu.eudat.data.query.definition.TableQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
|
@ -15,12 +17,12 @@ import java.util.UUID;
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 10/2/2018.
|
* Created by ikalyvas on 10/2/2018.
|
||||||
*/
|
*/
|
||||||
public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria, Dataset, UUID> {
|
public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria, DescriptionEntity, UUID> {
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> applyCriteria() {
|
public QueryableList<DescriptionEntity> applyCriteria() {
|
||||||
QueryableList<Dataset> query = this.getQuery();
|
QueryableList<DescriptionEntity> query = this.getQuery();
|
||||||
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"), Dataset.Status.FINALISED.getValue()));
|
query.where((builder, root) -> builder.equal(root.get("status"), DescriptionStatus.Finalized.getValue()));
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
|
||||||
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
|
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
|
||||||
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
||||||
|
@ -45,12 +47,12 @@ public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria,
|
||||||
.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().getDatasetProfile())));
|
.where(((builder, root) -> root.get("profile").get("id").in(this.getCriteria().getDatasetProfile())));
|
||||||
if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty()) query
|
if (this.getCriteria().getDmpOrganisations() != null && !this.getCriteria().getDmpOrganisations().isEmpty()) query
|
||||||
.where(((builder, root) -> root.join("dmp").join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
|
.where(((builder, root) -> root.join("dmp").join("organisations").get("reference").in(this.getCriteria().getDmpOrganisations())));
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get(DescriptionEntity._isActive), IsActive.Inactive));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> applyPaging(QueryableList<Dataset> items) {
|
public QueryableList<DescriptionEntity> applyPaging(QueryableList<DescriptionEntity> items) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.eudat.data.query.items.table.dataset;
|
package eu.eudat.data.query.items.table.dataset;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
import eu.eudat.data.query.definition.TableQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
|
@ -10,10 +11,10 @@ import eu.eudat.queryable.types.SelectionField;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DatasetTableRequest extends TableQuery<DatasetCriteria, Dataset, UUID> {
|
public class DatasetTableRequest extends TableQuery<DatasetCriteria, DescriptionEntity, UUID> {
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> applyCriteria() {
|
public QueryableList<DescriptionEntity> applyCriteria() {
|
||||||
QueryableList<Dataset> query = this.getQuery();
|
QueryableList<DescriptionEntity> query = this.getQuery();
|
||||||
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
if (this.getCriteria().getLike() != null && !this.getCriteria().getLike().isEmpty())
|
||||||
query.where((builder, root) -> builder.or(
|
query.where((builder, root) -> builder.or(
|
||||||
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
|
builder.like(builder.upper(root.get("label")), "%" + this.getCriteria().getLike().toUpperCase() + "%"),
|
||||||
|
@ -28,12 +29,12 @@ public class DatasetTableRequest extends TableQuery<DatasetCriteria, Dataset, UU
|
||||||
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"), query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
||||||
if (this.getCriteria().getDmpIds() != null && !this.getCriteria().getDmpIds().isEmpty())
|
if (this.getCriteria().getDmpIds() != null && !this.getCriteria().getDmpIds().isEmpty())
|
||||||
query.where((builder, root) -> root.get("dmp").get("id").in(this.getCriteria().getDmpIds()));
|
query.where((builder, root) -> root.get("dmp").get("id").in(this.getCriteria().getDmpIds()));
|
||||||
query.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED));
|
query.where((builder, root) -> builder.equal(root.get("status"), DescriptionStatus.Finalized));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> applyPaging(QueryableList<Dataset> items) {
|
public QueryableList<DescriptionEntity> applyPaging(QueryableList<DescriptionEntity> items) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.query;
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
@ -134,7 +134,7 @@ public class DMPQuery extends Query<DMP, UUID> {
|
||||||
query.where((builder, root) -> root.get("creator").get("id").in(userInfoSubQuery));
|
query.where((builder, root) -> root.get("creator").get("id").in(userInfoSubQuery));
|
||||||
}
|
}
|
||||||
if(this.datasetQuery != null){
|
if(this.datasetQuery != null){
|
||||||
Subquery<Dataset> datasetSubQuery = this.datasetQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:id")));
|
Subquery<DescriptionEntity> datasetSubQuery = this.datasetQuery.getQuery().query(Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:id")));
|
||||||
query.where((builder, root) -> root.get("id").in(datasetSubQuery ));
|
query.where((builder, root) -> root.get("id").in(datasetSubQuery ));
|
||||||
}
|
}
|
||||||
if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) {
|
if (!this.getSelectionFields().isEmpty() && this.getSelectionFields() != null) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.query;
|
||||||
|
|
||||||
import eu.eudat.data.dao.DatabaseAccessLayer;
|
import eu.eudat.data.dao.DatabaseAccessLayer;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.queryable.types.FieldSelectionType;
|
import eu.eudat.queryable.types.FieldSelectionType;
|
||||||
import eu.eudat.queryable.types.SelectionField;
|
import eu.eudat.queryable.types.SelectionField;
|
||||||
|
@ -14,17 +14,17 @@ import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class DatasetQuery extends Query<Dataset, UUID> {
|
public class DatasetQuery extends Query<DescriptionEntity, UUID> {
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private DMPQuery dmpQuery;
|
private DMPQuery dmpQuery;
|
||||||
|
|
||||||
public DatasetQuery(DatabaseAccessLayer<Dataset, UUID> databaseAccessLayer) {
|
public DatasetQuery(DatabaseAccessLayer<DescriptionEntity, UUID> databaseAccessLayer) {
|
||||||
super(databaseAccessLayer);
|
super(databaseAccessLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetQuery(DatabaseAccessLayer<Dataset, UUID> databaseAccessLayer, List<String> selectionFields) {
|
public DatasetQuery(DatabaseAccessLayer<DescriptionEntity, UUID> databaseAccessLayer, List<String> selectionFields) {
|
||||||
super(databaseAccessLayer, selectionFields);
|
super(databaseAccessLayer, selectionFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ public class DatasetQuery extends Query<Dataset, UUID> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> getQuery() throws InvalidApplicationException {
|
public QueryableList<DescriptionEntity> getQuery() throws InvalidApplicationException {
|
||||||
QueryableList<Dataset> query = this.databaseAccessLayer.asQueryable();
|
QueryableList<DescriptionEntity> query = this.databaseAccessLayer.asQueryable();
|
||||||
if (this.id != null) {
|
if (this.id != null) {
|
||||||
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
|
query.where((builder, root) -> builder.equal(root.get("id"), this.id));
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import eu.eudat.criteria.DMPCriteria;
|
||||||
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
|
import eu.eudat.data.dao.criteria.DynamicFieldsCriteria;
|
||||||
import eu.eudat.data.dao.criteria.RequestItem;
|
import eu.eudat.data.dao.criteria.RequestItem;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||||
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
import eu.eudat.data.query.items.table.dmp.DataManagementPlanTableRequest;
|
||||||
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
|
import eu.eudat.exceptions.datamanagementplan.DMPNewVersionException;
|
||||||
|
@ -31,7 +31,6 @@ import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||||
import eu.eudat.models.data.listingmodels.VersionListingModel;
|
import eu.eudat.models.data.listingmodels.VersionListingModel;
|
||||||
import eu.eudat.query.DMPQuery;
|
import eu.eudat.query.DMPQuery;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import eu.eudat.types.Authorities;
|
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -373,21 +372,21 @@ public class DMPs extends BaseController {
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/index"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/index"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Dataset>> generateIndex() throws Exception {
|
ResponseEntity<ResponseItem<DescriptionEntity>> generateIndex() throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
this.dataManagementPlanManager.generateIndex();
|
this.dataManagementPlanManager.generateIndex();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = {"/index"})
|
@RequestMapping(method = RequestMethod.DELETE, value = {"/index"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Dataset>> clearIndex() throws Exception {
|
ResponseEntity<ResponseItem<DescriptionEntity>> clearIndex() throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
this.dataManagementPlanManager.clearIndex();
|
this.dataManagementPlanManager.clearIndex();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class DatasetProfileController extends BaseController {
|
||||||
/* @Transactional
|
/* @Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/save/{id}"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/save/{id}"}, consumes = "application/json", produces = "application/json")
|
||||||
public ResponseEntity<Object> updateDataset(@PathVariable String id, @RequestBody PropertiesModel properties) {
|
public ResponseEntity<Object> updateDataset(@PathVariable String id, @RequestBody PropertiesModel properties) {
|
||||||
eu.eudat.data.old.Dataset dataset = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(id));
|
eu.eudat.data.Dataset dataset = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao().find(UUID.fromString(id));
|
||||||
Map<String, Object> values = new HashMap<>();
|
Map<String, Object> values = new HashMap<>();
|
||||||
properties.toMap(values);
|
properties.toMap(values);
|
||||||
JSONObject jobject = new JSONObject(values);
|
JSONObject jobject = new JSONObject(values);
|
||||||
|
|
|
@ -2,7 +2,7 @@ package eu.eudat.controllers;
|
||||||
|
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
||||||
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileWizardAutocompleteRequest;
|
||||||
|
@ -289,33 +289,33 @@ public class Datasets extends BaseController {
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Dataset>> makePublic(@PathVariable UUID id, Locale locale) throws Exception {
|
ResponseEntity<ResponseItem<DescriptionEntity>> makePublic(@PathVariable UUID id, Locale locale) throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
this.datasetManager.makePublic(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id);
|
this.datasetManager.makePublic(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message(this.getApiContext().getHelpersService().getMessageSource().getMessage("dataset.public", new Object[]{}, locale)));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message(this.getApiContext().getHelpersService().getMessageSource().getMessage("dataset.public", new Object[]{}, locale)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.DELETE, value = {"/delete/{id}"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Dataset>> delete(@PathVariable(value = "id") UUID id) throws Exception {
|
ResponseEntity<ResponseItem<DescriptionEntity>> delete(@PathVariable(value = "id") UUID id) throws Exception {
|
||||||
new DatasetWizardManager().delete(this.getApiContext(), id);
|
new DatasetWizardManager().delete(this.getApiContext(), id);
|
||||||
this.fileManager.markAllFilesOfEntityIdAsDeleted(id);
|
this.fileManager.markAllFilesOfEntityIdAsDeleted(id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted"));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Deleted"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/{id}/unlock"}, produces = "application/json")
|
@RequestMapping(method = RequestMethod.GET, value = {"/{id}/unlock"}, produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Dataset>> unlock(@PathVariable(value = "id") UUID id) throws Exception {
|
ResponseEntity<ResponseItem<DescriptionEntity>> unlock(@PathVariable(value = "id") UUID id) throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
new DatasetWizardManager().unlock(this.getApiContext(), id);
|
new DatasetWizardManager().unlock(this.getApiContext(), id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
|
||||||
} catch (DatasetWizardCannotUnlockException datasetWizardCannotUnlockException) {
|
} catch (DatasetWizardCannotUnlockException datasetWizardCannotUnlockException) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Dataset>().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage()));
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.ERROR_MESSAGE).message(datasetWizardCannotUnlockException.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -324,8 +324,8 @@ public class Datasets extends BaseController {
|
||||||
ResponseEntity<ResponseItem<Boolean>> validate(@PathVariable(value = "id") UUID id) throws Exception {
|
ResponseEntity<ResponseItem<Boolean>> validate(@PathVariable(value = "id") UUID id) throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
Dataset dataset = datasetManager.getEntitySingle(id);
|
DescriptionEntity descriptionEntity = datasetManager.getEntitySingle(id);
|
||||||
String failedField = datasetManager.checkDatasetValidation(dataset);
|
String failedField = datasetManager.checkDatasetValidation(descriptionEntity);
|
||||||
if (failedField == null) {
|
if (failedField == null) {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Valid"));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Boolean>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Valid"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -342,8 +342,8 @@ public class Datasets extends BaseController {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Dataset dataset = this.datasetManager.createDatasetFromXml(file, dmpId, datasetProfileId);
|
DescriptionEntity descriptionEntity = this.datasetManager.createDatasetFromXml(file, dmpId, datasetProfileId);
|
||||||
if (dataset != null){
|
if (descriptionEntity != null){
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -362,21 +362,21 @@ public class Datasets extends BaseController {
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/index"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/index"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Dataset>> generateIndex() throws Exception {
|
ResponseEntity<ResponseItem<DescriptionEntity>> generateIndex() throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
this.datasetManager.generateIndex();
|
this.datasetManager.generateIndex();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = {"/index"})
|
@RequestMapping(method = RequestMethod.DELETE, value = {"/index"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Dataset>> clearIndex() throws Exception {
|
ResponseEntity<ResponseItem<DescriptionEntity>> clearIndex() throws Exception {
|
||||||
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
this.authorizationService.authorizeForce(Permission.AuthenticatedRole);
|
||||||
|
|
||||||
this.datasetManager.clearIndex();
|
this.datasetManager.clearIndex();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DescriptionEntity>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
@ -10,29 +7,27 @@ import eu.eudat.commons.enums.FieldType;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
import eu.eudat.commons.types.descriptiontemplate.FieldEntity;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.FieldSetEntity;
|
|
||||||
import eu.eudat.commons.types.descriptiontemplate.SectionEntity;
|
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.UploadDataEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
import eu.eudat.data.DmpEntity;
|
||||||
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.FileUpload;
|
import eu.eudat.data.old.FileUpload;
|
||||||
import eu.eudat.exceptions.security.UnauthorisedException;
|
import eu.eudat.exceptions.security.UnauthorisedException;
|
||||||
import eu.eudat.logic.managers.DatasetProfileManager;
|
import eu.eudat.logic.managers.DatasetProfileManager;
|
||||||
import eu.eudat.logic.services.ApiContext;
|
import eu.eudat.logic.services.ApiContext;
|
||||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||||
import eu.eudat.logic.utilities.json.JsonSearcher;
|
|
||||||
import eu.eudat.models.HintedModelFactory;
|
import eu.eudat.models.HintedModelFactory;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
|
import eu.eudat.query.DmpQuery;
|
||||||
import eu.eudat.types.ApiMessageCode;
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
import gr.cite.tools.data.query.QueryFactory;
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import jakarta.xml.bind.JAXBException;
|
import jakarta.xml.bind.JAXBException;
|
||||||
import org.apache.poi.util.IOUtils;
|
import org.apache.poi.util.IOUtils;
|
||||||
import org.json.JSONArray;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
@ -40,7 +35,6 @@ import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.util.unit.DataSize;
|
import org.springframework.util.unit.DataSize;
|
||||||
import org.springframework.util.unit.DataUnit;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@ -147,11 +141,14 @@ public class FileController {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fileUpload.getEntityType().name().equals(FileUpload.EntityType.DATASET.name())) {
|
if(fileUpload.getEntityType().name().equals(FileUpload.EntityType.DATASET.name())) {
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().find(fileUpload.getEntityId(), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(fileUpload.getEntityId(), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
if (datasetEntity == null) {
|
if (descriptionEntityEntity == null) {
|
||||||
throw new NoSuchElementException("No dataset with id " + fileUpload.getEntityId() + " found. This dataset was related to the file with id " + id);
|
throw new NoSuchElementException("No dataset with id " + fileUpload.getEntityId() + " found. This dataset was related to the file with id " + id);
|
||||||
}
|
}
|
||||||
if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers()
|
|
||||||
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
||||||
|
|
||||||
|
if (!dmp.isPublic() && dmp.getUsers()
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0)
|
.collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.controllers.v2;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import eu.eudat.audit.AuditableAction;
|
import eu.eudat.audit.AuditableAction;
|
||||||
import eu.eudat.authorization.AuthorizationFlags;
|
import eu.eudat.authorization.AuthorizationFlags;
|
||||||
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.model.DescriptionTemplate;
|
import eu.eudat.model.DescriptionTemplate;
|
||||||
import eu.eudat.model.DmpBlueprint;
|
import eu.eudat.model.DmpBlueprint;
|
||||||
|
@ -12,9 +13,11 @@ import eu.eudat.model.censorship.DmpBlueprintCensor;
|
||||||
import eu.eudat.model.persist.DescriptionTemplatePersist;
|
import eu.eudat.model.persist.DescriptionTemplatePersist;
|
||||||
import eu.eudat.model.persist.NewVersionDescriptionTemplatePersist;
|
import eu.eudat.model.persist.NewVersionDescriptionTemplatePersist;
|
||||||
import eu.eudat.model.result.QueryResult;
|
import eu.eudat.model.result.QueryResult;
|
||||||
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
||||||
import eu.eudat.query.DescriptionTemplateQuery;
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
import eu.eudat.query.lookup.DescriptionTemplateLookup;
|
import eu.eudat.query.lookup.DescriptionTemplateLookup;
|
||||||
import eu.eudat.service.descriptiontemplate.DescriptionTemplateService;
|
import eu.eudat.service.descriptiontemplate.DescriptionTemplateService;
|
||||||
|
import eu.eudat.types.ApiMessageCode;
|
||||||
import gr.cite.tools.auditing.AuditService;
|
import gr.cite.tools.auditing.AuditService;
|
||||||
import gr.cite.tools.data.builder.BuilderFactory;
|
import gr.cite.tools.data.builder.BuilderFactory;
|
||||||
import gr.cite.tools.data.censor.CensorFactory;
|
import gr.cite.tools.data.censor.CensorFactory;
|
||||||
|
@ -30,6 +33,7 @@ import jakarta.xml.bind.JAXBException;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.MessageSource;
|
import org.springframework.context.MessageSource;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
import eu.eudat.data.dao.criteria.DatasetCriteria;
|
||||||
|
@ -10,7 +12,7 @@ import eu.eudat.data.dao.entities.DatasetDao;
|
||||||
import eu.eudat.data.dao.entities.GrantDao;
|
import eu.eudat.data.dao.entities.GrantDao;
|
||||||
import eu.eudat.data.dao.entities.OrganisationDao;
|
import eu.eudat.data.dao.entities.OrganisationDao;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
||||||
|
@ -97,7 +99,7 @@ public class DashBoardManager {
|
||||||
LinkedList<Grant> grants = new LinkedList<>();
|
LinkedList<Grant> grants = new LinkedList<>();
|
||||||
for (DMP dmp : dmps) {
|
for (DMP dmp : dmps) {
|
||||||
numberOfDatasets = numberOfDatasets + dmp.getDataset().stream()
|
numberOfDatasets = numberOfDatasets + dmp.getDataset().stream()
|
||||||
.filter(item -> item.getStatus() == Dataset.Status.FINALISED.getValue()).count();
|
.filter(item -> item.getStatus() == DescriptionStatus.Finalized).count();
|
||||||
if (dmp.getGrant() != null) {
|
if (dmp.getGrant() != null) {
|
||||||
grants.add(dmp.getGrant());
|
grants.add(dmp.getGrant());
|
||||||
}
|
}
|
||||||
|
@ -206,7 +208,7 @@ public class DashBoardManager {
|
||||||
.withHint("datasetRecentActivity")
|
.withHint("datasetRecentActivity")
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
.take(numberofactivities)
|
.take(numberofactivities)
|
||||||
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(item.getModified()).id(item.getId().toString()).build())
|
.selectAsync(item -> recentActivityDataBuilder.label(item.getLabel()).timestamp(Date.from(item.getUpdatedAt())).id(item.getId().toString()).build())
|
||||||
.whenComplete((datasetActivities, throwable) -> activity.setRecentDatasetActivities(datasetActivities));
|
.whenComplete((datasetActivities, throwable) -> activity.setRecentDatasetActivities(datasetActivities));
|
||||||
|
|
||||||
CompletableFuture<List<RecentActivityData>> grants = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user)
|
CompletableFuture<List<RecentActivityData>> grants = grantRepository.getAuthenticated(grantRepository.getWithCriteria(grantCriteria), user)
|
||||||
|
@ -317,7 +319,7 @@ public class DashBoardManager {
|
||||||
|
|
||||||
CompletableFuture<List<SearchBarItem>> publicDatasets = datasetRepository.asQueryable()
|
CompletableFuture<List<SearchBarItem>> publicDatasets = datasetRepository.asQueryable()
|
||||||
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
||||||
.where((builder, root) -> builder.equal(root.get("status"), Dataset.Status.FINALISED.getValue()))
|
.where((builder, root) -> builder.equal(root.get("status"), DescriptionStatus.Finalized))
|
||||||
.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true))
|
.where((builder, root) -> builder.equal(root.get("dmp").get("isPublic"), true))
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DATASET.getValue(), true))
|
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DATASET.getValue(), true))
|
||||||
|
@ -335,8 +337,8 @@ public class DashBoardManager {
|
||||||
CompletableFuture<List<SearchBarItem>> datasets = datasetRepository.getAuthenticated(datasetRepository.asQueryable(), user, roles)
|
CompletableFuture<List<SearchBarItem>> datasets = datasetRepository.getAuthenticated(datasetRepository.asQueryable(), user, roles)
|
||||||
.withHint("datasetRecentActivity")
|
.withHint("datasetRecentActivity")
|
||||||
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
.where((builder, root) -> builder.like(builder.upper(root.get("label")), "%" + like.toUpperCase() + "%"))
|
||||||
.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()))
|
.where((builder, root) -> builder.notEqual(root.get(DescriptionEntity._isActive), IsActive.Inactive))
|
||||||
.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.CANCELED.getValue()))
|
.where((builder, root) -> builder.notEqual(root.get("status"), DescriptionStatus.Canceled))
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
.orderBy((builder, root) -> builder.desc(root.get("modified")))
|
||||||
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DATASET.getValue(), false))
|
.selectAsync(item -> new SearchBarItem(item.getId().toString(), item.getLabel(), SearchBarItemType.DATASET.getValue(), false))
|
||||||
.whenComplete((dataSetItems, throwable) -> searchBarItems.addAll(dataSetItems));
|
.whenComplete((dataSetItems, throwable) -> searchBarItems.addAll(dataSetItems));
|
||||||
|
|
|
@ -4,11 +4,12 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
import eu.eudat.commons.XmlHandlingService;
|
import eu.eudat.commons.XmlHandlingService;
|
||||||
|
import eu.eudat.commons.enums.*;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.commons.enums.EntityType;
|
|
||||||
import eu.eudat.commons.types.dmpblueprint.*;
|
import eu.eudat.commons.types.dmpblueprint.*;
|
||||||
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
import eu.eudat.configurations.dynamicgrant.DynamicGrantConfiguration;
|
||||||
import eu.eudat.configurations.dynamicgrant.entities.Property;
|
import eu.eudat.configurations.dynamicgrant.entities.Property;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.data.dao.criteria.*;
|
import eu.eudat.data.dao.criteria.*;
|
||||||
|
@ -59,8 +60,6 @@ import eu.eudat.models.data.dmp.*;
|
||||||
import eu.eudat.models.data.doi.DepositRequest;
|
import eu.eudat.models.data.doi.DepositRequest;
|
||||||
import eu.eudat.models.data.doi.Doi;
|
import eu.eudat.models.data.doi.Doi;
|
||||||
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
import eu.eudat.models.data.dynamicfields.DynamicFieldWithValue;
|
||||||
import eu.eudat.commons.enums.DmpBlueprintFieldCategory;
|
|
||||||
import eu.eudat.commons.enums.DmpBlueprintSystemFieldType;
|
|
||||||
import eu.eudat.models.data.funder.FunderDMPEditorModel;
|
import eu.eudat.models.data.funder.FunderDMPEditorModel;
|
||||||
import eu.eudat.models.data.grant.GrantDMPEditorModel;
|
import eu.eudat.models.data.grant.GrantDMPEditorModel;
|
||||||
import eu.eudat.models.data.helpermodels.Tuple;
|
import eu.eudat.models.data.helpermodels.Tuple;
|
||||||
|
@ -69,6 +68,7 @@ import eu.eudat.models.data.listingmodels.*;
|
||||||
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
import eu.eudat.models.data.project.ProjectDMPEditorModel;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import eu.eudat.models.data.userinfo.UserListingModel;
|
import eu.eudat.models.data.userinfo.UserListingModel;
|
||||||
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
import eu.eudat.query.DmpBlueprintQuery;
|
import eu.eudat.query.DmpBlueprintQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.service.dmpblueprint.DmpBlueprintService;
|
import eu.eudat.service.dmpblueprint.DmpBlueprintService;
|
||||||
|
@ -279,12 +279,12 @@ public class DataManagementPlanManager {
|
||||||
return dataTable;
|
return dataTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Dataset> retrieveRelevantDatasets(DatasetCriteria datasetCriteria) throws InvalidApplicationException {
|
private Set<DescriptionEntity> retrieveRelevantDatasets(DatasetCriteria datasetCriteria) throws InvalidApplicationException {
|
||||||
return retrieveRelevantDatasets(datasetCriteria, null);
|
return retrieveRelevantDatasets(datasetCriteria, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<Dataset> retrieveRelevantDatasets (DatasetCriteria datasetCriteria, UUID principal) throws InvalidApplicationException {
|
private Set<DescriptionEntity> retrieveRelevantDatasets (DatasetCriteria datasetCriteria, UUID principal) throws InvalidApplicationException {
|
||||||
QueryableList<Dataset> datasetItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria)
|
QueryableList<DescriptionEntity> datasetItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria)
|
||||||
.orderBy((builder, root) -> builder.desc(root.get("modified")));
|
.orderBy((builder, root) -> builder.desc(root.get("modified")));
|
||||||
if (principal != null) {
|
if (principal != null) {
|
||||||
UserInfo userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal);
|
UserInfo userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal);
|
||||||
|
@ -297,13 +297,13 @@ public class DataManagementPlanManager {
|
||||||
DatasetTableRequest datasetTableRequest = new DatasetTableRequest();
|
DatasetTableRequest datasetTableRequest = new DatasetTableRequest();
|
||||||
datasetTableRequest.setOffset(0);
|
datasetTableRequest.setOffset(0);
|
||||||
datasetTableRequest.setLength(3);
|
datasetTableRequest.setLength(3);
|
||||||
Set<Dataset> datasetsSet = new LinkedHashSet<>();
|
Set<DescriptionEntity> datasetsSet = new LinkedHashSet<>();
|
||||||
try {
|
try {
|
||||||
datasetItems = PaginationManager.applyPaging(datasetItems, datasetTableRequest);
|
datasetItems = PaginationManager.applyPaging(datasetItems, datasetTableRequest);
|
||||||
List<Dataset> datasets = datasetItems.distinct().toList();
|
List<DescriptionEntity> descriptionEntities = datasetItems.distinct().toList();
|
||||||
datasetsSet.addAll(datasets);
|
datasetsSet.addAll(descriptionEntities);
|
||||||
for (int i = 0; i < maxDatasets - datasets.size(); i++) {
|
for (int i = 0; i < maxDatasets - descriptionEntities.size(); i++) {
|
||||||
Dataset fakedataset = new Dataset();
|
DescriptionEntity fakedataset = new DescriptionEntity();
|
||||||
fakedataset.setId(UUID.randomUUID());
|
fakedataset.setId(UUID.randomUUID());
|
||||||
datasetsSet.add(fakedataset);
|
datasetsSet.add(fakedataset);
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ public class DataManagementPlanManager {
|
||||||
});
|
});
|
||||||
});*/
|
});*/
|
||||||
if (isPublic) {
|
if (isPublic) {
|
||||||
dataManagementPlan.setDatasets(dataManagementPlan.getDatasets().stream().filter(dataset -> dataset.getStatus() == Dataset.Status.FINALISED.getValue()).collect(Collectors.toList()));
|
dataManagementPlan.setDatasets(dataManagementPlan.getDatasets().stream().filter(dataset -> dataset.getStatus() == DescriptionStatus.Finalized).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dataManagementPlan.fromDataModelNoDatasets(dataManagementPlanEntity);
|
dataManagementPlan.fromDataModelNoDatasets(dataManagementPlanEntity);
|
||||||
|
@ -383,7 +383,7 @@ public class DataManagementPlanManager {
|
||||||
datamanagementPlan.fromDataModelDatasets(dataManagementPlanEntity);
|
datamanagementPlan.fromDataModelDatasets(dataManagementPlanEntity);
|
||||||
datamanagementPlan.setDatasets(datamanagementPlan.getDatasets().stream().sorted(Comparator.comparing(DatasetOverviewModel::getCreated).reversed()).collect(Collectors.toList()));
|
datamanagementPlan.setDatasets(datamanagementPlan.getDatasets().stream().sorted(Comparator.comparing(DatasetOverviewModel::getCreated).reversed()).collect(Collectors.toList()));
|
||||||
if (isPublic) {
|
if (isPublic) {
|
||||||
datamanagementPlan.setDatasets(datamanagementPlan.getDatasets().stream().filter(dataset -> dataset.getStatus() == Dataset.Status.FINALISED.getValue()).collect(Collectors.toList()));
|
datamanagementPlan.setDatasets(datamanagementPlan.getDatasets().stream().filter(dataset -> dataset.getStatus() == DescriptionStatus.Finalized).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return datamanagementPlan;
|
return datamanagementPlan;
|
||||||
|
@ -492,9 +492,9 @@ public class DataManagementPlanManager {
|
||||||
if (dbTime.toEpochMilli() != modelTime.toEpochMilli()) {
|
if (dbTime.toEpochMilli() != modelTime.toEpochMilli()) {
|
||||||
throw new Exception("Another user have already edit that DMP.");
|
throw new Exception("Another user have already edit that DMP.");
|
||||||
}
|
}
|
||||||
List<Dataset> datasetList = dmp1.getDataset().stream().filter(dataset -> dataset.getStatus() != 99).collect(Collectors.toList());
|
List<DescriptionEntity> descriptionEntityList = dmp1.getDataset().stream().filter(dataset -> dataset.getIsActive() != IsActive.Inactive).collect(Collectors.toList());
|
||||||
for (Dataset dataset : datasetList) {
|
for (DescriptionEntity descriptionEntity : descriptionEntityList) {
|
||||||
if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> dataset.getProfile().getId().equals(associatedProfile.getDescriptionTemplateId())).findAny().orElse(null) == null)
|
if (dataManagementPlan.getProfiles().stream().filter(associatedProfile -> descriptionEntity.getProfile().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()))
|
||||||
|
@ -596,32 +596,32 @@ public class DataManagementPlanManager {
|
||||||
if (dataManagementPlan.getDatasetsToBeFinalized() != null && !dataManagementPlan.getDatasetsToBeFinalized().isEmpty()) {
|
if (dataManagementPlan.getDatasetsToBeFinalized() != null && !dataManagementPlan.getDatasetsToBeFinalized().isEmpty()) {
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasetsToBeFinalized()))
|
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasetsToBeFinalized()))
|
||||||
.update(root -> root.<Integer>get("status"), Dataset.Status.FINALISED.getValue());
|
.update(root -> root.<Integer>get("status"), DescriptionStatus.Finalized);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasetsToBeFinalized()))
|
.asQueryable().where((builder, root) -> root.get("id").in(dataManagementPlan.getDatasetsToBeFinalized()))
|
||||||
.update(root -> root.<Date>get("finalizedat"), new Date());
|
.update(root -> root.<Date>get("finalizedat"), new Date());
|
||||||
|
|
||||||
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
||||||
for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) {
|
for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) {
|
||||||
if (!(dataset.getStatus() == (int) Dataset.Status.FINALISED.getValue()) && !dataManagementPlan.getDatasetsToBeFinalized().contains(dataset.getId())) {
|
if (!(dataset.getStatus() == DescriptionStatus.Finalized) && !dataManagementPlan.getDatasetsToBeFinalized().contains(dataset.getId())) {
|
||||||
datasetsToBeCanceled.add(UUID.fromString(dataset.getId().toString()));
|
datasetsToBeCanceled.add(UUID.fromString(dataset.getId().toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!datasetsToBeCanceled.isEmpty())
|
if (!datasetsToBeCanceled.isEmpty())
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
||||||
.update(root -> root.<Integer>get("status"), Dataset.Status.CANCELED.getValue());
|
.update(root -> root.<Integer>get("status"), DescriptionStatus.Canceled);
|
||||||
} else {
|
} else {
|
||||||
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
||||||
for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) {
|
for (DatasetWizardModel dataset : dataManagementPlan.getDatasets()) {
|
||||||
if (!(dataset.getStatus() == (int) Dataset.Status.FINALISED.getValue())) {
|
if (!(dataset.getStatus() == DescriptionStatus.Finalized)) {
|
||||||
datasetsToBeCanceled.add(dataset.getId());
|
datasetsToBeCanceled.add(dataset.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!datasetsToBeCanceled.isEmpty())
|
if (!datasetsToBeCanceled.isEmpty())
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
||||||
.update(root -> root.<Integer>get("status"), Dataset.Status.CANCELED.getValue());
|
.update(root -> root.<Integer>get("status"), DescriptionStatus.Canceled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,7 +666,7 @@ public class DataManagementPlanManager {
|
||||||
} else {
|
} else {
|
||||||
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.DRAFT);
|
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.DRAFT);
|
||||||
}
|
}
|
||||||
List<Dataset> datasets = new ArrayList<>();
|
List<DescriptionEntity> descriptionEntities = new ArrayList<>();
|
||||||
DMP tempDMP = dataManagementPlan.toDataModel();
|
DMP tempDMP = dataManagementPlan.toDataModel();
|
||||||
if (tempDMP.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue()) {
|
if (tempDMP.getStatus() == (int) DMP.DMPStatus.FINALISED.getValue()) {
|
||||||
checkDmpValidationRules(tempDMP);
|
checkDmpValidationRules(tempDMP);
|
||||||
|
@ -689,8 +689,8 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
for (DatasetWizardModel datasetWizardModel: dataManagementPlan.getDatasets()) {
|
for (DatasetWizardModel datasetWizardModel: dataManagementPlan.getDatasets()) {
|
||||||
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModel(result));
|
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModel(result));
|
||||||
Dataset dataset = datasetManager.createOrUpdate(datasetWizardModel);
|
DescriptionEntity descriptionEntity = datasetManager.createOrUpdate(datasetWizardModel);
|
||||||
datasets.add(dataset);
|
descriptionEntities.add(descriptionEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID dmpId = result.getId();
|
UUID dmpId = result.getId();
|
||||||
|
@ -910,15 +910,15 @@ public class DataManagementPlanManager {
|
||||||
} catch (IOException | InvalidApplicationException e) {
|
} catch (IOException | InvalidApplicationException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
for (Dataset dataset: dmp.getDataset()) {
|
for (DescriptionEntity descriptionEntity : dmp.getDataset()) {
|
||||||
try {
|
try {
|
||||||
List<Tag> tags = new ArrayList<>();
|
List<Tag> tags = new ArrayList<>();
|
||||||
eu.eudat.elastic.entities.Dataset elastic = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString());
|
eu.eudat.elastic.entities.Dataset elastic = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(descriptionEntity.getId().toString());
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
dataset.setDmp(dmp);
|
descriptionEntity.setDmp(dmp.getId());
|
||||||
this.datasetManager.updateTags(dataset, tags);
|
this.datasetManager.updateTags(descriptionEntity, tags);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -1040,89 +1040,97 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyDatasets(DMP newDmp, DatasetDao datasetDao) throws InvalidApplicationException {
|
private void copyDatasets(DMP newDmp, DatasetDao datasetDao) throws InvalidApplicationException {
|
||||||
List<CompletableFuture<Dataset>> futures = new LinkedList<>();
|
List<CompletableFuture<DescriptionEntity>> futures = new LinkedList<>();
|
||||||
for (Dataset dataset : newDmp.getDataset()) {
|
for (DescriptionEntity descriptionEntity : newDmp.getDataset()) {
|
||||||
Dataset tempDataset = datasetDao.find(dataset.getId());
|
DescriptionEntity tempDescriptionEntity = datasetDao.find(descriptionEntity.getId());
|
||||||
try {
|
try {
|
||||||
List<Tag> tags = new ArrayList<>();
|
List<Tag> tags = new ArrayList<>();
|
||||||
eu.eudat.elastic.entities.Dataset elastic = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString());
|
eu.eudat.elastic.entities.Dataset elastic = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(descriptionEntity.getId().toString());
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
UUID dmpId = tempDataset.getDmp().getId();
|
UUID dmpId = tempDescriptionEntity.getDmp();
|
||||||
tempDataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
//TODO
|
||||||
this.datasetManager.updateTags(tempDataset, tags);
|
//tempDescriptionEntity.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
||||||
|
this.datasetManager.updateTags(tempDescriptionEntity, tags);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
datasetDao.asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)).where((builder, root) -> builder.equal(root.get("id"), dataset.getId())).getSingleAsync()
|
datasetDao.asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)).where((builder, root) -> builder.equal(root.get("id"), descriptionEntity.getId())).getSingleAsync()
|
||||||
.thenApplyAsync(entityDataset -> {
|
.thenApplyAsync(entityDataset -> {
|
||||||
Dataset newDataset = new Dataset();
|
DescriptionEntity newDescriptionEntity = new DescriptionEntity();
|
||||||
newDataset.update(entityDataset);
|
newDescriptionEntity.update(entityDataset);
|
||||||
newDataset.setDmp(newDmp);
|
newDescriptionEntity.setDmp(newDmp.getId());
|
||||||
newDataset.setStatus(Dataset.Status.SAVED.getValue());
|
newDescriptionEntity.setStatus(DescriptionStatus.Saved);
|
||||||
if (newDataset.getDatasetDataRepositories() != null) {
|
//TODO
|
||||||
newDataset.setDatasetDataRepositories(newDataset.getDatasetDataRepositories().stream().map(item -> {
|
// if (newDescriptionEntity.getDatasetDataRepositories() != null) {
|
||||||
DataRepository dataRepository = new DataRepository();
|
// newDescriptionEntity.setDatasetDataRepositories(newDescriptionEntity.getDatasetDataRepositories().stream().map(item -> {
|
||||||
dataRepository.setId(item.getDataRepository().getId());
|
// DataRepository dataRepository = new DataRepository();
|
||||||
|
// dataRepository.setId(item.getDataRepository().getId());
|
||||||
DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
//
|
||||||
datasetDataRepository.setDataRepository(dataRepository);
|
// DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
||||||
datasetDataRepository.setDataset(newDataset);
|
// datasetDataRepository.setDataRepository(dataRepository);
|
||||||
datasetDataRepository.setData(item.getData());
|
// datasetDataRepository.setDataset(newDescriptionEntity);
|
||||||
return datasetDataRepository;
|
// datasetDataRepository.setData(item.getData());
|
||||||
}).collect(Collectors.toSet()));
|
// return datasetDataRepository;
|
||||||
}
|
// }).collect(Collectors.toSet()));
|
||||||
|
// }
|
||||||
if (newDataset.getDatasetExternalDatasets() != null) {
|
//
|
||||||
newDataset.setDatasetExternalDatasets(newDataset.getDatasetExternalDatasets().stream().map(item -> {
|
// if (newDescriptionEntity.getDatasetExternalDatasets() != null) {
|
||||||
ExternalDataset externalDataset = new ExternalDataset();
|
// newDescriptionEntity.setDatasetExternalDatasets(newDescriptionEntity.getDatasetExternalDatasets().stream().map(item -> {
|
||||||
externalDataset.setId(item.getExternalDataset().getId());
|
// ExternalDataset externalDataset = new ExternalDataset();
|
||||||
DatasetExternalDataset datasetExternalDataset = new DatasetExternalDataset();
|
// externalDataset.setId(item.getExternalDataset().getId());
|
||||||
datasetExternalDataset.setExternalDataset(externalDataset);
|
// DatasetExternalDataset datasetExternalDataset = new DatasetExternalDataset();
|
||||||
datasetExternalDataset.setDataset(newDataset);
|
// datasetExternalDataset.setExternalDataset(externalDataset);
|
||||||
datasetExternalDataset.setData(item.getData());
|
// datasetExternalDataset.setDataset(newDescriptionEntity);
|
||||||
return datasetExternalDataset;
|
// datasetExternalDataset.setData(item.getData());
|
||||||
}).collect(Collectors.toSet()));
|
// return datasetExternalDataset;
|
||||||
}
|
// }).collect(Collectors.toSet()));
|
||||||
|
// }
|
||||||
if (newDataset.getRegistries() != null) {
|
//
|
||||||
newDataset.setRegistries(newDataset.getRegistries().stream().map(item -> {
|
// if (newDescriptionEntity.getRegistries() != null) {
|
||||||
Registry registry = new Registry();
|
// newDescriptionEntity.setRegistries(newDescriptionEntity.getRegistries().stream().map(item -> {
|
||||||
registry.setId(item.getId());
|
// Registry registry = new Registry();
|
||||||
return registry;
|
// registry.setId(item.getId());
|
||||||
}).collect(Collectors.toSet()));
|
// return registry;
|
||||||
}
|
// }).collect(Collectors.toSet()));
|
||||||
|
// }
|
||||||
if (newDataset.getServices() != null) {
|
//
|
||||||
newDataset.setServices(newDataset.getServices().stream().map(item -> {
|
// if (newDescriptionEntity.getServices() != null) {
|
||||||
Service service = new Service();
|
// newDescriptionEntity.setServices(newDescriptionEntity.getServices().stream().map(item -> {
|
||||||
service.setId(item.getId());
|
// Service service = new Service();
|
||||||
DatasetService datasetService = new DatasetService();
|
// service.setId(item.getId());
|
||||||
datasetService.setService(service);
|
// DatasetService datasetService = new DatasetService();
|
||||||
datasetService.setDataset(newDataset);
|
// datasetService.setService(service);
|
||||||
datasetService.setData(item.getData());
|
// datasetService.setDataset(newDescriptionEntity);
|
||||||
return datasetService;
|
// datasetService.setData(item.getData());
|
||||||
}).collect(Collectors.toSet()));
|
// return datasetService;
|
||||||
}
|
// }).collect(Collectors.toSet()));
|
||||||
newDataset.setCreated(new Date());
|
// }
|
||||||
return newDataset;
|
newDescriptionEntity.setCreatedAt(Instant.now());
|
||||||
|
return newDescriptionEntity;
|
||||||
}).thenApplyAsync(item -> {
|
}).thenApplyAsync(item -> {
|
||||||
futures.add(datasetDao.createOrUpdateAsync(item).whenComplete(((dataset1, throwable) -> {
|
futures.add(datasetDao.createOrUpdateAsync(item).whenComplete(((dataset1, throwable) -> {
|
||||||
|
DMP dmp = null;
|
||||||
|
try {
|
||||||
|
dmp = this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(dataset1.getDmp());
|
||||||
|
} catch (InvalidApplicationException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.DRAFT);
|
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.DRAFT);
|
||||||
eu.eudat.elastic.entities.Dataset datasetElastic = new eu.eudat.elastic.entities.Dataset();
|
eu.eudat.elastic.entities.Dataset datasetElastic = new eu.eudat.elastic.entities.Dataset();
|
||||||
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().getId());
|
datasetElastic.setTemplate(dataset1.getProfile());
|
||||||
datasetElastic.setStatus(dataset1.getStatus());
|
datasetElastic.setStatus(dataset1.getStatus().getValue());
|
||||||
datasetElastic.setDmp(dataset1.getDmp().getId());
|
datasetElastic.setDmp(dataset1.getDmp());
|
||||||
datasetElastic.setGroup(dataset1.getDmp().getGroupId());
|
datasetElastic.setGroup(dmp.getGroupId());
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dataset1.getDmp().getProfile(), DmpBlueprintSystemFieldType.Grant)) {
|
if(this.dmpBlueprintService.fieldInBlueprint(dmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) {
|
||||||
datasetElastic.setGrant(dataset1.getDmp().getGrant().getId());
|
datasetElastic.setGrant(dmp.getGrant().getId());
|
||||||
}
|
}
|
||||||
if (dataset1.getDmp().getUsers() != null) {
|
if (dmp.getUsers() != null) {
|
||||||
datasetElastic.setCollaborators(dataset1.getDmp().getUsers().stream().map(user -> {
|
datasetElastic.setCollaborators(dmp.getUsers().stream().map(user -> {
|
||||||
Collaborator collaborator = new Collaborator();
|
Collaborator collaborator = new Collaborator();
|
||||||
collaborator.setId(user.getId().toString());
|
collaborator.setId(user.getId().toString());
|
||||||
collaborator.setRole(user.getRole());
|
collaborator.setRole(user.getRole());
|
||||||
|
@ -1132,21 +1140,21 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
datasetElastic.setLastVersion(true);
|
datasetElastic.setLastVersion(true);
|
||||||
datasetElastic.setLastPublicVersion(false);
|
datasetElastic.setLastPublicVersion(false);
|
||||||
if (dataset1.getDmp().getOrganisations() != null) {
|
if (dmp.getOrganisations() != null) {
|
||||||
datasetElastic.setOrganizations(dataset1.getDmp().getOrganisations().stream().map(org -> {
|
datasetElastic.setOrganizations(dmp.getOrganisations().stream().map(org -> {
|
||||||
Organization organization = new Organization();
|
Organization organization = new Organization();
|
||||||
organization.setId(org.getId().toString());
|
organization.setId(org.getId().toString());
|
||||||
organization.setName(org.getLabel());
|
organization.setName(org.getLabel());
|
||||||
return organization;
|
return organization;
|
||||||
}).collect(Collectors.toList()));
|
}).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
datasetElastic.setPublic(dataset1.getDmp().isPublic());
|
datasetElastic.setPublic(dmp.isPublic());
|
||||||
if(this.dmpBlueprintService.fieldInBlueprint(dataset1.getDmp().getProfile(), DmpBlueprintSystemFieldType.Grant)) {
|
if(this.dmpBlueprintService.fieldInBlueprint(dmp.getProfile(), DmpBlueprintSystemFieldType.Grant)) {
|
||||||
datasetElastic.setGrantStatus(dataset1.getDmp().getGrant().getStatus());
|
datasetElastic.setGrantStatus(dmp.getGrant().getStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
eu.eudat.elastic.entities.Dataset oldDatasetElastic = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString());
|
eu.eudat.elastic.entities.Dataset oldDatasetElastic = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(descriptionEntity.getId().toString());
|
||||||
if (oldDatasetElastic != null) {
|
if (oldDatasetElastic != null) {
|
||||||
datasetElastic.setTags(oldDatasetElastic.getTags());
|
datasetElastic.setTags(oldDatasetElastic.getTags());
|
||||||
}
|
}
|
||||||
|
@ -1186,8 +1194,9 @@ public class DataManagementPlanManager {
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
UUID tmdmpId = dataset.getDmp().getId();
|
UUID tmdmpId = dataset.getDmp();
|
||||||
dataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), tmdmpId)).toList()));
|
//TODO
|
||||||
|
//dataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), tmdmpId)).toList()));
|
||||||
this.datasetManager.updateTags(dataset, tags);
|
this.datasetManager.updateTags(dataset, tags);
|
||||||
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.PUBLISHED);
|
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.PUBLISHED);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -1206,27 +1215,27 @@ public class DataManagementPlanManager {
|
||||||
throw new Exception("User does not have the privilege to do this action.");
|
throw new Exception("User does not have the privilege to do this action.");
|
||||||
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
|
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()))
|
||||||
throw new Exception("DMP is already finalized");
|
throw new Exception("DMP is already finalized");
|
||||||
List<Dataset> indexDatasets = new ArrayList<>();
|
List<DescriptionEntity> indexDescriptionEntities = new ArrayList<>();
|
||||||
if (datasetsToBeFinalized != null && datasetsToBeFinalized.getUuids() != null && !datasetsToBeFinalized.getUuids().isEmpty()) {
|
if (datasetsToBeFinalized != null && datasetsToBeFinalized.getUuids() != null && !datasetsToBeFinalized.getUuids().isEmpty()) {
|
||||||
List<Dataset> finalizedDatasets = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
List<DescriptionEntity> finalizedDescriptionEntities = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeFinalized.getUuids()))
|
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeFinalized.getUuids()))
|
||||||
.toList();
|
.toList();
|
||||||
for (Dataset dataset: finalizedDatasets) {
|
for (DescriptionEntity descriptionEntity : finalizedDescriptionEntities) {
|
||||||
Dataset.Status status = Dataset.Status.fromInteger(dataset.getStatus());
|
DescriptionStatus status = descriptionEntity.getStatus();
|
||||||
Date finalizedDate = dataset.getFinalizedAt();
|
Instant finalizedDate = descriptionEntity.getFinalizedAt();
|
||||||
dataset.setStatus(Dataset.Status.FINALISED.getValue());
|
descriptionEntity.setStatus(DescriptionStatus.Finalized);
|
||||||
dataset.setFinalizedAt(new Date());
|
descriptionEntity.setFinalizedAt(Instant.now());
|
||||||
DatasetWizardModel wizardModel = new DatasetWizardModel();
|
DatasetWizardModel wizardModel = new DatasetWizardModel();
|
||||||
wizardModel = wizardModel.fromDataModel(dataset);
|
wizardModel = wizardModel.fromDataModel(descriptionEntity);
|
||||||
wizardModel.setDatasetProfileDefinition(this.datasetManager.getPagedProfile(wizardModel, dataset));
|
wizardModel.setDatasetProfileDefinition(this.datasetManager.getPagedProfile(wizardModel, descriptionEntity));
|
||||||
try {
|
try {
|
||||||
datasetManager.createOrUpdate(wizardModel);
|
datasetManager.createOrUpdate(wizardModel);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
dataset.setStatus(status.getValue());
|
descriptionEntity.setStatus(status);
|
||||||
dataset.setFinalizedAt(finalizedDate);
|
descriptionEntity.setFinalizedAt(finalizedDate);
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
dataset.setModified(new Date());
|
descriptionEntity.setUpdatedAt(Instant.now());
|
||||||
}
|
}
|
||||||
/*apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
/*apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeFinalized.getUuids()))
|
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeFinalized.getUuids()))
|
||||||
|
@ -1237,35 +1246,35 @@ public class DataManagementPlanManager {
|
||||||
dataset.setFinalizedAt(new Date());
|
dataset.setFinalizedAt(new Date());
|
||||||
dataset.setModified(new Date());
|
dataset.setModified(new Date());
|
||||||
} );*/
|
} );*/
|
||||||
indexDatasets.addAll(finalizedDatasets);
|
indexDescriptionEntities.addAll(finalizedDescriptionEntities);
|
||||||
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
||||||
for (Dataset dataset : dmp.getDataset()) {
|
for (DescriptionEntity descriptionEntity : dmp.getDataset()) {
|
||||||
if (!dataset.getStatus().equals(Dataset.Status.FINALISED.getValue()) && !datasetsToBeFinalized.getUuids().contains(dataset.getId())) {
|
if (!descriptionEntity.getStatus().equals(DescriptionStatus.Finalized) && !datasetsToBeFinalized.getUuids().contains(descriptionEntity.getId())) {
|
||||||
datasetsToBeCanceled.add(dataset.getId());
|
datasetsToBeCanceled.add(descriptionEntity.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!datasetsToBeCanceled.isEmpty()) {
|
if (!datasetsToBeCanceled.isEmpty()) {
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
||||||
.update(root -> root.<Integer>get("status"), Dataset.Status.CANCELED.getValue());
|
.update(root -> root.<Integer>get("status"), DescriptionStatus.Canceled);
|
||||||
List<Dataset> cancelledDatasets = dmp.getDataset().stream().filter(dataset -> datasetsToBeCanceled.contains(dataset.getId())).collect(Collectors.toList());
|
List<DescriptionEntity> cancelledDescriptionEntities = dmp.getDataset().stream().filter(dataset -> datasetsToBeCanceled.contains(dataset.getId())).collect(Collectors.toList());
|
||||||
cancelledDatasets.forEach(dataset -> dataset.setStatus(Dataset.Status.CANCELED.getValue()));
|
cancelledDescriptionEntities.forEach(dataset -> dataset.setStatus(DescriptionStatus.Canceled));
|
||||||
indexDatasets.addAll(cancelledDatasets);
|
indexDescriptionEntities.addAll(cancelledDescriptionEntities);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
List<UUID> datasetsToBeCanceled = new LinkedList<>();
|
||||||
for (Dataset dataset : dmp.getDataset()) {
|
for (DescriptionEntity descriptionEntity : dmp.getDataset()) {
|
||||||
if (!dataset.getStatus().equals(Dataset.Status.FINALISED.getValue())) {
|
if (!descriptionEntity.getStatus().equals(DescriptionStatus.Finalized)) {
|
||||||
datasetsToBeCanceled.add(dataset.getId());
|
datasetsToBeCanceled.add(descriptionEntity.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!datasetsToBeCanceled.isEmpty()) {
|
if (!datasetsToBeCanceled.isEmpty()) {
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao()
|
||||||
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
.asQueryable().where((builder, root) -> root.get("id").in(datasetsToBeCanceled))
|
||||||
.update(root -> root.<Integer>get("status"), Dataset.Status.CANCELED.getValue());
|
.update(root -> root.<Integer>get("status"), DescriptionStatus.Canceled);
|
||||||
List<Dataset> cancelledDatasets = dmp.getDataset().stream().filter(dataset -> datasetsToBeCanceled.contains(dataset.getId())).collect(Collectors.toList());
|
List<DescriptionEntity> cancelledDescriptionEntities = dmp.getDataset().stream().filter(dataset -> datasetsToBeCanceled.contains(dataset.getId())).collect(Collectors.toList());
|
||||||
cancelledDatasets.forEach(dataset -> dataset.setStatus(Dataset.Status.CANCELED.getValue()));
|
cancelledDescriptionEntities.forEach(dataset -> dataset.setStatus(DescriptionStatus.Canceled));
|
||||||
indexDatasets.addAll(cancelledDatasets);
|
indexDescriptionEntities.addAll(cancelledDescriptionEntities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dmp.setStatus(DMP.DMPStatus.FINALISED.getValue());
|
dmp.setStatus(DMP.DMPStatus.FINALISED.getValue());
|
||||||
|
@ -1277,9 +1286,9 @@ public class DataManagementPlanManager {
|
||||||
sendNotification(dmp, user, NotificationType.DMP_FINALISED);
|
sendNotification(dmp, user, NotificationType.DMP_FINALISED);
|
||||||
metricsManager.decreaseValue(MetricNames.DMP, 1, MetricNames.DRAFT);
|
metricsManager.decreaseValue(MetricNames.DMP, 1, MetricNames.DRAFT);
|
||||||
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.FINALIZED);
|
metricsManager.increaseValue(MetricNames.DMP, 1, MetricNames.FINALIZED);
|
||||||
this.updateDatasetsIndex(indexDatasets);
|
this.updateDatasetsIndex(indexDescriptionEntities);
|
||||||
metricsManager.decreaseValue(MetricNames.DATASET, indexDatasets.size(), MetricNames.DRAFT);
|
metricsManager.decreaseValue(MetricNames.DATASET, indexDescriptionEntities.size(), MetricNames.DRAFT);
|
||||||
metricsManager.increaseValue(MetricNames.DATASET, indexDatasets.size(), MetricNames.FINALIZED);
|
metricsManager.increaseValue(MetricNames.DATASET, indexDescriptionEntities.size(), MetricNames.FINALIZED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void undoFinalize(UUID id) throws Exception {
|
public void undoFinalize(UUID id) throws Exception {
|
||||||
|
@ -1537,11 +1546,11 @@ public class DataManagementPlanManager {
|
||||||
final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
final Boolean isFinalized = dmpEntity.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
||||||
final Boolean isPublic = dmpEntity.isPublic();
|
final Boolean isPublic = dmpEntity.isPublic();
|
||||||
dmpEntity.getDataset().stream()
|
dmpEntity.getDataset().stream()
|
||||||
.filter(item -> item.getStatus() != Dataset.Status.CANCELED.getValue())
|
.filter(item -> item.getStatus() != DescriptionStatus.Canceled)
|
||||||
.filter(item -> item.getStatus() != Dataset.Status.DELETED.getValue())
|
.filter(item -> item.getIsActive() != IsActive.Inactive)
|
||||||
.filter(item -> !isPublic && !isFinalized || item.getStatus() == Dataset.Status.FINALISED.getValue())
|
.filter(item -> !isPublic && !isFinalized || item.getStatus() == DescriptionStatus.Finalized)
|
||||||
.filter(item -> item.getDmpSectionIndex().equals(section.getOrdinal() - 1))
|
.filter(item -> item.getDmpSectionIndex().equals(section.getOrdinal() - 1))
|
||||||
.sorted(Comparator.comparing(Dataset::getCreated))
|
.sorted(Comparator.comparing(DescriptionEntity::getCreatedAt))
|
||||||
.forEach(datasetEntity -> {
|
.forEach(datasetEntity -> {
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (datasetEntity.getProperties() != null) {
|
||||||
|
@ -1591,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(datasetEntity.getProfile().getLabel());
|
runDatasetTemplate.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getProfile()).first().getLabel());
|
||||||
runDatasetTemplate.setColor("116a78");
|
runDatasetTemplate.setColor("116a78");
|
||||||
//runDatasetTemplate.setBold(true);
|
//runDatasetTemplate.setBold(true);
|
||||||
//runDatasetTemplate.setFontSize(12);
|
//runDatasetTemplate.setFontSize(12);
|
||||||
|
@ -1637,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(datasetEntity.getProfile().getLabel());
|
runDatasetDescription.setText(this.queryFactory.query(DescriptionTemplateQuery.class).ids(datasetEntity.getProfile()).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);
|
||||||
|
|
||||||
|
@ -1709,10 +1718,10 @@ public class DataManagementPlanManager {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
final Boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
final Boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
||||||
final Boolean isPublic = dmp.isPublic();
|
final Boolean isPublic = dmp.isPublic();
|
||||||
List<Dataset> datasets = dmp.getDataset().stream()
|
List<DescriptionEntity> descriptionEntities = dmp.getDataset().stream()
|
||||||
.filter(dataset -> dataset.getStatus() != Dataset.Status.DELETED.getValue() &&
|
.filter(dataset -> dataset.getIsActive() != IsActive.Inactive &&
|
||||||
dataset.getStatus() != Dataset.Status.CANCELED.getValue())
|
dataset.getStatus() != DescriptionStatus.Canceled)
|
||||||
.filter(dataset -> !isPublic && !isFinalized || dataset.getStatus() == Dataset.Status.FINALISED.getValue())
|
.filter(dataset -> !isPublic && !isFinalized || dataset.getStatus() == DescriptionStatus.Finalized)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
/*String fileName = dmp.getLabel();
|
/*String fileName = dmp.getLabel();
|
||||||
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");*/
|
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");*/
|
||||||
|
@ -1904,33 +1913,33 @@ public class DataManagementPlanManager {
|
||||||
dmpElement.appendChild(extraFields);
|
dmpElement.appendChild(extraFields);
|
||||||
|
|
||||||
Element datasetsElement = xmlDoc.createElement("datasets");
|
Element datasetsElement = xmlDoc.createElement("datasets");
|
||||||
for (Dataset dataset : datasets) {
|
for (DescriptionEntity descriptionEntity : descriptionEntities) {
|
||||||
Element datasetElement = xmlDoc.createElement("dataset");
|
Element datasetElement = xmlDoc.createElement("dataset");
|
||||||
datasetElement.setAttribute("name", dataset.getLabel());
|
datasetElement.setAttribute("name", descriptionEntity.getLabel());
|
||||||
|
|
||||||
Element datasetDescriptionElement = xmlDoc.createElement("description");
|
Element datasetDescriptionElement = xmlDoc.createElement("description");
|
||||||
datasetElement.appendChild(datasetDescriptionElement);
|
datasetElement.appendChild(datasetDescriptionElement);
|
||||||
datasetDescriptionElement.setTextContent(dataset.getDescription());
|
datasetDescriptionElement.setTextContent(descriptionEntity.getDescription());
|
||||||
|
|
||||||
Element datasetDmpSectionIndex = xmlDoc.createElement("dmpSectionIndex");
|
Element datasetDmpSectionIndex = xmlDoc.createElement("dmpSectionIndex");
|
||||||
datasetElement.appendChild(datasetDmpSectionIndex);
|
datasetElement.appendChild(datasetDmpSectionIndex);
|
||||||
datasetDmpSectionIndex.setTextContent(String.valueOf(dataset.getDmpSectionIndex()));
|
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(dataset.getProfile().getId().toString());
|
datsetProfileElement.setTextContent(descriptionEntity.getProfile().toString());
|
||||||
|
|
||||||
Element datsetProfileLabelElement = xmlDoc.createElement("profile-label");
|
Element datsetProfileLabelElement = xmlDoc.createElement("profile-label");
|
||||||
datasetElement.appendChild(datsetProfileLabelElement);
|
datasetElement.appendChild(datsetProfileLabelElement);
|
||||||
datsetProfileLabelElement.setTextContent(dataset.getProfile().getLabel());
|
datsetProfileLabelElement.setTextContent(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntity.getProfile()).first().getLabel());
|
||||||
|
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (dataset.getProperties() != null) {
|
if (descriptionEntity.getProperties() != null) {
|
||||||
JSONObject jobject = new JSONObject(dataset.getProperties());
|
JSONObject jobject = new JSONObject(descriptionEntity.getProperties());
|
||||||
properties = jobject.toMap();
|
properties = jobject.toMap();
|
||||||
}
|
}
|
||||||
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(datasetWizardModel, dataset);
|
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(datasetWizardModel, descriptionEntity);
|
||||||
visibilityRuleService.setProperties(properties);
|
visibilityRuleService.setProperties(properties);
|
||||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||||
datasetElement.appendChild(xmlBuilder.createPages(pagedDatasetProfile.getPages(), visibilityRuleService, xmlDoc));
|
datasetElement.appendChild(xmlBuilder.createPages(pagedDatasetProfile.getPages(), visibilityRuleService, xmlDoc));
|
||||||
|
@ -1991,9 +2000,9 @@ public class DataManagementPlanManager {
|
||||||
final boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
final boolean isFinalized = dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue();
|
||||||
final boolean isPublic = dmp.isPublic();
|
final boolean isPublic = dmp.isPublic();
|
||||||
dmp.setDataset(dmp.getDataset().stream()
|
dmp.setDataset(dmp.getDataset().stream()
|
||||||
.filter(dataset -> dataset.getStatus() != Dataset.Status.DELETED.getValue() &&
|
.filter(dataset -> dataset.getIsActive() != IsActive.Inactive &&
|
||||||
dataset.getStatus() != Dataset.Status.CANCELED.getValue())
|
dataset.getStatus() != DescriptionStatus.Canceled)
|
||||||
.filter(dataset -> !isPublic && !isFinalized || dataset.getStatus() == Dataset.Status.FINALISED.getValue())
|
.filter(dataset -> !isPublic && !isFinalized || dataset.getStatus() == DescriptionStatus.Finalized)
|
||||||
.collect(Collectors.toSet()));
|
.collect(Collectors.toSet()));
|
||||||
String result = rdaManager.convertToRDA(dmp);
|
String result = rdaManager.convertToRDA(dmp);
|
||||||
|
|
||||||
|
@ -2220,24 +2229,24 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
List<DatasetListingModel> datasets = new LinkedList<>();
|
List<DatasetListingModel> datasets = new LinkedList<>();
|
||||||
for (DatasetImportModels das: dataManagementPlans.get(0).getDatasetImportModels()) {
|
for (DatasetImportModels das: dataManagementPlans.get(0).getDatasetImportModels()) {
|
||||||
Dataset dataset = new Dataset();
|
DescriptionEntity descriptionEntity = new DescriptionEntity();
|
||||||
dataset.setLabel(das.getName());
|
descriptionEntity.setLabel(das.getName());
|
||||||
dataset.setDmpSectionIndex(das.getDmpSectionIndex());
|
descriptionEntity.setDmpSectionIndex(das.getDmpSectionIndex());
|
||||||
try {
|
try {
|
||||||
dataset.setProfile(databaseRepository.getDatasetProfileDao().find(das.getProfile()));
|
descriptionEntity.setProfile(das.getProfile());
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
dataset.setProfile(databaseRepository.getDatasetProfileDao().find(associatedProfiles.get(0).getDescriptionTemplateId()));
|
descriptionEntity.setProfile(associatedProfiles.get(0).getDescriptionTemplateId());
|
||||||
}
|
}
|
||||||
dataset.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels()));
|
descriptionEntity.setProperties(objectMapper.writeValueAsString(das.getFieldImportModels()));
|
||||||
dataset.setStatus((short) 0);
|
descriptionEntity.setStatus(DescriptionStatus.Saved);
|
||||||
dataset.setRegistries(new HashSet<>());
|
// descriptionEntity.setRegistries(new HashSet<>());
|
||||||
dataset.setDatasetDataRepositories(new HashSet<>());
|
// descriptionEntity.setDatasetDataRepositories(new HashSet<>());
|
||||||
dataset.setServices(new HashSet<>());
|
// descriptionEntity.setServices(new HashSet<>());
|
||||||
dataset.setDatasetExternalDatasets(new HashSet<>());
|
// descriptionEntity.setDatasetExternalDatasets(new HashSet<>());
|
||||||
dataset.setDmp(dmp);
|
descriptionEntity.setDmp(dmp.getId());
|
||||||
DatasetWizardModel datasetWizard = new DatasetWizardModel();
|
DatasetWizardModel datasetWizard = new DatasetWizardModel();
|
||||||
datasetWizard.setDatasetProfileDefinition(this.datasetManager.getPagedProfile(datasetWizard, dataset));
|
datasetWizard.setDatasetProfileDefinition(this.datasetManager.getPagedProfile(datasetWizard, descriptionEntity));
|
||||||
datasetWizard.fromDataModel(dataset);
|
datasetWizard.fromDataModel(descriptionEntity);
|
||||||
this.datasetManager.createOrUpdate(datasetWizard);
|
this.datasetManager.createOrUpdate(datasetWizard);
|
||||||
// datasets.add(new DatasetListingModel().fromDataModel(dataset));
|
// datasets.add(new DatasetListingModel().fromDataModel(dataset));
|
||||||
}
|
}
|
||||||
|
@ -2280,15 +2289,15 @@ public class DataManagementPlanManager {
|
||||||
this.updateIndex(dmp);
|
this.updateIndex(dmp);
|
||||||
}
|
}
|
||||||
dmp.getDataset().forEach(dataset -> {
|
dmp.getDataset().forEach(dataset -> {
|
||||||
dataset.setStatus(Dataset.Status.SAVED.getValue());
|
dataset.setStatus(DescriptionStatus.Saved);
|
||||||
dataset.setCreated(new Date());
|
dataset.setCreatedAt(Instant.now());
|
||||||
dataset.setModified(new Date());
|
dataset.setUpdatedAt(Instant.now());
|
||||||
dataset.setDmp(dmp);
|
dataset.setDmp(dmp.getId());
|
||||||
dataset = databaseRepository.getDatasetDao().createOrUpdate(dataset);
|
dataset = databaseRepository.getDatasetDao().createOrUpdate(dataset);
|
||||||
dataset.setRegistries(new HashSet<>());
|
// dataset.setRegistries(new HashSet<>());
|
||||||
dataset.setDatasetDataRepositories(new HashSet<>());
|
// dataset.setDatasetDataRepositories(new HashSet<>());
|
||||||
dataset.setDatasetExternalDatasets(new HashSet<>());
|
// dataset.setDatasetExternalDatasets(new HashSet<>());
|
||||||
dataset.setServices(new HashSet<>());
|
// dataset.setServices(new HashSet<>());
|
||||||
if (dmp.getOrganisations() == null) {
|
if (dmp.getOrganisations() == null) {
|
||||||
dmp.setOrganisations(new HashSet<>());
|
dmp.setOrganisations(new HashSet<>());
|
||||||
}
|
}
|
||||||
|
@ -2381,8 +2390,8 @@ public class DataManagementPlanManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateDatasetsIndex(List<Dataset> datasets) {
|
private void updateDatasetsIndex(List<DescriptionEntity> descriptionEntities) {
|
||||||
datasets.forEach(dataset -> {
|
descriptionEntities.forEach(dataset -> {
|
||||||
List<Tag> tags = new ArrayList<>();
|
List<Tag> tags = new ArrayList<>();
|
||||||
eu.eudat.elastic.entities.Dataset elastic = null;
|
eu.eudat.elastic.entities.Dataset elastic = null;
|
||||||
try {
|
try {
|
||||||
|
@ -2390,8 +2399,9 @@ public class DataManagementPlanManager {
|
||||||
if (elastic != null) {
|
if (elastic != null) {
|
||||||
tags = elastic.getTags();
|
tags = elastic.getTags();
|
||||||
}
|
}
|
||||||
UUID dmpId = dataset.getDmp().getId();
|
UUID dmpId = dataset.getDmp();
|
||||||
dataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
//TODO
|
||||||
|
//dataset.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
||||||
this.datasetManager.updateTags(dataset, tags);
|
this.datasetManager.updateTags(dataset, tags);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
@ -2570,9 +2580,9 @@ public class DataManagementPlanManager {
|
||||||
ZipOutputStream zout = new ZipOutputStream(fout);
|
ZipOutputStream zout = new ZipOutputStream(fout);
|
||||||
|
|
||||||
boolean hasFileUploaded = false;
|
boolean hasFileUploaded = false;
|
||||||
Set<Dataset> datasets = dmp.getDataset();
|
Set<DescriptionEntity> descriptionEntities = dmp.getDataset();
|
||||||
for (Dataset dataset : datasets) {
|
for (DescriptionEntity descriptionEntity : descriptionEntities) {
|
||||||
List<FileUpload> files = this.apiContext.getOperationsContext().getDatabaseRepository().getFileUploadDao().getFileUploads(dataset.getId());
|
List<FileUpload> files = this.apiContext.getOperationsContext().getDatabaseRepository().getFileUploadDao().getFileUploads(descriptionEntity.getId());
|
||||||
for (FileUpload f : files) {
|
for (FileUpload f : files) {
|
||||||
if(!f.getIsDeleted()){
|
if(!f.getIsDeleted()){
|
||||||
File exportFile = new File(this.environment.getProperty("file.storage") + f.getId());
|
File exportFile = new File(this.environment.getProperty("file.storage") + f.getId());
|
||||||
|
|
|
@ -5,7 +5,10 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.authorization.Permission;
|
import eu.eudat.authorization.Permission;
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.dao.criteria.*;
|
import eu.eudat.data.dao.criteria.*;
|
||||||
import eu.eudat.data.dao.entities.DataRepositoryDao;
|
import eu.eudat.data.dao.entities.DataRepositoryDao;
|
||||||
|
@ -51,9 +54,11 @@ import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||||
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
import eu.eudat.models.data.listingmodels.DatasetListingModel;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
|
import eu.eudat.query.DescriptionTemplateQuery;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.types.MetricNames;
|
import eu.eudat.types.MetricNames;
|
||||||
import gr.cite.commons.web.authz.service.AuthorizationService;
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
||||||
|
import gr.cite.tools.data.query.QueryFactory;
|
||||||
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
import org.apache.poi.xwpf.extractor.XWPFWordExtractor;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||||
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
import org.apache.poi.xwpf.usermodel.XWPFParagraph;
|
||||||
|
@ -117,10 +122,11 @@ public class DatasetManager {
|
||||||
private final FileManager fileManager;
|
private final FileManager fileManager;
|
||||||
private final UserScope userScope;
|
private final UserScope userScope;
|
||||||
private final AuthorizationService authorizationService;
|
private final AuthorizationService authorizationService;
|
||||||
|
private final QueryFactory queryFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public DatasetManager(ApiContext apiContext, UserManager userManager, ConfigLoader configLoader, Environment environment, MetricsManager metricsManager,
|
public DatasetManager(ApiContext apiContext, UserManager userManager, ConfigLoader configLoader, Environment environment, MetricsManager metricsManager,
|
||||||
FileManager fileManager, UserScope userScope, AuthorizationService authorizationService) {
|
FileManager fileManager, UserScope userScope, AuthorizationService authorizationService, QueryFactory queryFactory) {
|
||||||
this.apiContext = apiContext;
|
this.apiContext = apiContext;
|
||||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||||
this.datasetRepository = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository();
|
this.datasetRepository = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository();
|
||||||
|
@ -132,6 +138,7 @@ public class DatasetManager {
|
||||||
this.fileManager = fileManager;
|
this.fileManager = fileManager;
|
||||||
this.userScope = userScope;
|
this.userScope = userScope;
|
||||||
this.authorizationService = authorizationService;
|
this.authorizationService = authorizationService;
|
||||||
|
this.queryFactory = queryFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTableData<DatasetListingModel> getPaged(DatasetTableRequest datasetTableRequest) throws Exception {
|
public DataTableData<DatasetListingModel> getPaged(DatasetTableRequest datasetTableRequest) throws Exception {
|
||||||
|
@ -176,8 +183,8 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
UserInfo userInfo = builderFactory.getBuilder(UserInfoBuilder.class).id(this.userScope.getUserIdSafe()).build();
|
UserInfo userInfo = builderFactory.getBuilder(UserInfoBuilder.class).id(this.userScope.getUserIdSafe()).build();
|
||||||
// QueryableList<eu.eudat.data.old.Dataset> items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
// QueryableList<eu.eudat.data.Dataset> items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
||||||
QueryableList<Dataset> items;
|
QueryableList<DescriptionEntity> items;
|
||||||
if (datasets != null) {
|
if (datasets != null) {
|
||||||
|
|
||||||
if (!datasets.isEmpty()) {
|
if (!datasets.isEmpty()) {
|
||||||
|
@ -193,8 +200,8 @@ public class DatasetManager {
|
||||||
items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));//.withFields(Collections.singletonList("id"));
|
items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));//.withFields(Collections.singletonList("id"));
|
||||||
}
|
}
|
||||||
List<Integer> roles = new LinkedList<>();
|
List<Integer> roles = new LinkedList<>();
|
||||||
QueryableList<Dataset> pagedItems;
|
QueryableList<DescriptionEntity> pagedItems;
|
||||||
QueryableList<Dataset> authItems;
|
QueryableList<DescriptionEntity> authItems;
|
||||||
if (!datasetTableRequest.getCriteria().getIsPublic()) {
|
if (!datasetTableRequest.getCriteria().getIsPublic()) {
|
||||||
if (this.userScope.getUserIdSafe() == null) {
|
if (this.userScope.getUserIdSafe() == null) {
|
||||||
throw new UnauthorisedException("You are not allowed to access those datasets");
|
throw new UnauthorisedException("You are not allowed to access those datasets");
|
||||||
|
@ -251,7 +258,7 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
/*datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
|
/*datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
|
||||||
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();*/
|
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();*/
|
||||||
QueryableList<Dataset> items;
|
QueryableList<DescriptionEntity> items;
|
||||||
if (datasets != null) {
|
if (datasets != null) {
|
||||||
if (!datasets.isEmpty()) {
|
if (!datasets.isEmpty()) {
|
||||||
items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
||||||
|
@ -276,7 +283,7 @@ public class DatasetManager {
|
||||||
if (count == 0L) {
|
if (count == 0L) {
|
||||||
count = items.count();
|
count = items.count();
|
||||||
}
|
}
|
||||||
QueryableList<Dataset> pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
|
QueryableList<DescriptionEntity> pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
|
||||||
DataTableData<DatasetListingModel> dataTable = new DataTableData<>();
|
DataTableData<DatasetListingModel> dataTable = new DataTableData<>();
|
||||||
|
|
||||||
List<DatasetListingModel> datasetListis = pagedItems.
|
List<DatasetListingModel> datasetListis = pagedItems.
|
||||||
|
@ -291,17 +298,18 @@ public class DatasetManager {
|
||||||
|
|
||||||
public DatasetWizardModel getSingle(String id) throws InvalidApplicationException {
|
public DatasetWizardModel getSingle(String id) throws InvalidApplicationException {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
if (datasetEntity.getDmp().getUsers()
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
||||||
|
if (dmp.getUsers()
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0 && !datasetEntity.getDmp().isPublic())
|
.collect(Collectors.toList()).size() == 0 && !dmp.isPublic())
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
|
||||||
dataset.fromDataModel(datasetEntity);
|
dataset.fromDataModel(descriptionEntityEntity);
|
||||||
|
|
||||||
// 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 = datasetEntity.getProfile().getGroupId();
|
UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getProfile()).first().getGroupId();
|
||||||
List<UUID> uuidList = new LinkedList<>();
|
List<UUID> uuidList = new LinkedList<>();
|
||||||
uuidList.add(profileId);
|
uuidList.add(profileId);
|
||||||
profileCriteria.setGroupIds(uuidList);
|
profileCriteria.setGroupIds(uuidList);
|
||||||
|
@ -332,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(datasetEntity.getProfile().getVersion().toString());
|
boolean latestVersion = profile.getVersion().toString().equals(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getProfile()).first().getVersion());
|
||||||
dataset.setIsProfileLatestVersion(latestVersion);
|
dataset.setIsProfileLatestVersion(latestVersion);
|
||||||
|
|
||||||
eu.eudat.elastic.entities.Dataset datasetElastic;
|
eu.eudat.elastic.entities.Dataset datasetElastic;
|
||||||
|
@ -355,11 +363,11 @@ public class DatasetManager {
|
||||||
|
|
||||||
public DatasetWizardModel getSinglePublic(String id) throws Exception {
|
public DatasetWizardModel getSinglePublic(String id) throws Exception {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().isPublicDataset(UUID.fromString(id));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().isPublicDataset(UUID.fromString(id));
|
||||||
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
||||||
if (datasetEntity != null && datasetEntity.getStatus() == 1 && datasetEntity.getDmp().getStatus() == 1) {
|
if (descriptionEntityEntity != null && descriptionEntityEntity.getStatus() == DescriptionStatus.Finalized && dmp.getStatus() == 1) {
|
||||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
|
||||||
dataset.fromDataModel(datasetEntity);
|
dataset.fromDataModel(descriptionEntityEntity);
|
||||||
return dataset;
|
return dataset;
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Selected dataset is not public");
|
throw new Exception("Selected dataset is not public");
|
||||||
|
@ -367,34 +375,35 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetOverviewModel getOverviewSingle(String id, boolean isPublic) throws Exception {
|
public DatasetOverviewModel getOverviewSingle(String id, boolean isPublic) throws Exception {
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id));
|
||||||
if (datasetEntity.getStatus() == Dataset.Status.DELETED.getValue()) {
|
if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) {
|
||||||
throw new Exception("Dataset is deleted.");
|
throw new Exception("Dataset is deleted.");
|
||||||
}
|
}
|
||||||
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
||||||
if (!isPublic && !this.userScope.isSet()) {
|
if (!isPublic && !this.userScope.isSet()) {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
} else
|
} else
|
||||||
if (!isPublic && datasetEntity.getDmp().getUsers()
|
if (!isPublic && dmp.getUsers()
|
||||||
.stream().noneMatch(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))) {
|
.stream().noneMatch(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))) {
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
} else if (isPublic && !datasetEntity.getDmp().isPublic()) {
|
} else if (isPublic && !dmp.isPublic()) {
|
||||||
throw new ForbiddenException("Selected Dataset is not public");
|
throw new ForbiddenException("Selected Dataset is not public");
|
||||||
}
|
}
|
||||||
DatasetOverviewModel dataset = new DatasetOverviewModel();
|
DatasetOverviewModel dataset = new DatasetOverviewModel();
|
||||||
dataset.fromDataModel(datasetEntity);
|
dataset.fromDataModel(descriptionEntityEntity);
|
||||||
|
|
||||||
return dataset;
|
return dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset getEntitySingle(UUID id) throws InvalidApplicationException {
|
public DescriptionEntity getEntitySingle(UUID id) throws InvalidApplicationException {
|
||||||
return databaseRepository.getDatasetDao().find(id);
|
return databaseRepository.getDatasetDao().find(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, Dataset datasetEntity) {
|
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, DescriptionEntity descriptionEntityEntity) {
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getProfile()).first());
|
||||||
datasetprofile.setStatus(dataset.getStatus());
|
datasetprofile.setStatus(dataset.getStatus().getValue());
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (descriptionEntityEntity.getProperties() != null) {
|
||||||
JSONObject jObject = new JSONObject(datasetEntity.getProperties());
|
JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
|
||||||
Map<String, Object> properties = jObject.toMap();
|
Map<String, Object> properties = jObject.toMap();
|
||||||
datasetprofile.fromJsonObject(properties);
|
datasetprofile.fromJsonObject(properties);
|
||||||
}
|
}
|
||||||
|
@ -403,18 +412,17 @@ public class DatasetManager {
|
||||||
return pagedDatasetProfile;
|
return pagedDatasetProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
private XWPFDocument getWordDocument(ConfigLoader configLoader, Dataset datasetEntity, VisibilityRuleService visibilityRuleService) throws IOException {
|
private XWPFDocument getWordDocument(ConfigLoader configLoader, DescriptionEntity descriptionEntityEntity, VisibilityRuleService visibilityRuleService) throws IOException, InvalidApplicationException {
|
||||||
WordBuilder wordBuilder = new WordBuilder(this.environment, configLoader);
|
WordBuilder wordBuilder = new WordBuilder(this.environment, configLoader);
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
XWPFDocument document = configLoader.getDatasetDocument();
|
XWPFDocument document = configLoader.getDatasetDocument();
|
||||||
|
|
||||||
DMP dmpEntity = datasetEntity.getDmp();
|
DMP dmpEntity = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
||||||
|
|
||||||
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())).collect(Collectors.toList()).size() == 0)
|
if (!dmpEntity.isPublic() && dmpEntity.getUsers().stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId())).collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
|
|
||||||
wordBuilder.fillFirstPage(dmpEntity, datasetEntity, document, true);
|
wordBuilder.fillFirstPage(dmpEntity, descriptionEntityEntity, document, true);
|
||||||
wordBuilder.fillFooter(dmpEntity, datasetEntity, document, true);
|
wordBuilder.fillFooter(dmpEntity, descriptionEntityEntity, document, true);
|
||||||
|
|
||||||
int powered_pos = wordBuilder.findPosOfPoweredBy(document);
|
int powered_pos = wordBuilder.findPosOfPoweredBy(document);
|
||||||
XWPFParagraph powered_par = null;
|
XWPFParagraph powered_par = null;
|
||||||
|
@ -478,17 +486,17 @@ public class DatasetManager {
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (descriptionEntityEntity.getProperties() != null) {
|
||||||
JSONObject jObject = new JSONObject(datasetEntity.getProperties());
|
JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
|
||||||
properties = jObject.toMap();
|
properties = jObject.toMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
// wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
// wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER2, BigInteger.ZERO);
|
||||||
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, datasetEntity);
|
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, descriptionEntityEntity);
|
||||||
visibilityRuleService.setProperties(properties);
|
visibilityRuleService.setProperties(properties);
|
||||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||||
wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService);
|
wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService);
|
||||||
String label = datasetEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
String label = descriptionEntityEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
||||||
// File exportFile = new File(label + ".docx");
|
// File exportFile = new File(label + ".docx");
|
||||||
|
|
||||||
// Removes the top empty headings.
|
// Removes the top empty headings.
|
||||||
|
@ -546,17 +554,18 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileEnvelope getWordDocumentFile(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService) throws IOException, InvalidApplicationException {
|
public FileEnvelope getWordDocumentFile(ConfigLoader configLoader, String id, VisibilityRuleService visibilityRuleService) throws IOException, InvalidApplicationException {
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers()
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
||||||
|
if (!dmp.isPublic() && dmp.getUsers()
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0)
|
.collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
String label = datasetEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
String label = descriptionEntityEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
||||||
FileEnvelope exportEnvelope = new FileEnvelope();
|
FileEnvelope exportEnvelope = new FileEnvelope();
|
||||||
exportEnvelope.setFilename(label + ".docx");
|
exportEnvelope.setFilename(label + ".docx");
|
||||||
String uuid = UUID.randomUUID().toString();
|
String uuid = UUID.randomUUID().toString();
|
||||||
File exportFile = new File(this.environment.getProperty("temp.temp") + uuid + ".docx");
|
File exportFile = new File(this.environment.getProperty("temp.temp") + uuid + ".docx");
|
||||||
XWPFDocument document = getWordDocument(configLoader, datasetEntity, visibilityRuleService);
|
XWPFDocument document = getWordDocument(configLoader, descriptionEntityEntity, visibilityRuleService);
|
||||||
FileOutputStream out = new FileOutputStream(exportFile);
|
FileOutputStream out = new FileOutputStream(exportFile);
|
||||||
document.write(out);
|
document.write(out);
|
||||||
out.close();
|
out.close();
|
||||||
|
@ -564,9 +573,9 @@ public class DatasetManager {
|
||||||
return exportEnvelope;
|
return exportEnvelope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getWordDocumentText (Dataset datasetEntity) throws Exception {
|
public String getWordDocumentText (DescriptionEntity descriptionEntityEntity) throws Exception {
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(datasetEntity);
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(descriptionEntityEntity);
|
||||||
datasetWizardModel.setDatasetProfileDefinition(this.getPagedProfile(datasetWizardModel, datasetEntity));
|
datasetWizardModel.setDatasetProfileDefinition(this.getPagedProfile(datasetWizardModel, descriptionEntityEntity));
|
||||||
XWPFDocument document = getLightWordDocument(this.configLoader, datasetWizardModel, new VisibilityRuleServiceImpl());
|
XWPFDocument document = getLightWordDocument(this.configLoader, datasetWizardModel, new VisibilityRuleServiceImpl());
|
||||||
XWPFWordExtractor extractor = new XWPFWordExtractor(document);
|
XWPFWordExtractor extractor = new XWPFWordExtractor(document);
|
||||||
return extractor.getText();/*.replaceAll("\n\\s*", " ");*/
|
return extractor.getText();/*.replaceAll("\n\\s*", " ");*/
|
||||||
|
@ -575,37 +584,38 @@ public class DatasetManager {
|
||||||
public FileEnvelope getXmlDocument(String id, VisibilityRuleService visibilityRuleService) throws InstantiationException, IllegalAccessException, IOException, InvalidApplicationException {
|
public FileEnvelope getXmlDocument(String id, VisibilityRuleService visibilityRuleService) throws InstantiationException, IllegalAccessException, IOException, InvalidApplicationException {
|
||||||
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
|
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
if (!datasetEntity.getDmp().isPublic() && datasetEntity.getDmp().getUsers()
|
DMP dmp = databaseRepository.getDmpDao().find(descriptionEntityEntity.getDmp());
|
||||||
|
if (!dmp.isPublic() && dmp.getUsers()
|
||||||
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
.stream().filter(userInfo -> this.userScope.getUserIdSafe().equals(userInfo.getUser().getId()))
|
||||||
.collect(Collectors.toList()).size() == 0)
|
.collect(Collectors.toList()).size() == 0)
|
||||||
throw new UnauthorisedException();
|
throw new UnauthorisedException();
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (descriptionEntityEntity.getProperties() != null) {
|
||||||
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
JSONObject jobject = new JSONObject(descriptionEntityEntity.getProperties());
|
||||||
properties = jobject.toMap();
|
properties = jobject.toMap();
|
||||||
}
|
}
|
||||||
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, datasetEntity);
|
PagedDatasetProfile pagedDatasetProfile = getPagedProfile(dataset, descriptionEntityEntity);
|
||||||
visibilityRuleService.setProperties(properties);
|
visibilityRuleService.setProperties(properties);
|
||||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||||
File file = xmlBuilder.build(pagedDatasetProfile, datasetEntity.getProfile().getId(), visibilityRuleService, environment);
|
File file = xmlBuilder.build(pagedDatasetProfile, descriptionEntityEntity.getProfile(), visibilityRuleService, environment);
|
||||||
FileEnvelope fileEnvelope = new FileEnvelope();
|
FileEnvelope fileEnvelope = new FileEnvelope();
|
||||||
fileEnvelope.setFile(file);
|
fileEnvelope.setFile(file);
|
||||||
String label = datasetEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
String label = descriptionEntityEntity.getLabel().replaceAll("[^a-zA-Z0-9+ ]", "");
|
||||||
fileEnvelope.setFilename(label);
|
fileEnvelope.setFilename(label);
|
||||||
return fileEnvelope;
|
return fileEnvelope;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset createOrUpdate(DatasetWizardModel datasetWizardModel) throws Exception {
|
public DescriptionEntity createOrUpdate(DatasetWizardModel datasetWizardModel) throws Exception {
|
||||||
Boolean sendNotification = false;
|
Boolean sendNotification = false;
|
||||||
Dataset tempDataset = null;
|
DescriptionEntity tempDescriptionEntity = null;
|
||||||
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(datasetWizardModel.getDmp().getId());
|
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(datasetWizardModel.getDmp().getId());
|
||||||
if (datasetWizardModel.getId() != null) {
|
if (datasetWizardModel.getId() != null) {
|
||||||
tempDataset = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(datasetWizardModel.getId());
|
tempDescriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(datasetWizardModel.getId());
|
||||||
if (tempDataset != null) {
|
if (tempDescriptionEntity != null) {
|
||||||
|
|
||||||
Instant dbTime = Instant.ofEpochMilli(tempDataset.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS);
|
Instant dbTime = tempDescriptionEntity.getCreatedAt().truncatedTo(ChronoUnit.SECONDS);
|
||||||
Instant modelTime = Instant.ofEpochMilli(datasetWizardModel.getModified().getTime()).truncatedTo(ChronoUnit.SECONDS);
|
Instant modelTime = datasetWizardModel.getModified().truncatedTo(ChronoUnit.SECONDS);
|
||||||
if (modelTime.toEpochMilli() != dbTime.toEpochMilli()) {
|
if (modelTime.toEpochMilli() != dbTime.toEpochMilli()) {
|
||||||
throw new Exception("Dataset has been modified already by another user.");
|
throw new Exception("Dataset has been modified already by another user.");
|
||||||
}
|
}
|
||||||
|
@ -616,47 +626,50 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()) && datasetWizardModel.getId() != null)
|
if (dmp.getStatus().equals(DMP.DMPStatus.FINALISED.getValue()) && datasetWizardModel.getId() != null)
|
||||||
throw new Exception("DMP is finalized, therefore Dataset cannot be edited.");
|
throw new Exception("DMP is finalized, therefore Dataset cannot be edited.");
|
||||||
Dataset dataset = datasetWizardModel.toDataModel();
|
DescriptionEntity descriptionEntity = datasetWizardModel.toDataModel();
|
||||||
dataset.setDmp(dmp);
|
descriptionEntity.setDmp(dmp.getId());
|
||||||
dataset.setProperties(propertiesModelToString(datasetWizardModel.getDatasetProfileDefinition()));
|
descriptionEntity.setProperties(propertiesModelToString(datasetWizardModel.getDatasetProfileDefinition()));
|
||||||
if (this.apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().getClient() != null) {
|
if (this.apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().getClient() != null) {
|
||||||
this.getTagsFromProfile(datasetWizardModel, dataset);
|
this.getTagsFromProfile(datasetWizardModel, descriptionEntity);
|
||||||
}
|
}
|
||||||
if (datasetWizardModel.getStatus() == (int) Dataset.Status.FINALISED.getValue()) {
|
if (datasetWizardModel.getStatus() == DescriptionStatus.Finalized) {
|
||||||
String failedField = checkDatasetValidation(dataset);
|
String failedField = checkDatasetValidation(descriptionEntity);
|
||||||
if (failedField != null) {
|
if (failedField != null) {
|
||||||
throw new Exception("Field value of " + failedField + " must be filled.");
|
throw new Exception("Field value of " + failedField + " must be filled.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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();
|
||||||
dataset.setCreator(userInfo);
|
descriptionEntity.setCreator(userInfo.getId());
|
||||||
|
|
||||||
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), dataset);
|
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), descriptionEntity);
|
||||||
createExternalDatasetsIfTheyDontExist(dataset);
|
createExternalDatasetsIfTheyDontExist(descriptionEntity);
|
||||||
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), dataset);
|
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), descriptionEntity);
|
||||||
createServicesIfTheyDontExist(dataset);
|
createServicesIfTheyDontExist(descriptionEntity);
|
||||||
Dataset dataset1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
|
DescriptionEntity descriptionEntity1 = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
||||||
datasetWizardModel.setId(dataset1.getId());
|
datasetWizardModel.setId(descriptionEntity1.getId());
|
||||||
if (datasetWizardModel.getDmp().getGrant() == null) {
|
if (datasetWizardModel.getDmp().getGrant() == null) {
|
||||||
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dataset1.getDmp()));
|
DMP dmp1 = databaseRepository.getDmpDao().find(descriptionEntity1.getDmp());
|
||||||
|
|
||||||
|
datasetWizardModel.setDmp(new DataManagementPlan().fromDataModelNoDatasets(dmp1));
|
||||||
}
|
}
|
||||||
dataset1.setProfile(this.apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(datasetWizardModel.getProfile().getId()));
|
descriptionEntity1.setProfile(datasetWizardModel.getProfile().getId());
|
||||||
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
// datasetWizardModel.setDatasetProfileDefinition(getPagedProfile(datasetWizardModel, dataset1));
|
||||||
UUID dmpId = dataset1.getDmp().getId();
|
UUID dmpId = descriptionEntity1.getDmp();
|
||||||
dataset1.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
DMP dmp1 = databaseRepository.getDmpDao().find(descriptionEntity1.getDmp());
|
||||||
updateTags(dataset1, datasetWizardModel.getTags());
|
dmp1.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
||||||
|
updateTags(descriptionEntity1, datasetWizardModel.getTags());
|
||||||
if (sendNotification) {
|
if (sendNotification) {
|
||||||
if (dataset1.getStatus() != Dataset.Status.FINALISED.getValue()) {
|
if (descriptionEntity1.getStatus() != DescriptionStatus.Finalized) {
|
||||||
this.sendNotification(dataset1, dataset1.getDmp(), userInfo, NotificationType.DATASET_MODIFIED);
|
this.sendNotification(descriptionEntity1, dmp1, userInfo, NotificationType.DATASET_MODIFIED);
|
||||||
} else {
|
} else {
|
||||||
this.sendNotification(dataset1, dataset1.getDmp(), userInfo, NotificationType.DATASET_MODIFIED_FINALISED);
|
this.sendNotification(descriptionEntity1, dmp1, userInfo, NotificationType.DATASET_MODIFIED_FINALISED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.deleteOldFilesAndAddNew(datasetWizardModel, userInfo);
|
this.deleteOldFilesAndAddNew(datasetWizardModel, userInfo);
|
||||||
|
|
||||||
|
|
||||||
return dataset1;
|
return descriptionEntity1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteOldFilesAndAddNew(DatasetWizardModel datasetWizardModel, UserInfo userInfo) throws JsonProcessingException, InvalidApplicationException {
|
private void deleteOldFilesAndAddNew(DatasetWizardModel datasetWizardModel, UserInfo userInfo) throws JsonProcessingException, InvalidApplicationException {
|
||||||
|
@ -697,7 +710,7 @@ public class DatasetManager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendNotification(Dataset dataset, DMP dmp, UserInfo user, NotificationType notificationType) throws InvalidApplicationException {
|
private void sendNotification(DescriptionEntity descriptionEntity, DMP dmp, UserInfo user, NotificationType notificationType) throws InvalidApplicationException {
|
||||||
List<UserDMP> userDMPS = databaseRepository.getUserDmpDao().asQueryable().where(((builder, root) -> builder.equal(root.get("dmp").get("id"), dmp.getId()))).toList();
|
List<UserDMP> userDMPS = databaseRepository.getUserDmpDao().asQueryable().where(((builder, root) -> builder.equal(root.get("dmp").get("id"), dmp.getId()))).toList();
|
||||||
for (UserDMP userDMP : userDMPS) {
|
for (UserDMP userDMP : userDMPS) {
|
||||||
if (!userDMP.getUser().getId().equals(user.getId())) {
|
if (!userDMP.getUser().getId().equals(user.getId())) {
|
||||||
|
@ -708,8 +721,8 @@ public class DatasetManager {
|
||||||
notification.setIsActive(ActiveStatus.ACTIVE);
|
notification.setIsActive(ActiveStatus.ACTIVE);
|
||||||
notification.setData("{" +
|
notification.setData("{" +
|
||||||
"\"userId\": \"" + userDMP.getUser().getId() + "\"" +
|
"\"userId\": \"" + userDMP.getUser().getId() + "\"" +
|
||||||
", \"id\": \"" + dataset.getId() + "\"" +
|
", \"id\": \"" + descriptionEntity.getId() + "\"" +
|
||||||
", \"name\": \"" + dataset.getLabel() + "\"" +
|
", \"name\": \"" + descriptionEntity.getLabel() + "\"" +
|
||||||
", \"path\": \"" + notificationPaths.get(notificationType) + "\"" +
|
", \"path\": \"" + notificationPaths.get(notificationType) + "\"" +
|
||||||
"}");
|
"}");
|
||||||
notification.setCreatedAt(new Date());
|
notification.setCreatedAt(new Date());
|
||||||
|
@ -722,9 +735,9 @@ public class DatasetManager {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String checkDatasetValidation(Dataset dataset) 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(dataset.getProfile().getId());
|
DescriptionTemplateEntity profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(descriptionEntity.getProfile());
|
||||||
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()));
|
||||||
|
@ -742,12 +755,12 @@ public class DatasetManager {
|
||||||
nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET);
|
nodeList = (NodeList) xPath.compile(expression).evaluate(xmlDocument, XPathConstants.NODESET);
|
||||||
|
|
||||||
|
|
||||||
JSONObject obj = new JSONObject(dataset.getProperties());
|
JSONObject obj = new JSONObject(descriptionEntity.getProperties());
|
||||||
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
VisibilityRuleService visibilityRuleService = new VisibilityRuleServiceImpl();
|
||||||
visibilityRuleService.setProperties(obj.toMap());
|
visibilityRuleService.setProperties(obj.toMap());
|
||||||
|
|
||||||
dataset.setProfile(profile);
|
descriptionEntity.setProfile(profile.getId());
|
||||||
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), dataset);
|
PagedDatasetProfile pagedDatasetProfile = this.getPagedProfile(new DatasetWizardModel(), descriptionEntity);
|
||||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||||
|
|
||||||
|
|
||||||
|
@ -798,7 +811,7 @@ public class DatasetManager {
|
||||||
return jobject.toString();
|
return jobject.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTags(Dataset datasetEntity, List<Tag> tags) throws Exception {
|
public void updateTags(DescriptionEntity descriptionEntityEntity, List<Tag> tags) throws Exception {
|
||||||
// if (datasetWizardModel.getTags() != null && !datasetWizardModel.getTags().isEmpty()) {
|
// if (datasetWizardModel.getTags() != null && !datasetWizardModel.getTags().isEmpty()) {
|
||||||
/*eu.eudat.elastic.entities.Dataset dataset = new eu.eudat.elastic.entities.Dataset();
|
/*eu.eudat.elastic.entities.Dataset dataset = new eu.eudat.elastic.entities.Dataset();
|
||||||
dataset.setId(datasetWizardModel.getId().toString());
|
dataset.setId(datasetWizardModel.getId().toString());
|
||||||
|
@ -854,92 +867,96 @@ public class DatasetManager {
|
||||||
dataset.setGrantStatus(datasetWizardModel.getDmp().getGrant().getStatus());
|
dataset.setGrantStatus(datasetWizardModel.getDmp().getGrant().getStatus());
|
||||||
dataset.setFormData(this.getWordDocumentText(datasetWizardModel));*/
|
dataset.setFormData(this.getWordDocumentText(datasetWizardModel));*/
|
||||||
DatasetMapper mapper = new DatasetMapper(apiContext, this);
|
DatasetMapper mapper = new DatasetMapper(apiContext, this);
|
||||||
eu.eudat.elastic.entities.Dataset dataset = mapper.toElastic(datasetEntity, tags);
|
eu.eudat.elastic.entities.Dataset dataset = mapper.toElastic(descriptionEntityEntity, tags);
|
||||||
apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().createOrUpdate(dataset);
|
apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().createOrUpdate(dataset);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void createRegistriesIfTheyDontExist(RegistryDao registryDao, Dataset dataset) throws InvalidApplicationException {
|
private void createRegistriesIfTheyDontExist(RegistryDao registryDao, DescriptionEntity descriptionEntity) throws InvalidApplicationException {
|
||||||
if (dataset.getRegistries() != null && !dataset.getRegistries().isEmpty()) {
|
//TODO implement it on create
|
||||||
for (Registry registry : dataset.getRegistries()) {
|
// if (descriptionEntity.getRegistries() != null && !descriptionEntity.getRegistries().isEmpty()) {
|
||||||
RegistryCriteria criteria = new RegistryCriteria();
|
// for (Registry registry : descriptionEntity.getRegistries()) {
|
||||||
criteria.setLike(registry.getReference());
|
// RegistryCriteria criteria = new RegistryCriteria();
|
||||||
List<Registry> entries = registryDao.getWithCriteria(criteria).toList();
|
// criteria.setLike(registry.getReference());
|
||||||
if (entries != null && !entries.isEmpty()) registry.setId(entries.get(0).getId());
|
// List<Registry> entries = registryDao.getWithCriteria(criteria).toList();
|
||||||
else {
|
// if (entries != null && !entries.isEmpty()) registry.setId(entries.get(0).getId());
|
||||||
registry.setCreated(new Date());
|
// else {
|
||||||
registryDao.createOrUpdate(registry);
|
// registry.setCreated(new Date());
|
||||||
}
|
// registryDao.createOrUpdate(registry);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createDataRepositoriesIfTheyDontExist(DataRepositoryDao dataRepositoryDao, Dataset dataset) throws InvalidApplicationException {
|
private void createDataRepositoriesIfTheyDontExist(DataRepositoryDao dataRepositoryDao, DescriptionEntity descriptionEntity) throws InvalidApplicationException {
|
||||||
if (dataset.getDatasetDataRepositories() != null && !dataset.getDatasetDataRepositories().isEmpty()) {
|
//TODO implement it on create
|
||||||
for (DatasetDataRepository datasetDataRepository : dataset.getDatasetDataRepositories()) {
|
// if (descriptionEntity.getDatasetDataRepositories() != null && !descriptionEntity.getDatasetDataRepositories().isEmpty()) {
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
// for (DatasetDataRepository datasetDataRepository : descriptionEntity.getDatasetDataRepositories()) {
|
||||||
criteria.setLike(datasetDataRepository.getDataRepository().getReference());
|
// DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
List<DataRepository> entries = dataRepositoryDao.getWithCriteria(criteria).toList();
|
// criteria.setLike(datasetDataRepository.getDataRepository().getReference());
|
||||||
if (entries != null && !entries.isEmpty()) {
|
// List<DataRepository> entries = dataRepositoryDao.getWithCriteria(criteria).toList();
|
||||||
datasetDataRepository.getDataRepository().setId(entries.get(0).getId());
|
// if (entries != null && !entries.isEmpty()) {
|
||||||
datasetDataRepository.setDataset(dataset);
|
// datasetDataRepository.getDataRepository().setId(entries.get(0).getId());
|
||||||
dataset.getDatasetDataRepositories().add(datasetDataRepository);
|
// datasetDataRepository.setDataset(descriptionEntity);
|
||||||
} else {
|
// descriptionEntity.getDatasetDataRepositories().add(datasetDataRepository);
|
||||||
datasetDataRepository.getDataRepository().setId(UUID.randomUUID());
|
// } else {
|
||||||
DataRepository dataRepository = dataRepositoryDao.createOrUpdate(datasetDataRepository.getDataRepository());
|
// datasetDataRepository.getDataRepository().setId(UUID.randomUUID());
|
||||||
datasetDataRepository.setDataset(dataset);
|
// DataRepository dataRepository = dataRepositoryDao.createOrUpdate(datasetDataRepository.getDataRepository());
|
||||||
datasetDataRepository.setDataRepository(dataRepository);
|
// datasetDataRepository.setDataset(descriptionEntity);
|
||||||
dataset.getDatasetDataRepositories().add(datasetDataRepository);
|
// datasetDataRepository.setDataRepository(dataRepository);
|
||||||
}
|
// descriptionEntity.getDatasetDataRepositories().add(datasetDataRepository);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createServicesIfTheyDontExist(Dataset dataset) throws InvalidApplicationException {
|
private void createServicesIfTheyDontExist(DescriptionEntity descriptionEntity) throws InvalidApplicationException {
|
||||||
if (dataset.getServices() != null && !dataset.getServices().isEmpty()) {
|
//TODO implement it on create
|
||||||
for (DatasetService service : dataset.getServices()) {
|
// if (descriptionEntity.getServices() != null && !descriptionEntity.getServices().isEmpty()) {
|
||||||
ServiceCriteria criteria = new ServiceCriteria();
|
// for (DatasetService service : descriptionEntity.getServices()) {
|
||||||
criteria.setLike(service.getService().getReference());
|
// ServiceCriteria criteria = new ServiceCriteria();
|
||||||
List<Service> entries = databaseRepository.getServiceDao().getWithCriteria(criteria).toList();
|
// criteria.setLike(service.getService().getReference());
|
||||||
if (entries != null && !entries.isEmpty()) {
|
// List<Service> entries = databaseRepository.getServiceDao().getWithCriteria(criteria).toList();
|
||||||
service.setDataset(dataset);
|
// if (entries != null && !entries.isEmpty()) {
|
||||||
service.getService().setCreated(new Date());
|
// service.setDataset(descriptionEntity);
|
||||||
service.setService(service.getService());
|
// service.getService().setCreated(new Date());
|
||||||
this.databaseRepository.getServiceDao().createOrUpdate(service.getService());
|
// service.setService(service.getService());
|
||||||
dataset.getServices().add(service);
|
// this.databaseRepository.getServiceDao().createOrUpdate(service.getService());
|
||||||
}
|
// descriptionEntity.getServices().add(service);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createExternalDatasetsIfTheyDontExist(Dataset dataset) throws InvalidApplicationException {
|
private void createExternalDatasetsIfTheyDontExist(DescriptionEntity descriptionEntity) throws InvalidApplicationException {
|
||||||
if (dataset.getDatasetExternalDatasets() != null && !dataset.getDatasetExternalDatasets().isEmpty()) {
|
//TODO implement it on create
|
||||||
for (DatasetExternalDataset datasetExternalDataset : dataset.getDatasetExternalDatasets()) {
|
// if (descriptionEntity.getDatasetExternalDatasets() != null && !descriptionEntity.getDatasetExternalDatasets().isEmpty()) {
|
||||||
ExternalDatasetCriteria criteria = new ExternalDatasetCriteria();
|
// for (DatasetExternalDataset datasetExternalDataset : descriptionEntity.getDatasetExternalDatasets()) {
|
||||||
criteria.setLike(datasetExternalDataset.getExternalDataset().getReference());
|
// ExternalDatasetCriteria criteria = new ExternalDatasetCriteria();
|
||||||
List<ExternalDataset> entries = databaseRepository.getExternalDatasetDao().getWithCriteria(criteria).toList();
|
// criteria.setLike(datasetExternalDataset.getExternalDataset().getReference());
|
||||||
if (entries != null && !entries.isEmpty()) {
|
// List<ExternalDataset> entries = databaseRepository.getExternalDatasetDao().getWithCriteria(criteria).toList();
|
||||||
datasetExternalDataset.getExternalDataset().setId(entries.get(0).getId());
|
// if (entries != null && !entries.isEmpty()) {
|
||||||
datasetExternalDataset.setDataset(dataset);
|
// datasetExternalDataset.getExternalDataset().setId(entries.get(0).getId());
|
||||||
dataset.getDatasetExternalDatasets().add(datasetExternalDataset);
|
// datasetExternalDataset.setDataset(descriptionEntity);
|
||||||
} else {
|
// descriptionEntity.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||||
datasetExternalDataset.getExternalDataset().setId(UUID.randomUUID());
|
// } else {
|
||||||
datasetExternalDataset.setDataset(dataset);
|
// datasetExternalDataset.getExternalDataset().setId(UUID.randomUUID());
|
||||||
ExternalDataset externalDataset = databaseRepository.getExternalDatasetDao().createOrUpdate(datasetExternalDataset.getExternalDataset());
|
// datasetExternalDataset.setDataset(descriptionEntity);
|
||||||
datasetExternalDataset.setExternalDataset(externalDataset);
|
// ExternalDataset externalDataset = databaseRepository.getExternalDatasetDao().createOrUpdate(datasetExternalDataset.getExternalDataset());
|
||||||
dataset.getDatasetExternalDatasets().add(datasetExternalDataset);
|
// datasetExternalDataset.setExternalDataset(externalDataset);
|
||||||
}
|
// descriptionEntity.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void makePublic(DatasetDao datasetDao, UUID id) throws Exception {
|
public void makePublic(DatasetDao datasetDao, UUID id) throws Exception {
|
||||||
Dataset dataset = datasetDao.find(id);
|
DescriptionEntity descriptionEntity = datasetDao.find(id);
|
||||||
if (dataset.getStatus() != Dataset.Status.FINALISED.getValue())
|
if (descriptionEntity.getStatus() != DescriptionStatus.Finalized)
|
||||||
throw new Exception("You cannot make public a Dataset That Has not Been Finalised");
|
throw new Exception("You cannot make public a Dataset That Has not Been Finalised");
|
||||||
datasetDao.createOrUpdate(dataset);
|
datasetDao.createOrUpdate(descriptionEntity);
|
||||||
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.PUBLISHED);
|
metricsManager.increaseValue(MetricNames.DATASET, 1, MetricNames.PUBLISHED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -965,7 +982,7 @@ public class DatasetManager {
|
||||||
HttpStatus.OK);
|
HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset createDatasetFromXml(MultipartFile importFile, String dmpId, String datasetProfileId) throws JAXBException, IOException, InvalidApplicationException {
|
public DescriptionEntity createDatasetFromXml(MultipartFile importFile, String dmpId, String datasetProfileId) throws JAXBException, IOException, InvalidApplicationException {
|
||||||
DatasetImportPagedDatasetProfile importModel = new DatasetImportPagedDatasetProfile();
|
DatasetImportPagedDatasetProfile importModel = new DatasetImportPagedDatasetProfile();
|
||||||
JAXBContext jaxbContext;
|
JAXBContext jaxbContext;
|
||||||
|
|
||||||
|
@ -1008,21 +1025,21 @@ public class DatasetManager {
|
||||||
JSONObject jsonDatasetProperties = new JSONObject(importMap);
|
JSONObject jsonDatasetProperties = new JSONObject(importMap);
|
||||||
|
|
||||||
// Creates the entity data set to save.
|
// Creates the entity data set to save.
|
||||||
Dataset entity = new Dataset();
|
DescriptionEntity entity = new DescriptionEntity();
|
||||||
entity.setProperties(jsonDatasetProperties.toString());
|
entity.setProperties(jsonDatasetProperties.toString());
|
||||||
entity.setLabel(importFile.getOriginalFilename());
|
entity.setLabel(importFile.getOriginalFilename());
|
||||||
DMP dmp = new DMP();
|
DMP dmp = new DMP();
|
||||||
dmp.setId(UUID.fromString(dmpId));
|
dmp.setId(UUID.fromString(dmpId));
|
||||||
entity.setDmp(dmp);
|
entity.setDmp(dmp.getId());
|
||||||
entity.setStatus((short) 0);
|
entity.setStatus(DescriptionStatus.Saved);
|
||||||
entity.setCreated(new Date());
|
entity.setCreatedAt(Instant.now());
|
||||||
entity.setModified(new Date());
|
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);
|
entity.setProfile(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);
|
entity.setCreator(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);
|
||||||
|
@ -1034,19 +1051,20 @@ public class DatasetManager {
|
||||||
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(entity);
|
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateTagsXmlImportDataset(DatasetRepository datasetRepository, Dataset dataset) throws IOException {
|
public void updateTagsXmlImportDataset(DatasetRepository datasetRepository, DescriptionEntity descriptionEntity) throws IOException {
|
||||||
// TODO: When tags functionality return.
|
// TODO: When tags functionality return.
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetWizardModel datasetUpdateProfile(String id) throws InvalidApplicationException {
|
public DatasetWizardModel datasetUpdateProfile(String id) throws InvalidApplicationException {
|
||||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||||
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, datasetEntity));
|
dataset.setDatasetProfileDefinition(getPagedProfile(dataset, descriptionEntityEntity));
|
||||||
dataset.fromDataModel(datasetEntity);
|
dataset.fromDataModel(descriptionEntityEntity);
|
||||||
|
|
||||||
// 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 = datasetEntity.getProfile().getGroupId();
|
|
||||||
|
UUID profileId = this.queryFactory.query(DescriptionTemplateQuery.class).ids(descriptionEntityEntity.getProfile()).first().getGroupId();
|
||||||
List<UUID> uuidList = new LinkedList<>();
|
List<UUID> uuidList = new LinkedList<>();
|
||||||
uuidList.add(profileId);
|
uuidList.add(profileId);
|
||||||
profileCriteria.setGroupIds(uuidList);
|
profileCriteria.setGroupIds(uuidList);
|
||||||
|
@ -1055,7 +1073,7 @@ public class DatasetManager {
|
||||||
DescriptionTemplateEntity item = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria).getSingle();
|
DescriptionTemplateEntity item = databaseRepository.getDatasetProfileDao().getWithCriteria(profileCriteria).getSingle();
|
||||||
|
|
||||||
// Sets the latest version of dataet Profile to the Dataset in question.
|
// Sets the latest version of dataet Profile to the Dataset in question.
|
||||||
dataset.setDatasetProfileDefinition(getLatestDatasetProfile(datasetEntity, item));
|
dataset.setDatasetProfileDefinition(getLatestDatasetProfile(descriptionEntityEntity, item));
|
||||||
dataset.setProfile(new DatasetProfileOverviewModel().fromDataModel(item));
|
dataset.setProfile(new DatasetProfileOverviewModel().fromDataModel(item));
|
||||||
|
|
||||||
// Now at latest version.
|
// Now at latest version.
|
||||||
|
@ -1078,11 +1096,11 @@ public class DatasetManager {
|
||||||
return dataset;
|
return dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PagedDatasetProfile getLatestDatasetProfile(Dataset datasetEntity, DescriptionTemplateEntity profile) {
|
public PagedDatasetProfile getLatestDatasetProfile(DescriptionEntity descriptionEntityEntity, DescriptionTemplateEntity profile) {
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
|
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
|
||||||
datasetprofile.setStatus(datasetEntity.getStatus());
|
datasetprofile.setStatus(descriptionEntityEntity.getStatus().getValue());
|
||||||
if (datasetEntity.getProperties() != null) {
|
if (descriptionEntityEntity.getProperties() != null) {
|
||||||
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
JSONObject jobject = new JSONObject(descriptionEntityEntity.getProperties());
|
||||||
Map<String, Object> properties = jobject.toMap();
|
Map<String, Object> properties = jobject.toMap();
|
||||||
datasetprofile.fromJsonObject(properties);
|
datasetprofile.fromJsonObject(properties);
|
||||||
}
|
}
|
||||||
|
@ -1108,12 +1126,13 @@ public class DatasetManager {
|
||||||
public void generateIndex() throws InvalidApplicationException {
|
public void generateIndex() throws InvalidApplicationException {
|
||||||
if (this.authorizationService.authorize(Permission.AdminRole)) {
|
if (this.authorizationService.authorize(Permission.AdminRole)) {
|
||||||
this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().toList();
|
this.apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable().toList();
|
||||||
List<Dataset> datasetEntities = new ArrayList<>(this.apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().asQueryable().toList());
|
List<DescriptionEntity> descriptionEntityEntities = new ArrayList<>(this.apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().asQueryable().toList());
|
||||||
datasetEntities.forEach(datasetEntity -> {
|
descriptionEntityEntities.forEach(datasetEntity -> {
|
||||||
try {
|
try {
|
||||||
eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(datasetEntity.getId().toString());
|
eu.eudat.elastic.entities.Dataset dataset = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(datasetEntity.getId().toString());
|
||||||
UUID dmpId = datasetEntity.getDmp().getId();
|
UUID dmpId = datasetEntity.getDmp();
|
||||||
datasetEntity.getDmp().setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
DMP dmp = databaseRepository.getDmpDao().find(datasetEntity.getDmp());
|
||||||
|
dmp.setUsers(new HashSet<>(apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().asQueryable().where((builder, root) -> builder.equal(root.get("dmp").get("id"), dmpId)).toList()));
|
||||||
updateTags(datasetEntity, dataset != null ? dataset.getTags() : null);
|
updateTags(datasetEntity, dataset != null ? dataset.getTags() : null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
@ -1132,9 +1151,9 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getTagsFromProfile(DatasetWizardModel wizardModel, Dataset dataset) throws IOException, InvalidApplicationException {
|
public void getTagsFromProfile(DatasetWizardModel wizardModel, DescriptionEntity descriptionEntity) throws IOException, InvalidApplicationException {
|
||||||
dataset.setProfile(apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(dataset.getProfile().getId()));
|
descriptionEntity.setProfile(descriptionEntity.getProfile());
|
||||||
wizardModel.setDatasetProfileDefinition(this.getPagedProfile(wizardModel, dataset));
|
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());
|
||||||
JsonNode propertiesJson = mapper.readTree(json);
|
JsonNode propertiesJson = mapper.readTree(json);
|
||||||
|
@ -1184,7 +1203,7 @@ public class DatasetManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
private DatasetListingModel mapModel(Dataset item) {
|
private DatasetListingModel mapModel(DescriptionEntity item) {
|
||||||
/*if (item.getProfile() == null)
|
/*if (item.getProfile() == null)
|
||||||
return null;*/
|
return null;*/
|
||||||
DatasetListingModel listingModel = new DatasetListingModel().fromDataModel(item);
|
DatasetListingModel listingModel = new DatasetListingModel().fromDataModel(item);
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package eu.eudat.logic.managers;
|
package eu.eudat.logic.managers;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.scope.user.UserScope;
|
import eu.eudat.commons.scope.user.UserScope;
|
||||||
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
import eu.eudat.data.dao.criteria.DatasetProfileCriteria;
|
||||||
import eu.eudat.data.dao.entities.DMPDao;
|
import eu.eudat.data.dao.entities.DMPDao;
|
||||||
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
import eu.eudat.data.dao.entities.DatasetProfileDao;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.old.UserInfo;
|
import eu.eudat.data.old.UserInfo;
|
||||||
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
import eu.eudat.data.query.items.item.dataset.DatasetWizardAutocompleteRequest;
|
||||||
|
@ -51,20 +53,21 @@ public class DatasetWizardManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unlock(ApiContext apiContext, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
|
public void unlock(ApiContext apiContext, UUID uuid) throws DatasetWizardCannotUnlockException, InvalidApplicationException {
|
||||||
Dataset dataset = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
DescriptionEntity descriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
||||||
if(dataset.getDmp().getStatus() == DMP.DMPStatus.FINALISED.getValue()) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
|
DMP dmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(descriptionEntity.getDmp());
|
||||||
dataset.setStatus(Dataset.Status.SAVED.getValue());
|
if(dmp.getStatus() == DMP.DMPStatus.FINALISED.getValue()) throw new DatasetWizardCannotUnlockException("To perform this action you will need to revert DMP's finalisation");
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
|
descriptionEntity.setStatus(DescriptionStatus.Saved);
|
||||||
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(descriptionEntity);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(ApiContext apiContext, UUID uuid) throws IOException, InvalidApplicationException {
|
public void delete(ApiContext apiContext, UUID uuid) throws IOException, InvalidApplicationException {
|
||||||
Dataset oldDataset = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
DescriptionEntity oldDescriptionEntity = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().find(uuid);
|
||||||
eu.eudat.elastic.entities.Dataset oldDatasetElasitc = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(uuid.toString());
|
eu.eudat.elastic.entities.Dataset oldDatasetElasitc = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(uuid.toString());
|
||||||
oldDataset.setStatus(Dataset.Status.DELETED.getValue());
|
oldDescriptionEntity.setIsActive(IsActive.Inactive);
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(oldDataset);
|
apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(oldDescriptionEntity);
|
||||||
if (oldDatasetElasitc != null && uuid != null && oldDatasetElasitc.getId()!= null) {
|
if (oldDatasetElasitc != null && uuid != null && oldDatasetElasitc.getId()!= null) {
|
||||||
oldDatasetElasitc.setStatus(oldDataset.getStatus());
|
oldDatasetElasitc.setStatus(oldDescriptionEntity.getStatus().getValue());
|
||||||
apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().createOrUpdate(oldDatasetElasitc);
|
apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().createOrUpdate(oldDatasetElasitc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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().getId()).stream().distinct().count();
|
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetCriteria).select(root -> root.getProfile()).stream().distinct().count();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.logic.mapper.elastic;
|
package eu.eudat.logic.mapper.elastic;
|
||||||
|
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
import eu.eudat.data.dao.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.elastic.criteria.DatasetCriteria;
|
import eu.eudat.elastic.criteria.DatasetCriteria;
|
||||||
|
@ -22,64 +23,65 @@ public class DatasetMapper {
|
||||||
this.datasetManager = datasetManager;
|
this.datasetManager = datasetManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset toElastic(eu.eudat.data.old.Dataset dataset, List<Tag> tags) throws Exception {
|
public Dataset toElastic(DescriptionEntity descriptionEntity, List<Tag> tags) throws Exception {
|
||||||
if (dataset.getProfile() == null) {
|
if (descriptionEntity.getProfile() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
//TODO
|
||||||
Dataset elastic = new Dataset();
|
Dataset elastic = new Dataset();
|
||||||
elastic.setId(dataset.getId().toString());
|
// elastic.setId(descriptionEntity.getId().toString());
|
||||||
if (tags != null && !tags.isEmpty()) {
|
// if (tags != null && !tags.isEmpty()) {
|
||||||
DatasetCriteria criteria = new DatasetCriteria();
|
// DatasetCriteria criteria = new DatasetCriteria();
|
||||||
criteria.setTags(tags);
|
// criteria.setTags(tags);
|
||||||
criteria.setHasTags(true);
|
// criteria.setHasTags(true);
|
||||||
List<Tag> tags1 = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream)
|
// List<Tag> tags1 = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().query(criteria).stream().map(eu.eudat.elastic.entities.Dataset::getTags).flatMap(Collection::stream)
|
||||||
.filter(StreamDistinctBy.distinctByKey(Tag::getId)).filter(tag -> tags.stream().anyMatch(tag1 -> tag1.getName().equals(tag.getName()))).collect(Collectors.toList());
|
// .filter(StreamDistinctBy.distinctByKey(Tag::getId)).filter(tag -> tags.stream().anyMatch(tag1 -> tag1.getName().equals(tag.getName()))).collect(Collectors.toList());
|
||||||
if (tags1.isEmpty()) {
|
// if (tags1.isEmpty()) {
|
||||||
tags.forEach(tag -> tag.setId(UUID.randomUUID().toString()));
|
// tags.forEach(tag -> tag.setId(UUID.randomUUID().toString()));
|
||||||
elastic.setTags(tags);
|
// elastic.setTags(tags);
|
||||||
} else {
|
// } else {
|
||||||
if (tags1.size() < tags.size()) {
|
// if (tags1.size() < tags.size()) {
|
||||||
tags.stream().filter(tag -> tag.getId() == null || tag.getId().equals("")).forEach(tag -> tags1.add(new Tag(UUID.randomUUID().toString(), tag.getName())));
|
// tags.stream().filter(tag -> tag.getId() == null || tag.getId().equals("")).forEach(tag -> tags1.add(new Tag(UUID.randomUUID().toString(), tag.getName())));
|
||||||
}
|
// }
|
||||||
elastic.setTags(tags1);
|
// elastic.setTags(tags1);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
elastic.setLabel(dataset.getLabel());
|
// elastic.setLabel(descriptionEntity.getLabel());
|
||||||
elastic.setDescription(dataset.getDescription());
|
// elastic.setDescription(descriptionEntity.getDescription());
|
||||||
elastic.setTemplate(dataset.getProfile().getId());
|
// elastic.setTemplate(descriptionEntity.getProfile().getId());
|
||||||
elastic.setStatus(dataset.getStatus());
|
// elastic.setStatus(descriptionEntity.getStatus());
|
||||||
elastic.setDmp(dataset.getDmp().getId());
|
// elastic.setDmp(descriptionEntity.getDmp().getId());
|
||||||
elastic.setGroup(dataset.getDmp().getGroupId());
|
// elastic.setGroup(descriptionEntity.getDmp().getGroupId());
|
||||||
if (dataset.getDmp().getGrant() != null) {
|
// if (descriptionEntity.getDmp().getGrant() != null) {
|
||||||
elastic.setGrant(dataset.getDmp().getGrant().getId());
|
// elastic.setGrant(descriptionEntity.getDmp().getGrant().getId());
|
||||||
}
|
// }
|
||||||
elastic.setCreated(dataset.getCreated());
|
// elastic.setCreated(descriptionEntity.getCreated());
|
||||||
elastic.setModified(dataset.getModified());
|
// elastic.setModified(descriptionEntity.getModified());
|
||||||
elastic.setFinalizedAt(dataset.getFinalizedAt());
|
// elastic.setFinalizedAt(descriptionEntity.getFinalizedAt());
|
||||||
if (dataset.getDmp().getUsers() != null) {
|
// if (descriptionEntity.getDmp().getUsers() != null) {
|
||||||
elastic.setCollaborators(dataset.getDmp().getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser(), user.getRole())).collect(Collectors.toList()));
|
// elastic.setCollaborators(descriptionEntity.getDmp().getUsers().stream().map(user -> CollaboratorMapper.toElastic(user.getUser(), user.getRole())).collect(Collectors.toList()));
|
||||||
}
|
// }
|
||||||
DataManagementPlanCriteria dmpCriteria = new DataManagementPlanCriteria();
|
// DataManagementPlanCriteria dmpCriteria = new DataManagementPlanCriteria();
|
||||||
dmpCriteria.setAllVersions(true);
|
// dmpCriteria.setAllVersions(true);
|
||||||
dmpCriteria.setGroupIds(Collections.singletonList(dataset.getDmp().getGroupId()));
|
// dmpCriteria.setGroupIds(Collections.singletonList(descriptionEntity.getDmp().getGroupId()));
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream()
|
// apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream()
|
||||||
.max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp -> elastic.setLastVersion(dmp.getId().equals(dataset.getDmp().getId())));
|
// .max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp -> elastic.setLastVersion(dmp.getId().equals(descriptionEntity.getDmp().getId())));
|
||||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream().filter(DMP::isPublic)
|
// apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dmpCriteria).toList().stream().filter(DMP::isPublic)
|
||||||
.max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp -> elastic.setLastPublicVersion(dmp.getId().equals(dataset.getDmp().getId())));
|
// .max(Comparator.comparing(DMP::getVersion)).ifPresent(dmp -> elastic.setLastPublicVersion(dmp.getId().equals(descriptionEntity.getDmp().getId())));
|
||||||
if (elastic.getLastVersion() == null) {
|
// if (elastic.getLastVersion() == null) {
|
||||||
elastic.setLastVersion(true);
|
// elastic.setLastVersion(true);
|
||||||
}
|
// }
|
||||||
if (elastic.getLastPublicVersion() == null) {
|
// if (elastic.getLastPublicVersion() == null) {
|
||||||
elastic.setLastPublicVersion(false);
|
// elastic.setLastPublicVersion(false);
|
||||||
}
|
// }
|
||||||
if (dataset.getDmp().getOrganisations() != null) {
|
// if (descriptionEntity.getDmp().getOrganisations() != null) {
|
||||||
elastic.setOrganizations(dataset.getDmp().getOrganisations().stream().map(OrganizationMapper::toElastic).collect(Collectors.toList()));
|
// elastic.setOrganizations(descriptionEntity.getDmp().getOrganisations().stream().map(OrganizationMapper::toElastic).collect(Collectors.toList()));
|
||||||
}
|
// }
|
||||||
elastic.setPublic(dataset.getDmp().isPublic());
|
// elastic.setPublic(descriptionEntity.getDmp().isPublic());
|
||||||
if (dataset.getDmp().getGrant() != null) {
|
// if (descriptionEntity.getDmp().getGrant() != null) {
|
||||||
elastic.setGrantStatus(dataset.getDmp().getGrant().getStatus());
|
// elastic.setGrantStatus(descriptionEntity.getDmp().getGrant().getStatus());
|
||||||
}
|
// }
|
||||||
elastic.setFormData(datasetManager.getWordDocumentText(dataset));
|
// elastic.setFormData(datasetManager.getWordDocumentText(descriptionEntity));
|
||||||
|
|
||||||
return elastic;
|
return elastic;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class DmpMapper {
|
||||||
if (dataset1 != null) {
|
if (dataset1 != null) {
|
||||||
tags = dataset1.getTags();
|
tags = dataset1.getTags();
|
||||||
}
|
}
|
||||||
dataset.setDmp(dmp);
|
dataset.setDmp(dmp.getId());
|
||||||
return datasetMapper.toElastic(dataset, tags);
|
return datasetMapper.toElastic(dataset, tags);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.elastic.entities.Tag;
|
import eu.eudat.elastic.entities.Tag;
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
|
@ -52,10 +52,10 @@ public class PrefillingMapper {
|
||||||
DescriptionTemplateEntity profile, DatasetManager datasetManager, LicenseManager licenseManager) throws Exception {
|
DescriptionTemplateEntity profile, DatasetManager datasetManager, LicenseManager licenseManager) throws Exception {
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||||
datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
||||||
Dataset dataset = new Dataset();
|
DescriptionEntity descriptionEntity = new DescriptionEntity();
|
||||||
dataset.setProfile(profile);
|
descriptionEntity.setProfile(profile.getId());
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
JsonNode parentNode = mapper.readTree(mapper.writeValueAsString(datasetManager.getPagedProfile(datasetWizardModel, dataset)));
|
JsonNode parentNode = mapper.readTree(mapper.writeValueAsString(datasetManager.getPagedProfile(datasetWizardModel, descriptionEntity)));
|
||||||
for (DefaultPrefillingMapping prefillingMapping: prefillingGet.getMappings()) {
|
for (DefaultPrefillingMapping prefillingMapping: prefillingGet.getMappings()) {
|
||||||
List<String> sourceKeys = Arrays.asList(prefillingMapping.getSource().split("\\."));
|
List<String> sourceKeys = Arrays.asList(prefillingMapping.getSource().split("\\."));
|
||||||
Object sourceValue = null;
|
Object sourceValue = null;
|
||||||
|
@ -81,8 +81,8 @@ public class PrefillingMapper {
|
||||||
for (PrefillingFixedMapping fixedMapping: prefillingGet.getFixedMappings()) {
|
for (PrefillingFixedMapping fixedMapping: prefillingGet.getFixedMappings()) {
|
||||||
setValue(fixedMapping, fixedMapping.getValue(), datasetWizardModel, parentNode, properties, type, licenseManager);
|
setValue(fixedMapping, fixedMapping.getValue(), datasetWizardModel, parentNode, properties, type, licenseManager);
|
||||||
}
|
}
|
||||||
dataset.setProperties(mapper.writeValueAsString(properties));
|
descriptionEntity.setProperties(mapper.writeValueAsString(properties));
|
||||||
datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset));
|
datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, descriptionEntity));
|
||||||
return datasetWizardModel;
|
return datasetWizardModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.eudat.logic.security.repositorydeposit.mapper;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.depositinterface.models.*;
|
import eu.eudat.depositinterface.models.*;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
|
@ -52,11 +53,12 @@ public class DMPToDepositMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
private static DatasetDepositModel fromDataset(Dataset entity){
|
private static DatasetDepositModel fromDataset(DescriptionEntity entity){
|
||||||
DatasetDepositModel deposit = new DatasetDepositModel();
|
DatasetDepositModel deposit = new DatasetDepositModel();
|
||||||
deposit.setLabel(entity.getLabel());
|
deposit.setLabel(entity.getLabel());
|
||||||
deposit.setDescription(entity.getDescription());
|
deposit.setDescription(entity.getDescription());
|
||||||
deposit.setProfileDefinition(entity.getProfile().getDefinition());
|
//TODO
|
||||||
|
//deposit.setProfileDefinition(entity.getProfile().getDefinition());
|
||||||
deposit.setProperties(entity.getProperties());
|
deposit.setProperties(entity.getProperties());
|
||||||
deposit.setFields(fromDefinitionAndProperties(deposit.getProfileDefinition(), deposit.getProperties()));
|
deposit.setFields(fromDefinitionAndProperties(deposit.getProfileDefinition(), deposit.getProperties()));
|
||||||
return deposit;
|
return deposit;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.commons.enums.FieldDataComboBoxType;
|
import eu.eudat.commons.enums.FieldDataComboBoxType;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
import eu.eudat.commons.types.descriptiontemplate.fielddata.*;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.Organisation;
|
import eu.eudat.data.old.Organisation;
|
||||||
import eu.eudat.data.old.Researcher;
|
import eu.eudat.data.old.Researcher;
|
||||||
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
import eu.eudat.logic.proxy.config.configloaders.ConfigLoader;
|
||||||
|
@ -1014,7 +1014,7 @@ public class WordBuilder {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillFirstPage(DMP dmpEntity, Dataset datasetEntity, XWPFDocument document, boolean isDataset) {
|
public void fillFirstPage(DMP dmpEntity, DescriptionEntity descriptionEntityEntity, XWPFDocument document, boolean isDataset) {
|
||||||
int parPos = 0;
|
int parPos = 0;
|
||||||
int descrParPos = -1;
|
int descrParPos = -1;
|
||||||
XWPFParagraph descrPar = null;
|
XWPFParagraph descrPar = null;
|
||||||
|
@ -1030,17 +1030,17 @@ public class WordBuilder {
|
||||||
} else if(text.contains("{ARGOS.DMP.VERSION}")) {
|
} else if(text.contains("{ARGOS.DMP.VERSION}")) {
|
||||||
text = text.replace("{ARGOS.DMP.VERSION}", "Version " + dmpEntity.getVersion());
|
text = text.replace("{ARGOS.DMP.VERSION}", "Version " + dmpEntity.getVersion());
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
} else if(datasetEntity != null && text.contains("{ARGOS.DATASET.TITLE}")) {
|
} else if(descriptionEntityEntity != null && text.contains("{ARGOS.DATASET.TITLE}")) {
|
||||||
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
|
text = text.replace("{ARGOS.DATASET.TITLE}", descriptionEntityEntity.getLabel());
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
// } else if(text.equals("Description") && ((!isDataset && (dmpEntity == null || dmpEntity.getDescription() != null)) || (isDataset && (datasetEntity == null || datasetEntity.getDescription() == null)))) {
|
// } else if(text.equals("Description") && ((!isDataset && (dmpEntity == null || dmpEntity.getDescription() != null)) || (isDataset && (datasetEntity == null || datasetEntity.getDescription() == null)))) {
|
||||||
// r.setText("", 0);
|
// r.setText("", 0);
|
||||||
} else if((dmpEntity != null && text.contains("{ARGOS.DMP.DESCRIPTION}") && !isDataset) || (datasetEntity != null && text.contains("{ARGOS.DATASET.DESCRIPTION}") && isDataset)) {
|
} else if((dmpEntity != null && text.contains("{ARGOS.DMP.DESCRIPTION}") && !isDataset) || (descriptionEntityEntity != null && text.contains("{ARGOS.DATASET.DESCRIPTION}") && isDataset)) {
|
||||||
descrParPos = parPos;
|
descrParPos = parPos;
|
||||||
descrPar = p;
|
descrPar = p;
|
||||||
if(dmpEntity != null && !isDataset) {
|
if(dmpEntity != null && !isDataset) {
|
||||||
text = text.replace("{ARGOS.DMP.DESCRIPTION}", "");
|
text = text.replace("{ARGOS.DMP.DESCRIPTION}", "");
|
||||||
} else if(datasetEntity != null && isDataset) {
|
} else if(descriptionEntityEntity != null && isDataset) {
|
||||||
text = text.replace("{ARGOS.DATASET.DESCRIPTION}", "");
|
text = text.replace("{ARGOS.DATASET.DESCRIPTION}", "");
|
||||||
}
|
}
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
|
@ -1080,10 +1080,10 @@ public class WordBuilder {
|
||||||
HtmlToWorldBuilder htmlToWorldBuilder = new HtmlToWorldBuilder(descrPar, 0, cursor);
|
HtmlToWorldBuilder htmlToWorldBuilder = new HtmlToWorldBuilder(descrPar, 0, cursor);
|
||||||
NodeTraversor.traverse(htmlToWorldBuilder, htmlDoc);
|
NodeTraversor.traverse(htmlToWorldBuilder, htmlDoc);
|
||||||
}
|
}
|
||||||
if((descrParPos != -1) && (datasetEntity != null) && (datasetEntity.getDescription() != null) && isDataset) {
|
if((descrParPos != -1) && (descriptionEntityEntity != null) && (descriptionEntityEntity.getDescription() != null) && isDataset) {
|
||||||
XmlCursor cursor = descrPar.getCTP().newCursor();
|
XmlCursor cursor = descrPar.getCTP().newCursor();
|
||||||
cursor.toNextSibling();
|
cursor.toNextSibling();
|
||||||
Document htmlDoc = Jsoup.parse(((String)datasetEntity.getDescription()).replaceAll("\n", "<br>"));
|
Document htmlDoc = Jsoup.parse(((String) descriptionEntityEntity.getDescription()).replaceAll("\n", "<br>"));
|
||||||
HtmlToWorldBuilder htmlToWorldBuilder = new HtmlToWorldBuilder(descrPar, 0, cursor);
|
HtmlToWorldBuilder htmlToWorldBuilder = new HtmlToWorldBuilder(descrPar, 0, cursor);
|
||||||
NodeTraversor.traverse(htmlToWorldBuilder, htmlDoc);
|
NodeTraversor.traverse(htmlToWorldBuilder, htmlDoc);
|
||||||
}
|
}
|
||||||
|
@ -1116,7 +1116,7 @@ public class WordBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fillFooter(DMP dmpEntity, Dataset datasetEntity, XWPFDocument document, boolean isDataset) {
|
public void fillFooter(DMP dmpEntity, DescriptionEntity descriptionEntityEntity, XWPFDocument document, boolean isDataset) {
|
||||||
document.getFooterList().forEach(xwpfFooter -> {
|
document.getFooterList().forEach(xwpfFooter -> {
|
||||||
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
List<XWPFRun> runs = xwpfFooter.getParagraphs().get(0).getRuns();
|
||||||
if(runs != null){
|
if(runs != null){
|
||||||
|
@ -1127,8 +1127,8 @@ public class WordBuilder {
|
||||||
text = text.replace("{ARGOS.DMP.TITLE}", dmpEntity.getLabel());
|
text = text.replace("{ARGOS.DMP.TITLE}", dmpEntity.getLabel());
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
}
|
}
|
||||||
if(text.contains("{ARGOS.DATASET.TITLE}") && datasetEntity != null){
|
if(text.contains("{ARGOS.DATASET.TITLE}") && descriptionEntityEntity != null){
|
||||||
text = text.replace("{ARGOS.DATASET.TITLE}", datasetEntity.getLabel());
|
text = text.replace("{ARGOS.DATASET.TITLE}", descriptionEntityEntity.getLabel());
|
||||||
r.setText(text, 0);
|
r.setText(text, 0);
|
||||||
}
|
}
|
||||||
if(text.contains("{ARGOS.DMP.LICENSE}")){
|
if(text.contains("{ARGOS.DMP.LICENSE}")){
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
package eu.eudat.models.data.dashboard.recent.model;
|
package eu.eudat.models.data.dashboard.recent.model;
|
||||||
|
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
||||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class RecentDatasetModel extends RecentActivityModel<Dataset, RecentDatasetModel> {
|
public class RecentDatasetModel extends RecentActivityModel<DescriptionEntity, RecentDatasetModel> {
|
||||||
private String dmp;
|
private String dmp;
|
||||||
private String dmpId;
|
private String dmpId;
|
||||||
|
|
||||||
|
@ -28,54 +28,56 @@ public class RecentDatasetModel extends RecentActivityModel<Dataset, RecentDatas
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecentActivityModel fromEntity(Dataset entity) {
|
public RecentActivityModel fromEntity(DescriptionEntity entity) {
|
||||||
|
//TODO
|
||||||
this.setType(RecentActivityType.DATASET.getIndex());
|
this.setType(RecentActivityType.DATASET.getIndex());
|
||||||
this.setId(entity.getId().toString());
|
// this.setId(entity.getId().toString());
|
||||||
this.setTitle(entity.getLabel());
|
// this.setTitle(entity.getLabel());
|
||||||
this.setCreated(entity.getCreated());
|
// this.setCreated(entity.getCreated());
|
||||||
this.setModified(entity.getModified());
|
// this.setModified(entity.getModified());
|
||||||
this.setStatus(entity.getStatus());
|
// this.setStatus(entity.getStatus());
|
||||||
this.setVersion(entity.getDmp() != null ? entity.getDmp().getVersion(): 0);
|
// this.setVersion(entity.getDmp() != null ? entity.getDmp().getVersion(): 0);
|
||||||
this.setFinalizedAt(entity.getFinalizedAt());
|
// this.setFinalizedAt(entity.getFinalizedAt());
|
||||||
this.setPublishedAt(entity.getDmp() != null ? entity.getDmp().getPublishedAt() : new Date());
|
// this.setPublishedAt(entity.getDmp() != null ? entity.getDmp().getPublishedAt() : new Date());
|
||||||
this.setProfile(entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()): null);
|
// this.setProfile(entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()): null);
|
||||||
if (entity.getDmp() != null && entity.getDmp().getGrant() != null) {
|
// if (entity.getDmp() != null && entity.getDmp().getGrant() != null) {
|
||||||
this.setGrant(entity.getDmp().getGrant().getLabel());
|
// this.setGrant(entity.getDmp().getGrant().getLabel());
|
||||||
}
|
// }
|
||||||
this.setDmp( entity.getDmp() != null ? entity.getDmp().getLabel() : "");
|
// this.setDmp( entity.getDmp() != null ? entity.getDmp().getLabel() : "");
|
||||||
this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
|
// this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
|
||||||
this.setPublic(entity.getDmp().isPublic());
|
// this.setPublic(entity.getDmp().isPublic());
|
||||||
this.setUsers(entity.getDmp().getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()));
|
// this.setUsers(entity.getDmp().getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RecentDatasetModel fromDmpEntity(Dataset entity) {
|
public RecentDatasetModel fromDmpEntity(DescriptionEntity entity) {
|
||||||
|
//TODO
|
||||||
this.setType(RecentActivityType.DATASET.getIndex());
|
this.setType(RecentActivityType.DATASET.getIndex());
|
||||||
this.setId(entity.getId().toString());
|
// this.setId(entity.getId().toString());
|
||||||
this.setTitle(entity.getLabel());
|
// this.setTitle(entity.getLabel());
|
||||||
this.setCreated(entity.getCreated());
|
// this.setCreated(entity.getCreated());
|
||||||
this.setModified(entity.getModified());
|
// this.setModified(entity.getModified());
|
||||||
this.setStatus(entity.getStatus());
|
// this.setStatus(entity.getStatus());
|
||||||
this.setVersion(entity.getDmp() != null ? entity.getDmp().getVersion(): 0);
|
// this.setVersion(entity.getDmp() != null ? entity.getDmp().getVersion(): 0);
|
||||||
this.setFinalizedAt(entity.getFinalizedAt());
|
// this.setFinalizedAt(entity.getFinalizedAt());
|
||||||
this.setPublishedAt(entity.getDmp() != null ? entity.getDmp().getPublishedAt() : new Date());
|
// this.setPublishedAt(entity.getDmp() != null ? entity.getDmp().getPublishedAt() : new Date());
|
||||||
this.setProfile(entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()) : null);
|
// this.setProfile(entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()) : null);
|
||||||
if (entity.getDmp() != null && entity.getDmp().getGrant() != null) {
|
// if (entity.getDmp() != null && entity.getDmp().getGrant() != null) {
|
||||||
this.setGrant(entity.getDmp().getGrant().getLabel());
|
// this.setGrant(entity.getDmp().getGrant().getLabel());
|
||||||
}
|
// }
|
||||||
this.setDmp( entity.getDmp() != null ? entity.getDmp().getLabel() : "");
|
// this.setDmp( entity.getDmp() != null ? entity.getDmp().getLabel() : "");
|
||||||
this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
|
// this.setDmpId(entity.getDmp() != null ? entity.getDmp().getId().toString() : "");
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RecentDatasetModel fromDataModel(Dataset entity) {
|
public RecentDatasetModel fromDataModel(DescriptionEntity entity) {
|
||||||
return (RecentDatasetModel) this.fromEntity(entity);
|
return (RecentDatasetModel) this.fromEntity(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset toDataModel() throws Exception {
|
public DescriptionEntity toDataModel() throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.models.data.dataset;
|
package eu.eudat.models.data.dataset;
|
||||||
|
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.DatasetDataRepository;
|
import eu.eudat.data.old.DatasetDataRepository;
|
||||||
import eu.eudat.data.old.DatasetService;
|
import eu.eudat.data.old.DatasetService;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
@ -12,7 +13,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Dataset implements DataModel<eu.eudat.data.old.Dataset, Dataset> {
|
public class Dataset implements DataModel<DescriptionEntity, Dataset> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private String reference;
|
private String reference;
|
||||||
|
@ -131,60 +132,62 @@ public class Dataset implements DataModel<eu.eudat.data.old.Dataset, Dataset> {
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dataset fromDataModel(eu.eudat.data.old.Dataset entity) {
|
public Dataset fromDataModel(DescriptionEntity entity) {
|
||||||
this.id = entity.getId();
|
//TODO
|
||||||
this.label = entity.getLabel();
|
// this.id = entity.getId();
|
||||||
this.properties = entity.getProperties();
|
// this.label = entity.getLabel();
|
||||||
this.reference = entity.getReference();
|
// this.properties = entity.getProperties();
|
||||||
this.description = entity.getDescription();
|
// this.reference = entity.getReference();
|
||||||
this.profile = new DatasetProfileListingModel();
|
// this.description = entity.getDescription();
|
||||||
this.profile.fromDataModel(entity.getProfile());
|
// this.profile = new DatasetProfileListingModel();
|
||||||
this.registries = entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList());
|
// this.profile.fromDataModel(entity.getProfile());
|
||||||
this.dataRepositories = entity.getDatasetDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item.getDataRepository())).collect(Collectors.toList());
|
// this.registries = entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.services = entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList());
|
// this.dataRepositories = entity.getDatasetDataRepositories().stream().map(item -> new DataRepository().fromDataModel(item.getDataRepository())).collect(Collectors.toList());
|
||||||
this.created = entity.getCreated();
|
// this.services = entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList());
|
||||||
|
// this.created = entity.getCreated();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public eu.eudat.data.old.Dataset toDataModel() throws Exception {
|
public DescriptionEntity toDataModel() throws Exception {
|
||||||
eu.eudat.data.old.Dataset entity = new eu.eudat.data.old.Dataset();
|
DescriptionEntity entity = new DescriptionEntity();
|
||||||
entity.setId(this.id);
|
//TODO
|
||||||
entity.setLabel(this.label);
|
// entity.setId(this.id);
|
||||||
entity.setReference(this.reference);
|
// entity.setLabel(this.label);
|
||||||
entity.setUri(this.uri);
|
// entity.setReference(this.reference);
|
||||||
entity.setProperties(this.properties);
|
// entity.setUri(this.uri);
|
||||||
entity.setStatus(this.status);
|
// entity.setProperties(this.properties);
|
||||||
entity.setDmp(dmp.toDataModel());
|
// entity.setStatus(this.status);
|
||||||
entity.setDescription(this.description);
|
// entity.setDmp(dmp.toDataModel());
|
||||||
entity.setCreated(this.created != null ? this.created : new Date());
|
// entity.setDescription(this.description);
|
||||||
entity.setModified(new Date());
|
// entity.setCreated(this.created != null ? this.created : new Date());
|
||||||
entity.setProfile(profile.toDataModel()); ///TODO
|
// entity.setModified(new Date());
|
||||||
if (!this.registries.isEmpty()) {
|
// entity.setProfile(profile.toDataModel()); ///TODO
|
||||||
entity.setRegistries(new HashSet<eu.eudat.data.old.Registry>());
|
// if (!this.registries.isEmpty()) {
|
||||||
for (Registry registry : this.registries) {
|
// entity.setRegistries(new HashSet<eu.eudat.data.old.Registry>());
|
||||||
entity.getRegistries().add(registry.toDataModel());
|
// for (Registry registry : this.registries) {
|
||||||
}
|
// entity.getRegistries().add(registry.toDataModel());
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
if (!this.dataRepositories.isEmpty()) {
|
//
|
||||||
entity.setDatasetDataRepositories(new HashSet<>());
|
// if (!this.dataRepositories.isEmpty()) {
|
||||||
for (DataRepository dataRepositoryModel : this.dataRepositories) {
|
// entity.setDatasetDataRepositories(new HashSet<>());
|
||||||
DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
// for (DataRepository dataRepositoryModel : this.dataRepositories) {
|
||||||
eu.eudat.data.old.DataRepository dataRepository = dataRepositoryModel.toDataModel();
|
// DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
||||||
datasetDataRepository.setDataRepository(dataRepository);
|
// eu.eudat.data.old.DataRepository dataRepository = dataRepositoryModel.toDataModel();
|
||||||
entity.getDatasetDataRepositories().add(datasetDataRepository);
|
// datasetDataRepository.setDataRepository(dataRepository);
|
||||||
}
|
// entity.getDatasetDataRepositories().add(datasetDataRepository);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
if (!this.services.isEmpty()) {
|
//
|
||||||
entity.setServices(new HashSet<DatasetService>());
|
// if (!this.services.isEmpty()) {
|
||||||
for (Service serviceModel : this.services) {
|
// entity.setServices(new HashSet<DatasetService>());
|
||||||
eu.eudat.data.old.Service service = serviceModel.toDataModel();
|
// for (Service serviceModel : this.services) {
|
||||||
DatasetService datasetService = new DatasetService();
|
// eu.eudat.data.old.Service service = serviceModel.toDataModel();
|
||||||
datasetService.setService(service);
|
// DatasetService datasetService = new DatasetService();
|
||||||
entity.getServices().add(datasetService);
|
// datasetService.setService(service);
|
||||||
}
|
// entity.getServices().add(datasetService);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,30 +1,32 @@
|
||||||
package eu.eudat.models.data.dataset;
|
package eu.eudat.models.data.dataset;
|
||||||
|
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
||||||
import eu.eudat.models.data.grant.GrantOverviewModel;
|
import eu.eudat.models.data.grant.GrantOverviewModel;
|
||||||
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
|
import eu.eudat.models.data.listingmodels.DataManagementPlanOverviewModel;
|
||||||
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
import eu.eudat.models.data.listingmodels.UserInfoListingModel;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DatasetOverviewModel implements DataModel<Dataset, DatasetOverviewModel> {
|
public class DatasetOverviewModel implements DataModel<DescriptionEntity, DatasetOverviewModel> {
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private short status;
|
private DescriptionStatus status;
|
||||||
private DatasetProfileOverviewModel datasetTemplate;
|
private DatasetProfileOverviewModel datasetTemplate;
|
||||||
private List<UserInfoListingModel> users;
|
private List<UserInfoListingModel> users;
|
||||||
private DataManagementPlanOverviewModel dmp;
|
private DataManagementPlanOverviewModel dmp;
|
||||||
private GrantOverviewModel grant;
|
private GrantOverviewModel grant;
|
||||||
private String description;
|
private String description;
|
||||||
private Boolean isPublic;
|
private Boolean isPublic;
|
||||||
private Date modified;
|
private Instant modified;
|
||||||
private Date created;
|
private Instant created;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -40,10 +42,10 @@ public class DatasetOverviewModel implements DataModel<Dataset, DatasetOverviewM
|
||||||
this.label = label;
|
this.label = label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getStatus() {
|
public DescriptionStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
public void setStatus(short status) {
|
public void setStatus(DescriptionStatus status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,43 +96,44 @@ public class DatasetOverviewModel implements DataModel<Dataset, DatasetOverviewM
|
||||||
isPublic = aPublic;
|
isPublic = aPublic;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getModified() {
|
public Instant getModified() {
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setModified(Date modified) {
|
public void setModified(Instant modified) {
|
||||||
this.modified = modified;
|
this.modified = modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreated() {
|
public Instant getCreated() {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreated(Date created) {
|
public void setCreated(Instant created) {
|
||||||
this.created = created;
|
this.created = created;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasetOverviewModel fromDataModel(Dataset entity) {
|
public DatasetOverviewModel fromDataModel(DescriptionEntity entity) {
|
||||||
this.id = entity.getId();
|
//TODO Implement it on transfer
|
||||||
this.label = entity.getLabel();
|
// this.id = entity.getId();
|
||||||
this.status = entity.getStatus();
|
// this.label = entity.getLabel();
|
||||||
this.datasetTemplate = new DatasetProfileOverviewModel().fromDataModel(entity.getProfile());
|
// this.status = entity.getStatus();
|
||||||
this.users = entity.getDmp().getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
// this.datasetTemplate = new DatasetProfileOverviewModel().fromDataModel(entity.getProfile());
|
||||||
this.dmp = new DataManagementPlanOverviewModel().fromDataModel(entity.getDmp());
|
// this.users = entity.getDmp().getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
||||||
if (entity.getDmp().getGrant() != null) {
|
// this.dmp = new DataManagementPlanOverviewModel().fromDataModel(entity.getDmp());
|
||||||
this.grant = new GrantOverviewModel().fromDataModel(entity.getDmp().getGrant());
|
// if (entity.getDmp().getGrant() != null) {
|
||||||
}
|
// this.grant = new GrantOverviewModel().fromDataModel(entity.getDmp().getGrant());
|
||||||
this.description = entity.getDescription();
|
// }
|
||||||
this.isPublic = entity.getDmp().isPublic();
|
// this.description = entity.getDescription();
|
||||||
this.modified = entity.getModified();
|
// this.isPublic = entity.getDmp().isPublic();
|
||||||
this.created = entity.getCreated();
|
// this.modified = entity.getCreatedAt();
|
||||||
|
// this.created = entity.getUpdatedAt();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset toDataModel() throws Exception {
|
public DescriptionEntity toDataModel() throws Exception {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.eudat.models.data.datasetwizard;
|
package eu.eudat.models.data.datasetwizard;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.elastic.entities.Tag;
|
import eu.eudat.elastic.entities.Tag;
|
||||||
|
@ -13,19 +15,20 @@ import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
import net.minidev.json.JSONValue;
|
import net.minidev.json.JSONValue;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel> {
|
public class DatasetWizardModel implements DataModel<DescriptionEntity, DatasetWizardModel> {
|
||||||
|
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private String reference;
|
private String reference;
|
||||||
private String uri;
|
private String uri;
|
||||||
private String description;
|
private String description;
|
||||||
private short status;
|
private DescriptionStatus status;
|
||||||
private Date created;
|
private Instant created;
|
||||||
private DataManagementPlan dmp;
|
private DataManagementPlan dmp;
|
||||||
private Integer dmpSectionIndex;
|
private Integer dmpSectionIndex;
|
||||||
private PagedDatasetProfile datasetProfileDefinition;
|
private PagedDatasetProfile datasetProfileDefinition;
|
||||||
|
@ -36,7 +39,7 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
private List<ExternalDatasetListingModel> externalDatasets;
|
private List<ExternalDatasetListingModel> externalDatasets;
|
||||||
private DatasetProfileOverviewModel profile;
|
private DatasetProfileOverviewModel profile;
|
||||||
private Boolean isProfileLatestVersion;
|
private Boolean isProfileLatestVersion;
|
||||||
private Date modified;
|
private Instant modified;
|
||||||
|
|
||||||
public UUID getId() {
|
public UUID getId() {
|
||||||
return id;
|
return id;
|
||||||
|
@ -73,17 +76,17 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getStatus() {
|
public DescriptionStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
public void setStatus(short status) {
|
public void setStatus(DescriptionStatus status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreated() {
|
public Instant getCreated() {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
public void setCreated(Date created) {
|
public void setCreated(Instant created) {
|
||||||
this.created = created;
|
this.created = created;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,154 +161,157 @@ public class DatasetWizardModel implements DataModel<Dataset, DatasetWizardModel
|
||||||
isProfileLatestVersion = profileLatestVersion;
|
isProfileLatestVersion = profileLatestVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getModified() {
|
public Instant getModified() {
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
public void setModified(Date modified) {
|
public void setModified(Instant modified) {
|
||||||
this.modified = modified;
|
this.modified = modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasetWizardModel fromDataModel(Dataset entity) {
|
public DatasetWizardModel fromDataModel(DescriptionEntity entity) {
|
||||||
this.id = entity.getId();
|
//TODO Implement it on transfer
|
||||||
this.label = entity.getLabel();
|
// this.id = entity.getId();
|
||||||
this.status = entity.getStatus();
|
// this.label = entity.getLabel();
|
||||||
this.reference = entity.getReference();
|
// this.status = entity.getStatus();
|
||||||
this.description = entity.getDescription();
|
// this.reference = entity.getReference();
|
||||||
this.profile = new DatasetProfileOverviewModel();
|
// this.description = entity.getDescription();
|
||||||
this.profile = this.profile.fromDataModel(entity.getProfile());
|
// this.profile = new DatasetProfileOverviewModel();
|
||||||
this.uri = entity.getUri();
|
// this.profile = this.profile.fromDataModel(entity.getProfile());
|
||||||
this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.uri = entity.getUri();
|
||||||
this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
|
// this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
DataRepository dataRepository = new DataRepository().fromDataModel(item.getDataRepository());
|
// this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
|
||||||
if (item.getData() != null) {
|
// DataRepository dataRepository = new DataRepository().fromDataModel(item.getDataRepository());
|
||||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
// if (item.getData() != null) {
|
||||||
Map<String, String> values = data.get("data");
|
// Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
dataRepository.setInfo(values.get("info"));
|
// Map<String, String> values = data.get("data");
|
||||||
}
|
// dataRepository.setInfo(values.get("info"));
|
||||||
return dataRepository;
|
// }
|
||||||
}).collect(Collectors.toList()) : new ArrayList<>();
|
// return dataRepository;
|
||||||
this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
|
// }).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.created = entity.getCreated();
|
// this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.dmp = new DataManagementPlan().fromDataModelNoDatasets(entity.getDmp());
|
// this.created = entity.getCreated();
|
||||||
this.dmpSectionIndex = entity.getDmpSectionIndex();
|
// this.dmp = new DataManagementPlan().fromDataModelNoDatasets(entity.getDmp());
|
||||||
this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
|
// this.dmpSectionIndex = entity.getDmpSectionIndex();
|
||||||
ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset());
|
// this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
|
||||||
if (item.getData() != null) {
|
// ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset());
|
||||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
// if (item.getData() != null) {
|
||||||
Map<String, String> values = data.get("data");
|
// Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
externalDatasetListingModel.setInfo(values.get("info"));
|
// Map<String, String> values = data.get("data");
|
||||||
externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
|
// externalDatasetListingModel.setInfo(values.get("info"));
|
||||||
}
|
// externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
|
||||||
return externalDatasetListingModel;
|
// }
|
||||||
}).collect(Collectors.toList()) : new ArrayList<>();
|
// return externalDatasetListingModel;
|
||||||
this.modified = entity.getModified();
|
// }).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
|
// this.modified = entity.getUpdatedAt();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetWizardModel fromDataModelNoDmp(Dataset entity) {
|
public DatasetWizardModel fromDataModelNoDmp(DescriptionEntity entity) {
|
||||||
this.id = entity.getId();
|
//TODO Implement it on transfer
|
||||||
this.label = entity.getLabel();
|
// this.id = entity.getId();
|
||||||
this.status = entity.getStatus();
|
// this.label = entity.getLabel();
|
||||||
this.reference = entity.getReference();
|
// this.status = entity.getStatus();
|
||||||
this.description = entity.getDescription();
|
// this.reference = entity.getReference();
|
||||||
this.profile = new DatasetProfileOverviewModel();
|
// this.description = entity.getDescription();
|
||||||
this.profile = this.profile.fromDataModel(entity.getProfile());
|
// this.profile = new DatasetProfileOverviewModel();
|
||||||
this.uri = entity.getUri();
|
// this.profile = this.profile.fromDataModel(entity.getProfile());
|
||||||
this.dmpSectionIndex = entity.getDmpSectionIndex();
|
// this.uri = entity.getUri();
|
||||||
this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.dmpSectionIndex = entity.getDmpSectionIndex();
|
||||||
this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
|
// this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new Registry().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
DataRepository dataRepository = new DataRepository().fromDataModel(item.getDataRepository());
|
// this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
|
||||||
if (item.getData() != null) {
|
// DataRepository dataRepository = new DataRepository().fromDataModel(item.getDataRepository());
|
||||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
// if (item.getData() != null) {
|
||||||
Map<String, String> values = data.get("data");
|
// Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
dataRepository.setInfo(values.get("info"));
|
// Map<String, String> values = data.get("data");
|
||||||
}
|
// dataRepository.setInfo(values.get("info"));
|
||||||
return dataRepository;
|
// }
|
||||||
}).collect(Collectors.toList()) : new ArrayList<>();
|
// return dataRepository;
|
||||||
this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
|
// }).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.created = entity.getCreated();
|
// this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new Service().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
|
// this.created = entity.getCreated();
|
||||||
ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset());
|
// this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
|
||||||
if (item.getData() != null) {
|
// ExternalDatasetListingModel externalDatasetListingModel = new ExternalDatasetListingModel().fromDataModel(item.getExternalDataset());
|
||||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
// if (item.getData() != null) {
|
||||||
Map<String, String> values = data.get("data");
|
// Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
externalDatasetListingModel.setInfo(values.get("info"));
|
// Map<String, String> values = data.get("data");
|
||||||
externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
|
// externalDatasetListingModel.setInfo(values.get("info"));
|
||||||
}
|
// externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
|
||||||
return externalDatasetListingModel;
|
// }
|
||||||
}).collect(Collectors.toList()) : new ArrayList<>();
|
// return externalDatasetListingModel;
|
||||||
this.modified = entity.getModified();
|
// }).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
|
// this.modified = entity.getModified();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset toDataModel() throws Exception {
|
public DescriptionEntity toDataModel() throws Exception {
|
||||||
Dataset entity = new Dataset();
|
DescriptionEntity entity = new DescriptionEntity();
|
||||||
entity.setId(this.id);
|
//TODO Implement it on transfer
|
||||||
entity.setLabel(this.label);
|
// entity.setId(this.id);
|
||||||
entity.setReference(this.reference);
|
// entity.setLabel(this.label);
|
||||||
entity.setUri(this.uri);
|
// entity.setReference(this.reference);
|
||||||
entity.setStatus(this.status);
|
// entity.setUri(this.uri);
|
||||||
if (this.status == (int) Dataset.Status.FINALISED.getValue())
|
// entity.setStatus(this.status);
|
||||||
entity.setFinalizedAt(new Date());
|
// if (this.status == (int) DescriptionEntity.Status.FINALISED.getValue())
|
||||||
DMP dmp = new DMP();
|
// entity.setFinalizedAt(new Date());
|
||||||
dmp.setId(this.dmp.getId());
|
// DMP dmp = new DMP();
|
||||||
entity.setDmp(dmp);
|
// dmp.setId(this.dmp.getId());
|
||||||
entity.setDmpSectionIndex(this.dmpSectionIndex);
|
// entity.setDmp(dmp);
|
||||||
entity.setDescription(this.description);
|
// entity.setDmpSectionIndex(this.dmpSectionIndex);
|
||||||
entity.setCreated(this.created != null ? this.created : new Date());
|
// entity.setDescription(this.description);
|
||||||
entity.setModified(new Date());
|
// entity.setCreated(this.created != null ? this.created : new Date());
|
||||||
DescriptionTemplateEntity profile = new DescriptionTemplateEntity();
|
// entity.setModified(new Date());
|
||||||
profile.setId(this.profile.getId());
|
// DescriptionTemplateEntity profile = new DescriptionTemplateEntity();
|
||||||
entity.setProfile(profile);
|
// profile.setId(this.profile.getId());
|
||||||
if (this.registries != null && !this.registries.isEmpty()) {
|
// entity.setProfile(profile);
|
||||||
entity.setRegistries(new HashSet<>());
|
// if (this.registries != null && !this.registries.isEmpty()) {
|
||||||
for (Registry registry : this.registries) {
|
// entity.setRegistries(new HashSet<>());
|
||||||
entity.getRegistries().add(registry.toDataModel());
|
// for (Registry registry : this.registries) {
|
||||||
}
|
// entity.getRegistries().add(registry.toDataModel());
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
if (this.dataRepositories != null && !this.dataRepositories.isEmpty()) {
|
//
|
||||||
entity.setDatasetDataRepositories(new HashSet<>());
|
// if (this.dataRepositories != null && !this.dataRepositories.isEmpty()) {
|
||||||
for (DataRepository dataRepositoryModel : this.dataRepositories) {
|
// entity.setDatasetDataRepositories(new HashSet<>());
|
||||||
eu.eudat.data.old.DataRepository dataRepository = dataRepositoryModel.toDataModel();
|
// for (DataRepository dataRepositoryModel : this.dataRepositories) {
|
||||||
DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
// eu.eudat.data.old.DataRepository dataRepository = dataRepositoryModel.toDataModel();
|
||||||
datasetDataRepository.setDataRepository(dataRepository);
|
// DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
||||||
Map<String, Map<String, String>> data = new HashMap<>();
|
// datasetDataRepository.setDataRepository(dataRepository);
|
||||||
Map<String, String> values = new HashMap<>();
|
// Map<String, Map<String, String>> data = new HashMap<>();
|
||||||
values.put("info", dataRepositoryModel.getInfo());
|
// Map<String, String> values = new HashMap<>();
|
||||||
data.put("data", values);
|
// values.put("info", dataRepositoryModel.getInfo());
|
||||||
datasetDataRepository.setData(JSONValue.toJSONString(data));
|
// data.put("data", values);
|
||||||
entity.getDatasetDataRepositories().add(datasetDataRepository);
|
// datasetDataRepository.setData(JSONValue.toJSONString(data));
|
||||||
}
|
// entity.getDatasetDataRepositories().add(datasetDataRepository);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
if (this.services != null && !this.services.isEmpty()) {
|
//
|
||||||
entity.setServices(new HashSet<>());
|
// if (this.services != null && !this.services.isEmpty()) {
|
||||||
for (Service serviceModel : this.services) {
|
// entity.setServices(new HashSet<>());
|
||||||
eu.eudat.data.old.Service service = serviceModel.toDataModel();
|
// for (Service serviceModel : this.services) {
|
||||||
DatasetService datasetService = new DatasetService();
|
// eu.eudat.data.old.Service service = serviceModel.toDataModel();
|
||||||
datasetService.setService(service);
|
// DatasetService datasetService = new DatasetService();
|
||||||
entity.getServices().add(datasetService);
|
// datasetService.setService(service);
|
||||||
}
|
// entity.getServices().add(datasetService);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
if (this.externalDatasets != null && !this.externalDatasets.isEmpty()) {
|
//
|
||||||
entity.setDatasetExternalDatasets(new HashSet<>());
|
// if (this.externalDatasets != null && !this.externalDatasets.isEmpty()) {
|
||||||
for (ExternalDatasetListingModel externalDataset : this.externalDatasets) {
|
// entity.setDatasetExternalDatasets(new HashSet<>());
|
||||||
ExternalDataset externalDatasetEntity = externalDataset.toDataModel();
|
// for (ExternalDatasetListingModel externalDataset : this.externalDatasets) {
|
||||||
DatasetExternalDataset datasetExternalDataset = new DatasetExternalDataset();
|
// ExternalDataset externalDatasetEntity = externalDataset.toDataModel();
|
||||||
datasetExternalDataset.setExternalDataset(externalDatasetEntity);
|
// DatasetExternalDataset datasetExternalDataset = new DatasetExternalDataset();
|
||||||
Map<String,Map<String,String>> data = new HashMap<>();
|
// datasetExternalDataset.setExternalDataset(externalDatasetEntity);
|
||||||
Map<String,String> values = new HashMap<>();
|
// Map<String,Map<String,String>> data = new HashMap<>();
|
||||||
values.put("info",externalDataset.getInfo());
|
// Map<String,String> values = new HashMap<>();
|
||||||
values.put("type",externalDataset.getType().toString());
|
// values.put("info",externalDataset.getInfo());
|
||||||
data.put("data",values);
|
// values.put("type",externalDataset.getType().toString());
|
||||||
datasetExternalDataset.setData(JSONValue.toJSONString(data));
|
// data.put("data",values);
|
||||||
entity.getDatasetExternalDatasets().add(datasetExternalDataset);
|
// datasetExternalDataset.setData(JSONValue.toJSONString(data));
|
||||||
}
|
// entity.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@ package eu.eudat.models.data.dmp;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DmpBlueprintEntity;
|
import eu.eudat.data.DmpBlueprintEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
@ -283,11 +286,11 @@ public class DataManagementPlan implements DataModel<DMP, DataManagementPlan> {
|
||||||
if (entity.getDataset() != null) {
|
if (entity.getDataset() != null) {
|
||||||
if (entity.isPublic()) {
|
if (entity.isPublic()) {
|
||||||
this.datasets = entity.getDataset().stream()
|
this.datasets = entity.getDataset().stream()
|
||||||
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()) && !dataset.getStatus().equals(Dataset.Status.SAVED.getValue()))
|
.filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled) && !dataset.getStatus().equals(DescriptionStatus.Saved))
|
||||||
.map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
.map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
this.datasets = entity.getDataset().stream()
|
this.datasets = entity.getDataset().stream()
|
||||||
.filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()))
|
.filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Saved))
|
||||||
.map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
.map(x -> new DatasetWizardModel().fromDataModelNoDmp(x)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package eu.eudat.models.data.dmp;
|
package eu.eudat.models.data.dmp;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.dataset.Dataset;
|
import eu.eudat.models.data.dataset.Dataset;
|
||||||
|
@ -176,14 +177,14 @@ public class DataManagementPlanNewVersionModel implements DataModel<DMP, DataMan
|
||||||
entity.setCreated(new Date());
|
entity.setCreated(new Date());
|
||||||
entity.setLabel(this.label);
|
entity.setLabel(this.label);
|
||||||
entity.setModified(new Date());
|
entity.setModified(new Date());
|
||||||
List<eu.eudat.data.old.Dataset> datasets = new LinkedList<>();
|
List<DescriptionEntity> descriptionEntities = new LinkedList<>();
|
||||||
if (this.datasets != null) {
|
if (this.datasets != null) {
|
||||||
for (Dataset dataset : this.datasets) {
|
for (Dataset dataset : this.datasets) {
|
||||||
eu.eudat.data.old.Dataset entityDataset = new eu.eudat.data.old.Dataset();
|
DescriptionEntity entityDescriptionEntity = new DescriptionEntity();
|
||||||
entityDataset.setId(dataset.getId());
|
entityDescriptionEntity.setId(dataset.getId());
|
||||||
datasets.add(entityDataset);
|
descriptionEntities.add(entityDescriptionEntity);
|
||||||
}
|
}
|
||||||
entity.setDataset(new HashSet<>(datasets));
|
entity.setDataset(new HashSet<>(descriptionEntities));
|
||||||
}
|
}
|
||||||
if (this.organisations != null && !this.organisations.isEmpty())
|
if (this.organisations != null && !this.organisations.isEmpty())
|
||||||
entity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
entity.setOrganisations(new HashSet<>(this.organisations.stream().map(item -> item.toDataModel()).collect(Collectors.toList())));
|
||||||
|
|
|
@ -2,9 +2,11 @@ package eu.eudat.models.data.listingmodels;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.DMPDatasetProfile;
|
import eu.eudat.data.old.DMPDatasetProfile;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
import eu.eudat.models.data.dataset.DatasetOverviewModel;
|
||||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||||
|
@ -195,7 +197,7 @@ public class DataManagementPlanOverviewModel implements DataModel<DMP, DataManag
|
||||||
this.modifiedTime = entity.getModified();
|
this.modifiedTime = entity.getModified();
|
||||||
this.finalizedAt = entity.getFinalizedAt();
|
this.finalizedAt = entity.getFinalizedAt();
|
||||||
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
this.organisations = entity.getOrganisations().stream().map(item -> new Organisation().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue())).map(x-> new DatasetOverviewModel().fromDataModel(x)).collect(Collectors.toList());
|
this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled)).map(x-> new DatasetOverviewModel().fromDataModel(x)).collect(Collectors.toList());
|
||||||
this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
this.users = entity.getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList());
|
||||||
this.description = entity.getDescription();
|
this.description = entity.getDescription();
|
||||||
if (entity.getResearchers() != null) {
|
if (entity.getResearchers() != null) {
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package eu.eudat.models.data.listingmodels;
|
package eu.eudat.models.data.listingmodels;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -13,19 +15,19 @@ import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
public class DatasetListingModel implements DataModel<Dataset, DatasetListingModel> {
|
public class DatasetListingModel implements DataModel<DescriptionEntity, DatasetListingModel> {
|
||||||
private String id;
|
private String id;
|
||||||
private String label;
|
private String label;
|
||||||
private String grant;
|
private String grant;
|
||||||
private String dmp;
|
private String dmp;
|
||||||
private String dmpId;
|
private String dmpId;
|
||||||
private DatasetProfileOverviewModel profile;
|
private DatasetProfileOverviewModel profile;
|
||||||
private int status;
|
private DescriptionStatus status;
|
||||||
private Date created;
|
private Instant created;
|
||||||
private Date modified;
|
private Instant modified;
|
||||||
private String description;
|
private String description;
|
||||||
private Date finalizedAt;
|
private Instant finalizedAt;
|
||||||
private Date dmpPublishedAt;
|
private Instant dmpPublishedAt;
|
||||||
private int version;
|
private int version;
|
||||||
private List<UserInfoListingModel> users;
|
private List<UserInfoListingModel> users;
|
||||||
private Boolean isPublic;
|
private Boolean isPublic;
|
||||||
|
@ -73,24 +75,24 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
|
||||||
this.profile = profile;
|
this.profile = profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStatus() {
|
public DescriptionStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
public void setStatus(int status) {
|
public void setStatus(DescriptionStatus status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getCreated() {
|
public Instant getCreated() {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
public void setCreated(Date created) {
|
public void setCreated(Instant created) {
|
||||||
this.created = created;
|
this.created = created;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getModified() {
|
public Instant getModified() {
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
public void setModified(Date modified) {
|
public void setModified(Instant modified) {
|
||||||
this.modified = modified;
|
this.modified = modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,17 +103,17 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getFinalizedAt() {
|
public Instant getFinalizedAt() {
|
||||||
return finalizedAt;
|
return finalizedAt;
|
||||||
}
|
}
|
||||||
public void setFinalizedAt(Date finalizedAt) {
|
public void setFinalizedAt(Instant finalizedAt) {
|
||||||
this.finalizedAt = finalizedAt;
|
this.finalizedAt = finalizedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getDmpPublishedAt() {
|
public Instant getDmpPublishedAt() {
|
||||||
return dmpPublishedAt;
|
return dmpPublishedAt;
|
||||||
}
|
}
|
||||||
public void setDmpPublishedAt(Date dmpPublishedAt) {
|
public void setDmpPublishedAt(Instant dmpPublishedAt) {
|
||||||
this.dmpPublishedAt = dmpPublishedAt;
|
this.dmpPublishedAt = dmpPublishedAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,54 +141,56 @@ public class DatasetListingModel implements DataModel<Dataset, DatasetListingMod
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasetListingModel fromDataModel(Dataset entity) {
|
public DatasetListingModel fromDataModel(DescriptionEntity entity) {
|
||||||
this.id = entity.getId() != null ? entity.getId().toString() : "";
|
//TODO Implement it on transfer
|
||||||
this.label = entity.getLabel();
|
// this.id = entity.getId() != null ? entity.getId().toString() : "";
|
||||||
this.created = entity.getCreated();
|
// this.label = entity.getLabel();
|
||||||
this.modified = entity.getModified();
|
// this.created = entity.getCreatedAt();
|
||||||
this.grant = (entity.getDmp() != null && entity.getDmp().getGrant() != null) ? entity.getDmp().getGrant().getLabel() : "";
|
// this.modified = entity.getUpdatedAt();
|
||||||
this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
|
// this.grant = (entity.getDmp() != null && entity.getDmp().getGrant() != null) ? entity.getDmp().getGrant().getLabel() : "";
|
||||||
this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
|
// this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
|
||||||
this.profile = entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()) : null;
|
// this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
|
||||||
this.description = entity.getDescription();
|
// this.profile = entity.getProfile() != null ? new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()) : null;
|
||||||
this.status = entity.getStatus();
|
// this.description = entity.getDescription();
|
||||||
if (entity.getFinalizedAt() == null && entity.getStatus() == Dataset.Status.FINALISED.getValue()) {
|
// this.status = entity.getStatus();
|
||||||
this.finalizedAt = entity.getDmp().getFinalizedAt();
|
// if (entity.getFinalizedAt() == null && entity.getStatus() == DescriptionStatus.Finalized) {
|
||||||
} else {
|
// this.finalizedAt = entity.getDmp().getFinalizedAt();
|
||||||
this.finalizedAt = entity.getFinalizedAt();
|
// } else {
|
||||||
}
|
// this.finalizedAt = entity.getFinalizedAt();
|
||||||
this.dmpPublishedAt = entity.getDmp().getPublishedAt();
|
// }
|
||||||
this.version = entity.getDmp().getVersion();
|
// this.dmpPublishedAt = entity.getDmp().getPublishedAt();
|
||||||
this.users = entity.getDmp() != null ? entity.getDmp().getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.version = entity.getDmp().getVersion();
|
||||||
this.isPublic = entity.getDmp() != null ? entity.getDmp().isPublic() : false;
|
// this.users = entity.getDmp() != null ? entity.getDmp().getUsers().stream().map(x -> new UserInfoListingModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
|
// this.isPublic = entity.getDmp() != null ? entity.getDmp().isPublic() : false;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset toDataModel() {
|
public DescriptionEntity toDataModel() {
|
||||||
Dataset entity = new Dataset();
|
//TODO Implement it on transfer
|
||||||
entity.setId(UUID.fromString(this.getId()));
|
DescriptionEntity entity = new DescriptionEntity();
|
||||||
entity.setLabel(this.getLabel());
|
// entity.setId(UUID.fromString(this.getId()));
|
||||||
entity.setCreated(this.getCreated());
|
// entity.setLabel(this.getLabel());
|
||||||
entity.setModified(this.getModified());
|
// entity.setCreatedAt(this.getCreated());
|
||||||
entity.setDescription(this.getDescription());
|
// entity.setUpdatedAt(this.getModified());
|
||||||
entity.setFinalizedAt(this.getFinalizedAt());
|
// entity.setDescription(this.getDescription());
|
||||||
entity.setStatus(Integer.valueOf(this.getStatus()).shortValue());
|
// entity.setFinalizedAt(this.getFinalizedAt());
|
||||||
DMP dmp = new DMP();
|
// entity.setStatus(this.getStatus());
|
||||||
if (this.getGrant() != null && !this.getGrant().isEmpty()) {
|
// DMP dmp = new DMP();
|
||||||
Grant grant = new Grant();
|
// if (this.getGrant() != null && !this.getGrant().isEmpty()) {
|
||||||
grant.setLabel(this.getGrant());
|
// Grant grant = new Grant();
|
||||||
dmp.setGrant(grant);
|
// grant.setLabel(this.getGrant());
|
||||||
}
|
// dmp.setGrant(grant);
|
||||||
dmp.setLabel(this.getDmp());
|
// }
|
||||||
dmp.setId(UUID.fromString(this.getDmpId()));
|
// dmp.setLabel(this.getDmp());
|
||||||
dmp.setPublishedAt(this.getDmpPublishedAt());
|
// dmp.setId(UUID.fromString(this.getDmpId()));
|
||||||
dmp.setVersion(this.getVersion());
|
// dmp.setPublishedAt(this.getDmpPublishedAt());
|
||||||
dmp.setUsers(this.getUsers().stream().map(UserInfoListingModel::toDataModel).collect(Collectors.toSet()));
|
// dmp.setVersion(this.getVersion());
|
||||||
dmp.setPublic(this.getPublic());
|
// dmp.setUsers(this.getUsers().stream().map(UserInfoListingModel::toDataModel).collect(Collectors.toSet()));
|
||||||
dmp.setFinalizedAt(this.getFinalizedAt());
|
// dmp.setPublic(this.getPublic());
|
||||||
entity.setDmp(dmp);
|
// dmp.setFinalizedAt(this.getFinalizedAt());
|
||||||
entity.setProfile(this.getProfile() != null ? this.getProfile().toDataModel() : null);
|
// entity.setDmp(dmp);
|
||||||
|
// entity.setProfile(this.getProfile() != null ? this.getProfile().toDataModel() : null);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
package eu.eudat.models.data.quickwizard;
|
package eu.eudat.models.data.quickwizard;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
import eu.eudat.models.data.datasetprofile.DatasetProfileOverviewModel;
|
||||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||||
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
import eu.eudat.models.data.datasetwizard.DatasetWizardModel;
|
||||||
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
||||||
|
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class DatasetDescriptionQuickWizardModel extends PagedDatasetProfile {
|
public class DatasetDescriptionQuickWizardModel extends PagedDatasetProfile {
|
||||||
|
@ -25,10 +27,10 @@ public class DatasetDescriptionQuickWizardModel extends PagedDatasetProfile {
|
||||||
public DatasetWizardModel toDataModel(DataManagementPlan dmp, DescriptionTemplateEntity profile){
|
public DatasetWizardModel toDataModel(DataManagementPlan dmp, DescriptionTemplateEntity profile){
|
||||||
DatasetWizardModel newDataset = new DatasetWizardModel();
|
DatasetWizardModel newDataset = new DatasetWizardModel();
|
||||||
newDataset.setLabel(datasetLabel);
|
newDataset.setLabel(datasetLabel);
|
||||||
newDataset.setCreated(new Date());
|
newDataset.setCreated(Instant.now());
|
||||||
newDataset.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
newDataset.setProfile(new DatasetProfileOverviewModel().fromDataModel(profile));
|
||||||
newDataset.setDmp(dmp);
|
newDataset.setDmp(dmp);
|
||||||
newDataset.setStatus((short) this.getStatus());
|
newDataset.setStatus(DescriptionStatus.of((short)this.getStatus()));
|
||||||
//newDataset.setStatus(Dataset.Status.SAVED.getValue());
|
//newDataset.setStatus(Dataset.Status.SAVED.getValue());
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
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 com.jayway.jsonpath.JsonPath;
|
import com.jayway.jsonpath.JsonPath;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
|
@ -150,23 +150,23 @@ public class DatasetRDAExportModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DatasetRDAExportModel fromDataModel(Dataset dataset, DatasetManager datasetManager) {
|
public DatasetRDAExportModel fromDataModel(DescriptionEntity descriptionEntity, DatasetManager datasetManager) {
|
||||||
// Map of template Ids to rda values.
|
// Map of template Ids to rda values.
|
||||||
JSONObject jObject = new JSONObject(dataset.getProperties());
|
JSONObject jObject = new JSONObject(descriptionEntity.getProperties());
|
||||||
Map<String, Object> templateIdsToValues = jObject.toMap();
|
Map<String, Object> templateIdsToValues = jObject.toMap();
|
||||||
|
|
||||||
/*--------- Building dataset rda export model ---------*/
|
/*--------- Building dataset rda export model ---------*/
|
||||||
DatasetRDAExportModel datasetRDAExportModel = new DatasetRDAExportModel();
|
DatasetRDAExportModel datasetRDAExportModel = new DatasetRDAExportModel();
|
||||||
datasetRDAExportModel.setDataset_id(new IdRDAExportModel(dataset.getId().toString(), "other"));
|
datasetRDAExportModel.setDataset_id(new IdRDAExportModel(descriptionEntity.getId().toString(), "other"));
|
||||||
if (dataset.getDescription() != null) datasetRDAExportModel.setDescription(dataset.getDescription().replace("\n", " "));
|
if (descriptionEntity.getDescription() != null) datasetRDAExportModel.setDescription(descriptionEntity.getDescription().replace("\n", " "));
|
||||||
datasetRDAExportModel.setIssued(DateFormat.getDateInstance(DateFormat.SHORT).format(dataset.getCreated()));
|
datasetRDAExportModel.setIssued(DateFormat.getDateInstance(DateFormat.SHORT).format(descriptionEntity.getCreatedAt()));
|
||||||
datasetRDAExportModel.setLanguage("en"); // mock data
|
datasetRDAExportModel.setLanguage("en"); // mock data
|
||||||
datasetRDAExportModel.setTitle(dataset.getLabel());
|
datasetRDAExportModel.setTitle(descriptionEntity.getLabel());
|
||||||
|
|
||||||
// Transform the answered dataset description to json so we can parse it and fill the rda model.
|
// Transform the answered dataset description to json so we can parse it and fill the rda model.
|
||||||
JSONObject datasetDescriptionJson = null;
|
JSONObject datasetDescriptionJson = null;
|
||||||
try {
|
try {
|
||||||
String jsonResult = mapper.writeValueAsString(datasetManager.getSingle(dataset.getId().toString()).getDatasetProfileDefinition());
|
String jsonResult = mapper.writeValueAsString(datasetManager.getSingle(descriptionEntity.getId().toString()).getDatasetProfileDefinition());
|
||||||
datasetDescriptionJson = new JSONObject(jsonResult);
|
datasetDescriptionJson = new JSONObject(jsonResult);
|
||||||
} catch (JsonProcessingException | InvalidApplicationException e) {
|
} catch (JsonProcessingException | InvalidApplicationException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
@ -192,26 +192,27 @@ public class DatasetRDAExportModel {
|
||||||
datasetRDAExportModel.setSensitive_data("unknown");
|
datasetRDAExportModel.setSensitive_data("unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO
|
||||||
/*--------- Building type. ---------*/
|
/*--------- Building type. ---------*/
|
||||||
datasetRDAExportModel.setType(buildSingleProperties("dataset.type", datasetDescriptionJson, templateIdsToValues));
|
// datasetRDAExportModel.setType(buildSingleProperties("dataset.type", datasetDescriptionJson, templateIdsToValues));
|
||||||
|
//
|
||||||
/*--------- Building data_quality_assurance. ---------*/
|
// /*--------- Building data_quality_assurance. ---------*/
|
||||||
datasetRDAExportModel.setData_quality_assurance(buildDataQualityAssurance(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
// datasetRDAExportModel.setData_quality_assurance(buildDataQualityAssurance(datasetDescriptionJson, templateIdsToValues, descriptionEntity.getProfile().getDefinition()));
|
||||||
|
//
|
||||||
/*--------- Building distribution. ---------*/
|
// /*--------- Building distribution. ---------*/
|
||||||
datasetRDAExportModel.setDistribution(buildDistribution(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
// datasetRDAExportModel.setDistribution(buildDistribution(datasetDescriptionJson, templateIdsToValues, descriptionEntity.getProfile().getDefinition()));
|
||||||
|
//
|
||||||
/*--------- Building keywords. ---------*/
|
// /*--------- Building keywords. ---------*/
|
||||||
datasetRDAExportModel.setKeyword(buildKeywords(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
// datasetRDAExportModel.setKeyword(buildKeywords(datasetDescriptionJson, templateIdsToValues, descriptionEntity.getProfile().getDefinition()));
|
||||||
|
//
|
||||||
/*--------- Building metadata items. ---------*/
|
// /*--------- Building metadata items. ---------*/
|
||||||
datasetRDAExportModel.setMetadata(buildMetadata(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
// datasetRDAExportModel.setMetadata(buildMetadata(datasetDescriptionJson, templateIdsToValues, descriptionEntity.getProfile().getDefinition()));
|
||||||
|
//
|
||||||
/*--------- Building security and privacy items. ---------*/
|
// /*--------- Building security and privacy items. ---------*/
|
||||||
datasetRDAExportModel.setSecurity_and_privacy(buildSecurityAndPrivacy(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
// datasetRDAExportModel.setSecurity_and_privacy(buildSecurityAndPrivacy(datasetDescriptionJson, templateIdsToValues, descriptionEntity.getProfile().getDefinition()));
|
||||||
|
//
|
||||||
/*--------- Building technical_resource. ---------*/
|
// /*--------- Building technical_resource. ---------*/
|
||||||
datasetRDAExportModel.setTechnical_resource(buildTechnicalResource(datasetDescriptionJson, templateIdsToValues, dataset.getProfile().getDefinition()));
|
// datasetRDAExportModel.setTechnical_resource(buildTechnicalResource(datasetDescriptionJson, templateIdsToValues, descriptionEntity.getProfile().getDefinition()));
|
||||||
|
|
||||||
return datasetRDAExportModel;
|
return datasetRDAExportModel;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package eu.eudat.models.data.rda;
|
package eu.eudat.models.data.rda;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.data.EntityDoiEntity;
|
import eu.eudat.data.EntityDoiEntity;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.UserDMP;
|
import eu.eudat.data.old.UserDMP;
|
||||||
import eu.eudat.logic.managers.DatasetManager;
|
import eu.eudat.logic.managers.DatasetManager;
|
||||||
|
|
||||||
|
@ -139,9 +141,9 @@ public class DmpRDAExportModel {
|
||||||
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
|
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
|
||||||
dmpRda.created = formatter.format(entity.getCreated());
|
dmpRda.created = formatter.format(entity.getCreated());
|
||||||
dmpRda.dataset = new LinkedList<>();
|
dmpRda.dataset = new LinkedList<>();
|
||||||
for (Dataset dataset : entity.getDataset()) {
|
for (DescriptionEntity descriptionEntity : entity.getDataset()) {
|
||||||
if (dataset.getStatus() != Dataset.Status.DELETED.getValue() && dataset.getStatus() != Dataset.Status.CANCELED.getValue())
|
if (descriptionEntity.getIsActive() != IsActive.Inactive && descriptionEntity.getStatus() != DescriptionStatus.Canceled)
|
||||||
dmpRda.dataset.add(new DatasetRDAExportModel().fromDataModel(dataset, datasetManager));
|
dmpRda.dataset.add(new DatasetRDAExportModel().fromDataModel(descriptionEntity, datasetManager));
|
||||||
}
|
}
|
||||||
dmpRda.description = entity.getDescription().replace("\n", " ");
|
dmpRda.description = entity.getDescription().replace("\n", " ");
|
||||||
if (entity.getDois() != null && !entity.getDois().isEmpty()) {
|
if (entity.getDois() != null && !entity.getDois().isEmpty()) {
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
package eu.eudat.models.data.urls;
|
package eu.eudat.models.data.urls;
|
||||||
|
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 7/23/2018.
|
* Created by ikalyvas on 7/23/2018.
|
||||||
*/
|
*/
|
||||||
public class DatasetUrlListing extends UrlListing<Dataset, DatasetUrlListing> {
|
public class DatasetUrlListing extends UrlListing<DescriptionEntity, DatasetUrlListing> {
|
||||||
@Override
|
@Override
|
||||||
public DatasetUrlListing fromDataModel(Dataset entity) {
|
public DatasetUrlListing fromDataModel(DescriptionEntity entity) {
|
||||||
this.setLabel(entity.getLabel());
|
this.setLabel(entity.getLabel());
|
||||||
this.setUrl(entity.getId().toString());
|
this.setUrl(entity.getId().toString());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset toDataModel() {
|
public DescriptionEntity toDataModel() {
|
||||||
Dataset entity = new Dataset();
|
DescriptionEntity entity = new DescriptionEntity();
|
||||||
entity.setId(UUID.fromString(this.getUrl()));
|
entity.setId(UUID.fromString(this.getUrl()));
|
||||||
entity.setLabel(this.getLabel());
|
entity.setLabel(this.getLabel());
|
||||||
return entity;
|
return entity;
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eu.eudat.models.rda.mapper;
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.elastic.criteria.DatasetCriteria;
|
import eu.eudat.elastic.criteria.DatasetCriteria;
|
||||||
import eu.eudat.elastic.entities.Tag;
|
import eu.eudat.elastic.entities.Tag;
|
||||||
|
@ -43,20 +44,20 @@ public class DatasetRDAMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Dataset toRDA(eu.eudat.data.old.Dataset dataset, eu.eudat.models.rda.Dmp dmp) {
|
public Dataset toRDA(DescriptionEntity descriptionEntity, eu.eudat.models.rda.Dmp dmp) {
|
||||||
Dataset rda = new Dataset();
|
Dataset rda = new Dataset();
|
||||||
// rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId()));
|
// rda.setDatasetId(DatasetIdRDAMapper.toRDA(dataset.getId()));
|
||||||
if (dataset.getLabel() == null) {
|
if (descriptionEntity.getLabel() == null) {
|
||||||
throw new IllegalArgumentException("Dataset Label is missing");
|
throw new IllegalArgumentException("Dataset Label is missing");
|
||||||
}
|
}
|
||||||
rda.setTitle(dataset.getLabel());
|
rda.setTitle(descriptionEntity.getLabel());
|
||||||
rda.setDescription(dataset.getDescription());
|
rda.setDescription(descriptionEntity.getDescription());
|
||||||
rda.setAdditionalProperty("template", dataset.getProfile().getId());
|
rda.setAdditionalProperty("template", descriptionEntity.getProfile());
|
||||||
try {
|
try {
|
||||||
JSONObject jObject = new JSONObject(dataset.getProperties());
|
JSONObject jObject = new JSONObject(descriptionEntity.getProperties());
|
||||||
Map<String, Object> templateIdsToValues = jObject.toMap();
|
Map<String, Object> templateIdsToValues = jObject.toMap();
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(dataset);
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel().fromDataModel(descriptionEntity);
|
||||||
datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, dataset));
|
datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, descriptionEntity));
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition());
|
String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition());
|
||||||
JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson);
|
JsonNode datasetDescriptionObj = mapper.readTree(datasetDescriptionJson);
|
||||||
|
@ -65,7 +66,7 @@ public class DatasetRDAMapper {
|
||||||
rda.setDatasetId(DatasetIdRDAMapper.toRDA(idNodes));
|
rda.setDatasetId(DatasetIdRDAMapper.toRDA(idNodes));
|
||||||
}
|
}
|
||||||
if (rda.getDatasetId() == null) {
|
if (rda.getDatasetId() == null) {
|
||||||
rda.setDatasetId(new DatasetId(dataset.getId().toString(), DatasetId.Type.OTHER));
|
rda.setDatasetId(new DatasetId(descriptionEntity.getId().toString(), DatasetId.Type.OTHER));
|
||||||
}
|
}
|
||||||
List<JsonNode> typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.type");
|
List<JsonNode> typeNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.type");
|
||||||
if (!typeNodes.isEmpty() && !typeNodes.get(0).get("value").asText().isEmpty()) {
|
if (!typeNodes.isEmpty() && !typeNodes.get(0).get("value").asText().isEmpty()) {
|
||||||
|
@ -80,11 +81,13 @@ public class DatasetRDAMapper {
|
||||||
rda.setLanguage(Language.fromValue(lang));
|
rda.setLanguage(Language.fromValue(lang));
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e){
|
catch (IllegalArgumentException e){
|
||||||
logger.warn("Language " + lang + " from semantic rda.dataset.language was not found. Setting '" + dataset.getProfile().getLanguage() +"' as language from the dataset profile.");
|
//TODO
|
||||||
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(dataset.getProfile().getLanguage()));
|
// logger.warn("Language " + lang + " from semantic rda.dataset.language was not found. Setting '" + descriptionEntity.getProfile().getLanguage() +"' as language from the dataset profile.");
|
||||||
|
// rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(descriptionEntity.getProfile().getLanguage()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(dataset.getProfile().getLanguage()));
|
//TODO
|
||||||
|
// rda.setLanguage(LanguageRDAMapper.mapLanguageIsoToRDAIso(descriptionEntity.getProfile().getLanguage()));
|
||||||
}
|
}
|
||||||
List<JsonNode> metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.metadata");
|
List<JsonNode> metadataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.metadata");
|
||||||
if (!metadataNodes.isEmpty()) {
|
if (!metadataNodes.isEmpty()) {
|
||||||
|
@ -147,7 +150,7 @@ public class DatasetRDAMapper {
|
||||||
rda.setAdditionalProperty("keyword" + (i + 1), keywordNodes.get(i).get("id").asText());
|
rda.setAdditionalProperty("keyword" + (i + 1), keywordNodes.get(i).get("id").asText());
|
||||||
}
|
}
|
||||||
} else if (apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().exists()) {
|
} else if (apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().exists()) {
|
||||||
List<String> tags = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(dataset.getId().toString()).getTags().stream().map(Tag::getName).collect(Collectors.toList());
|
List<String> tags = apiContext.getOperationsContext().getElasticRepository().getDatasetRepository().findDocument(descriptionEntity.getId().toString()).getTags().stream().map(Tag::getName).collect(Collectors.toList());
|
||||||
rda.setKeyword(tags);
|
rda.setKeyword(tags);
|
||||||
}
|
}
|
||||||
List<JsonNode> personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.personal_data");
|
List<JsonNode> personalDataNodes = JsonSearcher.findNodes(datasetDescriptionObj, "schematics", "rda.dataset.personal_data");
|
||||||
|
@ -280,21 +283,22 @@ public class DatasetRDAMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public eu.eudat.data.old.Dataset toEntity(Dataset rda, DescriptionTemplateEntity defaultProfile) {
|
public DescriptionEntity toEntity(Dataset rda, DescriptionTemplateEntity defaultProfile) {
|
||||||
eu.eudat.data.old.Dataset entity = new eu.eudat.data.old.Dataset();
|
DescriptionEntity entity = new DescriptionEntity();
|
||||||
entity.setLabel(rda.getTitle());
|
entity.setLabel(rda.getTitle());
|
||||||
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);
|
entity.setProfile(profile.getId());
|
||||||
}catch(Exception e) {
|
}catch(Exception e) {
|
||||||
logger.warn(e.getMessage(), e);
|
logger.warn(e.getMessage(), e);
|
||||||
entity.setProfile(defaultProfile);
|
entity.setProfile(defaultProfile.getId());
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Map<String, Object> properties = new HashMap<>();
|
Map<String, Object> properties = new HashMap<>();
|
||||||
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
DatasetWizardModel datasetWizardModel = new DatasetWizardModel();
|
||||||
datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()));
|
//TODO
|
||||||
|
//datasetWizardModel.setProfile(new DatasetProfileOverviewModel().fromDataModel(entity.getProfile()));
|
||||||
datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, entity));
|
datasetWizardModel.setDatasetProfileDefinition(datasetManager.getPagedProfile(datasetWizardModel, entity));
|
||||||
ObjectMapper mapper = new ObjectMapper();
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition());
|
String datasetDescriptionJson = mapper.writeValueAsString(datasetWizardModel.getDatasetProfileDefinition());
|
||||||
|
|
|
@ -123,7 +123,7 @@ public class DmpRDAMapper {
|
||||||
rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
rda.getContributor().addAll(dmp.getResearchers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
// rda.getContributor().addAll(dmp.getUsers().stream().map(ContributorRDAMapper::toRDA).collect(Collectors.toList()));
|
||||||
rda.setDataset(dmp.getDataset().stream().filter(dataset -> dataset.getStatus() != eu.eudat.elastic.entities.Dmp.DMPStatus.DELETED.getValue()).map(dataset -> datasetRDAMapper.toRDA(dataset, rda)).collect(Collectors.toList()));
|
rda.setDataset(dmp.getDataset().stream().filter(dataset -> dataset.getStatus().getValue() != eu.eudat.elastic.entities.Dmp.DMPStatus.DELETED.getValue()).map(dataset -> datasetRDAMapper.toRDA(dataset, rda)).collect(Collectors.toList()));
|
||||||
if (dmp.getProject() != null) {
|
if (dmp.getProject() != null) {
|
||||||
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
|
rda.setProject(Collections.singletonList(ProjectRDAMapper.toRDA(dmp.getProject(), dmp.getGrant())));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.publicapi.criteria.dataset;
|
package eu.eudat.publicapi.criteria.dataset;
|
||||||
|
|
||||||
import eu.eudat.data.dao.criteria.Criteria;
|
import eu.eudat.data.dao.criteria.Criteria;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.elastic.entities.Tag;
|
import eu.eudat.elastic.entities.Tag;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
public class DatasetPublicCriteria extends Criteria<Dataset> {
|
public class DatasetPublicCriteria extends Criteria<DescriptionEntity> {
|
||||||
@ApiModelProperty(value = "periodStart", name = "periodStart", dataType = "Date", example = "2022-01-01T13:19:42.210Z")
|
@ApiModelProperty(value = "periodStart", name = "periodStart", dataType = "Date", example = "2022-01-01T13:19:42.210Z")
|
||||||
private Date periodStart;
|
private Date periodStart;
|
||||||
@ApiModelProperty(value = "periodEnd", name = "periodEnd", dataType = "Date", example = "2022-12-31T13:19:42.210Z")
|
@ApiModelProperty(value = "periodEnd", name = "periodEnd", dataType = "Date", example = "2022-12-31T13:19:42.210Z")
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
package eu.eudat.publicapi.managers;
|
package eu.eudat.publicapi.managers;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.query.definition.helpers.ColumnOrderings;
|
import eu.eudat.data.query.definition.helpers.ColumnOrderings;
|
||||||
import eu.eudat.elastic.criteria.DatasetCriteria;
|
import eu.eudat.elastic.criteria.DatasetCriteria;
|
||||||
|
@ -61,7 +63,7 @@ public class DatasetPublicManager {
|
||||||
}
|
}
|
||||||
datasetCriteria.setGroupIds(datasetTableRequest.getCriteria().getGroupIds());
|
datasetCriteria.setGroupIds(datasetTableRequest.getCriteria().getGroupIds());
|
||||||
datasetCriteria.setGrantStatus(GrantStateType.ONGOING.getValue().shortValue()); // grant status ongoing
|
datasetCriteria.setGrantStatus(GrantStateType.ONGOING.getValue().shortValue()); // grant status ongoing
|
||||||
datasetCriteria.setStatus(Dataset.Status.FINALISED.getValue()); // dataset status finalized
|
datasetCriteria.setStatus(DescriptionStatus.Finalized.getValue()); // dataset status finalized
|
||||||
if (datasetTableRequest.getOrderings() != null) {
|
if (datasetTableRequest.getOrderings() != null) {
|
||||||
datasetCriteria.setSortCriteria(DmpPublicCriteriaMapper.toElasticSorting(datasetTableRequest.getOrderings()));
|
datasetCriteria.setSortCriteria(DmpPublicCriteriaMapper.toElasticSorting(datasetTableRequest.getOrderings()));
|
||||||
}
|
}
|
||||||
|
@ -83,7 +85,7 @@ public class DatasetPublicManager {
|
||||||
/*datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class)));
|
/*datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class)));
|
||||||
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();*/
|
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();*/
|
||||||
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class)));
|
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class)));
|
||||||
QueryableList<Dataset> items;
|
QueryableList<DescriptionEntity> items;
|
||||||
if (datasets != null) {
|
if (datasets != null) {
|
||||||
if (!datasets.isEmpty()) {
|
if (!datasets.isEmpty()) {
|
||||||
items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class));
|
items = databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetPublicListingModel.class));
|
||||||
|
@ -108,7 +110,7 @@ public class DatasetPublicManager {
|
||||||
if (count == 0L) {
|
if (count == 0L) {
|
||||||
count = items.count();
|
count = items.count();
|
||||||
}
|
}
|
||||||
QueryableList<Dataset> pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
|
QueryableList<DescriptionEntity> pagedItems = PaginationManager.applyPaging(items, datasetTableRequest);
|
||||||
DataTableData<DatasetPublicListingModel> dataTable = new DataTableData<>();
|
DataTableData<DatasetPublicListingModel> dataTable = new DataTableData<>();
|
||||||
|
|
||||||
List<DatasetPublicListingModel> datasetLists = pagedItems.
|
List<DatasetPublicListingModel> datasetLists = pagedItems.
|
||||||
|
@ -120,22 +122,23 @@ public class DatasetPublicManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetPublicModel getOverviewSinglePublic(String id) throws Exception {
|
public DatasetPublicModel getOverviewSinglePublic(String id) throws Exception {
|
||||||
Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id));
|
DescriptionEntity descriptionEntityEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id));
|
||||||
if (datasetEntity.getStatus() == Dataset.Status.DELETED.getValue()) {
|
if (descriptionEntityEntity.getIsActive() == IsActive.Inactive) {
|
||||||
throw new Exception("Dataset is deleted.");
|
throw new Exception("Dataset is deleted.");
|
||||||
}
|
}
|
||||||
if (!datasetEntity.getDmp().isPublic()) {
|
//TODO
|
||||||
throw new ForbiddenException("Selected Dataset is not public");
|
// if (!descriptionEntityEntity.getDmp().isPublic()) {
|
||||||
}
|
// throw new ForbiddenException("Selected Dataset is not public");
|
||||||
|
// }
|
||||||
DatasetPublicModel dataset = new DatasetPublicModel();
|
DatasetPublicModel dataset = new DatasetPublicModel();
|
||||||
dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus(), datasetEntity));
|
dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus(), descriptionEntityEntity));
|
||||||
dataset.fromDataModel(datasetEntity);
|
dataset.fromDataModel(descriptionEntityEntity);
|
||||||
|
|
||||||
return dataset;
|
return dataset;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
private DatasetPublicListingModel mapPublicModel(Dataset item) {
|
private DatasetPublicListingModel mapPublicModel(DescriptionEntity item) {
|
||||||
/*if (item.getProfile() == null)
|
/*if (item.getProfile() == null)
|
||||||
return null;*/
|
return null;*/
|
||||||
DatasetPublicListingModel listingPublicModel = new DatasetPublicListingModel().fromDataModel(item);
|
DatasetPublicListingModel listingPublicModel = new DatasetPublicListingModel().fromDataModel(item);
|
||||||
|
@ -151,16 +154,17 @@ public class DatasetPublicManager {
|
||||||
return listingPublicModel;
|
return listingPublicModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PagedDatasetProfile getPagedProfile(int status, Dataset datasetEntity){
|
private PagedDatasetProfile getPagedProfile(DescriptionStatus status, DescriptionEntity descriptionEntityEntity){
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(datasetEntity.getProfile());
|
//TODO
|
||||||
datasetprofile.setStatus(status);
|
// eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(descriptionEntityEntity.getProfile());
|
||||||
if (datasetEntity.getProperties() != null) {
|
// datasetprofile.setStatus(status.getValue());
|
||||||
JSONObject jObject = new JSONObject(datasetEntity.getProperties());
|
// if (descriptionEntityEntity.getProperties() != null) {
|
||||||
Map<String, Object> properties = jObject.toMap();
|
// JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
|
||||||
datasetprofile.fromJsonObject(properties);
|
// Map<String, Object> properties = jObject.toMap();
|
||||||
}
|
// datasetprofile.fromJsonObject(properties);
|
||||||
|
// }
|
||||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||||
pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
|
// pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
|
||||||
return pagedDatasetProfile;
|
return pagedDatasetProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package eu.eudat.publicapi.models.listingmodels;
|
package eu.eudat.publicapi.models.listingmodels;
|
||||||
|
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.old.Grant;
|
import eu.eudat.data.old.Grant;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
import eu.eudat.publicapi.models.datasetprofile.DatasetProfilePublicModel;
|
import eu.eudat.publicapi.models.datasetprofile.DatasetProfilePublicModel;
|
||||||
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DatasetPublicListingModel implements DataModel<Dataset, DatasetPublicListingModel> {
|
public class DatasetPublicListingModel implements DataModel<DescriptionEntity, DatasetPublicListingModel> {
|
||||||
private String id;
|
private String id;
|
||||||
private String label;
|
private String label;
|
||||||
private String grant;
|
private String grant;
|
||||||
|
@ -121,53 +121,55 @@ public class DatasetPublicListingModel implements DataModel<Dataset, DatasetPubl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasetPublicListingModel fromDataModel(Dataset entity) {
|
public DatasetPublicListingModel fromDataModel(DescriptionEntity entity) {
|
||||||
this.id = entity.getId() != null ? entity.getId().toString() : "";
|
//TODO
|
||||||
this.label = entity.getLabel();
|
// this.id = entity.getId() != null ? entity.getId().toString() : "";
|
||||||
this.createdAt = entity.getCreated();
|
// this.label = entity.getLabel();
|
||||||
this.modifiedAt = entity.getModified();
|
// this.createdAt = entity.getCreated();
|
||||||
if(entity.getDmp() != null && entity.getDmp().getGrant() != null) {
|
// this.modifiedAt = entity.getModified();
|
||||||
this.grant = entity.getDmp().getGrant().getLabel();
|
// if(entity.getDmp() != null && entity.getDmp().getGrant() != null) {
|
||||||
}
|
// this.grant = entity.getDmp().getGrant().getLabel();
|
||||||
this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
|
// }
|
||||||
this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
|
// this.dmp = entity.getDmp() != null ? entity.getDmp().getLabel() : "";
|
||||||
this.profile = entity.getProfile() != null ? new DatasetProfilePublicModel().fromDataModel(entity.getProfile()) : null;
|
// this.dmpId = entity.getDmp() != null ? entity.getDmp().getId().toString() : "";
|
||||||
this.description = entity.getDescription();
|
// this.profile = entity.getProfile() != null ? new DatasetProfilePublicModel().fromDataModel(entity.getProfile()) : null;
|
||||||
if (entity.getFinalizedAt() == null && entity.getStatus() == Dataset.Status.FINALISED.getValue()) {
|
// this.description = entity.getDescription();
|
||||||
this.finalizedAt = entity.getDmp().getFinalizedAt();
|
// if (entity.getFinalizedAt() == null && entity.getStatus() == DescriptionEntity.Status.FINALISED.getValue()) {
|
||||||
} else {
|
// this.finalizedAt = entity.getDmp().getFinalizedAt();
|
||||||
this.finalizedAt = entity.getFinalizedAt();
|
// } else {
|
||||||
}
|
// this.finalizedAt = entity.getFinalizedAt();
|
||||||
this.dmpPublishedAt = entity.getDmp().getPublishedAt();
|
// }
|
||||||
this.version = entity.getDmp().getVersion();
|
// this.dmpPublishedAt = entity.getDmp().getPublishedAt();
|
||||||
this.users = entity.getDmp() != null ? entity.getDmp().getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.version = entity.getDmp().getVersion();
|
||||||
|
// this.users = entity.getDmp() != null ? entity.getDmp().getUsers().stream().map(x -> new UserInfoPublicModel().fromDataModel(x)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset toDataModel() {
|
public DescriptionEntity toDataModel() {
|
||||||
Dataset entity = new Dataset();
|
//TODO
|
||||||
entity.setId(UUID.fromString(this.getId()));
|
DescriptionEntity entity = new DescriptionEntity();
|
||||||
entity.setLabel(this.getLabel());
|
// entity.setId(UUID.fromString(this.getId()));
|
||||||
entity.setCreated(this.getCreatedAt());
|
// entity.setLabel(this.getLabel());
|
||||||
entity.setModified(this.getModifiedAt());
|
// entity.setCreated(this.getCreatedAt());
|
||||||
entity.setDescription(this.getDescription());
|
// entity.setModified(this.getModifiedAt());
|
||||||
entity.setFinalizedAt(this.getFinalizedAt());
|
// entity.setDescription(this.getDescription());
|
||||||
entity.setStatus(Dataset.Status.FINALISED.getValue());
|
// entity.setFinalizedAt(this.getFinalizedAt());
|
||||||
DMP dmp = new DMP();
|
// entity.setStatus(DescriptionEntity.Status.FINALISED.getValue());
|
||||||
if (this.getGrant() != null && !this.getGrant().isEmpty()) {
|
// DMP dmp = new DMP();
|
||||||
Grant grant = new Grant();
|
// if (this.getGrant() != null && !this.getGrant().isEmpty()) {
|
||||||
grant.setLabel(this.getGrant());
|
// Grant grant = new Grant();
|
||||||
dmp.setGrant(grant);
|
// grant.setLabel(this.getGrant());
|
||||||
}
|
// dmp.setGrant(grant);
|
||||||
dmp.setLabel(this.getDmp());
|
// }
|
||||||
dmp.setId(UUID.fromString(this.getDmpId()));
|
// dmp.setLabel(this.getDmp());
|
||||||
dmp.setPublishedAt(this.getDmpPublishedAt());
|
// dmp.setId(UUID.fromString(this.getDmpId()));
|
||||||
dmp.setVersion(this.getVersion());
|
// dmp.setPublishedAt(this.getDmpPublishedAt());
|
||||||
dmp.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
|
// dmp.setVersion(this.getVersion());
|
||||||
dmp.setFinalizedAt(this.getFinalizedAt());
|
// dmp.setUsers(this.getUsers().stream().map(UserInfoPublicModel::toDataModel).collect(Collectors.toSet()));
|
||||||
entity.setDmp(dmp);
|
// dmp.setFinalizedAt(this.getFinalizedAt());
|
||||||
entity.setProfile(this.getProfile() != null ? this.getProfile().toDataModel() : null);
|
// entity.setDmp(dmp);
|
||||||
|
// entity.setProfile(this.getProfile() != null ? this.getProfile().toDataModel() : null);
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,12 @@ package eu.eudat.publicapi.models.overviewmodels;
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
import eu.eudat.commons.types.descriptiontemplate.DefinitionEntity;
|
||||||
import eu.eudat.data.old.DMP;
|
import eu.eudat.data.old.DMP;
|
||||||
import eu.eudat.data.old.DMPDatasetProfile;
|
import eu.eudat.data.old.DMPDatasetProfile;
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.commons.types.xml.XmlBuilder;
|
import eu.eudat.commons.types.xml.XmlBuilder;
|
||||||
import eu.eudat.models.DataModel;
|
import eu.eudat.models.DataModel;
|
||||||
|
@ -184,10 +186,10 @@ public class DataManagementPlanPublicModel implements DataModel<DMP, DataManagem
|
||||||
this.modifiedAt = entity.getModified();
|
this.modifiedAt = entity.getModified();
|
||||||
this.finalizedAt = entity.getFinalizedAt();
|
this.finalizedAt = entity.getFinalizedAt();
|
||||||
this.organisations = entity.getOrganisations().stream().map(item -> new OrganizationPublicModel().fromDataModel(item)).collect(Collectors.toList());
|
this.organisations = entity.getOrganisations().stream().map(item -> new OrganizationPublicModel().fromDataModel(item)).collect(Collectors.toList());
|
||||||
this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getStatus().equals(Dataset.Status.DELETED.getValue()) && !dataset.getStatus().equals(Dataset.Status.CANCELED.getValue()))
|
this.datasets = entity.getDataset().stream().filter(dataset -> !dataset.getIsActive().equals(IsActive.Inactive) && !dataset.getStatus().equals(DescriptionStatus.Canceled))
|
||||||
.map(datasetEntity-> {
|
.map(datasetEntity-> {
|
||||||
DatasetPublicModel dataset = new DatasetPublicModel();
|
DatasetPublicModel dataset = new DatasetPublicModel();
|
||||||
dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus(), datasetEntity));
|
dataset.setDatasetProfileDefinition(this.getPagedProfile(dataset.getStatus().getValue(), datasetEntity));
|
||||||
dataset.fromDataModel(datasetEntity);
|
dataset.fromDataModel(datasetEntity);
|
||||||
return dataset;
|
return dataset;
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
|
@ -217,16 +219,17 @@ public class DataManagementPlanPublicModel implements DataModel<DMP, DataManagem
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PagedDatasetProfile getPagedProfile(int status, Dataset datasetEntity){
|
private PagedDatasetProfile getPagedProfile(int status, DescriptionEntity descriptionEntityEntity){
|
||||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(datasetEntity.getProfile());
|
//TODO
|
||||||
datasetprofile.setStatus(status);
|
// eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = this.generateDatasetProfileModel(descriptionEntityEntity.getProfile());
|
||||||
if (datasetEntity.getProperties() != null) {
|
// datasetprofile.setStatus(status);
|
||||||
JSONObject jObject = new JSONObject(datasetEntity.getProperties());
|
// if (descriptionEntityEntity.getProperties() != null) {
|
||||||
Map<String, Object> properties = jObject.toMap();
|
// JSONObject jObject = new JSONObject(descriptionEntityEntity.getProperties());
|
||||||
datasetprofile.fromJsonObject(properties);
|
// Map<String, Object> properties = jObject.toMap();
|
||||||
}
|
// datasetprofile.fromJsonObject(properties);
|
||||||
|
// }
|
||||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||||
pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
|
//pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
|
||||||
return pagedDatasetProfile;
|
return pagedDatasetProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package eu.eudat.publicapi.models.overviewmodels;
|
package eu.eudat.publicapi.models.overviewmodels;
|
||||||
|
|
||||||
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.DescriptionTemplateEntity;
|
import eu.eudat.data.DescriptionTemplateEntity;
|
||||||
import eu.eudat.data.old.*;
|
import eu.eudat.data.old.*;
|
||||||
import eu.eudat.elastic.entities.Tag;
|
import eu.eudat.elastic.entities.Tag;
|
||||||
|
@ -16,13 +18,13 @@ import net.minidev.json.JSONValue;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class DatasetPublicModel implements DataModel<Dataset, DatasetPublicModel> {
|
public class DatasetPublicModel implements DataModel<DescriptionEntity, DatasetPublicModel> {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
private String label;
|
private String label;
|
||||||
private String reference;
|
private String reference;
|
||||||
private String uri;
|
private String uri;
|
||||||
private String description;
|
private String description;
|
||||||
private short status;
|
private DescriptionStatus status;
|
||||||
private Date createdAt;
|
private Date createdAt;
|
||||||
private DataManagementPlanPublicListingModel dmp;
|
private DataManagementPlanPublicListingModel dmp;
|
||||||
private PagedDatasetProfile datasetProfileDefinition;
|
private PagedDatasetProfile datasetProfileDefinition;
|
||||||
|
@ -69,10 +71,10 @@ public class DatasetPublicModel implements DataModel<Dataset, DatasetPublicModel
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public short getStatus() {
|
public DescriptionStatus getStatus() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
public void setStatus(short status) {
|
public void setStatus(DescriptionStatus status) {
|
||||||
this.status = status;
|
this.status = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -147,142 +149,145 @@ public class DatasetPublicModel implements DataModel<Dataset, DatasetPublicModel
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DatasetPublicModel fromDataModel(Dataset entity) {
|
public DatasetPublicModel fromDataModel(DescriptionEntity entity) {
|
||||||
this.id = entity.getId();
|
//TODO:
|
||||||
this.label = entity.getLabel();
|
// this.id = entity.getId();
|
||||||
this.reference = entity.getReference();
|
// this.label = entity.getLabel();
|
||||||
this.description = entity.getDescription();
|
// this.reference = entity.getReference();
|
||||||
this.status = entity.getStatus();
|
// this.description = entity.getDescription();
|
||||||
this.profile = new DatasetProfilePublicModel();
|
// this.status = entity.getStatus();
|
||||||
this.profile = this.profile.fromDataModel(entity.getProfile());
|
// this.profile = new DatasetProfilePublicModel();
|
||||||
this.uri = entity.getUri();
|
// this.profile = this.profile.fromDataModel(entity.getProfile());
|
||||||
this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new RegistryPublicModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.uri = entity.getUri();
|
||||||
this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
|
// this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new RegistryPublicModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
DataRepositoryPublicModel dataRepository = new DataRepositoryPublicModel().fromDataModel(item.getDataRepository());
|
// this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
|
||||||
if (item.getData() != null) {
|
// DataRepositoryPublicModel dataRepository = new DataRepositoryPublicModel().fromDataModel(item.getDataRepository());
|
||||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
// if (item.getData() != null) {
|
||||||
Map<String, String> values = data.get("data");
|
// Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
dataRepository.setInfo(values.get("info"));
|
// Map<String, String> values = data.get("data");
|
||||||
}
|
// dataRepository.setInfo(values.get("info"));
|
||||||
return dataRepository;
|
// }
|
||||||
}).collect(Collectors.toList()) : new ArrayList<>();
|
// return dataRepository;
|
||||||
this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new ServicePublicModel().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
|
// }).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.createdAt = entity.getCreated();
|
// this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new ServicePublicModel().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.dmp = new DataManagementPlanPublicListingModel().fromDataModelNoDatasets(entity.getDmp());
|
// this.createdAt = entity.getCreated();
|
||||||
this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
|
// this.dmp = new DataManagementPlanPublicListingModel().fromDataModelNoDatasets(entity.getDmp());
|
||||||
ExternalDatasetPublicListingModel externalDatasetListingModel = new ExternalDatasetPublicListingModel().fromDataModel(item.getExternalDataset());
|
// this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
|
||||||
if (item.getData() != null) {
|
// ExternalDatasetPublicListingModel externalDatasetListingModel = new ExternalDatasetPublicListingModel().fromDataModel(item.getExternalDataset());
|
||||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
// if (item.getData() != null) {
|
||||||
Map<String, String> values = data.get("data");
|
// Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
externalDatasetListingModel.setInfo(values.get("info"));
|
// Map<String, String> values = data.get("data");
|
||||||
externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
|
// externalDatasetListingModel.setInfo(values.get("info"));
|
||||||
}
|
// externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
|
||||||
return externalDatasetListingModel;
|
// }
|
||||||
}).collect(Collectors.toList()) : new ArrayList<>();
|
// return externalDatasetListingModel;
|
||||||
this.modifiedAt = entity.getModified();
|
// }).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
|
// this.modifiedAt = entity.getModified();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DatasetPublicModel fromDataModelNoDmp(Dataset entity) {
|
public DatasetPublicModel fromDataModelNoDmp(DescriptionEntity entity) {
|
||||||
this.id = entity.getId();
|
//TODO:
|
||||||
this.label = entity.getLabel();
|
// this.id = entity.getId();
|
||||||
this.reference = entity.getReference();
|
// this.label = entity.getLabel();
|
||||||
this.description = entity.getDescription();
|
// this.reference = entity.getReference();
|
||||||
this.status = entity.getStatus();
|
// this.description = entity.getDescription();
|
||||||
this.profile = new DatasetProfilePublicModel();
|
// this.status = entity.getStatus();
|
||||||
this.profile = this.profile.fromDataModel(entity.getProfile());
|
// this.profile = new DatasetProfilePublicModel();
|
||||||
this.uri = entity.getUri();
|
// this.profile = this.profile.fromDataModel(entity.getProfile());
|
||||||
this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new RegistryPublicModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
// this.uri = entity.getUri();
|
||||||
this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
|
// this.registries = entity.getRegistries() != null ? entity.getRegistries().stream().map(item -> new RegistryPublicModel().fromDataModel(item)).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
DataRepositoryPublicModel dataRepository = new DataRepositoryPublicModel().fromDataModel(item.getDataRepository());
|
// this.dataRepositories = entity.getDatasetDataRepositories() != null ? entity.getDatasetDataRepositories().stream().map(item -> {
|
||||||
if (item.getData() != null) {
|
// DataRepositoryPublicModel dataRepository = new DataRepositoryPublicModel().fromDataModel(item.getDataRepository());
|
||||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
// if (item.getData() != null) {
|
||||||
Map<String, String> values = data.get("data");
|
// Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
dataRepository.setInfo(values.get("info"));
|
// Map<String, String> values = data.get("data");
|
||||||
}
|
// dataRepository.setInfo(values.get("info"));
|
||||||
return dataRepository;
|
// }
|
||||||
}).collect(Collectors.toList()) : new ArrayList<>();
|
// return dataRepository;
|
||||||
this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new ServicePublicModel().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
|
// }).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.createdAt = entity.getCreated();
|
// this.services = entity.getServices() != null ? entity.getServices().stream().map(item -> new ServicePublicModel().fromDataModel(item.getService())).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
|
// this.createdAt = entity.getCreated();
|
||||||
ExternalDatasetPublicListingModel externalDatasetListingModel = new ExternalDatasetPublicListingModel().fromDataModel(item.getExternalDataset());
|
// this.externalDatasets = entity.getDatasetExternalDatasets() != null ? entity.getDatasetExternalDatasets().stream().map(item -> {
|
||||||
if (item.getData() != null) {
|
// ExternalDatasetPublicListingModel externalDatasetListingModel = new ExternalDatasetPublicListingModel().fromDataModel(item.getExternalDataset());
|
||||||
Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
// if (item.getData() != null) {
|
||||||
Map<String, String> values = data.get("data");
|
// Map<String, Map<String, String>> data = (Map<String, Map<String, String>>) JSONValue.parse(item.getData());
|
||||||
externalDatasetListingModel.setInfo(values.get("info"));
|
// Map<String, String> values = data.get("data");
|
||||||
externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
|
// externalDatasetListingModel.setInfo(values.get("info"));
|
||||||
}
|
// externalDatasetListingModel.setType(Integer.parseInt(values.get("type")));
|
||||||
return externalDatasetListingModel;
|
// }
|
||||||
}).collect(Collectors.toList()) : new ArrayList<>();
|
// return externalDatasetListingModel;
|
||||||
this.modifiedAt = entity.getModified();
|
// }).collect(Collectors.toList()) : new ArrayList<>();
|
||||||
|
// this.modifiedAt = entity.getModified();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dataset toDataModel() throws Exception {
|
public DescriptionEntity toDataModel() throws Exception {
|
||||||
Dataset entity = new Dataset();
|
//TODO:
|
||||||
entity.setId(this.id);
|
DescriptionEntity entity = new DescriptionEntity();
|
||||||
entity.setLabel(this.label);
|
// entity.setId(this.id);
|
||||||
entity.setStatus(this.status);
|
// entity.setLabel(this.label);
|
||||||
entity.setReference(this.reference);
|
// entity.setStatus(this.status);
|
||||||
entity.setUri(this.uri);
|
// entity.setReference(this.reference);
|
||||||
entity.setFinalizedAt(new Date());
|
// entity.setUri(this.uri);
|
||||||
DMP dmp = new DMP();
|
// entity.setFinalizedAt(new Date());
|
||||||
dmp.setId(UUID.fromString(this.dmp.getId()));
|
// DMP dmp = new DMP();
|
||||||
entity.setDmp(dmp);
|
// dmp.setId(UUID.fromString(this.dmp.getId()));
|
||||||
entity.setDescription(this.description);
|
// entity.setDmp(dmp);
|
||||||
entity.setCreated(this.createdAt != null ? this.createdAt : new Date());
|
// entity.setDescription(this.description);
|
||||||
entity.setModified(new Date());
|
// entity.setCreated(this.createdAt != null ? this.createdAt : new Date());
|
||||||
DescriptionTemplateEntity profile = new DescriptionTemplateEntity();
|
// entity.setModified(new Date());
|
||||||
profile.setId(this.profile.getId());
|
// DescriptionTemplateEntity profile = new DescriptionTemplateEntity();
|
||||||
entity.setProfile(profile);
|
// profile.setId(this.profile.getId());
|
||||||
if (this.registries != null && !this.registries.isEmpty()) {
|
// entity.setProfile(profile);
|
||||||
entity.setRegistries(new HashSet<>());
|
// if (this.registries != null && !this.registries.isEmpty()) {
|
||||||
for (RegistryPublicModel registry : this.registries) {
|
// entity.setRegistries(new HashSet<>());
|
||||||
entity.getRegistries().add(registry.toDataModel());
|
// for (RegistryPublicModel registry : this.registries) {
|
||||||
}
|
// entity.getRegistries().add(registry.toDataModel());
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
if (this.dataRepositories != null && !this.dataRepositories.isEmpty()) {
|
//
|
||||||
entity.setDatasetDataRepositories(new HashSet<>());
|
// if (this.dataRepositories != null && !this.dataRepositories.isEmpty()) {
|
||||||
for (DataRepositoryPublicModel dataRepositoryModel : this.dataRepositories) {
|
// entity.setDatasetDataRepositories(new HashSet<>());
|
||||||
DataRepository dataRepository = dataRepositoryModel.toDataModel();
|
// for (DataRepositoryPublicModel dataRepositoryModel : this.dataRepositories) {
|
||||||
DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
// DataRepository dataRepository = dataRepositoryModel.toDataModel();
|
||||||
datasetDataRepository.setDataRepository(dataRepository);
|
// DatasetDataRepository datasetDataRepository = new DatasetDataRepository();
|
||||||
Map<String, Map<String, String>> data = new HashMap<>();
|
// datasetDataRepository.setDataRepository(dataRepository);
|
||||||
Map<String, String> values = new HashMap<>();
|
// Map<String, Map<String, String>> data = new HashMap<>();
|
||||||
values.put("info", dataRepositoryModel.getInfo());
|
// Map<String, String> values = new HashMap<>();
|
||||||
data.put("data", values);
|
// values.put("info", dataRepositoryModel.getInfo());
|
||||||
datasetDataRepository.setData(JSONValue.toJSONString(data));
|
// data.put("data", values);
|
||||||
entity.getDatasetDataRepositories().add(datasetDataRepository);
|
// datasetDataRepository.setData(JSONValue.toJSONString(data));
|
||||||
}
|
// entity.getDatasetDataRepositories().add(datasetDataRepository);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
if (this.services != null && !this.services.isEmpty()) {
|
//
|
||||||
entity.setServices(new HashSet<>());
|
// if (this.services != null && !this.services.isEmpty()) {
|
||||||
for (ServicePublicModel serviceModel : this.services) {
|
// entity.setServices(new HashSet<>());
|
||||||
Service service = serviceModel.toDataModel();
|
// for (ServicePublicModel serviceModel : this.services) {
|
||||||
DatasetService datasetService = new DatasetService();
|
// Service service = serviceModel.toDataModel();
|
||||||
datasetService.setService(service);
|
// DatasetService datasetService = new DatasetService();
|
||||||
entity.getServices().add(datasetService);
|
// datasetService.setService(service);
|
||||||
}
|
// entity.getServices().add(datasetService);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
if (this.externalDatasets != null && !this.externalDatasets.isEmpty()) {
|
//
|
||||||
entity.setDatasetExternalDatasets(new HashSet<>());
|
// if (this.externalDatasets != null && !this.externalDatasets.isEmpty()) {
|
||||||
for (ExternalDatasetPublicListingModel externalDataset : this.externalDatasets) {
|
// entity.setDatasetExternalDatasets(new HashSet<>());
|
||||||
ExternalDataset externalDatasetEntity = externalDataset.toDataModel();
|
// for (ExternalDatasetPublicListingModel externalDataset : this.externalDatasets) {
|
||||||
DatasetExternalDataset datasetExternalDataset = new DatasetExternalDataset();
|
// ExternalDataset externalDatasetEntity = externalDataset.toDataModel();
|
||||||
datasetExternalDataset.setExternalDataset(externalDatasetEntity);
|
// DatasetExternalDataset datasetExternalDataset = new DatasetExternalDataset();
|
||||||
Map<String,Map<String,String>> data = new HashMap<>();
|
// datasetExternalDataset.setExternalDataset(externalDatasetEntity);
|
||||||
Map<String,String> values = new HashMap<>();
|
// Map<String,Map<String,String>> data = new HashMap<>();
|
||||||
values.put("info",externalDataset.getInfo());
|
// Map<String,String> values = new HashMap<>();
|
||||||
values.put("type",externalDataset.getType().toString());
|
// values.put("info",externalDataset.getInfo());
|
||||||
data.put("data",values);
|
// values.put("type",externalDataset.getType().toString());
|
||||||
datasetExternalDataset.setData(JSONValue.toJSONString(data));
|
// data.put("data",values);
|
||||||
entity.getDatasetExternalDatasets().add(datasetExternalDataset);
|
// datasetExternalDataset.setData(JSONValue.toJSONString(data));
|
||||||
}
|
// entity.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package eu.eudat.publicapi.request.dataset;
|
package eu.eudat.publicapi.request.dataset;
|
||||||
|
|
||||||
import eu.eudat.data.old.Dataset;
|
import eu.eudat.commons.enums.DescriptionStatus;
|
||||||
|
import eu.eudat.commons.enums.IsActive;
|
||||||
|
import eu.eudat.data.DescriptionEntity;
|
||||||
import eu.eudat.data.query.definition.TableQuery;
|
import eu.eudat.data.query.definition.TableQuery;
|
||||||
import eu.eudat.publicapi.criteria.dataset.DatasetPublicCriteria;
|
import eu.eudat.publicapi.criteria.dataset.DatasetPublicCriteria;
|
||||||
import eu.eudat.queryable.QueryableList;
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
@ -12,12 +14,12 @@ import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
|
||||||
public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria, Dataset, UUID> {
|
public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria, DescriptionEntity, UUID> {
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> applyCriteria() {
|
public QueryableList<DescriptionEntity> applyCriteria() {
|
||||||
QueryableList<Dataset> query = this.getQuery();
|
QueryableList<DescriptionEntity> query = this.getQuery();
|
||||||
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"), Dataset.Status.FINALISED.getValue()));
|
query.where((builder, root) -> builder.equal(root.get("status"), DescriptionStatus.Finalized));
|
||||||
// query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
|
// query.initSubQuery(String.class).where((builder, root) -> builder.equal(root.get("dmp").get("version"),
|
||||||
// query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
|
// query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.equal(externalRoot.get("dmp").get("groupId"), nestedRoot.get("dmp").get("groupId")),
|
||||||
// Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
// Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "dmp:version")), String.class)));
|
||||||
|
@ -54,12 +56,12 @@ public class DatasetPublicTableRequest extends TableQuery<DatasetPublicCriteria,
|
||||||
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("profile").get("groupId"),
|
query.<String>subQueryMax((builder1, externalRoot, nestedRoot) -> builder1.and(builder1.equal(externalRoot.get("profile").get("groupId"),
|
||||||
nestedRoot.get("profile").get("groupId")), builder1.equal(nestedRoot.get("dmp").get("isPublic"), true)), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "profile:version")), String.class)));
|
nestedRoot.get("profile").get("groupId")), builder1.equal(nestedRoot.get("dmp").get("isPublic"), true)), Arrays.asList(new SelectionField(FieldSelectionType.COMPOSITE_FIELD, "profile:version")), String.class)));
|
||||||
}
|
}
|
||||||
query.where((builder, root) -> builder.notEqual(root.get("status"), Dataset.Status.DELETED.getValue()));
|
query.where((builder, root) -> builder.notEqual(root.get("isActive"), IsActive.Inactive));
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public QueryableList<Dataset> applyPaging(QueryableList<Dataset> items) {
|
public QueryableList<DescriptionEntity> applyPaging(QueryableList<DescriptionEntity> items) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue