// object graph
if (processFlattened) {
ObjectStore objectStore = dataContext.getObjectStore();
Iterator iterator = relatedObjects.iterator();
while (iterator.hasNext()) {
DataObject relatedObject = (DataObject) iterator.next();
objectStore.recordArcDeleted(
object,
relatedObject.getObjectId(),
relationship.getName());
}
}
// process remaining rules
switch (relationship.getDeleteRule()) {
case DeleteRule.NO_ACTION:
break;
case DeleteRule.NULLIFY:
ObjRelationship inverseRelationship = relationship
.getReverseRelationship();
if (inverseRelationship == null) {
// nothing we can do here
break;
}
if (inverseRelationship.isToMany()) {
Iterator iterator = relatedObjects.iterator();
while (iterator.hasNext()) {
DataObject relatedObject = (DataObject) iterator.next();
relatedObject.removeToManyTarget(inverseRelationship
.getName(), object, true);
}
}
else {
// Inverse is to-one - find all related objects and
// nullify the reverse relationship
Iterator iterator = relatedObjects.iterator();
while (iterator.hasNext()) {
DataObject relatedObject = (DataObject) iterator.next();
relatedObject.setToOneTarget(
inverseRelationship.getName(),
null,
true);
}
}
break;
case DeleteRule.CASCADE:
// Delete all related objects
Iterator iterator = relatedObjects.iterator();
while (iterator.hasNext()) {
DataObject relatedObject = (DataObject) iterator.next();
new DataContextDeleteAction(this.dataContext)
.performDelete(relatedObject);
}
break;