diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagement.java index c270302..080255e 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagement.java @@ -39,7 +39,6 @@ import org.gcube.informationsystem.resourceregistry.types.properties.PropertyTyp import org.gcube.informationsystem.resourceregistry.types.relations.ConsistsOfTypeDefinitionManagement; import org.gcube.informationsystem.resourceregistry.types.relations.IsRelatedToTypeDefinitionManagement; import org.gcube.informationsystem.types.PropertyTypeName; -import org.gcube.informationsystem.types.PropertyTypeName.BaseType; import org.gcube.informationsystem.types.TypeMapper; import org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl; import org.gcube.informationsystem.types.reference.Type; @@ -422,27 +421,29 @@ public class SchemaManagement { op.setReadonly(propertyDefinition.isReadonly()); op.setRegexp(propertyDefinition.getRegexp()); - if(propertyTypeName.getGenericBaseType()!=null) { - if(propertyTypeName.getGenericBaseType().ordinal() >= BaseType.PROPERTY.ordinal()) { - if(propertyTypeName.getGenericBaseType()!=null) { - OType linkedOType = OrientDBTypeMapping.getOTypeByBaseType(propertyTypeName.getGenericBaseType()); - op.setLinkedType(OType.getById(Integer.valueOf(linkedOType.ordinal()).byteValue())); - }else if(propertyTypeName.getGenericClassName()!=null){ - - OClass linkedClass = getOClass(oSchema, propertyTypeName.getGenericClassName()); - - if(linkedClass == null) { - logger.trace("Class {} not found.", propertyTypeName.getGenericClassName()); - throw new Exception("Class " + propertyTypeName.getGenericClassName() + " not found."); - } - - if(linkedClass.isEdgeType() || linkedClass.isVertexType()) { - throw new Exception("A PropertyType cannot be an Entity type or a Relation type"); - } - - op.setLinkedClass(linkedClass); + if (propertyTypeName.isGenericType()) { + if (propertyTypeName.getGenericClassName() != null) { + + OClass linkedClass = getOClass(oSchema, propertyTypeName.getGenericClassName()); + + if (linkedClass == null) { + logger.trace("Class {} not found.", propertyTypeName.getGenericClassName()); + throw new Exception( + "Class " + propertyTypeName.getGenericClassName() + " not found."); } + + if (linkedClass.isEdgeType() || linkedClass.isVertexType()) { + throw new Exception( + "A PropertyType cannot be an Entity type or a Relation type"); + } + + op.setLinkedClass(linkedClass); + } else { + OType linkedOType = OrientDBTypeMapping + .getOTypeByBaseType(propertyTypeName.getGenericBaseType()); + op.setLinkedType(OType.getById(Integer.valueOf(linkedOType.ordinal()).byteValue())); } + } } } @@ -621,26 +622,26 @@ public class SchemaManagement { op.setReadonly(newPropertyDefinition.isReadonly()); op.setRegexp(newPropertyDefinition.getRegexp()); - if(newPropertyTypeName.getGenericBaseType()!=null) { - if(newPropertyTypeName.getGenericBaseType().ordinal() >= BaseType.PROPERTY.ordinal()) { - if(newPropertyTypeName.getGenericBaseType()!=null) { - OType linkedOType = OrientDBTypeMapping.getOTypeByBaseType(newPropertyTypeName.getGenericBaseType()); - op.setLinkedType(OType.getById(Integer.valueOf(linkedOType.ordinal()).byteValue())); - }else if(newPropertyTypeName.getGenericClassName()!=null){ - - OClass linkedClass = getOClass(oSchema, newPropertyTypeName.getGenericClassName()); - - if(linkedClass == null) { - logger.trace("Class {} not found.", newPropertyTypeName.getGenericClassName()); - throw new Exception("Class " + newPropertyTypeName.getGenericClassName() + " not found."); - } - - if(linkedClass.isEdgeType() || linkedClass.isVertexType()) { - throw new Exception("A PropertyType cannot be an Entity type or a Relation type"); - } - - op.setLinkedClass(linkedClass); + if (newPropertyTypeName.isGenericType()) { + if (newPropertyTypeName.getGenericClassName() != null) { + + OClass linkedClass = getOClass(oSchema, newPropertyTypeName.getGenericClassName()); + + if (linkedClass == null) { + logger.trace("Class {} not found.", newPropertyTypeName.getGenericClassName()); + throw new Exception( + "Class " + newPropertyTypeName.getGenericClassName() + " not found."); } + + if (linkedClass.isEdgeType() || linkedClass.isVertexType()) { + throw new Exception( + "A PropertyType cannot be an Entity type or a Relation type"); + } + + op.setLinkedClass(linkedClass); + } else { + OType linkedOType = OrientDBTypeMapping.getOTypeByBaseType(newPropertyTypeName.getGenericBaseType()); + op.setLinkedType(OType.getById(Integer.valueOf(linkedOType.ordinal()).byteValue())); } }