Class AbstractEntitySchemaManagement<E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>

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,E>
org.gcube.informationsystem.resourceregistry.persistence.orientdb.types.entities.AbstractEntitySchemaManagement<E>
All Implemented Interfaces:
TypeDefinitionManagement
Direct Known Subclasses:
EntitySchemaManagement, FacetSchemaManagement, ResourceSchemaManagement

public abstract class AbstractEntitySchemaManagement<E extends org.gcube.informationsystem.types.reference.entities.EntitySchema> extends EntityElementManagement<E,E> implements TypeDefinitionManagement
Author:
Luca Frosini (ISTI - CNR)
  • Field Details

    • name

      protected String name
      The name of the entity type definition being managed.
  • Constructor Details

    • AbstractEntitySchemaManagement

      protected AbstractEntitySchemaManagement(Class<E> clz)
      Creates a new AbstractEntitySchemaManagement instance bound to the specified entity type class.
      Parameters:
      clz - the class of the entity type
  • Method Details

    • getAffectedInstances

      public Map<UUID,org.gcube.com.fasterxml.jackson.databind.JsonNode> getAffectedInstances()
      Description copied from class: ElementManagement
      Returns the map of instances affected by operations on this element.
      Overrides:
      getAffectedInstances in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      Returns:
      the map of affected instances
    • getWorkingEnvironment

      protected Environment getWorkingEnvironment() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: ElementManagement
      Returns the active database working environment.
      Specified by:
      getWorkingEnvironment in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      Returns:
      the working environment
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the environment cannot be resolved
    • setName

      public void setName(String name)
      Description copied from interface: TypeDefinitionManagement
      Sets the name of the Type definition.
      Specified by:
      setName in interface TypeDefinitionManagement
      Parameters:
      name - the name of the Type definition to set
    • getName

      public String getName()
      Description copied from interface: TypeDefinitionManagement
      Returns the name of the Type definition.
      Specified by:
      getName in interface TypeDefinitionManagement
      Returns:
      the name of the Type definition
    • createCompleteJsonNode

      protected 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,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      Returns:
      the complete JSON node representing the element and its relationships
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on serialization or mapping error
    • reallyCreate

      protected com.orientechnologies.orient.core.record.OVertex reallyCreate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException, 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,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      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
    • reallyUpdate

      protected com.orientechnologies.orient.core.record.OVertex reallyUpdate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, 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,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      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
    • reallyDelete

      protected void reallyDelete() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: ElementManagement
      Deletes an existing element from the database (subclass hook).
      Specified by:
      reallyDelete in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      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
    • getElement

      public com.orientechnologies.orient.core.record.OVertex getElement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: ElementManagement
      Returns the OrientDB element instance, retrieving and caching it if not already present.
      Overrides:
      getElement in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      Returns:
      the OrientDB element instance
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException - if the element does not exist
      org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException - if the element belongs to another context
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database error
    • retrieveElement

      public com.orientechnologies.orient.core.record.OVertex retrieveElement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: ElementManagement
      Directly queries and retrieves the OrientDB element from the database.
      Overrides:
      retrieveElement in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      Returns:
      the loaded OrientDB element
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException - if the element does not exist
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database error
    • createVertex

      protected com.orientechnologies.orient.core.record.OVertex createVertex() throws org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: EntityElementManagement
      Instantiates, validates, and persists a new OrientDB Vertex element.
      Overrides:
      createVertex in class EntityElementManagement<E extends org.gcube.informationsystem.types.reference.entities.EntitySchema,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      Returns:
      the created OrientDB vertex
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException - if a vertex with the specified UUID already exists
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the schema class is abstract or if database creation fails
    • reallyGetAll

      public String reallyGetAll() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: ElementManagement
      Retrieves all elements from the database and returns them as a JSON array string.
      Specified by:
      reallyGetAll in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      Returns:
      JSON array string of all elements
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database traversal or serialization error
    • getSpecificNotFoundException

      protected org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException 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,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      Parameters:
      e - the generic exception
      Returns:
      the specific NotFoundException
    • getSpecificAlreadyPresentException

      protected org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException 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,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      Parameters:
      message - the exception message
      Returns:
      the specific AlreadyPresentException
    • sanityCheck

      public void sanityCheck() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Description copied from class: ElementManagement
      Performs runtime validation of the schema constraints this service enforces from the definition rather than through OrientDB: the mandatory properties, and the min and max bounds of the numeric values a creation or an update wrote. A System Restore, the only caller that sets ElementManagement.preservePassedMetadata, reproduces the archive as it is: it does not validate again the content the dumped registry held.
      Overrides:
      sanityCheck in class ElementManagement<com.orientechnologies.orient.core.record.OVertex,E extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
      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