From 2453cde47fcce2b7804304e7a6965d7326b063b8 Mon Sep 17 00:00:00 2001 From: gkolokythas Date: Wed, 29 May 2019 12:02:47 +0300 Subject: [PATCH] Fixes bug and efficiency on fetching DMPs. --- .../data/src/main/java/eu/eudat/data/entities/DMP.java | 6 +++--- .../eu/eudat/models/data/dmp/DataManagementPlan.java | 2 +- .../data/dmp/DataManagementPlanNewVersionModel.java | 10 ++-------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMP.java b/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMP.java index 22770c7c8..e21c1a42e 100644 --- a/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMP.java +++ b/dmp-backend/data/src/main/java/eu/eudat/data/entities/DMP.java @@ -100,7 +100,7 @@ public class DMP implements DataEntity { joinColumns = {@JoinColumn(name = "\"dmp\"", referencedColumnName = "\"ID\"")}, inverseJoinColumns = {@JoinColumn(name = "\"datasetprofile\"", referencedColumnName = "\"ID\"")} ) - private List associatedDmps; + private Set associatedDmps; @ManyToOne(fetch = FetchType.LAZY) @@ -237,10 +237,10 @@ public class DMP implements DataEntity { this.project = project; } - public List getAssociatedDmps() { + public Set getAssociatedDmps() { return associatedDmps; } - public void setAssociatedDmps(List associatedDmps) { + public void setAssociatedDmps(Set associatedDmps) { this.associatedDmps = associatedDmps; } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java index b9a967a6a..0fdb40505 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlan.java @@ -262,7 +262,7 @@ public class DataManagementPlan implements DataModel { associatedProfileDoc.appendChild(associatedProfilesElement); dataManagementPlanEntity.setAssociatedDmps(XmlBuilder.generateXml(associatedProfileDoc));*/ - List datasetProfiles = new LinkedList<>(); + Set datasetProfiles = new HashSet<>(); for (AssociatedProfile profile : this.profiles) { datasetProfiles.add(profile.toData()); } diff --git a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java index 57a2eb969..16d13e9d7 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java +++ b/dmp-backend/web/src/main/java/eu/eudat/models/data/dmp/DataManagementPlanNewVersionModel.java @@ -175,7 +175,8 @@ public class DataManagementPlanNewVersionModel implements DataModel(this.researchers.stream().map(item -> item.toDataModel()).collect(Collectors.toList()))); if (this.project != null) entity.setProject(this.project.toDataModel()); - if (this.profiles != null) { + if (this.profiles != null) + entity.setAssociatedDmps(this.profiles.stream().map(x -> x.toData()).collect(Collectors.toSet())); /*Document associatedProfileDoc = XmlBuilder.getDocument(); Element associatedProfilesElement = associatedProfileDoc.createElement("profiles"); for (AssociatedProfile associatedProfile : this.profiles) { @@ -183,13 +184,6 @@ public class DataManagementPlanNewVersionModel implements DataModel datasetProfiles = new LinkedList<>(); - for (AssociatedProfile profile : this.profiles) { - datasetProfiles.add(profile.toData()); - } - entity.setAssociatedDmps(datasetProfiles); - } return entity; }