use of com.qcadoo.model.api.types.Cascadeable in project qcadoo by qcadoo.
the class DataAccessServiceImpl method performCascadeStrategy.
private EntityOpResult performCascadeStrategy(final Entity entity, final FieldType fieldType, final Collection<Entity> children, final Set<EntitySignature> traversedEntities) {
if (children == null || children.isEmpty()) {
return EntityOpResult.successfull();
}
boolean isManyToManyType = fieldType instanceof ManyToManyType;
InternalDataDefinition childDataDefinition = (InternalDataDefinition) ((DataDefinitionHolder) fieldType).getDataDefinition();
Cascadeable.Cascade cascade = ((Cascadeable) fieldType).getCascade();
if (Cascadeable.Cascade.NULLIFY.equals(cascade)) {
if (!isManyToManyType) {
return performCascadeNullification(childDataDefinition, children, entity, fieldType);
}
return EntityOpResult.successfull();
} else if (Cascadeable.Cascade.DELETE.equals(cascade)) {
return performCascadeDelete(childDataDefinition, children, isManyToManyType, traversedEntities);
} else {
throw new IllegalArgumentException(String.format("Unsupported cascade value '%s'", cascade));
}
}
Aggregations