Class AbstractRelationSchemaManagement<T extends AbstractEntitySchemaManagement<TT>,TT 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<ResourceSchemaManagement,T,org.gcube.informationsystem.types.reference.entities.ResourceSchema,TT>
org.gcube.informationsystem.resourceregistry.persistence.orientdb.types.relations.AbstractRelationSchemaManagement<T,TT>
- All Implemented Interfaces:
TypeDefinitionManagement
- Direct Known Subclasses:
ConsistsOfSchemaManagement,IsRelatedToSchemaManagement,RelationSchemaManagement
public abstract class AbstractRelationSchemaManagement<T extends AbstractEntitySchemaManagement<TT>,TT extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
extends RelationElementManagement<ResourceSchemaManagement,T,org.gcube.informationsystem.types.reference.entities.ResourceSchema,TT>
implements TypeDefinitionManagement
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsFields inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.RelationElementManagement
IN, includeSource, includeTarget, OUT, sourceEntityClass, sourceEntityManagement, targetEntityClass, targetEntityManagementFields inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.ElementManagement
accessType, affectedInstances, AT, cachedType, complete, DELETED, DOLLAR, dryRun, element, elementClass, entryPoint, ignoreKeys, ignoreStartWithKeys, jsonNode, limit, logger, maskMetadata, metadataPolicy, oClass, oDatabaseDocument, offset, operation, polymorphic, preservePassedMetadata, reload, sanityCheckDeferred, self, typeName, UNDERSCORE, updateMode, uuid, workingEnvironment -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newAbstractRelationSchemaManagementinstance.AbstractRelationSchemaManagement(TypeEnvironment typeEnvironment, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, Class<TT> clz) Creates a newAbstractRelationSchemaManagementinstance with database and environment context bindings. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 map of instances affected by operations on this element.com.orientechnologies.orient.core.record.OEdgeReturns the OrientDB element instance, retrieving and caching it if not already present.getName()Returns the name of the Type definition.protected org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentExceptiongetSpecificAlreadyPresentException(String message) Converts a generic AlreadyPresentException into a subclass-specific AlreadyPresentException.protected org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundExceptiongetSpecificNotFoundException(org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException e) Converts a generic NotFoundException into a subclass-specific NotFoundException.protected EnvironmentReturns the active database working environment.protected ResourceSchemaManagementCreates a new management instance for the source 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).Retrieves all elements from the database and returns them as a JSON array string.protected com.orientechnologies.orient.core.record.OEdgeUpdates an existing element in the database (subclass hook).com.orientechnologies.orient.core.record.OEdgeDirectly queries and retrieves the OrientDB element from the database.voidSets the name of the Type definition.Methods inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.RelationElementManagement
getSourceEntityManagement, getTargetEntityManagement, includeSource, includeTarget, newTargetEntityManagement, setSourceEntityManagement, setTargetEntityManagementMethods inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.ElementManagement
all, applyPrivacyMask, applyPrivacyMask, checkERMatch, checkJsonNode, checkUUIDMatch, checkUUIDNotAlreadyInUse, cleanCachedSerialization, concludeTransaction, create, createOrUpdate, createOrUpdateElementWithResult, delete, exists, getAccessType, getAllProperties, getCachedType, getCurrentODatabaseDocumentFromThreadLocal, getLimit, getMandatoryErrorMessage, getMandatoryErrorMessage, getMetadataPolicy, getOClass, getOffset, getPropertyForJson, getPropertyMap, getTypeName, getUpdateMode, getUUID, internalCreate, internalCreateOrUdate, internalDelete, internalUpdate, isDryRun, isMaskMetadata, isPolymorphic, isPreservePassedMetadata, isReload, isSanityCheckDeferred, read, requireExplicitUUID, retrieveElementFromAnyContext, sanityCheck, serializeAsAffectedInstance, serializeAsJsonNode, serializeSelfAsJsonNode, setAsEntryPoint, setDryRun, setElement, setElementType, setJson, setJsonNode, setLimit, setMaskMetadata, setMetadataPolicy, setOClass, setODatabaseDocument, setOffset, setOperation, setPolymorphic, setPreservePassedMetadata, setProperty, setReload, setRequireExplicitUUID, setSanityCheckDeferred, setUpdateMode, setUUID, setWorkingEnvironment, typeSatified, update, updateProperties
-
Field Details
-
name
The name of the relation type.
-
-
Constructor Details
-
AbstractRelationSchemaManagement
Creates a newAbstractRelationSchemaManagementinstance.- Parameters:
clz- the target entity type class
-
AbstractRelationSchemaManagement
public AbstractRelationSchemaManagement(TypeEnvironment typeEnvironment, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, Class<TT> clz) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Creates a newAbstractRelationSchemaManagementinstance with database and environment context bindings.- Parameters:
typeEnvironment- the type environment contextoDatabaseDocument- the database connectionclz- the target entity type class- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if initialization fails
-
-
Method Details
-
getAffectedInstances
Description copied from class:ElementManagementReturns the map of instances affected by operations on this element.- Overrides:
getAffectedInstancesin classElementManagement<com.orientechnologies.orient.core.record.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT 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.ResourceRegistryExceptionDescription copied from class:ElementManagementReturns the active database working environment.- Specified by:
getWorkingEnvironmentin classElementManagement<com.orientechnologies.orient.core.record.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT 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
Description copied from interface:TypeDefinitionManagementSets the name of the Type definition.- Specified by:
setNamein interfaceTypeDefinitionManagement- Parameters:
name- the name of the Type definition to set
-
getName
Description copied from interface:TypeDefinitionManagementReturns the name of the Type definition.- Specified by:
getNamein interfaceTypeDefinitionManagement- Returns:
- the name of the Type definition
-
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.- Overrides:
createCompleteJsonNodein classRelationElementManagement<ResourceSchemaManagement,T extends AbstractEntitySchemaManagement<TT>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT 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.OEdge reallyCreate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from class:ElementManagementPersists a new element in the database (subclass hook).- Overrides:
reallyCreatein classRelationElementManagement<ResourceSchemaManagement,T extends AbstractEntitySchemaManagement<TT>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT 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
-
reallyUpdate
protected com.orientechnologies.orient.core.record.OEdge reallyUpdate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from class:ElementManagementUpdates an existing element in the database (subclass hook).- Overrides:
reallyUpdatein classRelationElementManagement<ResourceSchemaManagement,T extends AbstractEntitySchemaManagement<TT>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT 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.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from class:ElementManagementDeletes an existing element from the database (subclass hook).- Overrides:
reallyDeletein classRelationElementManagement<ResourceSchemaManagement,T extends AbstractEntitySchemaManagement<TT>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT 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 error
-
getElement
public com.orientechnologies.orient.core.record.OEdge getElement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from class:ElementManagementReturns the OrientDB element instance, retrieving and caching it if not already present.- Overrides:
getElementin classElementManagement<com.orientechnologies.orient.core.record.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT 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 existorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if the element belongs to another contextorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
retrieveElement
public com.orientechnologies.orient.core.record.OEdge retrieveElement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from class:ElementManagementDirectly queries and retrieves the OrientDB element from the database.- Overrides:
retrieveElementin classElementManagement<com.orientechnologies.orient.core.record.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT 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 existorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
reallyGetAll
public String reallyGetAll() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from class:ElementManagementRetrieves all elements from the database and returns them as a JSON array string.- Specified by:
reallyGetAllin classElementManagement<com.orientechnologies.orient.core.record.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT 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:ElementManagementConverts a generic NotFoundException into a subclass-specific NotFoundException.- Specified by:
getSpecificNotFoundExceptionin classElementManagement<com.orientechnologies.orient.core.record.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT 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:ElementManagementConverts a generic AlreadyPresentException into a subclass-specific AlreadyPresentException.- Specified by:
getSpecificAlreadyPresentExceptionin classElementManagement<com.orientechnologies.orient.core.record.OEdge,org.gcube.informationsystem.types.reference.relations.RelationSchema<org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT extends org.gcube.informationsystem.types.reference.entities.EntitySchema>> - Parameters:
message- the exception message- Returns:
- the specific AlreadyPresentException
-
newSourceEntityManagement
protected ResourceSchemaManagement newSourceEntityManagement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from class:RelationElementManagementCreates a new management instance for the source entity of the relation (subclass hook).- Specified by:
newSourceEntityManagementin classRelationElementManagement<ResourceSchemaManagement,T extends AbstractEntitySchemaManagement<TT>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT extends org.gcube.informationsystem.types.reference.entities.EntitySchema> - Returns:
- the source entity management instance
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or lookup error
-
checksourceAndTargetEntityCompliancy
protected void checksourceAndTargetEntityCompliancy() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from class:RelationElementManagementValidates that both source and target entities comply with relation constraints and schema rules.- Specified by:
checksourceAndTargetEntityCompliancyin classRelationElementManagement<ResourceSchemaManagement,T extends AbstractEntitySchemaManagement<TT>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, TT extends org.gcube.informationsystem.types.reference.entities.EntitySchema> - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if either the source or target entity is missingorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException- if any database/model schema constraints are violatedorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if any context boundary violations are foundorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if any other database error occurs
-