Fixed code

This commit is contained in:
Luca Frosini 2021-01-20 17:04:29 +01:00
parent 1ccefd44e2
commit 73e1fee53b
1 changed files with 40 additions and 39 deletions

View File

@ -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){
if (propertyTypeName.isGenericType()) {
if (propertyTypeName.getGenericClassName() != null) {
OClass linkedClass = getOClass(oSchema, propertyTypeName.getGenericClassName());
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 (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){
if (newPropertyTypeName.isGenericType()) {
if (newPropertyTypeName.getGenericClassName() != null) {
OClass linkedClass = getOClass(oSchema, newPropertyTypeName.getGenericClassName());
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 (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()));
}
}