Fixed test conrner case

This commit is contained in:
Luca Frosini 2021-02-17 15:52:09 +01:00
parent a553b9cd8d
commit dbbdd206d5
1 changed files with 18 additions and 3 deletions

View File

@ -89,10 +89,18 @@ public abstract class ElementManagement<El extends OElement> {
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<El extends OElement> {
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<El extends OElement> {
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<El extends OElement> {
public JsonNode serializeAsJsonNode() throws ResourceRegistryException {
try {
return createCompleteJsonNode();
if(complete==null) {
complete = createCompleteJsonNode();
}
return complete;
} catch(Exception e) {
throw new ResourceRegistryException(e);
}