diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java index 22e03ef..515298f 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java @@ -174,7 +174,7 @@ public class ContextManagement extends EntityElementManagement { try { IsParentOfManagement isParentOfManagement = new IsParentOfManagement(oDatabaseDocument); isParentOfManagement.setElement(edge); - JsonNode isParentOf = isParentOfManagement.serializeAsJsonNode(); + JsonNode isParentOf = isParentOfManagement.createCompleteJsonNode(true, false); if(isParentOf!=null) { ((ObjectNode) context).replace(Context.PARENT_PROPERTY, isParentOf); } @@ -405,7 +405,7 @@ public class ContextManagement extends EntityElementManagement { ContextManagement contextManagement = new ContextManagement(); contextManagement.setElement((OVertex) vertex); try { - JsonNode jsonObject = contextManagement.createCompleteJsonNode(); + JsonNode jsonObject = contextManagement.serializeAsJsonNode(); arrayNode.add(jsonObject); } catch(ResourceRegistryException e) { logger.error("Unable to correctly serialize {}. It will be excluded from results. {}", diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java index 78a8596..32bcf8d 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java @@ -89,11 +89,7 @@ public abstract class ElementManagement { protected JsonNode jsonNode; protected OClass oClass; protected String elementType; - - protected JsonNode self; - protected JsonNode complete; - - + protected El element; protected boolean reload; @@ -297,10 +293,7 @@ public abstract class ElementManagement { public JsonNode serializeSelfAsJsonNode() throws ResourceRegistryException { try { - if(self==null) { - self = createSelfJsonNode(); - } - return self.deepCopy(); + return createSelfJsonNode(); } catch(Exception e) { throw new ResourceRegistryException(e); } @@ -310,10 +303,7 @@ public abstract class ElementManagement { public JsonNode serializeAsJsonNode() throws ResourceRegistryException { try { - if(complete==null) { - complete = createCompleteJsonNode(); - } - return complete; + return createCompleteJsonNode(); } catch(Exception e) { throw new ResourceRegistryException(e); } @@ -416,8 +406,6 @@ public abstract class ElementManagement { if(uuid == null) { throw new NotFoundException("null UUID does not allow to retrieve the Element"); } - - return Utility.getElementByUUID(oDatabaseDocument, elementType == null ? accessType.getName() : elementType, uuid, elementClass); } catch(NotFoundException e) { @@ -463,9 +451,7 @@ public abstract class ElementManagement { } } } - - public boolean exists() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal(); try { @@ -682,8 +668,6 @@ public abstract class ElementManagement { if(current!=null) { current.activateOnCurrentThread(); - - } } } @@ -730,8 +714,6 @@ public abstract class ElementManagement { public ArrayNode getContextsAsArrayNode(ObjectMapper objectMapper) throws NotFoundException, ContextException, ResourceRegistryException { try { Set contexts = getContextsSet(); - - ArrayNode arrayNode = objectMapper.createArrayNode(); for(String contextUUID : contexts) { arrayNode.add(contextUUID); @@ -784,8 +766,6 @@ public abstract class ElementManagement { return value.asBoolean(); case NULL: - - break; case NUMBER: @@ -831,9 +811,7 @@ public abstract class ElementManagement { } Iterator> fields = jsonNode.fields(); - - OUTER_WHILE: while(fields.hasNext()) { Entry entry = fields.next(); @@ -991,9 +969,7 @@ public abstract class ElementManagement { if(object instanceof Collection) { Collection collection = (Collection) object; ArrayNode arrayNode = objectMapper.createArrayNode(); - - for(Object o : collection) { Object obj = getPropertyForJson("PLACEHOLDER", o);