Fixing issue: #24432 Using LinkedHashMap<String, String> instead of
LinkedHashMap<String, Object>
This commit is contained in:
parent
9f38eac98e
commit
c88d71c9d2
|
@ -6,7 +6,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
|
|
||||||
## [v2.0.1] - 2022-01-12
|
## [v2.0.1] - 2022-01-12
|
||||||
|
|
||||||
|
#### Bug fixes
|
||||||
|
|
||||||
- [#24263] Fixing JSON library v20090211
|
- [#24263] Fixing JSON library v20090211
|
||||||
|
- [#24432] Fixing serialization issue using LinkedHashMap<String, String> instead of LinkedHashMap<String, Object>
|
||||||
|
|
||||||
## [v2.0.0] - 2022-11-17
|
## [v2.0.0] - 2022-11-17
|
||||||
|
|
||||||
|
|
|
@ -867,7 +867,7 @@ public class ConvertToDataValueObjectModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (listDocumentKeys != null && !getFullMap) {
|
if (listDocumentKeys != null && !getFullMap) {
|
||||||
LinkedHashMap<String, Object> documentAsMap = new LinkedHashMap<String, Object>(listDocumentKeys.size());
|
LinkedHashMap<String, String> documentAsMap = new LinkedHashMap<String, String>(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, Object> documentAsMap = new LinkedHashMap<String, Object>(keySet.size());
|
LinkedHashMap<String, String> documentAsMap = new LinkedHashMap<String, String>(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, Object> fillMapValue(Document document, String key,
|
public static LinkedHashMap<String, String> fillMapValue(Document document, String key,
|
||||||
LinkedHashMap<String, Object> documentAsMap) {
|
LinkedHashMap<String, String> 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);
|
documentAsMap.put(key, value!=null?value.toString():null);
|
||||||
return documentAsMap;
|
return documentAsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ public class DocumentDV implements Serializable {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 4978517506036855883L;
|
private static final long serialVersionUID = 4978517506036855883L;
|
||||||
protected LinkedHashMap<String, Object> documentAsMap;
|
protected LinkedHashMap<String, String> 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, Object> getDocumentAsMap() {
|
public LinkedHashMap<String, String> getDocumentAsMap() {
|
||||||
return documentAsMap;
|
return documentAsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry<String, Object> getFirstEntryOfMap() {
|
public Entry<String, String> 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, Object> documentAsMap) {
|
public void setDocumentAsMap(LinkedHashMap<String, String> documentAsMap) {
|
||||||
this.documentAsMap = documentAsMap;
|
this.documentAsMap = documentAsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,9 +47,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, Object>();
|
documentAsMap = new LinkedHashMap<String, String>();
|
||||||
|
|
||||||
documentAsMap.put(property, value);
|
documentAsMap.put(property, value!=null?value.toString():null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BasicLifecycleInformationDV getLifecycleInfo() {
|
public BasicLifecycleInformationDV getLifecycleInfo() {
|
||||||
|
|
|
@ -2,6 +2,6 @@ package org.gcube.application.geoportalcommon.shared.geoportal.view;
|
||||||
|
|
||||||
public interface CheckEmpty {
|
public interface CheckEmpty {
|
||||||
|
|
||||||
public boolean isEmpty();
|
public Boolean isEmpty();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class SectionView implements Serializable, CheckEmpty {
|
||||||
* @return true, if is empty
|
* @return true, if is empty
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public Boolean isEmpty() {
|
||||||
if (listSubDocuments == null)
|
if (listSubDocuments == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ public class SectionView implements Serializable, CheckEmpty {
|
||||||
*
|
*
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
*/
|
*/
|
||||||
public boolean hasSpatialLayers() {
|
public Boolean hasSpatialLayers() {
|
||||||
if (listSubDocuments == null)
|
if (listSubDocuments == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class SubDocumentView implements Serializable, CheckEmpty {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isEmpty() {
|
public Boolean isEmpty() {
|
||||||
|
|
||||||
if (metadataAsJSON != null && !metadataAsJSON.isEmpty())
|
if (metadataAsJSON != null && !metadataAsJSON.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.gcube.application.geoportalcommon.util;
|
package org.gcube.application.geoportalcommon.util;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
@ -82,6 +83,12 @@ public class DateUtils {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new SimpleDateFormat("yyy-MM-dd").parse(date);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// TODO: handle exception
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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, Object> theMap = projectDV.getTheDocument().getDocumentAsMap();
|
LinkedHashMap<String, String> 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);
|
||||||
|
|
Loading…
Reference in New Issue