java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.instances.ERManagementUtility

public class ERManagementUtility extends Object
Author:
Luca Frosini (ISTI - CNR)
  • Constructor Details

    • ERManagementUtility

      public ERManagementUtility()
  • Method Details

    • getERManagement

      public static ElementManagement<?,?> getERManagement(String type) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Resolves and returns the corresponding ElementManagement instance for the specified class type name.
      Parameters:
      type - the class type name
      Returns:
      the mapped ElementManagement instance
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if the class type is not queryable or cannot be mapped
    • 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-ACTIVE descendant Contexts, as its hierarchical reads do; administrative callers align them too.

      Parameters:
      type - the concrete Resource type name
      uuid - the Resource UUID, or null to let a creation generate it
      json - the submitted Resource representation
      scope - the descendant Contexts to align
      administrative - whether the caller may write in non-ACTIVE Contexts
      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 corresponding ElementManagement instance for the specified element UUID.
      Parameters:
      workingContext - the working environment
      orientGraph - the database document connection
      uuid - the UUID of the element to resolve
      Returns:
      the resolved ElementManagement instance
      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 corresponding ElementManagement instance for the specified database element.
      Parameters:
      workingContext - the working environment
      orientGraph - the database document connection
      element - the OrientDB element to resolve
      Returns:
      the resolved ElementManagement instance
      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.ResourceRegistryException
      Adds a map of expected instances to the specified context without evaluating propagation constraints.
      Parameters:
      expectedInstances - map of expected instances, from UUID to JSON node
      contextUUID - the UUID of the target context
      dryRun - true to 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 exist
      org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException - if context rules are violated
      org.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.ResourceRegistryException
      Removes a map of expected instances from the specified context without evaluating propagation constraints.
      Parameters:
      expectedInstances - map of expected instances, from UUID to JSON node
      contextUUID - the UUID of the target context
      dryRun - true to 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 exist
      org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException - if removal rules are violated
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - on database or system failure