Class ERManagementUtility
java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.instances.ERManagementUtility
- Author:
- Luca Frosini (ISTI - CNR)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe descendant Contexts a hierarchy synchronization aligns to the submitted Resource.static final recordThe outcome of a hierarchy synchronization. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddToContextNoPropagationConstraint(Map<UUID, org.gcube.com.fasterxml.jackson.databind.JsonNode> expectedInstances, UUID contextUUID, boolean dryRun) Adds a map of expected instances to the specified context without evaluating propagation constraints.static ElementManagement<?,?> getERManagement(String type) Resolves and returns the correspondingElementManagementinstance for the specified class type name.static ElementManagement<?,?> getERManagement(String type, UUID uuid) Returns the management of the instance addressed by the given Type and UUID.static ElementManagement<?,?> getERManagement(Environment workingContext, com.orientechnologies.orient.core.db.document.ODatabaseDocument orientGraph, com.orientechnologies.orient.core.record.OElement element) Resolves and returns the correspondingElementManagementinstance for the specified database element.static ElementManagement<?,?> getERManagementFromUUID(Environment workingContext, com.orientechnologies.orient.core.db.document.ODatabaseDocument orientGraph, UUID uuid) Resolves and returns the correspondingElementManagementinstance for the specified element UUID.static booleanisDeletedInTransaction(com.orientechnologies.orient.core.record.OElement element, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument) Tells whether an element has been deleted by the open transaction of the given session.static booleanisInContext(com.orientechnologies.orient.core.record.OElement element, InstanceEnvironment instanceEnvironment, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument) Tells whether an element is present in a Context as the open transaction of the given session sees it: an element the transaction has already removed from the Context, or deleted, is absent, although the committed state still lists it.static booleanisInNoContext(com.orientechnologies.orient.core.record.OElement element, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument) Tells whether an element belongs to no Context at all as the open transaction of the given session sees it, the condition under which an instance is deleted.removeFromContextNoPropagationConstraint(Map<UUID, org.gcube.com.fasterxml.jackson.databind.JsonNode> expectedInstances, UUID contextUUID, boolean dryRun) Removes a map of expected instances from the specified context without evaluating propagation constraints.syncHierarchy(String type, UUID uuid, String json, ERManagementUtility.HierarchyScope scope, boolean administrative) Creates or updates a Resource in the current Context and aligns the selected descendant Contexts to the submitted representation, atomically: every aligned Context ends up with the Resource and exactly the ConsistsOf/Facet instances the payload describes.
-
Constructor Details
-
ERManagementUtility
public ERManagementUtility()
-
-
Method Details
-
isDeletedInTransaction
public static boolean isDeletedInTransaction(com.orientechnologies.orient.core.record.OElement element, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument) Tells whether an element has been deleted by the open transaction of the given session.- Parameters:
element- the element to checkoDatabaseDocument- the session whose transaction is evaluated- Returns:
trueif the transaction deletes the element
-
isInContext
public static boolean isInContext(com.orientechnologies.orient.core.record.OElement element, InstanceEnvironment instanceEnvironment, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument) Tells whether an element is present in a Context as the open transaction of the given session sees it: an element the transaction has already removed from the Context, or deleted, is absent, although the committed state still lists it.- Parameters:
element- the element to checkinstanceEnvironment- the ContextoDatabaseDocument- the session whose transaction is evaluated- Returns:
trueif the element is present in the Context
-
isInNoContext
public static boolean isInNoContext(com.orientechnologies.orient.core.record.OElement element, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument) Tells whether an element belongs to no Context at all as the open transaction of the given session sees it, the condition under which an instance is deleted.- Parameters:
element- the element to checkoDatabaseDocument- the session whose transaction is evaluated- Returns:
trueif the element belongs to no Context
-
getERManagement
public static ElementManagement<?,?> getERManagement(String type) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Resolves and returns the correspondingElementManagementinstance for the specified class type name.- Parameters:
type- the class type name- Returns:
- the mapped
ElementManagementinstance - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the class type is not queryable or cannot be mapped
-
getERManagement
public static ElementManagement<?,?> getERManagement(String type, UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Returns the management of the instance addressed by the given Type and UUID. A Type that exists but is not aResource,Facet,IsRelatedToorConsistsOfType has no instances: the key does not exist, exactly as with an unknown Type name or a Type that is not the concrete Type of the instance.- Parameters:
type- the concrete Type name of the instanceuuid- the UUID of the instance- Returns:
- the management, with its Type and UUID set
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the Type is not an instance Typeorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the Type does not exist
-
syncHierarchy
public static ERManagementUtility.HierarchySyncResult syncHierarchy(String type, UUID uuid, String json, ERManagementUtility.HierarchyScope scope, boolean administrative) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Creates or updates a Resource in the current Context and aligns the selected descendant Contexts to the submitted representation, atomically: every aligned Context ends up with the Resource and exactly the ConsistsOf/Facet instances the payload describes. It is a synchronization of the payload, not an Add to Context: propagation constraints are not consulted, and no IsRelatedTo instance nor related Resource moves.A non-administrative caller skips the non-
ACTIVEdescendant Contexts, as its hierarchical reads do; administrative callers align them too.- Parameters:
type- the concrete Resource type nameuuid- the Resource UUID, ornullto let a creation generate itjson- the submitted Resource representationscope- the descendant Contexts to alignadministrative- whether the caller may write in non-ACTIVEContexts- Returns:
- the outcome of the synchronization
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if synchronization fails
-
getERManagementFromUUID
public static ElementManagement<?,?> getERManagementFromUUID(Environment workingContext, com.orientechnologies.orient.core.db.document.ODatabaseDocument orientGraph, UUID uuid) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Resolves and returns the correspondingElementManagementinstance for the specified element UUID.- Parameters:
workingContext- the working environmentorientGraph- the database document connectionuuid- the UUID of the element to resolve- Returns:
- the resolved
ElementManagementinstance - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the element does not exist or has an unmanageable type
-
getERManagement
public static ElementManagement<?,?> getERManagement(Environment workingContext, com.orientechnologies.orient.core.db.document.ODatabaseDocument orientGraph, com.orientechnologies.orient.core.record.OElement element) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Resolves and returns the correspondingElementManagementinstance for the specified database element.- Parameters:
workingContext- the working environmentorientGraph- the database document connectionelement- the OrientDB element to resolve- Returns:
- the resolved
ElementManagementinstance - Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the element type is not manageable
-
addToContextNoPropagationConstraint
public static Map<UUID,org.gcube.com.fasterxml.jackson.databind.JsonNode> addToContextNoPropagationConstraint(Map<UUID, org.gcube.com.fasterxml.jackson.databind.JsonNode> expectedInstances, UUID contextUUID, boolean dryRun) throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionAdds a map of expected instances to the specified context without evaluating propagation constraints.- Parameters:
expectedInstances- map of expected instances, from UUID to JSON nodecontextUUID- the UUID of the target contextdryRun-trueto simulate the operation without committing- Returns:
- the map of successfully added instances
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the context does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if context rules are violatedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or system failure
-
removeFromContextNoPropagationConstraint
public static Map<UUID,org.gcube.com.fasterxml.jackson.databind.JsonNode> removeFromContextNoPropagationConstraint(Map<UUID, org.gcube.com.fasterxml.jackson.databind.JsonNode> expectedInstances, UUID contextUUID, boolean dryRun) throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionRemoves a map of expected instances from the specified context without evaluating propagation constraints.- Parameters:
expectedInstances- map of expected instances, from UUID to JSON nodecontextUUID- the UUID of the target contextdryRun-trueto simulate the operation without committing- Returns:
- the map of successfully removed instances
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the context does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException- if removal rules are violatedorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or system failure
-