Class ElementManagementUtility
java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.ElementManagementUtility
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic com.orientechnologies.orient.core.record.OElementgetAnyElementByUUID(com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, UUID uuid) Resolves an OrientDBOElement(Vertex or Edge) by its UUID within an active database session.static com.orientechnologies.orient.core.record.OElementgetAnyElementByUUID(UUID uuid) Resolves an OrientDBOElement(Vertex or Edge) by its UUID as an administrator, among theEntityElements first and theRelationElements then, whoseidindexes serve the lookup.static <E extends com.orientechnologies.orient.core.record.OElement>
EgetElementFromOptional(Optional<E> optional) Unwraps anOptionalcontaining anOElement, 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 appropriateEntityManagementsubclass for the specifiedOVertex.static ObjectgetObjectFromJsonNode(org.gcube.com.fasterxml.jackson.databind.JsonNode value) Deserializes and maps a JacksonJsonNodeinto a corresponding Java object or OrientDB document type.static com.orientechnologies.orient.core.metadata.schema.OClassgetOClass(com.orientechnologies.orient.core.record.OElement oElement) Retrieves the schema class of anOElement, 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 appropriateRelationManagementsubclass for the specifiedOEdge.
-
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 an OrientDBOElement(Vertex or Edge) by its UUID as an administrator, among theEntityElements first and theRelationElements then, whoseidindexes serve the lookup.- 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 UUIDorg.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 OrientDBOElement(Vertex or Edge) by its UUID within an active database session.- Parameters:
oDatabaseDocument- the active OrientDB database connectionuuid- the unique identifier of the element- Returns:
- the loaded
OElement - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if no record matches the UUIDorg.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 appropriateEntityManagementsubclass for the specifiedOVertex.- Parameters:
workingContext- the working database environmentoDatabaseDocument- the active OrientDB database sessionvertex- the OrientDB vertex element- Returns:
- the bound
EntityManagementinstance - 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 appropriateRelationManagementsubclass for the specifiedOEdge.- Parameters:
workingContext- the working database environmentoDatabaseDocument- the active OrientDB database sessionedge- the OrientDB edge element- Returns:
- the bound
RelationManagementinstance - 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 anOptionalcontaining anOElement, 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 anOElement, 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 JacksonJsonNodeinto 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 supportedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on deserialization error
-