java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.ElementManagementUtility

public class ElementManagementUtility extends Object
Static helpers shared by the OrientDB *Management classes: UUID-based element lookup (vertex or edge, admin or session-scoped), binding a raw OVertex/OEdge to the appropriate EntityManagement/RelationManagement subclass based on its schema type, and low-level OElement/JsonNode conversion utilities.
Author:
Luca Frosini (ISTI - CNR)
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.orientechnologies.orient.core.record.OElement
    getAnyElementByUUID(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, UUID uuid)
    Resolves an OrientDB OElement (Vertex or Edge) by its UUID within an active database session.
    static com.orientechnologies.orient.core.record.OElement
    Resolves the record holding a UUID as an administrator, whatever it is: among the EntityElements first and the RelationElements then, whose id indexes serve the lookup, and finally among the Property Type definitions, which are plain documents outside both hierarchies.
    static <E extends com.orientechnologies.orient.core.record.OElement>
    E
    Unwraps an Optional containing an OElement, throwing an exception if not present.
    static EntityManagement<?,?>
    getEntityManagement(Environment workingContext, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, com.orientechnologies.orient.core.record.OVertex vertex)
    Instantiates and binds the appropriate EntityManagement subclass for the specified OVertex.
    static Object
    getObjectFromJsonNode(org.gcube.com.fasterxml.jackson.databind.JsonNode value)
    Deserializes and maps a Jackson JsonNode into a corresponding Java object or OrientDB document type.
    static com.orientechnologies.orient.core.metadata.schema.OClass
    getOClass(com.orientechnologies.orient.core.record.OElement oElement)
    Retrieves the schema class of an OElement, throwing an exception if not defined.
    static RelationManagement<?,?>
    getRelationManagement(Environment workingContext, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, com.orientechnologies.orient.core.record.OEdge edge)
    Instantiates and binds the appropriate RelationManagement subclass for the specified OEdge.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ElementManagementUtility

      public ElementManagementUtility()
  • Method Details

    • getAnyElementByUUID

      public static com.orientechnologies.orient.core.record.OElement getAnyElementByUUID(UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Resolves the record holding a UUID as an administrator, whatever it is: among the EntityElements first and the RelationElements then, whose id indexes serve the lookup, and finally among the Property Type definitions, which are plain documents outside both hierarchies. It answers whether a UUID is occupied in the one graph-wide UUID namespace.
      Parameters:
      uuid - the unique identifier of the element
      Returns:
      the loaded OElement
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException - if no record matches the UUID
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database error
    • getAnyElementByUUID

      public static com.orientechnologies.orient.core.record.OElement getAnyElementByUUID(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Resolves an OrientDB OElement (Vertex or Edge) by its UUID within an active database session.
      Parameters:
      oDatabaseDocument - the active OrientDB database connection
      uuid - the unique identifier of the element
      Returns:
      the loaded OElement
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException - if no record matches the UUID
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database error
    • getEntityManagement

      public static EntityManagement<?,?> getEntityManagement(Environment workingContext, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, com.orientechnologies.orient.core.record.OVertex vertex) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Instantiates and binds the appropriate EntityManagement subclass for the specified OVertex.
      Parameters:
      workingContext - the working database environment
      oDatabaseDocument - the active OrientDB database session
      vertex - the OrientDB vertex element
      Returns:
      the bound EntityManagement instance
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if initialization fails, or if the vertex is of an unknown type
    • getRelationManagement

      public static RelationManagement<?,?> getRelationManagement(Environment workingContext, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, com.orientechnologies.orient.core.record.OEdge edge) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Instantiates and binds the appropriate RelationManagement subclass for the specified OEdge.
      Parameters:
      workingContext - the working database environment
      oDatabaseDocument - the active OrientDB database session
      edge - the OrientDB edge element
      Returns:
      the bound RelationManagement instance
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if initialization fails, or if the edge is of an unknown type
    • getElementFromOptional

      public static <E extends com.orientechnologies.orient.core.record.OElement> E getElementFromOptional(Optional<E> optional) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Unwraps an Optional containing an OElement, throwing an exception if not present.
      Type Parameters:
      E - the specific OElement type
      Parameters:
      optional - the optional wrapper
      Returns:
      the unwrapped element
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the optional is empty
    • getOClass

      public static com.orientechnologies.orient.core.metadata.schema.OClass getOClass(com.orientechnologies.orient.core.record.OElement oElement) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Retrieves the schema class of an OElement, throwing an exception if not defined.
      Parameters:
      oElement - the OrientDB element
      Returns:
      the schema class
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the element has no schema class
    • getObjectFromJsonNode

      public static Object getObjectFromJsonNode(org.gcube.com.fasterxml.jackson.databind.JsonNode value) throws jakarta.activation.UnsupportedDataTypeException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Deserializes and maps a Jackson JsonNode into a corresponding Java object or OrientDB document type.
      Parameters:
      value - the JSON value node
      Returns:
      the mapped object
      Throws:
      jakarta.activation.UnsupportedDataTypeException - if the value type is not supported
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on deserialization error