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.SerializationFeature;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.exc.InvalidTypeIdException;
|
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.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.ObjectNode;
|
||||||
import org.gcube.com.fasterxml.jackson.databind.node.TextNode;
|
import org.gcube.com.fasterxml.jackson.databind.node.TextNode;
|
||||||
import org.gcube.informationsystem.base.reference.AccessType;
|
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.Discovery;
|
||||||
import org.gcube.informationsystem.discovery.knowledge.Knowledge;
|
import org.gcube.informationsystem.discovery.knowledge.Knowledge;
|
||||||
import org.gcube.informationsystem.model.reference.ModelElement;
|
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.TypeMapper;
|
||||||
import org.gcube.informationsystem.types.reference.Type;
|
import org.gcube.informationsystem.types.reference.Type;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -207,24 +209,26 @@ public abstract class ElementMapper {
|
||||||
ArrayNode arrayNode = (ArrayNode) objectNode.get(ModelElement.SUPERTYPES_PROPERTY);
|
ArrayNode arrayNode = (ArrayNode) objectNode.get(ModelElement.SUPERTYPES_PROPERTY);
|
||||||
|
|
||||||
String candidatedSupertype = null;
|
String candidatedSupertype = null;
|
||||||
for(int i = 0; i < arrayNode.size(); i++) {
|
if(arrayNode!=null) {
|
||||||
String superType = arrayNode.get(i).asText();
|
for(int i = 0; i < arrayNode.size(); i++) {
|
||||||
if(knownTypes.containsKey(superType)) {
|
String superType = arrayNode.get(i).asText();
|
||||||
candidatedSupertype = superType;
|
if(knownTypes.containsKey(superType)) {
|
||||||
try {
|
candidatedSupertype = superType;
|
||||||
// Checking if it is one of the base type. In some cases we need to use dummy
|
try {
|
||||||
// implementation
|
// Checking if it is one of the base type. In some cases we need to use dummy
|
||||||
AccessType accessType = AccessType.getAccessType(superType);
|
// implementation
|
||||||
// It is one of the BaseType.
|
AccessType accessType = AccessType.getAccessType(superType);
|
||||||
// Looking if we need to set the dummy implementation class
|
// It is one of the BaseType.
|
||||||
if(accessType.getDummyImplementationClass()!=null) {
|
// Looking if we need to set the dummy implementation class
|
||||||
// This should not happen because the type has been assigned already to the dummy class.
|
if(accessType.getDummyImplementationClass()!=null) {
|
||||||
candidatedSupertype = accessType.getDummyImplementationClass().getSimpleName();
|
// 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) {
|
break;
|
||||||
// can continue discovery
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,7 +247,17 @@ public abstract class ElementMapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static JsonNode analizeTypes(ObjectNode objectNode) {
|
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)) {
|
if(!knownTypes.containsKey(cls)) {
|
||||||
objectNode = setTypeToBestAvailable(objectNode);
|
objectNode = setTypeToBestAvailable(objectNode);
|
||||||
}
|
}
|
||||||
|
@ -267,7 +281,7 @@ public abstract class ElementMapper {
|
||||||
}
|
}
|
||||||
return objectNode;
|
return objectNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static ArrayNode analizeTypes(ArrayNode arrayNode) {
|
protected static ArrayNode analizeTypes(ArrayNode arrayNode) {
|
||||||
ArrayNode ret = mapper.createArrayNode();
|
ArrayNode ret = mapper.createArrayNode();
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,11 @@ public class UUIDUtility {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getUUIDAsString(JsonNode jsonNode){
|
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{
|
public static String getUUIDAsString(String json) throws JsonProcessingException, IOException{
|
||||||
|
|
Loading…
Reference in New Issue