Class ResourceManagement
java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.ElementManagement<com.orientechnologies.orient.core.record.OVertex,ET>
org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.EntityElementManagement<E,ET>
org.gcube.informationsystem.resourceregistry.persistence.orientdb.instances.entities.EntityManagement<org.gcube.informationsystem.model.reference.entities.Resource,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
org.gcube.informationsystem.resourceregistry.persistence.orientdb.instances.entities.ResourceManagement
- All Implemented Interfaces:
ERManagement
public class ResourceManagement
extends EntityManagement<org.gcube.informationsystem.model.reference.entities.Resource,org.gcube.informationsystem.types.reference.entities.ResourceSchema>
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
Fields inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.instances.entities.EntityManagement
activeOnlyHierarchical, contextsPolicy, forceAddToContext, hierarchical, orphanCandidates, propagationMode, skipped, sourceInstanceEnvironment, targetInstanceEnvironment, visitedFields inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.EntityElementManagement
IN_PREFIX, OUT_PREFIX, relationManagementsFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.gcube.com.fasterxml.jackson.databind.JsonNodeaddConsistsOf(org.gcube.com.fasterxml.jackson.databind.JsonNode sourceResource, org.gcube.com.fasterxml.jackson.databind.JsonNode consistsOf) Helper that appends a "consistsOf" relation node to the given resource JSON node.static org.gcube.com.fasterxml.jackson.databind.JsonNodeaddIsRelatedTo(org.gcube.com.fasterxml.jackson.databind.JsonNode sourceResource, org.gcube.com.fasterxml.jackson.databind.JsonNode isRelatedTo) Helper that appends an "isRelatedTo" relation node to the given resource JSON node.protected booleanconstraintSatisfied(org.gcube.informationsystem.types.reference.properties.LinkedEntity constraint, String consistsOfType, String facetType) Checks whether a given relation and facet type satisfy the specified schema constraint.org.gcube.com.fasterxml.jackson.databind.JsonNodeAbstract method to create the complete JSON node representation of the element.protected Set<org.gcube.informationsystem.types.reference.properties.LinkedEntity>Resolves the set of facet-linking constraints defined on this resource type and its supertypes.protected org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceAlreadyPresentExceptiongetSpecificAlreadyPresentException(String message) Converts a generic AlreadyPresentException into a subclass-specific AlreadyPresentException.org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceAvailableInAnotherContextExceptionReturns the subclass-specific AvailableInAnotherContextException instance.protected org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceNotFoundExceptiongetSpecificNotFoundException(org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException e) Converts a generic NotFoundException into a subclass-specific NotFoundException.protected voidAbstract method implementation that performs the database-level operations to add the entity and its propagated components to the target context.protected com.orientechnologies.orient.core.record.OVertexPersists a new element in the database (subclass hook).protected voidDeletes an existing element from the database (subclass hook).protected com.orientechnologies.orient.core.record.OVertexUpdates an existing element in the database (subclass hook).voidThe default sanity check is not valid for resources which do not have properties and instead must be validated in terms of facets.voidDisables the sanity check on deletion operations.Methods inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.instances.entities.EntityManagement
addRelation, addToContext, addToRelationManagements, createVertex, getContexts, getContextsAsObjectNode, getContextsPolicy, getContextsSet, getElement, getMembershipView, getOrphanCandidates, getPropagationMode, getRelationManagement, getSourceInstanceEnvironment, getTargetInstanceEnvironment, getVisited, getWorkingEnvironment, internalAddToContext, internalRemoveFromContext, isActiveOnlyHierarchical, isForceAddToContext, isHierarchical, query, reallyGetAll, reallyQuery, reallyRemoveFromContext, removeFromContext, setActiveOnlyHierarchical, setContextsPolicy, setForceAddToContext, setHierarchical, setMembershipView, setOrphanCandidates, setPropagationMode, setSourceInstanceEnvironment, setTargetInstanceEnvironment, setVisitedMethods inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.EntityElementManagement
addToRelationManagement, getBaseRelationManagementMethods inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.ElementManagement
addIgnoredFields, all, applyPrivacyMask, applyPrivacyMask, checkERMatch, checkJsonNode, checkUUIDMatch, checkUUIDNotAlreadyInUse, cleanCachedSerialization, concludeTransaction, create, createOrUpdate, createOrUpdateElementWithResult, delete, exists, getAccessType, getAffectedInstances, getAllProperties, getCachedType, getCurrentODatabaseDocumentFromThreadLocal, getIgnoredFields, getLimit, getMandatoryErrorMessage, getMandatoryErrorMessage, getMetadataPolicy, getOClass, getOffset, getPropertyForJson, getPropertyMap, getTypeName, getUpdateMode, getUUID, internalCreate, internalCreateOrUdate, internalDelete, internalUpdate, isBackendLinkFieldName, isDryRun, isMaskMetadata, isPolymorphic, isPreservePassedMetadata, isReload, isSanityCheckDeferred, read, requireExplicitUUID, retrieveElement, retrieveElementFromAnyContext, 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, updatePropertiesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.gcube.informationsystem.resourceregistry.persistence.ERManagement
getAffectedInstances
-
Constructor Details
-
ResourceManagement
public ResourceManagement()Creates a newResourceManagementinstance.
-
-
Method Details
-
setSanityCheckNotRequired
public void setSanityCheckNotRequired()Disables the sanity check on deletion operations. -
getSpecificNotFoundException
protected org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceNotFoundException 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.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema> - Parameters:
e- the generic exception- Returns:
- the specific NotFoundException
-
getSpecificAvailableInAnotherContextException
public org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceAvailableInAnotherContextException getSpecificAvailableInAnotherContextException(String message) Description copied from interface:ERManagementReturns the subclass-specific AvailableInAnotherContextException instance.- Parameters:
message- the exception message- Returns:
- the specific AvailableInAnotherContextException
-
getSpecificAlreadyPresentException
protected org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceAlreadyPresentException 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.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema> - Parameters:
message- the exception message- Returns:
- the specific AlreadyPresentException
-
createCompleteJsonNode
public 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.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema> - Returns:
- the complete JSON node representing the element and its relationships
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on serialization or mapping error
-
addConsistsOf
public static org.gcube.com.fasterxml.jackson.databind.JsonNode addConsistsOf(org.gcube.com.fasterxml.jackson.databind.JsonNode sourceResource, org.gcube.com.fasterxml.jackson.databind.JsonNode consistsOf) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Helper that appends a "consistsOf" relation node to the given resource JSON node.- Parameters:
sourceResource- the source resource JSON nodeconsistsOf- the consistsOf relation JSON node- Returns:
- the updated JSON node
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the operation fails
-
addIsRelatedTo
public static org.gcube.com.fasterxml.jackson.databind.JsonNode addIsRelatedTo(org.gcube.com.fasterxml.jackson.databind.JsonNode sourceResource, org.gcube.com.fasterxml.jackson.databind.JsonNode isRelatedTo) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Helper that appends an "isRelatedTo" relation node to the given resource JSON node.- Parameters:
sourceResource- the source resource JSON nodeisRelatedTo- the isRelatedTo relation JSON node- Returns:
- the updated JSON node
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the operation fails
-
reallyCreate
protected com.orientechnologies.orient.core.record.OVertex reallyCreate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceAlreadyPresentException, 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.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema> - 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 errororg.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceAlreadyPresentException
-
reallyUpdate
protected com.orientechnologies.orient.core.record.OVertex reallyUpdate() throws org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceNotFoundException, 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.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema> - 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 errororg.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceNotFoundException
-
reallyDelete
protected void reallyDelete() throws org.gcube.informationsystem.resourceregistry.api.exceptions.instances.entities.resource.ResourceNotFoundException, 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.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema> - 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.entities.resource.ResourceNotFoundException
-
reallyAddToContext
protected void reallyAddToContext() throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from class:EntityManagementAbstract method implementation that performs the database-level operations to add the entity and its propagated components to the target context.- Overrides:
reallyAddToContextin classEntityManagement<org.gcube.informationsystem.model.reference.entities.Resource,org.gcube.informationsystem.types.reference.entities.ResourceSchema> - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if context rules or scoping constraints are violatedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or execution error
-
getResourceTypeConstraint
protected Set<org.gcube.informationsystem.types.reference.properties.LinkedEntity> getResourceTypeConstraint() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionResolves the set of facet-linking constraints defined on this resource type and its supertypes.- Returns:
- the set of constraints
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if a schema validation error occursorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if database lookup fails
-
constraintSatisfied
protected boolean constraintSatisfied(org.gcube.informationsystem.types.reference.properties.LinkedEntity constraint, String consistsOfType, String facetType) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Checks whether a given relation and facet type satisfy the specified schema constraint.- Parameters:
constraint- the schema constraint to checkconsistsOfType- the relation type namefacetType- the facet type name- Returns:
trueif satisfied,falseotherwise- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException- if validation failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if lookup fails
-
sanityCheck
public void sanityCheck() throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionThe default sanity check is not valid for resources which do not have properties and instead must be validated in terms of facets. The Resource Metadata is managed with dedicated code for all instaces.- Overrides:
sanityCheckin classElementManagement<com.orientechnologies.orient.core.record.OVertex,org.gcube.informationsystem.types.reference.entities.ResourceSchema> - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException- if a schema constraint is violatedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database lookup failure
-