From dbbdd206d5ec6d3e933d67e1c7921d012bb711c6 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Wed, 17 Feb 2021 15:52:09 +0100 Subject: [PATCH] Fixed test conrner case --- .../instances/base/ElementManagement.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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 32bcf8d..1f178a3 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,10 +89,18 @@ 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; + public void cleanCachedSerialization() { + this.self = null; + this.complete = null; + } + public UUID getUUID() { return uuid; } @@ -154,6 +162,7 @@ public abstract class ElementManagement { ObjectMapper mapper = new ObjectMapper(); try { this.jsonNode = mapper.readTree(json); + cleanCachedSerialization(); } catch(IOException e) { throw new ResourceRegistryException(e); } @@ -293,7 +302,10 @@ public abstract class ElementManagement { public JsonNode serializeSelfAsJsonNode() throws ResourceRegistryException { try { - return createSelfJsonNode(); + if(self==null) { + self = createSelfJsonNode(); + } + return self.deepCopy(); } catch(Exception e) { throw new ResourceRegistryException(e); } @@ -303,7 +315,10 @@ public abstract class ElementManagement { public JsonNode serializeAsJsonNode() throws ResourceRegistryException { try { - return createCompleteJsonNode(); + if(complete==null) { + complete = createCompleteJsonNode(); + } + return complete; } catch(Exception e) { throw new ResourceRegistryException(e); }