Fixing serilization

This commit is contained in:
Luca Frosini 2021-02-17 15:16:25 +01:00
parent 74be68d2b6
commit 2597379ad4
2 changed files with 5 additions and 29 deletions

View File

@ -174,7 +174,7 @@ public class ContextManagement extends EntityElementManagement<Context> {
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<Context> {
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. {}",

View File

@ -89,11 +89,7 @@ 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;
@ -297,10 +293,7 @@ public abstract class ElementManagement<El extends OElement> {
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<El extends OElement> {
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<El extends OElement> {
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<El extends OElement> {
}
}
}
public boolean exists() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
@ -682,8 +668,6 @@ public abstract class ElementManagement<El extends OElement> {
if(current!=null) {
current.activateOnCurrentThread();
}
}
}
@ -730,8 +714,6 @@ public abstract class ElementManagement<El extends OElement> {
public ArrayNode getContextsAsArrayNode(ObjectMapper objectMapper) throws NotFoundException, ContextException, ResourceRegistryException {
try {
Set<String> contexts = getContextsSet();
ArrayNode arrayNode = objectMapper.createArrayNode();
for(String contextUUID : contexts) {
arrayNode.add(contextUUID);
@ -784,8 +766,6 @@ public abstract class ElementManagement<El extends OElement> {
return value.asBoolean();
case NULL:
break;
case NUMBER:
@ -831,9 +811,7 @@ public abstract class ElementManagement<El extends OElement> {
}
Iterator<Entry<String,JsonNode>> fields = jsonNode.fields();
OUTER_WHILE: while(fields.hasNext()) {
Entry<String,JsonNode> entry = fields.next();
@ -991,9 +969,7 @@ public abstract class ElementManagement<El extends OElement> {
if(object instanceof Collection) {
Collection<?> collection = (Collection<?>) object;
ArrayNode arrayNode = objectMapper.createArrayNode();
for(Object o : collection) {
Object obj = getPropertyForJson("PLACEHOLDER", o);