diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ContextUtility.java b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ContextUtility.java index 98160e7..555afa9 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ContextUtility.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ContextUtility.java @@ -19,7 +19,7 @@ import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecur import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode; import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.resourceregistry.utils.Utility; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -224,7 +224,7 @@ public class ContextUtility { } OResult oResult = resultSet.next(); - OVertex context = ERManagement.getElementFromOptional(oResult.getVertex()); + OVertex context = ElementManagement.getElementFromOptional(oResult.getVertex()); logger.trace("Context Representing Vertex : {}", Utility.toJsonString(context, true)); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java index 4a7f3e5..226dd26 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/entities/ContextManagement.java @@ -20,7 +20,7 @@ import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.relations.IsParentOfManagement; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.resourceregistry.instances.base.entities.BaseEntityManagement; import org.gcube.informationsystem.resourceregistry.utils.Utility; import org.slf4j.Logger; @@ -320,7 +320,7 @@ public class ContextManagement extends BaseEntityManagement { move(newParentContextManagement, false); } - element = (OVertex) ERManagement.updateProperties(oClass, getElement(), jsonNode, ignoreKeys, + element = (OVertex) ElementManagement.updateProperties(oClass, getElement(), jsonNode, ignoreKeys, ignoreStartWithKeys); ContextUtility.getInstance().removeFromCache(uuid, (nameChanged && !parentChanged)); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java index 79df916..fd10a51 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/DatabaseEnvironment.java @@ -15,10 +15,10 @@ import java.util.UUID; import org.gcube.common.encryption.SymmetricKey; import org.gcube.informationsystem.base.reference.AccessType; import org.gcube.informationsystem.base.reference.ISConstants; -import org.gcube.informationsystem.base.reference.ISManageable; -import org.gcube.informationsystem.base.reference.entities.BaseEntity; -import org.gcube.informationsystem.base.reference.properties.BaseProperty; -import org.gcube.informationsystem.base.reference.relations.BaseRelation; +import org.gcube.informationsystem.base.reference.Element; +import org.gcube.informationsystem.base.reference.entities.EntityElement; +import org.gcube.informationsystem.base.reference.properties.PropertyElement; +import org.gcube.informationsystem.base.reference.relations.RelationElement; import org.gcube.informationsystem.model.reference.properties.Header; import org.gcube.informationsystem.model.reference.properties.Property; import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; @@ -26,19 +26,19 @@ import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecur import org.gcube.informationsystem.resourceregistry.contexts.security.ContextSecurityContext; import org.gcube.informationsystem.resourceregistry.contexts.security.SchemaSecurityContext; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.resourceregistry.types.properties.PropertyTypeDefinitionManagement; import org.gcube.informationsystem.types.TypeBinder; import org.gcube.informationsystem.types.reference.TypeDefinition; -import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition; -import org.gcube.informationsystem.types.reference.entities.FacetTypeDefinition; -import org.gcube.informationsystem.types.reference.entities.ResourceTypeDefinition; +import org.gcube.informationsystem.types.reference.entities.EntityType; +import org.gcube.informationsystem.types.reference.entities.FacetType; +import org.gcube.informationsystem.types.reference.entities.ResourceType; import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; -import org.gcube.informationsystem.types.reference.properties.PropertyTypeDefinition; -import org.gcube.informationsystem.types.reference.properties.ResourceEntryDefinition; -import org.gcube.informationsystem.types.reference.relations.ConsistsOfTypeDefinition; -import org.gcube.informationsystem.types.reference.relations.IsRelatedToTypeDefinition; -import org.gcube.informationsystem.types.reference.relations.RelationTypeDefinition; +import org.gcube.informationsystem.types.reference.properties.PropertyType; +import org.gcube.informationsystem.types.reference.properties.LinkedEntity; +import org.gcube.informationsystem.types.reference.relations.ConsistsOfType; +import org.gcube.informationsystem.types.reference.relations.IsRelatedToType; +import org.gcube.informationsystem.types.reference.relations.RelationType; import org.gcube.informationsystem.utils.discovery.ISMDiscovery; import org.gcube.informationsystem.utils.discovery.RegistrationProvider; import org.gcube.informationsystem.utils.discovery.SchemaAction; @@ -228,39 +228,39 @@ public class DatabaseEnvironment { schemaSecurityContext.create(); - List> definitionToBeCreated = new ArrayList<>(); - definitionToBeCreated.add(BaseProperty.class); + List> definitionToBeCreated = new ArrayList<>(); + definitionToBeCreated.add(PropertyElement.class); definitionToBeCreated.add(Property.class); definitionToBeCreated.add(Header.class); definitionToBeCreated.add(PropertyDefinition.class); - definitionToBeCreated.add(PropertyTypeDefinition.class); - definitionToBeCreated.add(ResourceEntryDefinition.class); - definitionToBeCreated.add(BaseEntity.class); - definitionToBeCreated.add(EntityTypeDefinition.class); - definitionToBeCreated.add(FacetTypeDefinition.class); - definitionToBeCreated.add(ResourceTypeDefinition.class); - definitionToBeCreated.add(BaseRelation.class); - definitionToBeCreated.add(RelationTypeDefinition.class); - definitionToBeCreated.add(IsRelatedToTypeDefinition.class); - definitionToBeCreated.add(ConsistsOfTypeDefinition.class); + definitionToBeCreated.add(PropertyType.class); + definitionToBeCreated.add(LinkedEntity.class); + definitionToBeCreated.add(EntityElement.class); + definitionToBeCreated.add(EntityType.class); + definitionToBeCreated.add(FacetType.class); + definitionToBeCreated.add(ResourceType.class); + definitionToBeCreated.add(RelationElement.class); + definitionToBeCreated.add(RelationType.class); + definitionToBeCreated.add(IsRelatedToType.class); + definitionToBeCreated.add(ConsistsOfType.class); SchemaAction schemaAction = new SchemaActionImpl(); - for(Class clz : definitionToBeCreated) { + for(Class clz : definitionToBeCreated) { - if(BaseProperty.class.isAssignableFrom(clz)) { - schemaAction.managePropertyClass((Class) clz); - } else if(BaseEntity.class.isAssignableFrom(clz)) { - schemaAction.manageEntityClass((Class) clz); - } else if(BaseRelation.class.isAssignableFrom(clz)) { - schemaAction.manageRelationClass((Class>) clz); + if(PropertyElement.class.isAssignableFrom(clz)) { + schemaAction.managePropertyClass((Class) clz); + } else if(EntityElement.class.isAssignableFrom(clz)) { + schemaAction.manageEntityClass((Class) clz); + } else if(RelationElement.class.isAssignableFrom(clz)) { + schemaAction.manageRelationClass((Class>) clz); } } - List> schemaToBeCreated = new ArrayList<>(); + List> schemaToBeCreated = new ArrayList<>(); schemaToBeCreated.add(Property.class); schemaToBeCreated.add(Header.class); - for(Class clz : schemaToBeCreated) { - ERManagement erManagement = new PropertyTypeDefinitionManagement(); + for(Class clz : schemaToBeCreated) { + ElementManagement erManagement = new PropertyTypeDefinitionManagement(); erManagement.setJson(TypeBinder.serializeType(clz)); erManagement.create(); } @@ -273,7 +273,7 @@ public class DatabaseEnvironment { AccessType[] accessTypes = AccessType.values(); for(AccessType accessType : accessTypes) { - Class clz = accessType.getTypeClass(); + Class clz = accessType.getTypeClass(); packages.add(clz.getPackage()); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/SchemaActionImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/SchemaActionImpl.java index 13e6cf7..54302bd 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/SchemaActionImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/dbinitialization/SchemaActionImpl.java @@ -1,9 +1,9 @@ package org.gcube.informationsystem.resourceregistry.dbinitialization; import org.gcube.informationsystem.base.reference.AccessType; -import org.gcube.informationsystem.base.reference.entities.BaseEntity; -import org.gcube.informationsystem.base.reference.properties.BaseProperty; -import org.gcube.informationsystem.base.reference.relations.BaseRelation; +import org.gcube.informationsystem.base.reference.entities.EntityElement; +import org.gcube.informationsystem.base.reference.properties.PropertyElement; +import org.gcube.informationsystem.base.reference.relations.RelationElement; import org.gcube.informationsystem.model.reference.entities.Facet; import org.gcube.informationsystem.model.reference.entities.Resource; import org.gcube.informationsystem.model.reference.properties.Header; @@ -25,7 +25,7 @@ public class SchemaActionImpl implements SchemaAction { private static Logger logger = LoggerFactory.getLogger(SchemaActionImpl.class); @Override - public > void manageRelationClass(Class r) + public > void manageRelationClass(Class r) throws Exception { try { SchemaManagementImpl schemaManagement = new SchemaManagementImpl(); @@ -37,18 +37,18 @@ public class SchemaActionImpl implements SchemaAction { } else if(IsRelatedTo.class.isAssignableFrom(r)) { schemaManagement.create(json, AccessType.IS_RELATED_TO); } else { - schemaManagement.create(json, AccessType.BASE_RELATION); + schemaManagement.create(json, AccessType.RELATION_ELEMENT); } } catch(SchemaAlreadyPresentException sape) { logger.warn("{} already exists. It will be ignored", TypeBinder.getType(r)); } catch(Exception ex) { - logger.error("Error creating schema for {} {}: {}", BaseRelation.NAME, r.getSimpleName(), ex.getMessage()); + logger.error("Error creating schema for {} {}: {}", RelationElement.NAME, r.getSimpleName(), ex.getMessage()); throw ex; } } @Override - public void manageEntityClass(Class e) throws Exception { + public void manageEntityClass(Class e) throws Exception { try { SchemaManagementImpl schemaManagement = new SchemaManagementImpl(); schemaManagement.setTypeName(TypeBinder.getType(e)); @@ -59,18 +59,18 @@ public class SchemaActionImpl implements SchemaAction { } else if(Resource.class.isAssignableFrom(e)) { schemaManagement.create(json, AccessType.RESOURCE); } else { - schemaManagement.create(json, AccessType.BASE_ENTITY); + schemaManagement.create(json, AccessType.ENTITY_ELEMENT); } } catch(SchemaAlreadyPresentException sape) { logger.warn("{} already exists. It will be ignored", TypeBinder.getType(e)); } catch(Exception ex) { - logger.error("Error creating schema for {} {}: {}", BaseEntity.NAME, e.getSimpleName(), ex.getMessage()); + logger.error("Error creating schema for {} {}: {}", EntityElement.NAME, e.getSimpleName(), ex.getMessage()); throw ex; } } @Override - public

void managePropertyClass(Class

p) throws Exception { + public

void managePropertyClass(Class

p) throws Exception { try { SchemaManagementImpl schemaManagement = new SchemaManagementImpl(); schemaManagement.setTypeName(TypeBinder.getType(p)); @@ -82,12 +82,12 @@ public class SchemaActionImpl implements SchemaAction { } schemaManagement.create(json, AccessType.PROPERTY); }else { - schemaManagement.create(json, AccessType.BASE_PROPERTY); + schemaManagement.create(json, AccessType.PROPERTY_ELEMENT); } } catch(SchemaAlreadyPresentException sape) { logger.warn("{} already exists. It will be ignored", TypeBinder.getType(p)); } catch(Exception ex) { - logger.error("Error creating schema for {} {}: {}", BaseProperty.NAME, p.getSimpleName(), ex.getMessage()); + logger.error("Error creating schema for {} {}: {}", PropertyElement.NAME, p.getSimpleName(), ex.getMessage()); throw ex; } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ERManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java similarity index 98% rename from src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ERManagement.java rename to src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java index e756409..f8b74cf 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ERManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagement.java @@ -19,7 +19,7 @@ import javax.activation.UnsupportedDataTypeException; import org.gcube.informationsystem.base.reference.AccessType; import org.gcube.informationsystem.base.reference.ER; -import org.gcube.informationsystem.base.reference.ISManageable; +import org.gcube.informationsystem.base.reference.Element; import org.gcube.informationsystem.context.reference.entities.Context; import org.gcube.informationsystem.model.reference.properties.Header; import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException; @@ -58,11 +58,11 @@ import com.tinkerpop.blueprints.util.StringFactory; /** * @author Luca Frosini (ISTI - CNR) */ -public abstract class ERManagement { +public abstract class ElementManagement { protected Logger logger = LoggerFactory.getLogger(this.getClass()); - private static Logger staticLogger = LoggerFactory.getLogger(ERManagement.class); + private static Logger staticLogger = LoggerFactory.getLogger(ElementManagement.class); public final String AT = "@"; public final String UNDERSCORE = "_"; @@ -114,7 +114,7 @@ public abstract class ERManagement { this.workingContext = workingContext; } - protected ERManagement(AccessType accessType) { + protected ElementManagement(AccessType accessType) { this.accessType = accessType; this.ignoreKeys = new HashSet(); @@ -176,7 +176,7 @@ public abstract class ERManagement { if(element != null) { oClass = getOClass(element); } else { - oClass = ERManagementUtility.getTypeSchema(elementType, accessType); + oClass = ElementManagementUtility.getTypeSchema(elementType, accessType); } } return oClass; @@ -757,8 +757,8 @@ public abstract class ERManagement { } public static String getClassProperty(JsonNode jsonNode) { - if(jsonNode.has(ISManageable.CLASS_PROPERTY)) { - return jsonNode.get(ISManageable.CLASS_PROPERTY).asText(); + if(jsonNode.has(Element.CLASS_PROPERTY)) { + return jsonNode.get(Element.CLASS_PROPERTY).asText(); } return null; } @@ -1047,12 +1047,12 @@ public abstract class ERManagement { OClass oClass = getOClass(); String type = oClass.getName(); - objectNode.put(ISManageable.CLASS_PROPERTY, type); + objectNode.put(Element.CLASS_PROPERTY, type); Collection superClasses = getSuperclasses(); ArrayNode arrayNode = objectMapper.valueToTree(superClasses); - objectNode.replace(ISManageable.SUPERCLASSES_PROPERTY, arrayNode); + objectNode.replace(Element.SUPERCLASSES_PROPERTY, arrayNode); return objectNode; } catch(ResourceRegistryException e) { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ERManagementUtility.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagementUtility.java similarity index 93% rename from src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ERManagementUtility.java rename to src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagementUtility.java index 854585c..98160f9 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ERManagementUtility.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/ElementManagementUtility.java @@ -39,13 +39,13 @@ import com.orientechnologies.orient.core.record.OVertex; /** * @author Luca Frosini (ISTI - CNR) */ -public class ERManagementUtility { +public class ElementManagementUtility { - private static Logger logger = LoggerFactory.getLogger(EntityManagement.class); + private static Logger logger = LoggerFactory.getLogger(ElementManagementUtility.class); public static AccessType getBaseAccessType(String type) throws ResourceRegistryException { - OClass oClass = ERManagementUtility.getTypeSchema(type, null); + OClass oClass = ElementManagementUtility.getTypeSchema(type, null); if(oClass.isSubClassOf(Resource.NAME)) { return AccessType.RESOURCE; @@ -65,10 +65,10 @@ public class ERManagementUtility { @SuppressWarnings("rawtypes") - public static ERManagement getERManagement(String type) throws ResourceRegistryException { + public static ElementManagement getERManagement(String type) throws ResourceRegistryException { - OClass oClass = ERManagementUtility.getTypeSchema(type, null); - ERManagement erManagement = null; + OClass oClass = ElementManagementUtility.getTypeSchema(type, null); + ElementManagement erManagement = null; if(oClass.isSubClassOf(Resource.NAME)) { erManagement = new ResourceManagement(); @@ -88,7 +88,7 @@ public class ERManagementUtility { return erManagement; } - public static ERManagement getERManagement(SecurityContext workingContext, ODatabaseDocument orientGraph, + public static ElementManagement getERManagement(SecurityContext workingContext, ODatabaseDocument orientGraph, OElement element) throws ResourceRegistryException { if(element instanceof OVertex) { return getEntityManagement(workingContext, orientGraph, (OVertex) element); @@ -125,7 +125,7 @@ public class ERManagementUtility { } @SuppressWarnings("rawtypes") - public static ERManagement getERManagementFromUUID(SecurityContext workingContext, ODatabaseDocument orientGraph, + public static ElementManagement getERManagementFromUUID(SecurityContext workingContext, ODatabaseDocument orientGraph, UUID uuid) throws ResourceRegistryException { OElement element; try { @@ -153,7 +153,7 @@ public class ERManagementUtility { OClass oClass = null; try { - oClass = ERManagement.getOClass(vertex); + oClass = ElementManagement.getOClass(vertex); } catch(Exception e) { String error = String.format("Unable to detect type of %s. %s", vertex.toString(), Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE); @@ -189,7 +189,7 @@ public class ERManagementUtility { OEdge.class.getSimpleName() + "instance is null. " + Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE); } - OClass oClass = ERManagement.getOClass(edge); + OClass oClass = ElementManagement.getOClass(edge); RelationManagement relationManagement = null; if(oClass.isSubClassOf(ConsistsOf.NAME)) { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/BaseEntityManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/BaseEntityManagement.java index 055abab..ec2f688 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/BaseEntityManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/entities/BaseEntityManagement.java @@ -4,14 +4,14 @@ import java.util.HashMap; import java.util.Map; import org.gcube.informationsystem.base.reference.AccessType; -import org.gcube.informationsystem.base.reference.entities.BaseEntity; +import org.gcube.informationsystem.base.reference.entities.EntityElement; import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.EntityAlreadyPresentException; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.gcube.informationsystem.resourceregistry.instances.base.relations.BaseRelationManagement; import org.gcube.informationsystem.resourceregistry.utils.Utility; @@ -27,7 +27,7 @@ import com.orientechnologies.orient.core.record.OVertex; /** * @author Luca Frosini (ISTI - CNR) */ -public abstract class BaseEntityManagement extends ERManagement { +public abstract class BaseEntityManagement extends ElementManagement { /** * Provide a cache edge-internal-id -> RelationManagement @@ -39,7 +39,7 @@ public abstract class BaseEntityManagement extends ERManag protected BaseEntityManagement(AccessType accessType) { super(accessType); - this.ignoreKeys.add(BaseEntity.HEADER_PROPERTY); + this.ignoreKeys.add(EntityElement.HEADER_PROPERTY); this.ignoreStartWithKeys.add(com.tinkerpop.blueprints.impls.orient.OrientVertex.CONNECTION_IN_PREFIX.toLowerCase()); this.ignoreStartWithKeys.add(com.tinkerpop.blueprints.impls.orient.OrientVertex.CONNECTION_OUT_PREFIX.toLowerCase()); @@ -67,7 +67,7 @@ public abstract class BaseEntityManagement extends ERManag String id = edge.getIdentity().toString(); BaseRelationManagement relationManagement = relationManagements.get(id); if(relationManagement == null) { - relationManagement = ERManagementUtility.getRelationManagement(getWorkingContext(), oDatabaseDocument, edge); + relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(), oDatabaseDocument, edge); relationManagements.put(id, relationManagement); } return relationManagement; @@ -134,7 +134,7 @@ public abstract class BaseEntityManagement extends ERManag } catch(NotFoundException e) { try { - OElement el = ERManagementUtility.getAnyElementByUUID(uuid); + OElement el = ElementManagementUtility.getAnyElementByUUID(uuid); String error = String.format("UUID %s is already used by another %s. This is not allowed.", uuid.toString(), (el instanceof OVertex) ? org.gcube.informationsystem.model.reference.entities.Entity.NAME : @@ -153,7 +153,7 @@ public abstract class BaseEntityManagement extends ERManag if(accessType == AccessType.RESOURCE) { // Facet and relation are created in calling method } else { - ERManagement.updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys); + ElementManagement.updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys); } logger.info("Created {} is {}", OVertex.class.getSimpleName(), diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/properties/BasePropertyManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/properties/BasePropertyManagement.java index b6b7f1f..df4e55f 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/properties/BasePropertyManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/properties/BasePropertyManagement.java @@ -5,7 +5,7 @@ import java.util.HashSet; import java.util.Set; import org.gcube.informationsystem.base.reference.AccessType; -import org.gcube.informationsystem.base.reference.ISManageable; +import org.gcube.informationsystem.base.reference.Element; import org.gcube.informationsystem.model.impl.properties.EncryptedImpl; import org.gcube.informationsystem.model.reference.properties.Encrypted; import org.gcube.informationsystem.model.reference.properties.Header; @@ -13,8 +13,8 @@ import org.gcube.informationsystem.model.reference.properties.Property; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException; import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.gcube.informationsystem.resourceregistry.utils.EncryptedOrient; import org.gcube.informationsystem.resourceregistry.utils.HeaderUtility; import org.slf4j.Logger; @@ -50,13 +50,13 @@ public class BasePropertyManagement { public static ODocument getPropertyDocument(JsonNode jsonNode) throws ResourceRegistryException { ODocument oDocument = null; - if(jsonNode.has(ISManageable.CLASS_PROPERTY)) { + if(jsonNode.has(Element.CLASS_PROPERTY)) { // Complex type - String type = ERManagement.getClassProperty(jsonNode); + String type = ElementManagement.getClassProperty(jsonNode); OClass oClass = null; try { - oClass = ERManagementUtility.getTypeSchema(type, AccessType.BASE_PROPERTY); + oClass = ElementManagementUtility.getTypeSchema(type, AccessType.PROPERTY_ELEMENT); } catch(SchemaNotFoundException e) { throw e; } @@ -125,7 +125,7 @@ public class BasePropertyManagement { return jsonNode; } - OClass oClass = ERManagementUtility.getTypeSchema(type, AccessType.BASE_PROPERTY); + OClass oClass = ElementManagementUtility.getTypeSchema(type, AccessType.PROPERTY_ELEMENT); /* * In case it is an Encrypted type the value is encrypted with the DB Key diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/BaseRelationManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/BaseRelationManagement.java index d4ee7ee..e7bd3ce 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/BaseRelationManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/base/relations/BaseRelationManagement.java @@ -3,13 +3,13 @@ package org.gcube.informationsystem.resourceregistry.instances.base.relations; import java.util.UUID; import org.gcube.informationsystem.base.reference.AccessType; -import org.gcube.informationsystem.base.reference.entities.BaseEntity; +import org.gcube.informationsystem.base.reference.entities.EntityElement; import org.gcube.informationsystem.model.reference.relations.Relation; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.RelationNotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.resourceregistry.instances.base.entities.BaseEntityManagement; import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement; import org.gcube.informationsystem.resourceregistry.utils.Utility; @@ -24,16 +24,16 @@ import com.orientechnologies.orient.core.record.OVertex; /** * @author Luca Frosini (ISTI - CNR) */ -public abstract class BaseRelationManagement, TEM extends BaseEntityManagement> - extends ERManagement { +public abstract class BaseRelationManagement, TEM extends BaseEntityManagement> + extends ElementManagement { - protected final Class sourceEntityClass; - protected final Class targetEntityClass; + protected final Class sourceEntityClass; + protected final Class targetEntityClass; protected SEM sourceEntityManagement; protected TEM targetEntityManagement; - protected BaseRelationManagement(AccessType accessType, Class sourceEntityClass, Class targetEntityClass) { + protected BaseRelationManagement(AccessType accessType, Class sourceEntityClass, Class targetEntityClass) { super(accessType); this.ignoreKeys.add(Relation.HEADER_PROPERTY); @@ -51,7 +51,7 @@ public abstract class BaseRelationManagement sourceEntityClass, Class targetEntityClass, SecurityContext workingContext, ODatabaseDocument orientGraph) { + protected BaseRelationManagement(AccessType accessType, Class sourceEntityClass, Class targetEntityClass, SecurityContext workingContext, ODatabaseDocument orientGraph) { this(accessType, sourceEntityClass, targetEntityClass); this.oDatabaseDocument = orientGraph; setWorkingContext(workingContext); @@ -100,12 +100,12 @@ public abstract class BaseRelationManagement sourceEntityManagement = getSourceEntityManagement(); + BaseEntityManagement sourceEntityManagement = getSourceEntityManagement(); ((ObjectNode) relation).replace(Relation.SOURCE_PROPERTY, sourceEntityManagement.serializeSelfOnly()); } if(includeTarget) { - BaseEntityManagement targetEntityManagement = getTargetEntityManagement(); + BaseEntityManagement targetEntityManagement = getTargetEntityManagement(); ((ObjectNode) relation).replace(Relation.TARGET_PROPERTY, targetEntityManagement.serializeAsJson()); } @@ -172,7 +172,7 @@ public abstract class BaseRelationManagement extends BaseEntityManagement { +public abstract class EntityManagement extends BaseEntityManagement { /** * Provide a cache edge-internal-id -> RelationManagement @@ -86,7 +86,7 @@ public abstract class EntityManagement extends BaseEntityM String id = edge.getIdentity().toString(); RelationManagement relationManagement = relationManagements.get(id); if(relationManagement == null) { - relationManagement = ERManagementUtility.getRelationManagement(getWorkingContext(), oDatabaseDocument, edge); + relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(), oDatabaseDocument, edge); relationManagements.put(id, relationManagement); } return relationManagement; @@ -153,7 +153,7 @@ public abstract class EntityManagement extends BaseEntityM } catch(NotFoundException e) { try { - OElement el = ERManagementUtility.getAnyElementByUUID(uuid); + OElement el = ElementManagementUtility.getAnyElementByUUID(uuid); String error = String.format("UUID %s is already used by another %s. This is not allowed.", uuid.toString(), (el instanceof OVertex) ? Entity.NAME : Relation.NAME); throw getSpecificERAvailableInAnotherContextException(error); @@ -170,7 +170,7 @@ public abstract class EntityManagement extends BaseEntityM if(accessType == AccessType.RESOURCE) { // Facet and relation are created in calling method } else { - ERManagement.updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys); + ElementManagement.updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys); } logger.info("Created {} is {}", OVertex.class.getSimpleName(), @@ -227,7 +227,7 @@ public abstract class EntityManagement extends BaseEntityM Iterable iterable = oDatabaseDocument.browseClass(elementType, polymorphic); for(ODocument vertex : iterable) { - EntityManagement entityManagement = ERManagementUtility.getEntityManagement(getWorkingContext(), + EntityManagement entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(), oDatabaseDocument, (OVertex) vertex); try { JsonNode jsonNode = entityManagement.serializeAsJson(); @@ -252,10 +252,10 @@ public abstract class EntityManagement extends BaseEntityM Iterable references = null; if(referenceUUID != null) { - OElement element = ERManagementUtility.getAnyElementByUUID(referenceUUID); + OElement element = ElementManagementUtility.getAnyElementByUUID(referenceUUID); if(element instanceof OVertex) { @SuppressWarnings("unchecked") - EntityManagement entityManagement = ERManagementUtility.getEntityManagement(getWorkingContext(), + EntityManagement entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(), oDatabaseDocument, (OVertex) element); String elementType = entityManagement.getElementType(); @@ -302,7 +302,7 @@ public abstract class EntityManagement extends BaseEntityM continue; } - OClass oClass = ERManagement.getOClass(vertex); + OClass oClass = ElementManagement.getOClass(vertex); if(polymorphic && oClass.isSubClassOf(elementType)) { // OK } else { @@ -311,7 +311,7 @@ public abstract class EntityManagement extends BaseEntityM } @SuppressWarnings("rawtypes") - EntityManagement entityManagement = ERManagementUtility.getEntityManagement(getWorkingContext(), + EntityManagement entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(), oDatabaseDocument, vertex); try { if(referenceUUID!=null && entityManagement.getUUID().compareTo(referenceUUID) == 0) { @@ -392,7 +392,7 @@ public abstract class EntityManagement extends BaseEntityM while(resultSet.hasNext()) { OResult oResult = resultSet.next(); - OElement element = ERManagement.getElementFromOptional(oResult.getElement()); + OElement element = ElementManagement.getElementFromOptional(oResult.getElement()); if(polymorphic) { OClass oClass = null; @@ -400,7 +400,7 @@ public abstract class EntityManagement extends BaseEntityM if(element instanceof OEdge) { continue; } - oClass = ERManagement.getOClass(element); + oClass = ElementManagement.getOClass(element); } catch(Exception e) { String error = String.format("Unable to detect type of %s. %s", element.toString(), Utility.SHOULD_NOT_OCCUR_ERROR_MESSAGE); @@ -417,7 +417,7 @@ public abstract class EntityManagement extends BaseEntityM OVertex vertex = (OVertex) element; @SuppressWarnings("rawtypes") - EntityManagement entityManagement = ERManagementUtility.getEntityManagement(getWorkingContext(), + EntityManagement entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(), oDatabaseDocument, vertex); try { if(constraint.containsKey(Entity.HEADER_PROPERTY + "." + Header.UUID_PROPERTY)) { @@ -446,13 +446,13 @@ public abstract class EntityManagement extends BaseEntityM try { oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.READER); - AccessType relationAccessType = ERManagementUtility.getBaseAccessType(relationType); + AccessType relationAccessType = ElementManagementUtility.getBaseAccessType(relationType); if(relationAccessType != AccessType.IS_RELATED_TO && relationAccessType != AccessType.CONSISTS_OF) { String error = String.format("%s must be a relation type", relationType); throw new ResourceRegistryException(error); } - AccessType referenceAccessType = ERManagementUtility.getBaseAccessType(referenceType); + AccessType referenceAccessType = ElementManagementUtility.getBaseAccessType(referenceType); if(referenceAccessType != AccessType.RESOURCE && referenceAccessType != AccessType.FACET) { String error = String.format("%s must be a en entity type", referenceType); throw new ResourceRegistryException(error); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/FacetManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/FacetManagement.java index d5d71a0..7b5aa37 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/FacetManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/entities/FacetManagement.java @@ -8,7 +8,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet. import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAvailableInAnotherContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import com.fasterxml.jackson.databind.JsonNode; import com.orientechnologies.orient.core.db.document.ODatabaseDocument; @@ -60,7 +60,7 @@ public class FacetManagement extends EntityManagement { @Override protected OVertex reallyUpdate() throws FacetNotFoundException, ResourceRegistryException { OVertex facet = getElement(); - facet = (OVertex) ERManagement.updateProperties(oClass, facet, jsonNode, ignoreKeys, ignoreStartWithKeys); + facet = (OVertex) ElementManagement.updateProperties(oClass, facet, jsonNode, ignoreKeys, ignoreStartWithKeys); return facet; } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java index de597bb..801144d 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/instances/model/relations/RelationManagement.java @@ -20,8 +20,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.Rela import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.gcube.informationsystem.resourceregistry.instances.base.relations.BaseRelationManagement; import org.gcube.informationsystem.resourceregistry.instances.model.entities.EntityManagement; import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement; @@ -145,7 +145,7 @@ public abstract class RelationManagement relationManagement = ERManagementUtility.getRelationManagement(getWorkingContext(), + RelationManagement relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(), oDatabaseDocument, edge); visitedSourceResources = relationManagement.fullSerialize(visitedSourceResources); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/query/QueryImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/query/QueryImpl.java index 34566c3..1101b23 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/query/QueryImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/query/QueryImpl.java @@ -9,8 +9,8 @@ import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.gcube.informationsystem.resourceregistry.utils.Utility; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,7 +68,7 @@ public class QueryImpl implements Query { while(resultSet.hasNext()) { OResult oResult = resultSet.next(); - OElement element = ERManagement.getElementFromOptional(oResult.getElement()); + OElement element = ElementManagement.getElementFromOptional(oResult.getElement()); try { JsonNode jsonNode = null; @@ -76,7 +76,7 @@ public class QueryImpl implements Query { jsonNode = Utility.toJsonNode(element, false); } else { @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(securityContext, oDatabaseDocument, + ElementManagement erManagement = ElementManagementUtility.getERManagement(securityContext, oDatabaseDocument, element); jsonNode = erManagement.serializeAsJson(); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java index 04e9173..a3f0ce9 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java @@ -35,8 +35,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement; import org.gcube.informationsystem.resourceregistry.query.Query; import org.gcube.informationsystem.resourceregistry.query.QueryImpl; @@ -182,7 +182,7 @@ public class Access { setCalledMethodLocal(HTTPMETHOD.GET, pathValues, map); @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); return erManagement.all(polymorphic); } @@ -206,7 +206,7 @@ public class Access { setCalledMethodLocal(HTTPMETHOD.HEAD, pathValues); @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); try { erManagement.setUUID(UUID.fromString(uuid)); @@ -246,7 +246,7 @@ public class Access { setCalledMethodLocal(HTTPMETHOD.GET, pathValues); @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); erManagement.setElementType(type); erManagement.setUUID(UUID.fromString(uuid)); @@ -338,7 +338,7 @@ public class Access { pathValues.add(referenceType); setCalledMethodLocal(HTTPMETHOD.GET, pathValues); - ERManagement erManagement = ERManagementUtility.getERManagement(resourcetype); + ElementManagement erManagement = ElementManagementUtility.getERManagement(resourcetype); if(erManagement instanceof ResourceManagement) { UUID refereceUUID = null; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/InstancesManager.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/InstancesManager.java index ce0320c..988417d 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/InstancesManager.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/InstancesManager.java @@ -27,8 +27,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundExcep import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -76,7 +76,7 @@ public class InstancesManager { setCalledMethod(HTTPMETHOD.GET, type, map); @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); return erManagement.all(polymorphic); } @@ -95,7 +95,7 @@ public class InstancesManager { setCalledMethod(HTTPMETHOD.HEAD, type, true); @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); try { erManagement.setUUID(UUID.fromString(uuid)); @@ -131,7 +131,7 @@ public class InstancesManager { setCalledMethod(HTTPMETHOD.GET, type, true); @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); erManagement.setElementType(type); erManagement.setUUID(UUID.fromString(uuid)); @@ -156,7 +156,7 @@ public class InstancesManager { setCalledMethod(HTTPMETHOD.PUT, type, true); @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); erManagement.setUUID(UUID.fromString(uuid)); erManagement.setElementType(type); erManagement.setJson(json); @@ -177,7 +177,7 @@ public class InstancesManager { setCalledMethod(HTTPMETHOD.DELETE, type, true); @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); erManagement.setUUID(UUID.fromString(uuid)); erManagement.delete(); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SchemaManager.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SchemaManager.java index 0728a79..8ad633d 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SchemaManager.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SchemaManager.java @@ -27,7 +27,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath; import org.gcube.informationsystem.resourceregistry.api.rest.TypePath; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.gcube.informationsystem.resourceregistry.types.SchemaManagement; import org.gcube.informationsystem.resourceregistry.types.SchemaManagementImpl; import org.gcube.informationsystem.types.TypeBinder; @@ -85,7 +85,7 @@ public class SchemaManager { throw new ResourceRegistryException("No superclasses defined"); } for(String superClass : superClasses) { - accessType = ERManagementUtility.getBaseAccessType(superClass); + accessType = ElementManagementUtility.getBaseAccessType(superClass); break; } } catch (ResourceRegistryException e) { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SharingManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SharingManagement.java index 0db9ec7..81ee969 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SharingManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/SharingManagement.java @@ -18,8 +18,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.context.Conte import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException; import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.api.rest.SharingPath; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,7 +57,7 @@ public class SharingManagement { setCalledMethod(HTTPMETHOD.PUT, type); @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); UUID uuid = null; try { uuid = UUID.fromString(id); @@ -94,7 +94,7 @@ public class SharingManagement { setCalledMethod(HTTPMETHOD.DELETE, type); @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); UUID uuid = null; try { uuid = UUID.fromString(id); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImpl.java index 18d043b..aa49149 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImpl.java @@ -12,9 +12,9 @@ import java.util.Set; import javax.activation.UnsupportedDataTypeException; import org.gcube.informationsystem.base.reference.AccessType; -import org.gcube.informationsystem.base.reference.entities.BaseEntity; -import org.gcube.informationsystem.base.reference.properties.BaseProperty; -import org.gcube.informationsystem.base.reference.relations.BaseRelation; +import org.gcube.informationsystem.base.reference.entities.EntityElement; +import org.gcube.informationsystem.base.reference.properties.PropertyElement; +import org.gcube.informationsystem.base.reference.relations.RelationElement; import org.gcube.informationsystem.model.reference.entities.Entity; import org.gcube.informationsystem.model.reference.entities.Facet; import org.gcube.informationsystem.model.reference.entities.Resource; @@ -29,24 +29,24 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.resourceregistry.types.entities.FacetTypeDefinitionManagement; import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement; import org.gcube.informationsystem.resourceregistry.types.properties.PropertyTypeDefinitionManagement; import org.gcube.informationsystem.resourceregistry.types.relations.ConsistsOfTypeDefinitionManagement; import org.gcube.informationsystem.resourceregistry.types.relations.IsRelatedToTypeDefinitionManagement; -import org.gcube.informationsystem.types.Type; +import org.gcube.informationsystem.types.OrientDBType; import org.gcube.informationsystem.types.TypeBinder; import org.gcube.informationsystem.types.reference.TypeDefinition; -import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition; -import org.gcube.informationsystem.types.reference.entities.FacetTypeDefinition; -import org.gcube.informationsystem.types.reference.entities.ResourceTypeDefinition; +import org.gcube.informationsystem.types.reference.entities.EntityType; +import org.gcube.informationsystem.types.reference.entities.FacetType; +import org.gcube.informationsystem.types.reference.entities.ResourceType; import org.gcube.informationsystem.types.reference.properties.PropertyDefinition; -import org.gcube.informationsystem.types.reference.properties.PropertyTypeDefinition; -import org.gcube.informationsystem.types.reference.properties.ResourceEntryDefinition; -import org.gcube.informationsystem.types.reference.relations.ConsistsOfTypeDefinition; -import org.gcube.informationsystem.types.reference.relations.IsRelatedToTypeDefinition; -import org.gcube.informationsystem.types.reference.relations.RelationTypeDefinition; +import org.gcube.informationsystem.types.reference.properties.PropertyType; +import org.gcube.informationsystem.types.reference.properties.LinkedEntity; +import org.gcube.informationsystem.types.reference.relations.ConsistsOfType; +import org.gcube.informationsystem.types.reference.relations.IsRelatedToType; +import org.gcube.informationsystem.types.reference.relations.RelationType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -134,7 +134,7 @@ public class SchemaManagementImpl implements SchemaManagement { private TypeDefinition getTypeDefinition(OClass oClass) throws SchemaException { try { - ERManagement erManagement = null; + ElementManagement erManagement = null; if(oClass.isSubClassOf(Property.NAME)) { erManagement = new PropertyTypeDefinitionManagement(); @@ -212,19 +212,19 @@ public class SchemaManagementImpl implements SchemaManagement { static { baseTypes = new HashSet(); - baseTypes.add(BaseProperty.NAME); - baseTypes.add(BaseEntity.NAME); - baseTypes.add(BaseRelation.NAME); + baseTypes.add(PropertyElement.NAME); + baseTypes.add(EntityElement.NAME); + baseTypes.add(RelationElement.NAME); typeDefinitionTypes = new HashSet(); - typeDefinitionTypes.add(PropertyTypeDefinition.NAME); - typeDefinitionTypes.add(ResourceEntryDefinition.NAME); - typeDefinitionTypes.add(EntityTypeDefinition.NAME); - typeDefinitionTypes.add(ResourceTypeDefinition.NAME); - typeDefinitionTypes.add(FacetTypeDefinition.NAME); - typeDefinitionTypes.add(RelationTypeDefinition.NAME); - typeDefinitionTypes.add(IsRelatedToTypeDefinition.NAME); - typeDefinitionTypes.add(ConsistsOfTypeDefinition.NAME); + typeDefinitionTypes.add(PropertyType.NAME); + typeDefinitionTypes.add(LinkedEntity.NAME); + typeDefinitionTypes.add(EntityType.NAME); + typeDefinitionTypes.add(ResourceType.NAME); + typeDefinitionTypes.add(FacetType.NAME); + typeDefinitionTypes.add(RelationType.NAME); + typeDefinitionTypes.add(IsRelatedToType.NAME); + typeDefinitionTypes.add(ConsistsOfType.NAME); } protected void registerTypeSchema(TypeDefinition typeDefinition, AccessType baseType) @@ -248,11 +248,11 @@ public class SchemaManagementImpl implements SchemaManagement { OClass oClass = null; - if(BaseEntity.class.isAssignableFrom(baseType.getTypeClass())) { + if(EntityElement.class.isAssignableFrom(baseType.getTypeClass())) { oClass = oDatabaseDocument.createVertexClass(typeDefinition.getName()); - } else if(BaseRelation.class.isAssignableFrom(baseType.getTypeClass())) { + } else if(RelationElement.class.isAssignableFrom(baseType.getTypeClass())) { oClass = oDatabaseDocument.createEdgeClass(typeDefinition.getName()); - } else if(BaseProperty.class.isAssignableFrom(baseType.getTypeClass())) { + } else if(PropertyElement.class.isAssignableFrom(baseType.getTypeClass())) { oClass = oSchema.createClass(typeDefinition.getName()); } else { String error = String.format("Allowed superclass are %s, %s, %s, or any subclasses of them.", @@ -288,7 +288,7 @@ public class SchemaManagementImpl implements SchemaManagement { oClass.setSuperClasses(oSuperclasses); } - if(!(typeDefinition instanceof ResourceTypeDefinition)) { + if(!(typeDefinition instanceof ResourceType)) { // A Resource cannot contains any properties. Set propertyDefinitions = typeDefinition.getProperties(); @@ -306,10 +306,10 @@ public class SchemaManagementImpl implements SchemaManagement { if(!typeDefinitionTypes.contains(typeDefinition.getName())) { switch(oType) { case EMBEDDEDLIST: - throw new UnsupportedDataTypeException(Type.OType.PROPERTYLIST + throw new UnsupportedDataTypeException(OrientDBType.OType.PROPERTYLIST + " support is currently disabled due to OrientDB bug see https://github.com/orientechnologies/orientdb/issues/7354"); case EMBEDDEDSET: - throw new UnsupportedDataTypeException(Type.OType.PROPERTYSET + throw new UnsupportedDataTypeException(OrientDBType.OType.PROPERTYSET + " support is currently disabled due to OrientDB bug see https://github.com/orientechnologies/orientdb/issues/7354"); default: break; @@ -419,7 +419,7 @@ public class SchemaManagementImpl implements SchemaManagement { registerTypeSchema(typeDefinition, accessType); - ERManagement erManagement = null; + ElementManagement erManagement = null; switch(accessType) { case PROPERTY: diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/EntityTypeDefinitionManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/EntityTypeDefinitionManagement.java index b492f9b..b38f8a4 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/EntityTypeDefinitionManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/EntityTypeDefinitionManagement.java @@ -14,11 +14,11 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.resourceregistry.instances.base.entities.BaseEntityManagement; import org.gcube.informationsystem.resourceregistry.utils.Utility; import org.gcube.informationsystem.types.TypeBinder; -import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition; +import org.gcube.informationsystem.types.reference.entities.EntityType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,14 +28,14 @@ import com.orientechnologies.orient.core.record.OVertex; import com.orientechnologies.orient.core.sql.executor.OResult; import com.orientechnologies.orient.core.sql.executor.OResultSet; -public abstract class EntityTypeDefinitionManagement extends BaseEntityManagement { +public abstract class EntityTypeDefinitionManagement extends BaseEntityManagement { private static Logger logger = LoggerFactory.getLogger(EntityTypeDefinitionManagement.class); protected String name; protected EntityTypeDefinitionManagement(Class clz) { - super(AccessType.ENTITY_TYPE_DEFINITION); + super(AccessType.ENTITY_TYPE); this.elementType = TypeBinder.getType(clz); } @@ -62,10 +62,10 @@ public abstract class EntityTypeDefinitionManagement()); @@ -144,7 +144,7 @@ public abstract class EntityTypeDefinitionManagement { +public class FacetTypeDefinitionManagement extends EntityTypeDefinitionManagement { public FacetTypeDefinitionManagement() { - super(FacetTypeDefinition.class); + super(FacetType.class); } public FacetTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException { - super(securityContext, oDatabaseDocument, FacetTypeDefinition.class); + super(securityContext, oDatabaseDocument, FacetType.class); } } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/ResourceTypeDefinitionManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/ResourceTypeDefinitionManagement.java index 0ac2437..57c668d 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/ResourceTypeDefinitionManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/entities/ResourceTypeDefinitionManagement.java @@ -2,18 +2,18 @@ package org.gcube.informationsystem.resourceregistry.types.entities; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; -import org.gcube.informationsystem.types.reference.entities.ResourceTypeDefinition; +import org.gcube.informationsystem.types.reference.entities.ResourceType; import com.orientechnologies.orient.core.db.document.ODatabaseDocument; -public class ResourceTypeDefinitionManagement extends EntityTypeDefinitionManagement { +public class ResourceTypeDefinitionManagement extends EntityTypeDefinitionManagement { public ResourceTypeDefinitionManagement() { - super(ResourceTypeDefinition.class); + super(ResourceType.class); } public ResourceTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException { - super(securityContext, oDatabaseDocument, ResourceTypeDefinition.class); + super(securityContext, oDatabaseDocument, ResourceType.class); } } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/properties/PropertyTypeDefinitionManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/properties/PropertyTypeDefinitionManagement.java index fdf30d4..9cdd3e1 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/properties/PropertyTypeDefinitionManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/properties/PropertyTypeDefinitionManagement.java @@ -13,10 +13,10 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.resourceregistry.utils.Utility; -import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition; -import org.gcube.informationsystem.types.reference.properties.PropertyTypeDefinition; +import org.gcube.informationsystem.types.reference.entities.EntityType; +import org.gcube.informationsystem.types.reference.properties.PropertyType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -27,15 +27,15 @@ import com.orientechnologies.orient.core.record.impl.ODocument; import com.orientechnologies.orient.core.sql.executor.OResult; import com.orientechnologies.orient.core.sql.executor.OResultSet; -public class PropertyTypeDefinitionManagement extends ERManagement { +public class PropertyTypeDefinitionManagement extends ElementManagement { private static Logger logger = LoggerFactory.getLogger(PropertyTypeDefinitionManagement.class); protected String name; public PropertyTypeDefinitionManagement() { - super(AccessType.PROPERTY_TYPE_DEFINITION); - this.elementType = PropertyTypeDefinition.NAME; + super(AccessType.PROPERTY_TYPE); + this.elementType = PropertyType.NAME; } public PropertyTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException { @@ -61,10 +61,10 @@ public class PropertyTypeDefinitionManagement extends ERManagement { if(name == null) { if(element == null) { if(jsonNode != null) { - name = jsonNode.get(PropertyTypeDefinition.NAME_PROPERTY).asText(); + name = jsonNode.get(PropertyType.NAME_PROPERTY).asText(); } } else { - name = element.getProperty(PropertyTypeDefinition.NAME_PROPERTY); + name = element.getProperty(PropertyType.NAME_PROPERTY); } } return name; @@ -82,22 +82,22 @@ public class PropertyTypeDefinitionManagement extends ERManagement { @Override protected OElement reallyCreate() throws AlreadyPresentException, ResourceRegistryException { - logger.debug("Going to create {} for {}", PropertyTypeDefinition.NAME, getName()); + logger.debug("Going to create {} for {}", PropertyType.NAME, getName()); return createElement(); } @Override protected OElement reallyUpdate() throws NotFoundException, ResourceRegistryException { - logger.debug("Going to update {} for {}", PropertyTypeDefinition.NAME, getName()); + logger.debug("Going to update {} for {}", PropertyType.NAME, getName()); OElement propertyTypeDefinition = getElement(); - propertyTypeDefinition = (OElement) ERManagement.updateProperties(oClass, propertyTypeDefinition, jsonNode, + propertyTypeDefinition = (OElement) ElementManagement.updateProperties(oClass, propertyTypeDefinition, jsonNode, ignoreKeys, ignoreStartWithKeys); return propertyTypeDefinition; } @Override protected boolean reallyDelete() throws NotFoundException, ResourceRegistryException { - logger.debug("Going to remove {} for {}", EntityTypeDefinition.NAME, getName()); + logger.debug("Going to remove {} for {}", EntityType.NAME, getName()); getElement().delete(); return true; } @@ -130,7 +130,7 @@ public class PropertyTypeDefinitionManagement extends ERManagement { throw new NotFoundException("null name does not allow to retrieve the Element"); } - String select = "SELECT FROM " + elementType + " WHERE " + PropertyTypeDefinition.NAME_PROPERTY + " = \"" + String select = "SELECT FROM " + elementType + " WHERE " + PropertyType.NAME_PROPERTY + " = \"" + getName() + "\""; OResultSet resultSet = oDatabaseDocument.query(select, new HashMap<>()); @@ -142,7 +142,7 @@ public class PropertyTypeDefinitionManagement extends ERManagement { } OResult oResult = resultSet.next(); - OElement element = (OElement) ERManagement.getElementFromOptional(oResult.getElement()); + OElement element = (OElement) ElementManagement.getElementFromOptional(oResult.getElement()); logger.trace("{} with id {} is : {}", elementType, getName(), Utility.toJsonString(element, true)); @@ -165,9 +165,9 @@ public class PropertyTypeDefinitionManagement extends ERManagement { try { this.element = new ODocument(elementType); - ERManagement.updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys); + ElementManagement.updateProperties(oClass, element, jsonNode, ignoreKeys, ignoreStartWithKeys); - logger.debug("Created {} is {}", PropertyTypeDefinition.NAME, Utility.toJsonString(element, true)); + logger.debug("Created {} is {}", PropertyType.NAME, Utility.toJsonString(element, true)); return element; } catch(ResourceRegistryException e) { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/ConsistsOfTypeDefinitionManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/ConsistsOfTypeDefinitionManagement.java index 059a824..eaf236b 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/ConsistsOfTypeDefinitionManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/ConsistsOfTypeDefinitionManagement.java @@ -3,23 +3,23 @@ package org.gcube.informationsystem.resourceregistry.types.relations; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.types.entities.FacetTypeDefinitionManagement; -import org.gcube.informationsystem.types.reference.entities.FacetTypeDefinition; -import org.gcube.informationsystem.types.reference.relations.ConsistsOfTypeDefinition; +import org.gcube.informationsystem.types.reference.entities.FacetType; +import org.gcube.informationsystem.types.reference.relations.ConsistsOfType; import com.orientechnologies.orient.core.db.document.ODatabaseDocument; public class ConsistsOfTypeDefinitionManagement - extends RelationTypeDefinitionManagement { + extends RelationTypeDefinitionManagement { public ConsistsOfTypeDefinitionManagement() { - super(FacetTypeDefinition.class); - this.elementType = ConsistsOfTypeDefinition.NAME; + super(FacetType.class); + this.elementType = ConsistsOfType.NAME; } public ConsistsOfTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException { - super(securityContext, oDatabaseDocument, FacetTypeDefinition.class); - this.elementType = ConsistsOfTypeDefinition.NAME; + super(securityContext, oDatabaseDocument, FacetType.class); + this.elementType = ConsistsOfType.NAME; } @Override diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/IsRelatedToTypeDefinitionManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/IsRelatedToTypeDefinitionManagement.java index c5a0a9e..2aa890e 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/IsRelatedToTypeDefinitionManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/IsRelatedToTypeDefinitionManagement.java @@ -3,23 +3,23 @@ package org.gcube.informationsystem.resourceregistry.types.relations; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement; -import org.gcube.informationsystem.types.reference.entities.ResourceTypeDefinition; -import org.gcube.informationsystem.types.reference.relations.IsRelatedToTypeDefinition; +import org.gcube.informationsystem.types.reference.entities.ResourceType; +import org.gcube.informationsystem.types.reference.relations.IsRelatedToType; import com.orientechnologies.orient.core.db.document.ODatabaseDocument; public class IsRelatedToTypeDefinitionManagement - extends RelationTypeDefinitionManagement { + extends RelationTypeDefinitionManagement { public IsRelatedToTypeDefinitionManagement() { - super(ResourceTypeDefinition.class); - this.elementType = IsRelatedToTypeDefinition.NAME; + super(ResourceType.class); + this.elementType = IsRelatedToType.NAME; } public IsRelatedToTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException { - super(securityContext, oDatabaseDocument, ResourceTypeDefinition.class); - this.elementType = IsRelatedToTypeDefinition.NAME; + super(securityContext, oDatabaseDocument, ResourceType.class); + this.elementType = IsRelatedToType.NAME; } @Override diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/RelationTypeDefinitionManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/RelationTypeDefinitionManagement.java index 4823bb6..61a32f8 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/RelationTypeDefinitionManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/types/relations/RelationTypeDefinitionManagement.java @@ -15,14 +15,14 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility; import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; import org.gcube.informationsystem.resourceregistry.instances.base.relations.BaseRelationManagement; import org.gcube.informationsystem.resourceregistry.types.entities.EntityTypeDefinitionManagement; import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement; import org.gcube.informationsystem.resourceregistry.utils.Utility; -import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition; -import org.gcube.informationsystem.types.reference.entities.ResourceTypeDefinition; -import org.gcube.informationsystem.types.reference.relations.RelationTypeDefinition; +import org.gcube.informationsystem.types.reference.entities.EntityType; +import org.gcube.informationsystem.types.reference.entities.ResourceType; +import org.gcube.informationsystem.types.reference.relations.RelationType; import com.orientechnologies.orient.core.db.document.ODatabaseDocument; import com.orientechnologies.orient.core.record.OEdge; @@ -30,14 +30,14 @@ import com.orientechnologies.orient.core.record.OVertex; import com.orientechnologies.orient.core.sql.executor.OResult; import com.orientechnologies.orient.core.sql.executor.OResultSet; -public abstract class RelationTypeDefinitionManagement, TT extends EntityTypeDefinition> +public abstract class RelationTypeDefinitionManagement, TT extends EntityType> extends BaseRelationManagement { protected String name; public RelationTypeDefinitionManagement(Class clz) { - super(AccessType.RELATION_TYPE_DEFINITION, ResourceTypeDefinition.class, clz); - this.elementType = RelationTypeDefinition.NAME; + super(AccessType.RELATION_TYPE, ResourceType.class, clz); + this.elementType = RelationType.NAME; } public RelationTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument, Class clz) throws ResourceRegistryException { @@ -63,10 +63,10 @@ public abstract class RelationTypeDefinitionManagement()); @@ -166,7 +166,7 @@ public abstract class RelationTypeDefinitionManagement P getPropertyDocument(Class

clz, OElement element, String property) + public static

P getPropertyDocument(Class

clz, OElement element, String property) throws ResourceRegistryException { try { ODocument oDocument = element.getProperty(property); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/ERManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/ERManagementTest.java index 0f01c47..04fd93f 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/ERManagementTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/ERManagementTest.java @@ -32,7 +32,7 @@ import org.gcube.informationsystem.resourceregistry.ContextTest; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement; import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement; import org.gcube.informationsystem.resourceregistry.instances.model.relations.ConsistsOfManagement; @@ -628,7 +628,7 @@ public class ERManagementTest extends ContextTest { /* Getting all instances of created specific Resources*/ for(String key : resources.keySet()){ - ResourceManagement resourceManagement = (ResourceManagement) ERManagementUtility.getERManagement(key); + ResourceManagement resourceManagement = (ResourceManagement) ElementManagementUtility.getERManagement(key); String json = resourceManagement.all(false); List list = ISMapper.unmarshalList(Resource.class, json); @@ -639,7 +639,7 @@ public class ERManagementTest extends ContextTest { /* Getting all Resources polymorphic and non polymorphic */ - ResourceManagement resourceManagement = (ResourceManagement) ERManagementUtility.getERManagement(Resource.NAME); + ResourceManagement resourceManagement = (ResourceManagement) ElementManagementUtility.getERManagement(Resource.NAME); String json = resourceManagement.all(true); List list = ISMapper.unmarshalList(Resource.class, json); @@ -654,7 +654,7 @@ public class ERManagementTest extends ContextTest { /* Getting all IsRelatedTo polymorphic and non polymorphic */ - IsRelatedToManagement isRelatedToManagement = (IsRelatedToManagement) ERManagementUtility.getERManagement(IsRelatedTo.NAME); + IsRelatedToManagement isRelatedToManagement = (IsRelatedToManagement) ElementManagementUtility.getERManagement(IsRelatedTo.NAME); json = isRelatedToManagement.all(true); @@ -672,7 +672,7 @@ public class ERManagementTest extends ContextTest { /* Getting all ConsistsOf polymorphic and non polymorphic */ - ConsistsOfManagement consistsOfManagement = (ConsistsOfManagement) ERManagementUtility.getERManagement(ConsistsOf.NAME); + ConsistsOfManagement consistsOfManagement = (ConsistsOfManagement) ElementManagementUtility.getERManagement(ConsistsOf.NAME); json = consistsOfManagement.all(true); List consistsOfPolimorphicList = ISMapper.unmarshalList(Resource.class, json); diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/ResourceManagementTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/ResourceManagementTest.java index 4f37238..fb8bd0b 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/ResourceManagementTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/instances/model/entity/ResourceManagementTest.java @@ -8,8 +8,8 @@ import org.gcube.informationsystem.model.reference.entities.Facet; import org.gcube.informationsystem.model.reference.relations.ConsistsOf; import org.gcube.informationsystem.resourceregistry.ContextTest; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagement; -import org.gcube.informationsystem.resourceregistry.instances.base.ERManagementUtility; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement; +import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility; import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement; import org.gcube.informationsystem.utils.ISMapper; import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl; @@ -99,7 +99,7 @@ public class ResourceManagementTest extends ContextTest { String type = Service.NAME; @SuppressWarnings("rawtypes") - ERManagement erManagement = ERManagementUtility.getERManagement(type); + ElementManagement erManagement = ElementManagementUtility.getERManagement(type); if (erManagement instanceof ResourceManagement) { boolean[] booleans = new boolean[] {true, false}; diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImplTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImplTest.java index c1fb987..3dd5f3d 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImplTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/types/SchemaManagementImplTest.java @@ -6,8 +6,8 @@ package org.gcube.informationsystem.resourceregistry.types; import java.util.List; import org.gcube.informationsystem.base.reference.AccessType; -import org.gcube.informationsystem.base.reference.ISManageable; -import org.gcube.informationsystem.base.reference.properties.BaseProperty; +import org.gcube.informationsystem.base.reference.Element; +import org.gcube.informationsystem.base.reference.properties.PropertyElement; import org.gcube.informationsystem.context.reference.entities.Context; import org.gcube.informationsystem.model.reference.entities.Entity; import org.gcube.informationsystem.model.reference.entities.Facet; @@ -21,13 +21,13 @@ import org.gcube.informationsystem.model.reference.relations.Relation; import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaAlreadyPresentException; import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException; import org.gcube.informationsystem.types.TypeBinder; -import org.gcube.informationsystem.types.impl.entities.EntityTypeDefinitionImpl; -import org.gcube.informationsystem.types.impl.properties.PropertyTypeDefinitionImpl; -import org.gcube.informationsystem.types.impl.relations.RelationTypeDefinitionImpl; +import org.gcube.informationsystem.types.impl.entities.EntityTypeImpl; +import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl; +import org.gcube.informationsystem.types.impl.relations.RelationTypeImpl; import org.gcube.informationsystem.types.reference.TypeDefinition; -import org.gcube.informationsystem.types.reference.entities.EntityTypeDefinition; -import org.gcube.informationsystem.types.reference.properties.PropertyTypeDefinition; -import org.gcube.informationsystem.types.reference.relations.RelationTypeDefinition; +import org.gcube.informationsystem.types.reference.entities.EntityType; +import org.gcube.informationsystem.types.reference.properties.PropertyType; +import org.gcube.informationsystem.types.reference.relations.RelationType; import org.gcube.informationsystem.utils.ISMapper; import org.gcube.resourcemanagement.model.reference.entities.facets.AccessPointFacet; import org.gcube.resourcemanagement.model.reference.entities.facets.ContactFacet; @@ -50,7 +50,7 @@ public class SchemaManagementImplTest { @Test public void registerPropertyTypeSchema() throws Exception { - Class clz = Header.class; + Class clz = Header.class; String json = TypeBinder.serializeType(clz); logger.debug(json); //new SchemaManagementImpl().create(json, AccessType.PROPERTY); @@ -102,7 +102,7 @@ public class SchemaManagementImplTest { @Test public void registerRelation() throws Exception { - Class clz = Hosts.class; + Class clz = Hosts.class; String json = TypeBinder.serializeType(clz); logger.trace(json); // new SchemaManagementImpl().registerFacetSchema(json); @@ -166,8 +166,8 @@ public class SchemaManagementImplTest { SchemaManagement schemaManagement = new SchemaManagementImpl(); try { - schemaManagement.read(BaseProperty.NAME, includeSubTypes); - throw new Exception("Should not be allowed to get " + BaseProperty.NAME + " schema"); + schemaManagement.read(PropertyElement.NAME, includeSubTypes); + throw new Exception("Should not be allowed to get " + PropertyElement.NAME + " schema"); } catch (SchemaException e) { } @@ -190,7 +190,7 @@ public class SchemaManagementImplTest { @Test(expected=SchemaAlreadyPresentException.class) public void createPropertyType() throws Exception { - PropertyTypeDefinition propertyTypeDefinition = new PropertyTypeDefinitionImpl<>(ValueSchema.class); + PropertyType propertyTypeDefinition = new PropertyTypeImpl<>(ValueSchema.class); SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(ValueSchema.NAME); @@ -202,7 +202,7 @@ public class SchemaManagementImplTest { @Test(expected=SchemaAlreadyPresentException.class) public void createEncryptedType() throws Exception { - PropertyTypeDefinition propertyTypeDefinition = new PropertyTypeDefinitionImpl<>(Encrypted.class); + PropertyType propertyTypeDefinition = new PropertyTypeImpl<>(Encrypted.class); SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(Encrypted.NAME); @@ -214,11 +214,11 @@ public class SchemaManagementImplTest { @Test(expected=SchemaAlreadyPresentException.class) public void createContextType() throws Exception { - EntityTypeDefinition entityTypeDefinition = new EntityTypeDefinitionImpl(Context.class); + EntityType entityTypeDefinition = new EntityTypeImpl(Context.class); SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(Context.NAME); - String ret = schemaManagement.create(ISMapper.marshal(entityTypeDefinition), AccessType.BASE_ENTITY); + String ret = schemaManagement.create(ISMapper.marshal(entityTypeDefinition), AccessType.ENTITY_ELEMENT); logger.debug(ret); @@ -226,7 +226,7 @@ public class SchemaManagementImplTest { @Test(expected=SchemaAlreadyPresentException.class) public void createFacetType() throws Exception { - EntityTypeDefinition entityTypeDefinition = new EntityTypeDefinitionImpl(AccessPointFacet.class); + EntityType entityTypeDefinition = new EntityTypeImpl(AccessPointFacet.class); SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(AccessPointFacet.NAME); @@ -238,7 +238,7 @@ public class SchemaManagementImplTest { @Test(expected=SchemaAlreadyPresentException.class) public void createResourceType() throws Exception { - EntityTypeDefinition entityTypeDefinition = new EntityTypeDefinitionImpl(EService.class); + EntityType entityTypeDefinition = new EntityTypeImpl(EService.class); SchemaManagement schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(EService.NAME); @@ -246,7 +246,7 @@ public class SchemaManagementImplTest { logger.debug(ret); - entityTypeDefinition = new EntityTypeDefinitionImpl(RunningPlugin.class); + entityTypeDefinition = new EntityTypeImpl(RunningPlugin.class); schemaManagement = new SchemaManagementImpl(); ((SchemaManagementImpl) schemaManagement).setTypeName(RunningPlugin.NAME); @@ -259,10 +259,10 @@ public class SchemaManagementImplTest { @Test public void createRelationTypeDefinitionType() throws Exception { @SuppressWarnings({"unchecked", "rawtypes"}) - RelationTypeDefinition relationTypeDefinition = new RelationTypeDefinitionImpl(RelationTypeDefinition.class); + RelationType relationTypeDefinition = new RelationTypeImpl(RelationType.class); SchemaManagement schemaManagement = new SchemaManagementImpl(); - ((SchemaManagementImpl) schemaManagement).setTypeName(RelationTypeDefinition.NAME); + ((SchemaManagementImpl) schemaManagement).setTypeName(RelationType.NAME); String ret = ISMapper.marshal(relationTypeDefinition);