Fixed serialization of unknown properties
This commit is contained in:
parent
8ac4511bde
commit
dc8595d13e
|
@ -25,6 +25,7 @@ import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import org.gcube.com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import org.gcube.com.fasterxml.jackson.databind.exc.InvalidTypeIdException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.JsonNodeType;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.TextNode;
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
|
@ -32,6 +33,7 @@ import org.gcube.informationsystem.base.reference.Element;
|
|||
import org.gcube.informationsystem.discovery.Discovery;
|
||||
import org.gcube.informationsystem.discovery.knowledge.Knowledge;
|
||||
import org.gcube.informationsystem.model.reference.ModelElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -207,24 +209,26 @@ public abstract class ElementMapper {
|
|||
ArrayNode arrayNode = (ArrayNode) objectNode.get(ModelElement.SUPERTYPES_PROPERTY);
|
||||
|
||||
String candidatedSupertype = null;
|
||||
for(int i = 0; i < arrayNode.size(); i++) {
|
||||
String superType = arrayNode.get(i).asText();
|
||||
if(knownTypes.containsKey(superType)) {
|
||||
candidatedSupertype = superType;
|
||||
try {
|
||||
// Checking if it is one of the base type. In some cases we need to use dummy
|
||||
// implementation
|
||||
AccessType accessType = AccessType.getAccessType(superType);
|
||||
// It is one of the BaseType.
|
||||
// Looking if we need to set the dummy implementation class
|
||||
if(accessType.getDummyImplementationClass()!=null) {
|
||||
// This should not happen because the type has been assigned already to the dummy class.
|
||||
candidatedSupertype = accessType.getDummyImplementationClass().getSimpleName();
|
||||
if(arrayNode!=null) {
|
||||
for(int i = 0; i < arrayNode.size(); i++) {
|
||||
String superType = arrayNode.get(i).asText();
|
||||
if(knownTypes.containsKey(superType)) {
|
||||
candidatedSupertype = superType;
|
||||
try {
|
||||
// Checking if it is one of the base type. In some cases we need to use dummy
|
||||
// implementation
|
||||
AccessType accessType = AccessType.getAccessType(superType);
|
||||
// It is one of the BaseType.
|
||||
// Looking if we need to set the dummy implementation class
|
||||
if(accessType.getDummyImplementationClass()!=null) {
|
||||
// This should not happen because the type has been assigned already to the dummy class.
|
||||
candidatedSupertype = accessType.getDummyImplementationClass().getSimpleName();
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
// can continue discovery
|
||||
}
|
||||
} catch(Exception ex) {
|
||||
// can continue discovery
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,7 +247,17 @@ public abstract class ElementMapper {
|
|||
}
|
||||
|
||||
protected static JsonNode analizeTypes(ObjectNode objectNode) {
|
||||
String cls = objectNode.get(Element.TYPE_PROPERTY).asText();
|
||||
String cls = null;
|
||||
|
||||
JsonNode typeJN = objectNode.get(Element.TYPE_PROPERTY);
|
||||
if(typeJN !=null) {
|
||||
cls = objectNode.get(Element.TYPE_PROPERTY).asText();
|
||||
}
|
||||
|
||||
if(cls==null && objectNode.getNodeType()==JsonNodeType.OBJECT) {
|
||||
cls = Property.NAME;
|
||||
}
|
||||
|
||||
if(!knownTypes.containsKey(cls)) {
|
||||
objectNode = setTypeToBestAvailable(objectNode);
|
||||
}
|
||||
|
|
|
@ -33,7 +33,11 @@ public class UUIDUtility {
|
|||
}
|
||||
|
||||
public static String getUUIDAsString(JsonNode jsonNode){
|
||||
return getUUID(jsonNode).toString();
|
||||
UUID uuid = getUUID(jsonNode);
|
||||
if(uuid!=null) {
|
||||
return uuid.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getUUIDAsString(String json) throws JsonProcessingException, IOException{
|
||||
|
|
Loading…
Reference in New Issue