Search in sources :

Example 6 with PrinterOutputType

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

the class PrinterOutputTypeLookupTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private PrinterOutputTypeLookupOutDto buildDto(UOW uow, Collection results, PrinterOutputTypeLookupInDto input) throws UOWException {
    PrinterOutputTypeLookupOutDto output = new PrinterOutputTypeLookupOutDto();
    int maxRecords = input.getMaxRecords() != null ? input.getMaxRecords().intValue() : 0;
    int counter = 0;
    for (Iterator i = results.iterator(); i.hasNext(); ) {
        if (++counter > maxRecords && maxRecords > 0) {
            output.setMoreRecordsExist(Boolean.TRUE);
            break;
        }
        PrinterOutputTypeLookupOutRowDto row = new PrinterOutputTypeLookupOutRowDto();
        PrinterOutputType printerOutputType = (PrinterOutputType) i.next();
        // .//GEN-END:_buildDto_1_be
        // Add custom code before all the setters //GEN-FIRST:_buildDto_1
        // .//GEN-LAST:_buildDto_1
        // .//GEN-BEGIN:_buildDto_OutputType_1_be
        row.setOutputType(printerOutputType.getOutputType());
        // .//GEN-END:_buildDto_OutputType_1_be
        // .//GEN-BEGIN:_buildDto_Description_1_be
        row.setDescription(printerOutputType.getDescription());
        // .//GEN-END:_buildDto_Description_1_be
        // .//GEN-BEGIN:_buildDto_DirectPrinting_1_be
        row.setDirectPrinting(printerOutputType.getDirectPrinting());
        // .//GEN-END:_buildDto_DirectPrinting_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        row.setCreatedOn(printerOutputType.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_CreatedBy_1_be
        row.setCreatedBy(printerOutputType.getCreatedBy());
        // .//GEN-END:_buildDto_CreatedBy_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedOn_1_be
        row.setLastChangedOn(printerOutputType.getLastChangedOn());
        // .//GEN-END:_buildDto_LastChangedOn_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedBy_1_be
        row.setLastChangedBy(printerOutputType.getLastChangedBy());
        // .//GEN-END:_buildDto_LastChangedBy_1_be
        // Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
        // .//GEN-LAST:_buildDto_2
        // .//GEN-BEGIN:_buildDto_3_be
        output.addRows(row);
    }
    return output;
}
Also used : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) PrinterOutputTypeLookupOutDto(org.jaffa.modules.printing.components.printeroutputtypelookup.dto.PrinterOutputTypeLookupOutDto) PrinterOutputTypeLookupOutRowDto(org.jaffa.modules.printing.components.printeroutputtypelookup.dto.PrinterOutputTypeLookupOutRowDto)

Example 7 with PrinterOutputType

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

the class PrinterOutputTypeMaintenanceTx 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 PrinterOutputType.
 * @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 PrinterOutputTypeMaintenancePrevalidateOutDto prevalidateCreate(PrinterOutputTypeMaintenanceCreateInDto 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
        PrinterOutputType domain = createDomain(uow, input, true);
        domain = postCreate(uow, input, domain, true);
        // Build the outbound dto
        PrinterOutputTypeMaintenancePrevalidateOutDto 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 : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UOW(org.jaffa.persistence.UOW)

Example 8 with PrinterOutputType

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

the class PrinterOutputTypeMaintenanceTx method prevalidateUpdate.

// .//GEN-END:_retrieve_1_be
// .//GEN-BEGIN:_prevalidateUpdate_1_be
/**
 * This method is used to perform prevalidations before updating an existing instance of PrinterOutputType.
 * @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 PrinterOutputTypeMaintenancePrevalidateOutDto prevalidateUpdate(PrinterOutputTypeMaintenanceUpdateInDto 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);
        // Retrieve the object
        PrinterOutputType domain = load(uow, input);
        // Ensure the domain object has not been modified
        domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastChangedOn());
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Update the domain object
        updateDomain(uow, input, domain, true);
        // Build the outbound dto
        PrinterOutputTypeMaintenancePrevalidateOutDto 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 : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) UOW(org.jaffa.persistence.UOW)

Example 9 with PrinterOutputType

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

the class PrinterOutputTypeMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private PrinterOutputType createDomain(UOW uow, PrinterOutputTypeMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    PrinterOutputType domain = new PrinterOutputType();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateOutputType(input.getOutputType());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDescription(input.getDescription());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateDirectPrinting(input.getDirectPrinting());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        if (!fromPrevalidate)
            domain.updateCreatedOn(new DateTime());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        if (!fromPrevalidate && input.getHeaderDto() != null && input.getHeaderDto().getUserId() != null)
            domain.updateCreatedBy(input.getHeaderDto().getUserId());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    // .//GEN-BEGIN:_createDomain_3_be
    if (appExps != null && appExps.size() > 0)
        throw appExps;
    return domain;
}
Also used : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) DateTime(org.jaffa.datatypes.DateTime)

Example 10 with PrinterOutputType

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

the class PrinterOutputTypeMaintenanceTx method delete.

/**
 * Deletes an existing instance of PrinterOutputType.
 * @param input The key values for the domain object to be deleted.
 * @param uow The delete will be performed using the input UOW.
 * @throws ApplicationExceptions This will be thrown if the input contains invalid data.
 * @throws FrameworkException Indicates some system error.
 */
public void delete(PrinterOutputTypeMaintenanceDeleteInDto input, UOW uow) throws FrameworkException, ApplicationExceptions {
    // Print Debug Information for the input
    if (log.isDebugEnabled())
        log.debug("Input: " + (input != null ? input.toString() : null));
    // Preprocess the input
    preprocess(uow, input);
    // Retrieve the object
    PrinterOutputType domain = load(uow, input);
    // Ensure the domain object has not been modified
    domainObjectChangedTest(input.getPerformDirtyReadCheck(), domain, input.getLastChangedOn());
    // Delete the domain object
    deleteDomain(uow, input, domain);
    // Print Debug Information for the output
    if (log.isDebugEnabled())
        log.debug("The domain object has been marked for deletion. It will be deleted when the UOW is committed");
}
Also used : PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType)

Aggregations

PrinterOutputType (org.jaffa.modules.printing.domain.PrinterOutputType)17 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)10 ApplicationException (org.jaffa.exceptions.ApplicationException)6 UOW (org.jaffa.persistence.UOW)6 FrameworkException (org.jaffa.exceptions.FrameworkException)5 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)4 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)3 Criteria (org.jaffa.persistence.Criteria)3 DateTime (org.jaffa.datatypes.DateTime)1 ValidationException (org.jaffa.datatypes.ValidationException)1 PrinterOutputTypeFinderOutDto (org.jaffa.modules.printing.components.printeroutputtypefinder.dto.PrinterOutputTypeFinderOutDto)1 PrinterOutputTypeFinderOutRowDto (org.jaffa.modules.printing.components.printeroutputtypefinder.dto.PrinterOutputTypeFinderOutRowDto)1 PrinterOutputTypeLookupOutDto (org.jaffa.modules.printing.components.printeroutputtypelookup.dto.PrinterOutputTypeLookupOutDto)1 PrinterOutputTypeLookupOutRowDto (org.jaffa.modules.printing.components.printeroutputtypelookup.dto.PrinterOutputTypeLookupOutRowDto)1 PrinterOutputTypeViewerOutDto (org.jaffa.modules.printing.components.printeroutputtypeviewer.dto.PrinterOutputTypeViewerOutDto)1 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)1 PrinterDefinition (org.jaffa.modules.printing.domain.PrinterDefinition)1