Search in sources :

Example 6 with RelatedDomainObjectFoundException

use of org.jaffa.exceptions.RelatedDomainObjectFoundException in project jaffa-framework by jaffa-projects.

the class PrinterOutputType method performPreDeleteReferentialIntegrity.

// .//GEN-END:performForeignKeyValidations_1_be
// .//GEN-BEGIN:performPreDeleteReferentialIntegrity_1_be
/**
 * This method is triggered by the UOW, before adding this object to the Delete-Store.
 * This will raise an exception if any associated/aggregated objects exist.
 * This will cascade delete all composite objects.
 * @throws PreDeleteFailedException if any error occurs during the process.
 */
public void performPreDeleteReferentialIntegrity() throws PreDeleteFailedException {
    OutputCommand[] outputCommandArray = null;
    try {
        outputCommandArray = getOutputCommandArray();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (outputCommandArray != null && outputCommandArray.length > 0) {
        try {
            // Perform cascade deletes
            for (int i = 0; i < outputCommandArray.length; i++) getUOW().delete(outputCommandArray[i]);
        } catch (Exception e) {
            throw new PreDeleteFailedException(null, e);
        }
    }
    PrinterDefinition[] printerDefinitionArray = null;
    try {
        printerDefinitionArray = getPrinterDefinitionArray();
    } catch (FrameworkException e) {
        throw new PreDeleteFailedException(null, e);
    }
    if (printerDefinitionArray != null && printerDefinitionArray.length > 0) {
        // Stop the deletion !!
        throw new PreDeleteFailedException(null, new RelatedDomainObjectFoundException(PrinterDefinitionMeta.getLabelToken()));
    }
}
Also used : PrinterDefinition(org.jaffa.modules.printing.domain.PrinterDefinition) FrameworkException(org.jaffa.exceptions.FrameworkException) OutputCommand(org.jaffa.modules.printing.domain.OutputCommand) RelatedDomainObjectFoundException(org.jaffa.exceptions.RelatedDomainObjectFoundException) FrameworkException(org.jaffa.exceptions.FrameworkException) InvalidForeignKeyException(org.jaffa.datatypes.exceptions.InvalidForeignKeyException) DuplicateKeyException(org.jaffa.exceptions.DuplicateKeyException) RelatedDomainObjectFoundException(org.jaffa.exceptions.RelatedDomainObjectFoundException)

Aggregations

RelatedDomainObjectFoundException (org.jaffa.exceptions.RelatedDomainObjectFoundException)6 FrameworkException (org.jaffa.exceptions.FrameworkException)4 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)3 DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)3 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)2 Criteria (org.jaffa.persistence.Criteria)2 Asset (org.jaffa.persistence.domainobjects.Asset)2 Item (org.jaffa.persistence.domainobjects.Item)2 FormDefinition (org.jaffa.modules.printing.domain.FormDefinition)1 FormUsage (org.jaffa.modules.printing.domain.FormUsage)1 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)1 PrinterDefinition (org.jaffa.modules.printing.domain.PrinterDefinition)1 PartAdditional (org.jaffa.persistence.domainobjects.PartAdditional)1 PartPicture (org.jaffa.persistence.domainobjects.PartPicture)1 PartRemarks (org.jaffa.persistence.domainobjects.PartRemarks)1 PartRemarksPicture (org.jaffa.persistence.domainobjects.PartRemarksPicture)1