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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDirection constant for incoming edge direction.protected booleanFlag indicating whether to include the source entity representation in output.protected booleanFlag indicating whether to include the target entity representation in output.static final StringDirection constant for outgoing edge direction.protected final Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement>Class representing the source entity type.protected SEMManager instance for the source entity.protected final Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement>Class representing the target entity type.protected TEMManager instance for the target entity.Fields inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.ElementManagement
accessType, affectedInstances, AT, cachedType, complete, DELETED, DOLLAR, dryRun, element, elementClass, entryPoint, ignoredFields, ignoreKeys, ignoreStartWithKeys, jsonNode, limit, logger, maskMetadata, metadataPolicy, oClass, oDatabaseDocument, offset, operation, polymorphic, preservePassedMetadata, reload, sanityCheckDeferred, self, typeName, UNDERSCORE, updateMode, uuid, workingEnvironment -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRelationElementManagement(String typeName, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> sourceEntityClass, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> targetEntityClass) Creates a newRelationElementManagementinstance with the specified relation type name, source class, and target class.protectedRelationElementManagement(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 newRelationElementManagementinstance with name, database, and environment context bindings.protectedRelationElementManagement(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 newRelationElementManagementinstance with the specified access type and entity classes.protectedRelationElementManagement(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 newRelationElementManagementinstance with database and environment context bindings. -
Method Summary
Modifier and TypeMethodDescriptionprotected static booleancarriesContent(org.gcube.com.fasterxml.jackson.databind.JsonNode endpoint, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> entityClass) Returns whether a submitted endpoint carries content beyond the system fields, i.e. whether it is the complete representation of the endpoint rather than an endpoint reference.protected abstract voidValidates that both source and target entities comply with relation constraints and schema rules.protected org.gcube.com.fasterxml.jackson.databind.JsonNodeAbstract method to create the complete JSON node representation of the element.Returns the manager instance for the source entity of this relation.protected org.gcube.com.fasterxml.jackson.databind.JsonNodegetSubmittedEndpoint(String property, boolean idRequired) Returns the submittedsourceortargetof this relation, which must be a JSON object carrying a textualtypeand a valid UUIDid.protected org.gcube.com.fasterxml.jackson.databind.JsonNodeReturns the submittedsourceof this relation, which is always an endpoint reference: a source never carries the content of the source Resource.Returns the manager instance for the target entity of this relation.voidincludeSource(boolean includeSource) Sets whether to include the source entity representation in the serialized JSON.voidincludeTarget(boolean includeTarget) Sets whether to include the target entity representation in the serialized JSON.protected abstract SEMCreates a new management instance for the source entity of the relation (subclass hook).protected abstract TEMCreates a new management instance for the target entity of the relation (subclass hook).protected com.orientechnologies.orient.core.record.OEdgePersists a new element in the database (subclass hook).protected voidDeletes an existing element from the database (subclass hook).protected com.orientechnologies.orient.core.record.OEdgeUpdates an existing element in the database (subclass hook).voidsetSourceEntityManagement(SEM sourceEntityManagement) Sets the manager instance for the source entity of this relation.voidsetTargetEntityManagement(TEM targetEntityManagement) Sets the manager instance for the target entity of this relation.protected voidwriteTarget(org.gcube.com.fasterxml.jackson.databind.JsonNode target) Resolves the target of a relation being created, already bound totargetEntityManagement.Methods inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.ElementManagement
addIgnoredFields, afterModification, all, applyPrivacyMask, applyPrivacyMask, checkERMatch, checkJsonNode, checkUUIDMatch, checkUUIDNotAlreadyInUse, cleanCachedSerialization, concludeTransaction, create, createOrUpdate, createOrUpdateElementWithResult, delete, exists, getAccessType, getAffectedInstances, getAllProperties, getCachedType, getCurrentODatabaseDocumentFromThreadLocal, getElement, getIgnoredFields, getLimit, getMandatoryErrorMessage, getMandatoryErrorMessage, getMetadataPolicy, getOClass, getOffset, getPropertyForJson, getPropertyMap, getSpecificAlreadyPresentException, getSpecificNotFoundException, getTypeName, getUpdateMode, getUUID, getWorkingEnvironment, internalCreate, internalCreateOrUdate, internalDelete, internalUpdate, isBackendLinkFieldName, isDryRun, isMaskMetadata, isPolymorphic, isPreservePassedMetadata, isReload, isSanityCheckDeferred, read, reallyGetAll, requireExplicitUUID, retrieveElement, retrieveElementFromAnyContext, sanityCheck, serializeAsAffectedInstance, serializeAsEndpointReference, serializeAsJsonNode, serializeSelfAsJsonNode, setAsEntryPoint, setDryRun, setElement, setElementType, setIgnoredFields, setJson, setJsonNode, setLimit, setMaskMetadata, setMetadataPolicy, setOClass, setODatabaseDocument, setOffset, setOperation, setPolymorphic, setPreservePassedMetadata, setProperty, setReload, setRequireExplicitUUID, setSanityCheckDeferred, setUpdateMode, setUUID, setWorkingEnvironment, typeSatified, update, updateProperties
-
Field Details
-
IN
Direction constant for incoming edge direction.- See Also:
-
OUT
Direction constant for outgoing edge direction.- See Also:
-
sourceEntityClass
protected final Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> sourceEntityClassClass representing the source entity type. -
targetEntityClass
protected final Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> targetEntityClassClass representing the target entity type. -
sourceEntityManagement
protected SEM extends EntityElementManagement<? extends org.gcube.informationsystem.base.reference.entities.EntityElement,SET> sourceEntityManagementManager instance for the source entity. -
targetEntityManagement
protected TEM extends EntityElementManagement<? extends org.gcube.informationsystem.base.reference.entities.EntityElement,TET> targetEntityManagementManager instance for the target entity. -
includeSource
protected boolean includeSourceFlag indicating whether to include the source entity representation in output. -
includeTarget
protected boolean includeTargetFlag 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 newRelationElementManagementinstance with the specified access type and entity classes.- Parameters:
accessType- the JAX-RS access type of the relationsourceEntityClass- the source entity classtargetEntityClass- 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 newRelationElementManagementinstance with the specified relation type name, source class, and target class.- Parameters:
typeName- the name of the relation typesourceEntityClass- the source entity classtargetEntityClass- 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 newRelationElementManagementinstance with database and environment context bindings.- Parameters:
accessType- the JAX-RS access typesourceEntityClass- the source entity classtargetEntityClass- the target entity classworkingContext- the working environment contextorientGraph- 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 newRelationElementManagementinstance with name, database, and environment context bindings.- Parameters:
typeName- the name of the relation typesourceEntityClass- the source entity classtargetEntityClass- the target entity classworkingContext- the working environment contextorientGraph- 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-trueto include,falseto exclude
-
includeTarget
public void includeTarget(boolean includeTarget) Sets whether to include the target entity representation in the serialized JSON.- Parameters:
includeTarget-trueto include,falseto exclude
-
getSourceEntityManagement
public SEM getSourceEntityManagement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns 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.ResourceRegistryExceptionReturns 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
Sets the manager instance for the source entity of this relation.- Parameters:
sourceEntityManagement- the source entity manager to set
-
setTargetEntityManagement
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.ResourceRegistryExceptionDescription copied from class:ElementManagementAbstract method to create the complete JSON node representation of the element.- Specified by:
createCompleteJsonNodein classElementManagement<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.ResourceRegistryExceptionValidates 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 missingorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if any context boundary violations are foundorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException- if any database/model schema constraints are violatedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if any other database error occurs
-
carriesContent
protected static boolean carriesContent(org.gcube.com.fasterxml.jackson.databind.JsonNode endpoint, Class<? extends org.gcube.informationsystem.base.reference.entities.EntityElement> entityClass) Returns whether a submitted endpoint carries content beyond the system fields, i.e. whether it is the complete representation of the endpoint rather than an endpoint reference. An emptyconsistsOforisRelatedToarray of a Resource is not content: it is how the model serializes a Resource that carries only itsid.- Parameters:
endpoint- the submitted endpointentityClass- the category of the endpoint- Returns:
trueif the endpoint carries any content
-
getSubmittedEndpoint
protected org.gcube.com.fasterxml.jackson.databind.JsonNode getSubmittedEndpoint(String property, boolean idRequired) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Returns the submittedsourceortargetof this relation, which must be a JSON object carrying a textualtypeand a valid UUIDid.- Parameters:
property-RelationElement.SOURCE_PROPERTYorRelationElement.TARGET_PROPERTYidRequired- whether the endpoint must carry itsid- Returns:
- the submitted endpoint
- Throws:
jakarta.ws.rs.BadRequestException- if the endpoint is missing, null or malformedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if theidis not a valid UUID
-
getSubmittedSourceReference
protected org.gcube.com.fasterxml.jackson.databind.JsonNode getSubmittedSourceReference() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the submittedsourceof this relation, which is always an endpoint reference: a source never carries the content of the source Resource.- Returns:
- the submitted source reference
- Throws:
jakarta.ws.rs.BadRequestException- if the source is missing, null, malformed or expandedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if theidis not a valid UUID
-
writeTarget
protected void writeTarget(org.gcube.com.fasterxml.jackson.databind.JsonNode target) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Resolves the target of a relation being created, already bound totargetEntityManagement. An endpoint reference never creates: it identifies an existing target in the token Context. A complete representation is written together with the relation: aPOSTcreates it, so its UUID must be unused; aPUTcreates it when its UUID is unused and replaces it otherwise, exactly as aPUTaddressed to the target itself.- Parameters:
target- the submitted target- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the target cannot be resolved or written
-
reallyCreate
protected com.orientechnologies.orient.core.record.OEdge reallyCreate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from class:ElementManagementPersists a new element in the database (subclass hook).- Specified by:
reallyCreatein classElementManagement<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 databaseorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on any database error
-
newSourceEntityManagement
protected abstract SEM newSourceEntityManagement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionCreates 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.ResourceRegistryExceptionCreates 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.ResourceRegistryExceptionDescription copied from class:ElementManagementUpdates an existing element in the database (subclass hook).- Specified by:
reallyUpdatein classElementManagement<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 databaseorg.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.ResourceRegistryExceptionDescription copied from class:ElementManagementDeletes an existing element from the database (subclass hook).- Specified by:
reallyDeletein classElementManagement<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 databaseorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on any database errororg.gcube.informationsystem.resourceregistry.api.exceptions.instances.relations.RelationNotFoundException
-