java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.ElementManagement<com.orientechnologies.orient.core.record.OVertex,ET>
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.EntityElementManagement<E,ET>
org.gcube.informationsystem.resourceregistry.persistence.orientdb.instances.entities.EntityManagement<org.gcube.informationsystem.model.reference.entities.Resource,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
org.gcube.informationsystem.resourceregistry.persistence.orientdb.instances.entities.ResourceManagement
All Implemented Interfaces:
ERManagement

public class ResourceManagement extends EntityManagement<org.gcube.informationsystem.model.reference.entities.Resource,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
Author:
Luca Frosini (ISTI - CNR)
  • Constructor Details

    • ResourceManagement

      public ResourceManagement()
      Creates a new ResourceManagement instance.
  • Method Details

    • setSanityCheckNotRequired

      public void setSanityCheckNotRequired()
      Disables the sanity check on deletion operations.
    • getSpecificNotFoundException

      protected org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceNotFoundException getSpecificNotFoundException(org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException e)
      Description copied from class: ElementManagement
      Converts a generic NotFoundException into a subclass-specific NotFoundException.
      Specified by:
      getSpecificNotFoundException in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
      Parameters:
      e - the generic exception
      Returns:
      the specific NotFoundException
    • getSpecificAvailableInAnotherContextException

      public org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceAvailableInAnotherContextException getSpecificAvailableInAnotherContextException(String message)
      Description copied from interface: ERManagement
      Returns the subclass-specific AvailableInAnotherContextException instance.
      Parameters:
      message - the exception message
      Returns:
      the specific AvailableInAnotherContextException
    • getSpecificAlreadyPresentException

      protected org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceAlreadyPresentException getSpecificAlreadyPresentException(String message)
      Description copied from class: ElementManagement
      Converts a generic AlreadyPresentException into a subclass-specific AlreadyPresentException.
      Specified by:
      getSpecificAlreadyPresentException in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
      Parameters:
      message - the exception message
      Returns:
      the specific AlreadyPresentException
    • createCompleteJsonNode

      public org.gcube.com.fasterxml.jackson.databind.JsonNode createCompleteJsonNode() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: ElementManagement
      Abstract method to create the complete JSON node representation of the element.
      Specified by:
      createCompleteJsonNode in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
      Returns:
      the complete JSON node representing the element and its relationships
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on serialization or mapping error
    • addConsistsOf

      public static org.gcube.com.fasterxml.jackson.databind.JsonNode addConsistsOf(org.gcube.com.fasterxml.jackson.databind.JsonNode sourceResource, org.gcube.com.fasterxml.jackson.databind.JsonNode consistsOf) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Helper that appends a "consistsOf" relation node to the given resource JSON node.
      Parameters:
      sourceResource - the source resource JSON node
      consistsOf - the consistsOf relation JSON node
      Returns:
      the updated JSON node
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the operation fails
    • addIsRelatedTo

      public static org.gcube.com.fasterxml.jackson.databind.JsonNode addIsRelatedTo(org.gcube.com.fasterxml.jackson.databind.JsonNode sourceResource, org.gcube.com.fasterxml.jackson.databind.JsonNode isRelatedTo) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Helper that appends an "isRelatedTo" relation node to the given resource JSON node.
      Parameters:
      sourceResource - the source resource JSON node
      isRelatedTo - the isRelatedTo relation JSON node
      Returns:
      the updated JSON node
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the operation fails
    • reallyCreate

      protected com.orientechnologies.orient.core.record.OVertex reallyCreate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceAlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: ElementManagement
      Persists a new element in the database (subclass hook).
      Specified by:
      reallyCreate in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
      Returns:
      the persisted OrientDB vertex
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException - if the element already exists in the database
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on any database error
      org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceAlreadyPresentException
    • reallyUpdate

      protected com.orientechnologies.orient.core.record.OVertex reallyUpdate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceNotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: ElementManagement
      Updates an existing element in the database (subclass hook).
      Specified by:
      reallyUpdate in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
      Returns:
      the updated OrientDB vertex
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException - if the element does not exist in the database
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on any database error
      org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceNotFoundException
    • reallyAddToContext

      protected void reallyAddToContext() throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: EntityManagement
      Abstract method implementation that performs the database-level operations to add the entity and its propagated components to the target context.
      Overrides:
      reallyAddToContext in class EntityManagement<org.gcube.informationsystem.model.reference.entities.Resource,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException - if context rules or scoping constraints are violated
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database or execution error
    • getResourceTypeConstraint

      protected Set<org.gcube.informationsystem.types.reference.properties.LinkedEntity> getResourceTypeConstraint() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Resolves the set of facet-linking constraints defined on this resource type and its supertypes.
      Returns:
      the set of constraints
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if a schema validation error occurs
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if database lookup fails
    • constraintSatisfied

      protected boolean constraintSatisfied(org.gcube.informationsystem.types.reference.properties.LinkedEntity constraint, String consistsOfType, String facetType) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Checks whether a given relation and facet type satisfy the specified schema constraint.
      Parameters:
      constraint - the schema constraint to check
      consistsOfType - the relation type name
      facetType - the facet type name
      Returns:
      true if satisfied, false otherwise
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException - if validation fails
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if lookup fails
    • sanityCheck

      public void sanityCheck() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      The default sanity check is not valid for resources which do not have properties and instead must be validated in terms of facets. The Resource Metadata is managed with dedicated code for all instaces.
      Overrides:
      sanityCheck in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException - if a schema constraint is violated
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database lookup failure