From 2ef9a4fa8c2b4c805640effc183c1eba95e3fc2c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 2 Feb 2023 16:56:21 +0100 Subject: [PATCH] Reverted serialization from Sting to Object values returning the Document as Map --- CHANGELOG.md | 6 ++++++ pom.xml | 2 +- .../geoportalcommon/ConvertToDataValueObjectModel.java | 10 +++++----- .../geoportalcommon/shared/geoportal/DocumentDV.java | 8 ++++---- .../shared/geoportal/ResultDocumentDV.java | 4 ++-- src/test/java/org/gcube/application/Project_Tests.java | 2 +- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb74d1..7abbb55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v2.0.2-SNAPSHOT] - 2022-02-02 + +#### Enhancements + +- [#24432] Reverted serialization from Sting to Object values returning the Document as Map + ## [v2.0.1] - 2022-01-19 #### Bug fixes diff --git a/pom.xml b/pom.xml index 438b614..1e565a7 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.gcube.application geoportal-data-common - 2.0.1 + 2.0.2-SNAPSHOT GeoPortal Data Common is common library used by GUI components developed for GeoNA diff --git a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java index 7023d7a..d5bf957 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java +++ b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java @@ -867,7 +867,7 @@ public class ConvertToDataValueObjectModel { } if (listDocumentKeys != null && !getFullMap) { - LinkedHashMap documentAsMap = new LinkedHashMap(listDocumentKeys.size()); + LinkedHashMap documentAsMap = new LinkedHashMap(listDocumentKeys.size()); for (String key : listDocumentKeys) { documentAsMap = fillMapValue(document, key, documentAsMap); @@ -877,7 +877,7 @@ public class ConvertToDataValueObjectModel { if (getFullMap) { Set keySet = document.keySet(); - LinkedHashMap documentAsMap = new LinkedHashMap(keySet.size()); + LinkedHashMap documentAsMap = new LinkedHashMap(keySet.size()); for (String key : keySet) { // documentAsMap.put(key, document.get(key)); documentAsMap = fillMapValue(document, key, documentAsMap); @@ -979,8 +979,8 @@ public class ConvertToDataValueObjectModel { * @param documentAsMap the document as map * @return the linked hash map */ - public static LinkedHashMap fillMapValue(Document document, String key, - LinkedHashMap documentAsMap) { + public static LinkedHashMap fillMapValue(Document document, String key, + LinkedHashMap documentAsMap) { Object value = document.get(key); String keyLower = key.toLowerCase(); @@ -1000,7 +1000,7 @@ public class ConvertToDataValueObjectModel { } } - documentAsMap.put(key, value!=null?value.toString():null); + documentAsMap.put(key, value); return documentAsMap; } 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 771b6f9..4c845f2 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 @@ -10,7 +10,7 @@ public class DocumentDV implements Serializable { * */ private static final long serialVersionUID = 4978517506036855883L; - protected LinkedHashMap documentAsMap; + protected LinkedHashMap documentAsMap; private String documentAsJSON; private ConfigurationDV configuration; @@ -19,11 +19,11 @@ public class DocumentDV implements Serializable { public DocumentDV() { } - public LinkedHashMap getDocumentAsMap() { + public LinkedHashMap getDocumentAsMap() { return documentAsMap; } - public Entry getFirstEntryOfMap() { + public Entry getFirstEntryOfMap() { if (documentAsMap != null && documentAsMap.size() >= 1) { return documentAsMap.entrySet().iterator().next(); } @@ -43,7 +43,7 @@ public class DocumentDV implements Serializable { return documentAsJSON; } - public void setDocumentAsMap(LinkedHashMap documentAsMap) { + public void setDocumentAsMap(LinkedHashMap documentAsMap) { this.documentAsMap = documentAsMap; } diff --git a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ResultDocumentDV.java b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ResultDocumentDV.java index 959c8c3..e463d98 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ResultDocumentDV.java +++ b/src/main/java/org/gcube/application/geoportalcommon/shared/geoportal/ResultDocumentDV.java @@ -49,9 +49,9 @@ public class ResultDocumentDV extends DocumentDV implements Serializable { public void addItemToMap(String property, Object value) { if (documentAsMap == null) - documentAsMap = new LinkedHashMap(); + documentAsMap = new LinkedHashMap(); - documentAsMap.put(property, value!=null?value.toString():null); + documentAsMap.put(property, value); } public BasicLifecycleInformationDV getLifecycleInfo() { diff --git a/src/test/java/org/gcube/application/Project_Tests.java b/src/test/java/org/gcube/application/Project_Tests.java index 94b3ac8..c4b8414 100644 --- a/src/test/java/org/gcube/application/Project_Tests.java +++ b/src/test/java/org/gcube/application/Project_Tests.java @@ -80,7 +80,7 @@ public class Project_Tests { ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder); System.out.println(projectDV); - LinkedHashMap theMap = projectDV.getTheDocument().getDocumentAsMap(); + LinkedHashMap theMap = projectDV.getTheDocument().getDocumentAsMap(); for (String key : theMap.keySet()) { Object theValue = theMap.get(key); System.out.println("The key: " + key + " has value: " + theValue);