Class RelationElementManagement<SEM extends EntityElementManagement<? extends org.gcube.informationsystem.base.reference.entities.EntityElement,SET>,TEM extends EntityElementManagement<? extends org.gcube.informationsystem.base.reference.entities.EntityElement,TET>,SET extends org.gcube.informationsystem.types.reference.entities.EntitySchema,TET extends org.gcube.informationsystem.types.reference.entities.EntitySchema>

java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.ElementManagement<com.orientechnologies.orient.core.record.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<SET,TET>>
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.RelationElementManagement<SEM,TEM,SET,TET>
Direct Known Subclasses:
AbstractRelationSchemaManagement, RelationManagement

public abstract class RelationElementManagement<SEM extends EntityElementManagement<? extends org.gcube.informationsystem.base.reference.entities.EntityElement,SET>,TEM extends EntityElementManagement<? extends org.gcube.informationsystem.base.reference.entities.EntityElement,TET>,SET extends org.gcube.informationsystem.types.reference.entities.EntitySchema,TET extends org.gcube.informationsystem.types.reference.entities.EntitySchema> extends ElementManagement<com.orientechnologies.orient.core.record.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<SET,TET>>
Author:
Luca Frosini (ISTI - CNR)
  • Field Details

    • IN

      public static final String IN
      Direction constant for incoming edge direction.
      See Also:
    • OUT

      public static final String OUT
      Direction constant for outgoing edge direction.
      See Also:
    • sourceEntityClass

      protected final Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> sourceEntityClass
      Class representing the source entity type.
    • targetEntityClass

      protected final Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> targetEntityClass
      Class representing the target entity type.
    • sourceEntityManagement

      protected SEM extends EntityElementManagement<? extends org.gcube.informationsystem.base.reference.entities.EntityElement,SET> sourceEntityManagement
      Manager instance for the source entity.
    • targetEntityManagement

      protected TEM extends EntityElementManagement<? extends org.gcube.informationsystem.base.reference.entities.EntityElement,TET> targetEntityManagement
      Manager instance for the target entity.
    • includeSource

      protected boolean includeSource
      Flag indicating whether to include the source entity representation in output.
    • includeTarget

      protected boolean includeTarget
      Flag indicating whether to include the target entity representation in output.
  • Constructor Details

    • RelationElementManagement

      protected RelationElementManagement(org.gcube.informationsystem.base.reference.AccessType accessType, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> sourceEntityClass, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> targetEntityClass)
      Creates a new RelationElementManagement instance with the specified access type and entity classes.
      Parameters:
      accessType - the JAX-RS access type of the relation
      sourceEntityClass - the source entity class
      targetEntityClass - the target entity class
    • RelationElementManagement

      protected RelationElementManagement(String typeName, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> sourceEntityClass, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> targetEntityClass)
      Creates a new RelationElementManagement instance with the specified relation type name, source class, and target class.
      Parameters:
      typeName - the name of the relation type
      sourceEntityClass - the source entity class
      targetEntityClass - the target entity class
    • RelationElementManagement

      protected RelationElementManagement(org.gcube.informationsystem.base.reference.AccessType accessType, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> sourceEntityClass, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> targetEntityClass, Environment workingContext, com.orientechnologies.orient.core.db.document.ODatabaseDocument orientGraph)
      Creates a new RelationElementManagement instance with database and environment context bindings.
      Parameters:
      accessType - the JAX-RS access type
      sourceEntityClass - the source entity class
      targetEntityClass - the target entity class
      workingContext - the working environment context
      orientGraph - the database document connection
    • RelationElementManagement

      protected RelationElementManagement(String typeName, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> sourceEntityClass, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> targetEntityClass, Environment workingContext, com.orientechnologies.orient.core.db.document.ODatabaseDocument orientGraph)
      Creates a new RelationElementManagement instance with name, database, and environment context bindings.
      Parameters:
      typeName - the name of the relation type
      sourceEntityClass - the source entity class
      targetEntityClass - the target entity class
      workingContext - the working environment context
      orientGraph - the database document connection
  • Method Details

    • includeSource

      public void includeSource(boolean includeSource)
      Sets whether to include the source entity representation in the serialized JSON.
      Parameters:
      includeSource - true to include, false to exclude
    • includeTarget

      public void includeTarget(boolean includeTarget)
      Sets whether to include the target entity representation in the serialized JSON.
      Parameters:
      includeTarget - true to include, false to exclude
    • getSourceEntityManagement

      public SEM getSourceEntityManagement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Returns the manager instance for the source entity of this relation.
      Returns:
      the source entity manager
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the lookup fails
    • getTargetEntityManagement

      public TEM getTargetEntityManagement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Returns the manager instance for the target entity of this relation.
      Returns:
      the target entity manager
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the lookup fails
    • setSourceEntityManagement

      public void setSourceEntityManagement(SEM sourceEntityManagement)
      Sets the manager instance for the source entity of this relation.
      Parameters:
      sourceEntityManagement - the source entity manager to set
    • setTargetEntityManagement

      public void setTargetEntityManagement(TEM targetEntityManagement)
      Sets the manager instance for the target entity of this relation.
      Parameters:
      targetEntityManagement - the target entity manager to set
    • 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.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<SET extends org.gcube.informationsystem.types.reference.entities.EntitySchema,TET 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
    • checksourceAndTargetEntityCompliancy

      protected abstract void checksourceAndTargetEntityCompliancy() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Validates that both source and target entities comply with relation constraints and schema rules.
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException - if either the source or target entity is missing
      org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException - if any context boundary violations are found
      org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException - if any database/model schema constraints are violated
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if any other database error occurs
    • reallyCreate

      protected com.orientechnologies.orient.core.record.OEdge reallyCreate() throws 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.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<SET extends org.gcube.informationsystem.types.reference.entities.EntitySchema,TET 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
    • newSourceEntityManagement

      protected abstract SEM newSourceEntityManagement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Creates a new management instance for the source entity of the relation (subclass hook).
      Returns:
      the source entity management instance
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database or lookup error
    • newTargetEntityManagement

      protected abstract TEM newTargetEntityManagement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Creates a new management instance for the target entity of the relation (subclass hook).
      Returns:
      the target entity management instance
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database or lookup error
    • reallyUpdate

      protected com.orientechnologies.orient.core.record.OEdge reallyUpdate() throws 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.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<SET extends org.gcube.informationsystem.types.reference.entities.EntitySchema,TET 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.instances.relations.RelationNotFoundException, 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.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<SET extends org.gcube.informationsystem.types.reference.entities.EntitySchema,TET 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
      org.gcube.informationsystem.resourceregistry.api.exceptions.instances.relations.RelationNotFoundException