Class OrphanCandidates
java.lang.Object
org.gcube.informationsystem.resourceregistry.persistence.orientdb.instances.OrphanCandidates
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidrecord(EntityManagement<?, ?> target) Records the target of a droppedcascadeWhenOrphanrelation.voidremoveOrphans(InstanceEnvironment instanceEnvironment, com.orientechnologies.orient.core.db.document.ODatabaseDocument oDatabaseDocument, Map<UUID, org.gcube.com.fasterxml.jackson.databind.JsonNode> affectedInstances) Removes from the Context every recorded target left with no incoming relation in it.
-
Constructor Details
-
OrphanCandidates
public OrphanCandidates()Creates an empty record.
-
-
Method Details
-
record
Records the target of a droppedcascadeWhenOrphanrelation.- 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.ResourceRegistryExceptionRemoves 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 onoDatabaseDocument- the session whose open transaction is evaluatedaffectedInstances- the affected instances of the operation, completed with what is removed here- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if a removal fails
-