From 40eb373fa7063c19285c0b7134f1b5129220f43b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 12 Oct 2022 15:23:01 +0200 Subject: [PATCH] Added projectId to DocumentDV --- .../ConvertToDataValueObjectModel.java | 22 +++++++++++-------- .../shared/geoportal/DocumentDV.java | 18 ++++++++++++--- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java index effe5aa..1a33364 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java +++ b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java @@ -509,7 +509,7 @@ public class ConvertToDataValueObjectModel { project.getProfileVersion() != null ? project.getProfileVersion().getValue() : ""); theProject.setVersion(project.getVersion() != null ? project.getVersion().getValue() : ""); - theProject.setTheDocument(toGenericDocumentDV(project.getTheDocument(), DocumentDV.class, + theProject.setTheDocument(toGenericDocumentDV(project.getId(), project.getTheDocument(), DocumentDV.class, projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap())); List relations = project.getRelationships(); @@ -531,8 +531,9 @@ public class ConvertToDataValueObjectModel { identificationReferences.size()); for (IdentificationReference identificationReference : identificationReferences) { - IdentificationReferenceDV idv = toIdentificationReferenceDV(identificationReference, - projectReader.getListDocumentKeys(), projectReader.isIncludeFullDocumentMap()); + IdentificationReferenceDV idv = toIdentificationReferenceDV(project.getId(), + identificationReference, projectReader.getListDocumentKeys(), + projectReader.isIncludeFullDocumentMap()); mapIdentReferenceDV.put(idv.getType(), idv); } @@ -588,7 +589,7 @@ public class ConvertToDataValueObjectModel { try { - ResultDocumentDV rd = (ResultDocumentDV) toGenericDocumentDV(project.getTheDocument(), + ResultDocumentDV rd = (ResultDocumentDV) toGenericDocumentDV(project.getId(), project.getTheDocument(), ResultDocumentDV.class, null, true); rd.setId(project.getId()); rd.setProfileID(project.getProfileID()); @@ -684,18 +685,19 @@ public class ConvertToDataValueObjectModel { /** * To identification reference DV. * + * @param projectID the project ID * @param identificationReference the identification reference * @param listDocumentKeys the list document keys * @param getFullMap the get full map * @return the identification reference DV */ - private static IdentificationReferenceDV toIdentificationReferenceDV( + private static IdentificationReferenceDV toIdentificationReferenceDV(String projectID, IdentificationReference identificationReference, List listDocumentKeys, boolean getFullMap) { if (identificationReference == null) return null; - IdentificationReferenceDV idv = (IdentificationReferenceDV) toGenericDocumentDV(identificationReference, - IdentificationReferenceDV.class, listDocumentKeys, getFullMap); + IdentificationReferenceDV idv = (IdentificationReferenceDV) toGenericDocumentDV(projectID, + identificationReference, IdentificationReferenceDV.class, listDocumentKeys, getFullMap); idv.setType(identificationReference.getType()); return idv; @@ -771,14 +773,15 @@ public class ConvertToDataValueObjectModel { * To generic document DV. * * @param the generic type + * @param projectID the project ID * @param document the document * @param targetClass the target class * @param listDocumentKeys the list document keys * @param getFullMap the get full map * @return the document DV */ - public static DocumentDV toGenericDocumentDV(Document document, Class targetClass, - List listDocumentKeys, boolean getFullMap) { + public static DocumentDV toGenericDocumentDV(String projectID, Document document, + Class targetClass, List listDocumentKeys, boolean getFullMap) { if (document == null) return null; @@ -819,6 +822,7 @@ public class ConvertToDataValueObjectModel { } documentDV.setDocumentAsJSON(document.toJson()); + documentDV.setProjectID(projectID); return documentDV; } diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/DocumentDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/DocumentDV.java index 9838bcc..4d767c3 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/DocumentDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/DocumentDV.java @@ -14,21 +14,31 @@ public class DocumentDV implements Serializable { private String documentAsJSON; private ConfigurationDV configuration; + private String projectID; + public DocumentDV() { } public LinkedHashMap getDocumentAsMap() { return documentAsMap; } - + public Entry getFirstEntryOfMap() { - if(documentAsMap!=null && documentAsMap.size()>1) { + if (documentAsMap != null && documentAsMap.size() > 1) { return documentAsMap.entrySet().iterator().next(); } - + return null; } + public String getProjectID() { + return projectID; + } + + public void setProjectID(String projectID) { + this.projectID = projectID; + } + public String getDocumentAsJSON() { return documentAsJSON; } @@ -58,6 +68,8 @@ public class DocumentDV implements Serializable { builder.append(documentAsJSON); builder.append(", configuration="); builder.append(configuration); + builder.append(", projectID="); + builder.append(projectID); builder.append("]"); return builder.toString(); }