Improved and optimized set and list management
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@147138 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
583c63797a
commit
bcd0d7c457
|
@ -61,7 +61,6 @@ import com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeType;
|
||||
import com.orientechnologies.orient.core.db.record.OTrackedList;
|
||||
import com.orientechnologies.orient.core.metadata.OMetadata;
|
||||
import com.orientechnologies.orient.core.metadata.schema.OClass;
|
||||
import com.orientechnologies.orient.core.metadata.schema.OProperty;
|
||||
|
@ -635,16 +634,19 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
return EmbeddedMangement.getEmbeddedType(value);
|
||||
|
||||
case ARRAY:
|
||||
List<Object> array = new ArrayList<>();
|
||||
//ODocument oDocument = new ODocument();
|
||||
//return oDocument.fromJSON("{ \"ARRAY\" : " + value.toString() + "}");
|
||||
|
||||
List<Object> list = new ArrayList<Object>();
|
||||
Iterator<JsonNode> arrayElement = value.elements();
|
||||
while (arrayElement.hasNext()) {
|
||||
JsonNode arrayNode = arrayElement.next();
|
||||
Object objectNode = getObjectFromElement(arrayNode);
|
||||
if (objectNode != null) {
|
||||
array.add(objectNode);
|
||||
list.add(objectNode);
|
||||
}
|
||||
}
|
||||
return array;
|
||||
return list;
|
||||
|
||||
case BINARY:
|
||||
break;
|
||||
|
@ -767,7 +769,12 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
set = true;
|
||||
}
|
||||
|
||||
if(object instanceof ArrayList){
|
||||
if(object instanceof Set){
|
||||
((OrientElement) element).setProperty(key, object, OType.EMBEDDEDSET);
|
||||
set = true;
|
||||
}
|
||||
|
||||
if(object instanceof List){
|
||||
((OrientElement) element).setProperty(key, object, OType.EMBEDDEDLIST);
|
||||
set = true;
|
||||
}
|
||||
|
@ -854,11 +861,10 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
return dateFormat.format((Date) object);
|
||||
}
|
||||
|
||||
if(object instanceof OTrackedList){
|
||||
OTrackedList<?> oTrackedList = (OTrackedList<?>) object;
|
||||
|
||||
if(object instanceof Collection){
|
||||
Collection<?> collection = (Collection<?>) object;
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for(Object o : oTrackedList){
|
||||
for(Object o : collection){
|
||||
Object obj = getPropertyForJson("PLACEHOLDER", o);
|
||||
jsonArray.put(obj);
|
||||
}
|
||||
|
@ -866,17 +872,6 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
|
|||
return jsonArray;
|
||||
}
|
||||
|
||||
if(object instanceof ArrayList){
|
||||
@SuppressWarnings("rawtypes")
|
||||
ArrayList arrayList = (ArrayList) object;
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
for(Object o : arrayList){
|
||||
Object obj = getPropertyForJson("PLACEHOLDER", o);
|
||||
jsonArray.put(obj);
|
||||
}
|
||||
|
||||
return jsonArray;
|
||||
}
|
||||
|
||||
return object.toString();
|
||||
|
||||
|
|
|
@ -96,8 +96,21 @@ public class ERManagementTest extends ScopedTest {
|
|||
|
||||
ServiceStateFacet serviceStateFacet = new ServiceStateFacetImpl();
|
||||
serviceStateFacet.setValue("ready");
|
||||
|
||||
List<Map<String, String>> list = new ArrayList<>();
|
||||
Map<String, String> map1 = new HashMap<String, String>();
|
||||
map1.put("Key1", "Value1");
|
||||
Map<String, String> map2 = new HashMap<String, String>();
|
||||
map2.put("Key2", "Value2");
|
||||
list.add(map1);
|
||||
list.add(map2);
|
||||
|
||||
serviceStateFacet.setAdditionalProperty("MY-TEST", list);
|
||||
|
||||
eService.addFacet(serviceStateFacet);
|
||||
|
||||
|
||||
|
||||
LicenseFacet licenseFacet = new LicenseFacetImpl();
|
||||
licenseFacet.setName("EUPL");
|
||||
licenseFacet
|
||||
|
|
Loading…
Reference in New Issue