Search in sources :

Example 16 with PrinterDefinition

use of org.jaffa.modules.printing.domain.PrinterDefinition in project jaffa-framework by jaffa-projects.

the class PrinterDefinitionMaintenanceTx method prevalidateCreate.

// .//GEN-END:_destroy_2_be
// .//GEN-BEGIN:_prevalidateCreate_1_be
/**
 * This method is used to perform prevalidations before creating a new instance of PrinterDefinition.
 * @param input The new values for the domain object.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details.
 */
public PrinterDefinitionMaintenancePrevalidateOutDto prevalidateCreate(PrinterDefinitionMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
    UOW uow = null;
    try {
        // Print Debug Information for the input
        if (log.isDebugEnabled())
            log.debug("Input: " + (input != null ? input.toString() : null));
        // create the UOW
        uow = new UOW();
        // Preprocess the input
        preprocess(uow, input);
        // Do not allow a Duplicate record
        duplicateCheck(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Create the domain object
        PrinterDefinition domain = createDomain(uow, input, true);
        // Perform post create processing
        postCreate(uow, input, domain, true);
        // Build the outbound dto
        PrinterDefinitionMaintenancePrevalidateOutDto output = createPrevalidateOutDto(uow, domain, input);
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Output: " + (output != null ? output.toString() : null));
        return output;
    } catch (FrameworkException e) {
        // If it is, then re-throw as ApplicationsExceptions, else throw the FrameworkException.
        if (e.getCause() != null && e.getCause() instanceof ApplicationExceptions) {
            throw (ApplicationExceptions) e.getCause();
        } else if (e.getCause() != null && e.getCause() instanceof ApplicationException) {
            ApplicationExceptions appExps = new ApplicationExceptions();
            appExps.add((ApplicationException) e.getCause());
            throw appExps;
        } else
            throw e;
    } finally {
        if (uow != null)
            uow.rollback();
    }
}
Also used : PrinterDefinition(org.jaffa.modules.printing.domain.PrinterDefinition) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UOW(org.jaffa.persistence.UOW)

Example 17 with PrinterDefinition

use of org.jaffa.modules.printing.domain.PrinterDefinition 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

PrinterDefinition (org.jaffa.modules.printing.domain.PrinterDefinition)17 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)10 ApplicationException (org.jaffa.exceptions.ApplicationException)6 FrameworkException (org.jaffa.exceptions.FrameworkException)6 UOW (org.jaffa.persistence.UOW)6 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)4 Criteria (org.jaffa.persistence.Criteria)3 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)2 ValidationException (org.jaffa.datatypes.ValidationException)1 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)1 DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)1 RelatedDomainObjectFoundException (org.jaffa.exceptions.RelatedDomainObjectFoundException)1 PrinterDefinitionFinderOutDto (org.jaffa.modules.printing.components.printerdefinitionfinder.dto.PrinterDefinitionFinderOutDto)1 PrinterDefinitionFinderOutRowDto (org.jaffa.modules.printing.components.printerdefinitionfinder.dto.PrinterDefinitionFinderOutRowDto)1 PrinterDefinitionLookupOutDto (org.jaffa.modules.printing.components.printerdefinitionlookup.dto.PrinterDefinitionLookupOutDto)1 PrinterDefinitionLookupOutRowDto (org.jaffa.modules.printing.components.printerdefinitionlookup.dto.PrinterDefinitionLookupOutRowDto)1 PrinterDefinitionViewerOutDto (org.jaffa.modules.printing.components.printerdefinitionviewer.dto.PrinterDefinitionViewerOutDto)1 PrinterOutputType (org.jaffa.modules.printing.domain.PrinterOutputType)1