Class RelationManagement<T extends EntityManagement<? extends org.gcube.informationsystem.model.reference.entities.Entity,TET>,TET extends org.gcube.informationsystem.types.reference.entities.EntitySchema>
- All Implemented Interfaces:
ERManagement
- Direct Known Subclasses:
ConsistsOfManagement,IsRelatedToManagement
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanWhether the active-only hierarchical reader channel must be used.protected booleanWhetherreallyAddToContext()actually calledtargetInstanceEnvironment.addElement(...)for this relation on its last run, i.e.protected org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicyThe contexts inclusion policy for responses.final org.gcube.informationsystem.model.reference.properties.PropagationConstraintThe default propagation constraint.protected booleanThe instance is added to the context even if not in source context.protected booleanWhether hierarchical lookup is enabled.protected org.gcube.informationsystem.model.reference.properties.PropagationConstraintThe active propagation constraint for this relation.protected org.gcube.informationsystem.resourceregistry.api.rest.PropagationModeBy default the system honours the propagation constraints so this variable is initialised as true.protected booleanFlag indicating whether the add operation was skipped.protected InstanceEnvironmentThe source context of an addToContextprotected InstanceEnvironmentThe target context of an addToContext/removeFromContextShared, mutable set of UUIDs (entities and relations alike) already visited during the currentaddToContext(UUID)cascade.Fields 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
ConstructorsModifierConstructorDescriptionprotectedRelationManagement(org.gcube.informationsystem.base.reference.AccessType accessType, Class<? extends org.gcube.informationsystem.model.reference.entities.Entity> targetEntityClass, org.gcube.informationsystem.model.reference.properties.PropagationConstraint defaultPropagationConstraint) Creates a newRelationManagementinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToContext(UUID contextUUID) Adds the entity/relationship to the specified context, evaluating schemas and constraints.protected voidVerifies, normalizes, and sets the propagation constraint on the database element.protected voidValidates that both source and target entities comply with relation constraints and schema rules.voidForces the addition of this relation and both its source and target entities to the target context environment, bypassing standard source-context presence validation.fullSerialize(Map<String, org.gcube.com.fasterxml.jackson.databind.JsonNode> visitedSourceResources) Serializes this relation fully into the given map of visited resources.Returns all contexts where this element is visible as a formatted JSON string.org.gcube.com.fasterxml.jackson.databind.node.ObjectNodeReturns all contexts where this element is visible as an ObjectNode mapping Context UUIDs to paths.org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicyReturns the contexts inclusion policy for responses.Returns the set of Context UUID strings where this element is visible.Gets the visibility policy for filtering contexts on read.Gets the current context path for context visibility resolution.com.orientechnologies.orient.core.record.OEdgeReturns the OrientDB element instance, retrieving and caching it if not already present.protected StringgetEntityTypeNotValidErrroMessage(String entityPosition, String requiredType, String effectiveType) Generates a schema violation error message when an entity type is not compatible with relation constraints.protected PropagationConstraintOrientgetPropagationConstraint(com.orientechnologies.orient.core.record.impl.ODocument oDocument) Resolves the propagation constraint for this relation from the given document, falling back to the default constraint if needed.org.gcube.informationsystem.resourceregistry.api.rest.PropagationModeReturns the propagation mode for context sharing.Returns the sourceInstanceEnvironmentused to evaluate context sharing operations.Returns the targetInstanceEnvironmentof the operation.Returns the shared, mutable set of UUIDs already visited during the currentERManagement.addToContext(UUID)cascade.protected EnvironmentReturns the active database working environment.Returns the source entity manager as-is (without lazy-loading).voidPerforms the internal low-level operations to add the entity/relationship to the target context.voidPerforms the internal low-level operations to remove the entity/relationship from the context.booleanGets whether the active-only hierarchical reader channel must be used instead of the unrestricted one - meaningless unlessERManagement.isHierarchical()is alsotrue.booleanReturns whether the lastreallyAddToContext()run added this relation to the target Context.booleanisAvailableOnContext(InstanceEnvironment instanceEnvironment) Returnstrueif this relation is available in the specified context.booleanGets whether descendant Contexts with a non-ACTIVEeffectiveStatemust additionally be filtered out of thecontextsmap.booleanGets whether the operation should force add to context even if the instance is not in source context.booleanGets whether hierarchical lookup is enabled.protected ResourceManagementCreates a new management instance for the source entity of the relation (subclass hook).protected voidAdds this relation and potentially its target to the target context environment, adhering to propagation constraints.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.Removes this relation and potentially its target from the target context environment, adhering to propagation constraints.protected com.orientechnologies.orient.core.record.OEdgeUpdates an existing element in the database (subclass hook).voidremoveFromContext(UUID contextUUID) Removes the entity/relationship from the specified context.protected StringserializeJsonNodeCollectionAsString(Collection<org.gcube.com.fasterxml.jackson.databind.JsonNode> collection) Serializes a collection ofJsonNodeentities into a JSON array string.voidsetActiveOnlyHierarchical(boolean activeOnlyHierarchical) Sets whether the active-only hierarchical reader channel must be used instead of the unrestricted one.voidsetContextsPolicy(org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy contextsPolicy) Sets the contexts inclusion policy for responses.voidSets the visibility policy for filtering contexts on read.voidsetCurrentContextPath(String path) Sets the current context path for context visibility resolution.voidsetFilterNonActiveDescendants(boolean filterNonActiveDescendants) Sets whether descendant Contexts with a non-ACTIVEeffectiveStatemust additionally be filtered out of thecontextsmap, on top of whateverERManagement.setContextVisibilityPolicy(ContextVisibilityPolicy)already applies.voidsetForceAddToContext(boolean forceAddToContext) Sets whether the operation should force add to context even if the instance is not in source context.voidsetHierarchical(boolean hierarchical) Sets whether hierarchical lookup is enabled.voidsetPropagationMode(org.gcube.informationsystem.resourceregistry.api.rest.PropagationMode propagationMode) Sets the propagation mode for context sharing.voidSets the source InstanceEnvironment used to evaluate addToContextvoidSets the target security context of addToContext/removeFromContextvoidsetVisited(Set<UUID> visited) Sets the shared, mutable set of UUIDs (entities and relations alike) already visited during the currentERManagement.addToContext(UUID)cascade.Methods inherited from class org.gcube.informationsystem.resourceregistry.persistence.orientdb.base.RelationElementManagement
createCompleteJsonNode, 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, getAffectedInstances, getAllProperties, getCachedType, getCurrentODatabaseDocumentFromThreadLocal, getLimit, getMandatoryErrorMessage, getMandatoryErrorMessage, getMetadataPolicy, getOClass, getOffset, getPropertyForJson, getPropertyMap, getSpecificAlreadyPresentException, getSpecificNotFoundException, getTypeName, getUpdateMode, getUUID, internalCreate, internalCreateOrUdate, internalDelete, internalUpdate, isDryRun, isMaskMetadata, isPolymorphic, isPreservePassedMetadata, isReload, isSanityCheckDeferred, read, requireExplicitUUID, retrieveElement, 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, 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, getSpecificAvailableInAnotherContextException
-
Field Details
-
sourceInstanceEnvironment
The source context of an addToContext -
targetInstanceEnvironment
The target context of an addToContext/removeFromContext -
propagationMode
protected org.gcube.informationsystem.resourceregistry.api.rest.PropagationMode propagationModeBy default the system honours the propagation constraints so this variable is initialised as true. To revert a previous operation or for a particular maintenance we could ask the service not to honour the propagation constraints, but only under certain conditions and with some limitations. These limitations are required to keep the system in a consistent state. In fact, this directive is only valid for Resources and IsRelatedTo relations. We need to take into account that when adding an IsRelatedTo to a context, the source and target Resources must always be in such a Context. Please also take into account that adding a Resource to a context always implies honouring the propagation constraints of ConsistsOf relations. In fact, a resource must be characterised by at least one facet in any context it belongs to. Given that we cannot make assumptions on which facets must be used, a way could be to consider only the facets that are mandatory for such a Resource Type, but the type could not have mandatory facets (even though every Resource Type in the gCube Model has one mandatory facet). Conversely, when a Resource is removed from a Context all the facets characterising it must be removed. This option can also be used in conjunction withElementManagement.dryRun=true. This allows simulating a sharing operation without honouring the propagation constraints. -
visited
Shared, mutable set of UUIDs (entities and relations alike) already visited during the currentaddToContext(UUID)cascade. Guarantees termination on a graph cycle (e.g. a cyclicIsRelatedTochain) independently ofPropagationMode— populated and checked unconditionally, even in modes (SHALLOW) whose own already-present check would already prevent a re-visit, so the guard stays uniform and orthogonal to mode semantics.Not the same bookkeeping as
ElementManagement.affectedInstances: this set is marked on entry, before recursing into children (pre-order) - a node re-entered mid-cycle is caught here even though its own processing hasn't finished yet.ElementManagement.affectedInstancesis only populated when processing completes successfully (post-order), so it cannot double as a cycle guard - a node being re-entered mid-recursion has not been added to it yet. -
addedToContext
protected boolean addedToContextWhetherreallyAddToContext()actually calledtargetInstanceEnvironment.addElement(...)for this relation on its last run, i.e. whether its add constraint let it (and its target) into the target Context.Distinct from both
visited(has this UUID been attempted at all, in this cascade - the cycle guard) andElementManagement.affectedInstances(what should be reported back to the caller): this field only answers "did this specific run ofreallyAddToContext()actually add the element to the target Context." -
forceAddToContext
protected boolean forceAddToContextThe instance is added to the context even if not in source context. -
hierarchical
protected boolean hierarchicalWhether hierarchical lookup is enabled. -
activeOnlyHierarchical
protected boolean activeOnlyHierarchicalWhether the active-only hierarchical reader channel must be used. -
contextsPolicy
protected org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy contextsPolicyThe contexts inclusion policy for responses. -
defaultPropagationConstraint
public final org.gcube.informationsystem.model.reference.properties.PropagationConstraint defaultPropagationConstraintThe default propagation constraint. -
propagationConstraint
protected org.gcube.informationsystem.model.reference.properties.PropagationConstraint propagationConstraintThe active propagation constraint for this relation. -
skipped
protected boolean skippedFlag indicating whether the add operation was skipped.
-
-
Constructor Details
-
RelationManagement
protected RelationManagement(org.gcube.informationsystem.base.reference.AccessType accessType, Class<? extends org.gcube.informationsystem.model.reference.entities.Entity> targetEntityClass, org.gcube.informationsystem.model.reference.properties.PropagationConstraint defaultPropagationConstraint) Creates a newRelationManagementinstance.- Parameters:
accessType- the JAX-RS access typetargetEntityClass- the target entity classdefaultPropagationConstraint- the default propagation constraint
-
-
Method Details
-
setContextVisibilityPolicy
Description copied from interface:ERManagementSets the visibility policy for filtering contexts on read.- Specified by:
setContextVisibilityPolicyin interfaceERManagement- Parameters:
policy- the ContextVisibilityPolicy to set
-
getContextVisibilityPolicy
Description copied from interface:ERManagementGets the visibility policy for filtering contexts on read.- Specified by:
getContextVisibilityPolicyin interfaceERManagement- Returns:
- the ContextVisibilityPolicy
-
setCurrentContextPath
Description copied from interface:ERManagementSets the current context path for context visibility resolution.- Specified by:
setCurrentContextPathin interfaceERManagement- Parameters:
path- the current context path to set
-
getCurrentContextPath
Description copied from interface:ERManagementGets the current context path for context visibility resolution.- Specified by:
getCurrentContextPathin interfaceERManagement- Returns:
- the current context path
-
setFilterNonActiveDescendants
public void setFilterNonActiveDescendants(boolean filterNonActiveDescendants) Description copied from interface:ERManagementSets whether descendant Contexts with a non-ACTIVEeffectiveStatemust additionally be filtered out of thecontextsmap, on top of whateverERManagement.setContextVisibilityPolicy(ContextVisibilityPolicy)already applies.- Specified by:
setFilterNonActiveDescendantsin interfaceERManagement- Parameters:
filterNonActiveDescendants-trueto filter non-ACTIVEdescendants
-
isFilterNonActiveDescendants
public boolean isFilterNonActiveDescendants()Description copied from interface:ERManagementGets whether descendant Contexts with a non-ACTIVEeffectiveStatemust additionally be filtered out of thecontextsmap.- Specified by:
isFilterNonActiveDescendantsin interfaceERManagement- Returns:
trueif non-ACTIVEdescendants are filtered
-
isAddedToContext
public boolean isAddedToContext()Returns whether the lastreallyAddToContext()run added this relation to the target Context.- Returns:
trueif the relation was added to the target Context
-
isHierarchical
public boolean isHierarchical()Description copied from interface:ERManagementGets whether hierarchical lookup is enabled.- Specified by:
isHierarchicalin interfaceERManagement- Returns:
trueif hierarchical,falseotherwise
-
setHierarchical
public void setHierarchical(boolean hierarchical) Description copied from interface:ERManagementSets whether hierarchical lookup is enabled.- Specified by:
setHierarchicalin interfaceERManagement- Parameters:
hierarchical-trueto enable hierarchical,falseotherwise
-
isActiveOnlyHierarchical
public boolean isActiveOnlyHierarchical()Description copied from interface:ERManagementGets whether the active-only hierarchical reader channel must be used instead of the unrestricted one - meaningless unlessERManagement.isHierarchical()is alsotrue.- Specified by:
isActiveOnlyHierarchicalin interfaceERManagement- Returns:
trueif the active-only channel must be used,falseotherwise
-
setActiveOnlyHierarchical
public void setActiveOnlyHierarchical(boolean activeOnlyHierarchical) Description copied from interface:ERManagementSets whether the active-only hierarchical reader channel must be used instead of the unrestricted one. The PEP layer sets this tofalseforALL_ADMIN_ROLESholders (unchanged, unrestricted behavior) andtruefor everyone else.- Specified by:
setActiveOnlyHierarchicalin interfaceERManagement- Parameters:
activeOnlyHierarchical-trueto use the active-only channel
-
getContextsPolicy
public org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy getContextsPolicy()Description copied from interface:ERManagementReturns the contexts inclusion policy for responses.- Specified by:
getContextsPolicyin interfaceERManagement- Returns:
- the contexts policy, or
nullif not explicitly set (falls back toContextsPolicy.DEFAULT)
-
setContextsPolicy
public void setContextsPolicy(org.gcube.informationsystem.resourceregistry.api.rest.ContextsPolicy contextsPolicy) Description copied from interface:ERManagementSets the contexts inclusion policy for responses.- Specified by:
setContextsPolicyin interfaceERManagement- Parameters:
contextsPolicy- the contexts policy to set
-
setSourceInstanceEnvironment
Description copied from interface:ERManagementSets the source InstanceEnvironment used to evaluate addToContext- Specified by:
setSourceInstanceEnvironmentin interfaceERManagement- Parameters:
source- the source security context
-
getContextsSet
public Set<String> getContextsSet() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the set of Context UUID strings where this element is visible.Warning: Any changes made to this implementation must also be applied to the corresponding method in
EntityManagementto keep both ER hierarchies synchronized.- Specified by:
getContextsSetin interfaceERManagement- Returns:
- the set of Context UUID strings
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if context mapping failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
getContexts
public String getContexts() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns all contexts where this element is visible as a formatted JSON string.Warning: Any changes made to this implementation must also be applied to the corresponding method in
EntityManagementto keep both ER hierarchies synchronized.- Specified by:
getContextsin interfaceERManagement- Returns:
- the JSON string of contexts mapping
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if context mapping failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
getContextsAsObjectNode
public org.gcube.com.fasterxml.jackson.databind.node.ObjectNode getContextsAsObjectNode() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns all contexts where this element is visible as an ObjectNode mapping Context UUIDs to paths.Warning: Keep synchronized with
EntityManagement#getContextsAsObjectNode()- Specified by:
getContextsAsObjectNodein interfaceERManagement- Returns:
- the JSON ObjectNode of contexts mapping
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the element does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if context mapping failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database error
-
getSourceInstanceEnvironment
Description copied from interface:ERManagementReturns the sourceInstanceEnvironmentused to evaluate context sharing operations.- Specified by:
getSourceInstanceEnvironmentin interfaceERManagement- Returns:
- the source instance environment
-
setTargetInstanceEnvironment
Description copied from interface:ERManagementSets the target security context of addToContext/removeFromContext- Specified by:
setTargetInstanceEnvironmentin interfaceERManagement- Parameters:
target- the target instance environment to set
-
getTargetInstanceEnvironment
Description copied from interface:ERManagementReturns the targetInstanceEnvironmentof the operation.- Specified by:
getTargetInstanceEnvironmentin interfaceERManagement- Returns:
- the target instance environment
-
getPropagationMode
public org.gcube.informationsystem.resourceregistry.api.rest.PropagationMode getPropagationMode()Description copied from interface:ERManagementReturns the propagation mode for context sharing.- Specified by:
getPropagationModein interfaceERManagement- Returns:
- the propagation mode
-
setPropagationMode
public void setPropagationMode(org.gcube.informationsystem.resourceregistry.api.rest.PropagationMode propagationMode) Description copied from interface:ERManagementSets the propagation mode for context sharing.- Specified by:
setPropagationModein interfaceERManagement- Parameters:
propagationMode- the propagation mode to set
-
isForceAddToContext
public boolean isForceAddToContext()Description copied from interface:ERManagementGets whether the operation should force add to context even if the instance is not in source context.- Specified by:
isForceAddToContextin interfaceERManagement- Returns:
trueif force add,falseotherwise
-
setForceAddToContext
public void setForceAddToContext(boolean forceAddToContext) Description copied from interface:ERManagementSets whether the operation should force add to context even if the instance is not in source context.- Specified by:
setForceAddToContextin interfaceERManagement- Parameters:
forceAddToContext-trueto force add,falseotherwise
-
setVisited
Description copied from interface:ERManagementSets the shared, mutable set of UUIDs (entities and relations alike) already visited during the currentERManagement.addToContext(UUID)cascade. Checked and populated unconditionally by everyERManagementinstance in the cascade, regardless ofPropagationMode— cycle-safety is kept orthogonal to whatever each mode otherwise decides about re-visiting an already-present instance, so it does not need to be re-derived if propagation semantics change later.- Specified by:
setVisitedin interfaceERManagement- Parameters:
visited- the shared visited-UUID set; the same instance must be threaded through the whole cascade of a singleERManagement.addToContext(UUID)call
-
getVisited
Description copied from interface:ERManagementReturns the shared, mutable set of UUIDs already visited during the currentERManagement.addToContext(UUID)cascade.- Specified by:
getVisitedin interfaceERManagement- Returns:
- the shared visited-UUID set, or
nullif not yet initialised
-
isAvailableOnContext
Returnstrueif this relation is available in the specified context.- Parameters:
instanceEnvironment- the instance environment context- Returns:
trueif available,falseotherwise
-
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, TET 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
-
getElement
public com.orientechnologies.orient.core.record.OEdge getElement() throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, 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, TET 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
-
giveMeSourceEntityManagementAsIs
public ResourceManagement giveMeSourceEntityManagementAsIs() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionReturns the source entity manager as-is (without lazy-loading).- Returns:
- the source entity manager instance
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the lookup fails
-
fullSerialize
protected Map<String,org.gcube.com.fasterxml.jackson.databind.JsonNode> fullSerialize(Map<String, org.gcube.com.fasterxml.jackson.databind.JsonNode> visitedSourceResources) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionSerializes this relation fully into the given map of visited resources.- Parameters:
visitedSourceResources- the map of already-visited resources to update- Returns:
- the updated visited resources map
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if serialization fails
-
getPropagationConstraint
protected PropagationConstraintOrient getPropagationConstraint(com.orientechnologies.orient.core.record.impl.ODocument oDocument) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Resolves the propagation constraint for this relation from the given document, falling back to the default constraint if needed.- Parameters:
oDocument- the database document representing the constraint- Returns:
- the resolved
PropagationConstraintOrient - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the constraint is invalid or parsing failsjakarta.ws.rs.BadRequestException- if this is aConsistsOfandremoveConstraintis anything other thanPropagationConstraint.RemoveConstraint.cascade(a structurally invalid enum combination, per the400 Bad Requestdisambiguation rule in07-api-foundations-and-roles.md)
-
checkPropagationConstraint
protected void checkPropagationConstraint() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionVerifies, normalizes, and sets the propagation constraint on the database element.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if validation or database set fails
-
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<ResourceManagement,T extends EntityManagement<? extends org.gcube.informationsystem.model.reference.entities.Entity, TET>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, 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 ResourceManagement 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<ResourceManagement,T extends EntityManagement<? extends org.gcube.informationsystem.model.reference.entities.Entity, TET>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, TET 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
-
getEntityTypeNotValidErrroMessage
protected String getEntityTypeNotValidErrroMessage(String entityPosition, String requiredType, String effectiveType) Generates a schema violation error message when an entity type is not compatible with relation constraints.- Parameters:
entityPosition- the position of the entity (source or target)requiredType- the required schema typeeffectiveType- the actual entity type provided- Returns:
- the formatted error message
-
checksourceAndTargetEntityCompliancy
protected 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.ResourceRegistryExceptionDescription copied from class:RelationElementManagementValidates that both source and target entities comply with relation constraints and schema rules.- Specified by:
checksourceAndTargetEntityCompliancyin classRelationElementManagement<ResourceManagement,T extends EntityManagement<? extends org.gcube.informationsystem.model.reference.entities.Entity, TET>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, TET 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.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
-
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).- Overrides:
reallyUpdatein classRelationElementManagement<ResourceManagement,T extends EntityManagement<? extends org.gcube.informationsystem.model.reference.entities.Entity, TET>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, 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
-
reallyAddToContext
protected void reallyAddToContext() throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionAdds this relation and potentially its target to the target context environment, adhering to propagation constraints.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if a context error occursorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if database or constraint processing fails
-
internalAddToContext
public void internalAddToContext() throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from interface:ERManagementPerforms the internal low-level operations to add the entity/relationship to the target context.- Specified by:
internalAddToContextin interfaceERManagement- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if context assignment violates rulesorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or system error
-
forcedAddToContext
public void forcedAddToContext() throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionForces the addition of this relation and both its source and target entities to the target context environment, bypassing standard source-context presence validation.- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if a context error occursorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if database operations fail
-
addToContext
public void addToContext(UUID contextUUID) throws org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException, org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Description copied from interface:ERManagementAdds the entity/relationship to the specified context, evaluating schemas and constraints.- Specified by:
addToContextin interfaceERManagement- Parameters:
contextUUID- the UUID of the destination context- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException- if schema rules are violatedorg.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the context does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if context assignment violates rulesorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or system error
-
reallyRemoveFromContext
protected Map<UUID,org.gcube.com.fasterxml.jackson.databind.JsonNode> reallyRemoveFromContext() throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionRemoves this relation and potentially its target from the target context environment, adhering to propagation constraints.- Returns:
- the map of affected instances and their JSON representations
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if a context error occursorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if database operations fail
-
internalRemoveFromContext
public void internalRemoveFromContext() throws org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionDescription copied from interface:ERManagementPerforms the internal low-level operations to remove the entity/relationship from the context.- Specified by:
internalRemoveFromContextin interfaceERManagement- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if removal violates rulesorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or system error
-
removeFromContext
public void removeFromContext(UUID contextUUID) throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Description copied from interface:ERManagementRemoves the entity/relationship from the specified context.- Specified by:
removeFromContextin interfaceERManagement- Parameters:
contextUUID- the UUID of the context from which to remove- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the context does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if removal violates rulesorg.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException- if schema rules are violatedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or system 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).- Overrides:
reallyDeletein classRelationElementManagement<ResourceManagement,T extends EntityManagement<? extends org.gcube.informationsystem.model.reference.entities.Entity, TET>, org.gcube.informationsystem.types.reference.entities.ResourceSchema, 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
-
serializeJsonNodeCollectionAsString
protected String serializeJsonNodeCollectionAsString(Collection<org.gcube.com.fasterxml.jackson.databind.JsonNode> collection) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Serializes a collection ofJsonNodeentities into a JSON array string.- Parameters:
collection- the collection of JSON nodes to serialize- Returns:
- the serialized JSON array string
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if serialization fails
-
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, TET 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
-