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

public class OrphanCandidates extends Object
The targets reached by a dropped cascadeWhenOrphan relation while an instance is removed from one Context. The constraint is evaluated on the final state of the operation: the avalanche only records the targets, and removeOrphans(org.gcube.informationsystem.resourceregistry.environments.instances.InstanceEnvironment, com.orientechnologies.orient.core.db.document.ODatabaseDocument, java.util.Map<java.util.UUID, org.gcube.com.fasterxml.jackson.databind.JsonNode>) decides when it has finished, so the outcome does not depend on the order the graph is visited in.

One instance is shared by the whole avalanche of one Context, as the visited set of an addition is.

  • Constructor Details

    • OrphanCandidates

      public OrphanCandidates()
      Creates an empty record.
  • Method Details

    • record

      public void record(EntityManagement<?,?> target)
      Records the target of a dropped cascadeWhenOrphan relation.
      Parameters:
      target - the management of the target, configured as for a cascade
    • removeOrphans

      public void removeOrphans(InstanceEnvironment instanceEnvironment, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, Map<UUID,org.gcube.com.fasterxml.jackson.databind.JsonNode> affectedInstances) throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException
      Removes from the Context every recorded target left with no incoming relation in it. Every incoming relation present in the Context counts, whatever its source. Removing an orphan follows the remove constraints of its own relations, which can record new targets and leave a target evaluated before without incoming relations: the evaluation is repeated until nothing changes. The record is empty when the method returns.
      Parameters:
      instanceEnvironment - the Context the removal acts on
      oDatabaseDocument - the session whose open transaction is evaluated
      affectedInstances - the affected instances of the operation, completed with what is removed here
      Throws:
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if a removal fails