Reverted serialization from Sting to Object values returning the

Document as Map
This commit is contained in:
Francesco Mangiacrapa 2023-02-02 16:56:21 +01:00
parent ebdf9714c9
commit 2ef9a4fa8c
6 changed files with 19 additions and 13 deletions

View File

@ -4,6 +4,12 @@
All notable changes to this project will be documented in this file. 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). 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 ## [v2.0.1] - 2022-01-19
#### Bug fixes #### Bug fixes

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.application</groupId> <groupId>org.gcube.application</groupId>
<artifactId>geoportal-data-common</artifactId> <artifactId>geoportal-data-common</artifactId>
<version>2.0.1</version> <version>2.0.2-SNAPSHOT</version>
<description>GeoPortal Data Common is common library used by GUI components developed for GeoNA</description> <description>GeoPortal Data Common is common library used by GUI components developed for GeoNA</description>
<scm> <scm>

View File

@ -867,7 +867,7 @@ public class ConvertToDataValueObjectModel {
} }
if (listDocumentKeys != null && !getFullMap) { if (listDocumentKeys != null && !getFullMap) {
LinkedHashMap<String, String> documentAsMap = new LinkedHashMap<String, String>(listDocumentKeys.size()); LinkedHashMap<String, Object> documentAsMap = new LinkedHashMap<String, Object>(listDocumentKeys.size());
for (String key : listDocumentKeys) { for (String key : listDocumentKeys) {
documentAsMap = fillMapValue(document, key, documentAsMap); documentAsMap = fillMapValue(document, key, documentAsMap);
@ -877,7 +877,7 @@ public class ConvertToDataValueObjectModel {
if (getFullMap) { if (getFullMap) {
Set<String> keySet = document.keySet(); Set<String> keySet = document.keySet();
LinkedHashMap<String, String> documentAsMap = new LinkedHashMap<String, String>(keySet.size()); LinkedHashMap<String, Object> documentAsMap = new LinkedHashMap<String, Object>(keySet.size());
for (String key : keySet) { for (String key : keySet) {
// documentAsMap.put(key, document.get(key)); // documentAsMap.put(key, document.get(key));
documentAsMap = fillMapValue(document, key, documentAsMap); documentAsMap = fillMapValue(document, key, documentAsMap);
@ -979,8 +979,8 @@ public class ConvertToDataValueObjectModel {
* @param documentAsMap the document as map * @param documentAsMap the document as map
* @return the linked hash map * @return the linked hash map
*/ */
public static LinkedHashMap<String, String> fillMapValue(Document document, String key, public static LinkedHashMap<String, Object> fillMapValue(Document document, String key,
LinkedHashMap<String, String> documentAsMap) { LinkedHashMap<String, Object> documentAsMap) {
Object value = document.get(key); Object value = document.get(key);
String keyLower = key.toLowerCase(); 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; return documentAsMap;
} }

View File

@ -10,7 +10,7 @@ public class DocumentDV implements Serializable {
* *
*/ */
private static final long serialVersionUID = 4978517506036855883L; private static final long serialVersionUID = 4978517506036855883L;
protected LinkedHashMap<String, String> documentAsMap; protected LinkedHashMap<String, Object> documentAsMap;
private String documentAsJSON; private String documentAsJSON;
private ConfigurationDV<?> configuration; private ConfigurationDV<?> configuration;
@ -19,11 +19,11 @@ public class DocumentDV implements Serializable {
public DocumentDV() { public DocumentDV() {
} }
public LinkedHashMap<String, String> getDocumentAsMap() { public LinkedHashMap<String, Object> getDocumentAsMap() {
return documentAsMap; return documentAsMap;
} }
public Entry<String, String> getFirstEntryOfMap() { public Entry<String, Object> getFirstEntryOfMap() {
if (documentAsMap != null && documentAsMap.size() >= 1) { if (documentAsMap != null && documentAsMap.size() >= 1) {
return documentAsMap.entrySet().iterator().next(); return documentAsMap.entrySet().iterator().next();
} }
@ -43,7 +43,7 @@ public class DocumentDV implements Serializable {
return documentAsJSON; return documentAsJSON;
} }
public void setDocumentAsMap(LinkedHashMap<String, String> documentAsMap) { public void setDocumentAsMap(LinkedHashMap<String, Object> documentAsMap) {
this.documentAsMap = documentAsMap; this.documentAsMap = documentAsMap;
} }

View File

@ -49,9 +49,9 @@ public class ResultDocumentDV extends DocumentDV implements Serializable {
public void addItemToMap(String property, Object value) { public void addItemToMap(String property, Object value) {
if (documentAsMap == null) if (documentAsMap == null)
documentAsMap = new LinkedHashMap<String, String>(); documentAsMap = new LinkedHashMap<String, Object>();
documentAsMap.put(property, value!=null?value.toString():null); documentAsMap.put(property, value);
} }
public BasicLifecycleInformationDV getLifecycleInfo() { public BasicLifecycleInformationDV getLifecycleInfo() {

View File

@ -80,7 +80,7 @@ public class Project_Tests {
ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder); ProjectDV projectDV = ConvertToDataValueObjectModel.toProjectDV(project, projectBuilder);
System.out.println(projectDV); System.out.println(projectDV);
LinkedHashMap<String, String> theMap = projectDV.getTheDocument().getDocumentAsMap(); LinkedHashMap<String, Object> theMap = projectDV.getTheDocument().getDocumentAsMap();
for (String key : theMap.keySet()) { for (String key : theMap.keySet()) {
Object theValue = theMap.get(key); Object theValue = theMap.get(key);
System.out.println("The key: " + key + " has value: " + theValue); System.out.println("The key: " + key + " has value: " + theValue);