Search in sources :

Example 6 with PrinterDefinition

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

the class PrinterDefinitionMaintenanceTx 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 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 prevalidateUpdate(PrinterDefinitionMaintenanceUpdateInDto 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
        PrinterDefinition domain = load(uow, input);
        // Validate the foreign objects
        validateForeignObjects(uow, input);
        // Update the domain object
        updateDomain(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 7 with PrinterDefinition

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

the class PrinterDefinitionViewerTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private PrinterDefinitionViewerOutDto buildDto(UOW uow, Collection results) throws UOWException {
    PrinterDefinitionViewerOutDto output = null;
    Iterator itr = results.iterator();
    if (itr.hasNext()) {
        // just return the details for the 1st record retrieved.
        PrinterDefinition printerDefinition = (PrinterDefinition) itr.next();
        output = new PrinterDefinitionViewerOutDto();
        // .//GEN-END:_buildDto_1_be
        // Add custom code before all the setters //GEN-FIRST:_buildDto_1
        // .//GEN-LAST:_buildDto_1
        // .//GEN-BEGIN:_buildDto_PrinterId_1_be
        output.setPrinterId(printerDefinition.getPrinterId());
        // .//GEN-END:_buildDto_PrinterId_1_be
        // .//GEN-BEGIN:_buildDto_Description_1_be
        output.setDescription(printerDefinition.getDescription());
        // .//GEN-END:_buildDto_Description_1_be
        // .//GEN-BEGIN:_buildDto_SiteCode_1_be
        output.setSiteCode(printerDefinition.getSiteCode());
        // .//GEN-END:_buildDto_SiteCode_1_be
        // .//GEN-BEGIN:_buildDto_LocationCode_1_be
        output.setLocationCode(printerDefinition.getLocationCode());
        // .//GEN-END:_buildDto_LocationCode_1_be
        // .//GEN-BEGIN:_buildDto_Remote_1_be
        output.setRemote(printerDefinition.getRemote());
        // .//GEN-END:_buildDto_Remote_1_be
        // .//GEN-BEGIN:_buildDto_RealPrinterName_1_be
        output.setRealPrinterName(printerDefinition.getRealPrinterName());
        // .//GEN-END:_buildDto_RealPrinterName_1_be
        // .//GEN-BEGIN:_buildDto_PrinterOption1_1_be
        output.setPrinterOption1(printerDefinition.getPrinterOption1());
        // .//GEN-END:_buildDto_PrinterOption1_1_be
        // .//GEN-BEGIN:_buildDto_PrinterOption2_1_be
        output.setPrinterOption2(printerDefinition.getPrinterOption2());
        // .//GEN-END:_buildDto_PrinterOption2_1_be
        // .//GEN-BEGIN:_buildDto_OutputType_1_be
        output.setOutputType(printerDefinition.getOutputType());
        // .//GEN-END:_buildDto_OutputType_1_be
        // .//GEN-BEGIN:_buildDto_ScaleToPageSize_1_be
        output.setScaleToPageSize(printerDefinition.getScaleToPageSize());
        // .//GEN-END:_buildDto_ScaleToPageSize_1_be
        // .//GEN-BEGIN:_buildDto_2_be
        // Add related objects, if required
        addRelatedDtos(uow, output, printerDefinition);
    // .//GEN-END:_buildDto_2_be
    // Add custom code to pass values to the dto //GEN-FIRST:_buildDto_2
    // .//GEN-LAST:_buildDto_2
    // .//GEN-BEGIN:_buildDto_3_be
    }
    return output;
}
Also used : PrinterDefinitionViewerOutDto(org.jaffa.modules.printing.components.printerdefinitionviewer.dto.PrinterDefinitionViewerOutDto) PrinterDefinition(org.jaffa.modules.printing.domain.PrinterDefinition)

Example 8 with PrinterDefinition

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

the class PrinterDefinitionFinderTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private PrinterDefinitionFinderOutDto buildDto(UOW uow, Collection results, PrinterDefinitionFinderInDto input) throws UOWException {
    PrinterDefinitionFinderOutDto output = new PrinterDefinitionFinderOutDto();
    for (Iterator i = results.iterator(); i.hasNext(); ) {
        PrinterDefinitionFinderOutRowDto row = new PrinterDefinitionFinderOutRowDto();
        PrinterDefinition printerDefinition = (PrinterDefinition) 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_PrinterId_1_be
        row.setPrinterId(printerDefinition.getPrinterId());
        // .//GEN-END:_buildDto_PrinterId_1_be
        // .//GEN-BEGIN:_buildDto_Description_1_be
        row.setDescription(printerDefinition.getDescription());
        // .//GEN-END:_buildDto_Description_1_be
        // .//GEN-BEGIN:_buildDto_SiteCode_1_be
        row.setSiteCode(printerDefinition.getSiteCode());
        // .//GEN-END:_buildDto_SiteCode_1_be
        // .//GEN-BEGIN:_buildDto_LocationCode_1_be
        row.setLocationCode(printerDefinition.getLocationCode());
        // .//GEN-END:_buildDto_LocationCode_1_be
        // .//GEN-BEGIN:_buildDto_Remote_1_be
        row.setRemote(printerDefinition.getRemote());
        // .//GEN-END:_buildDto_Remote_1_be
        // .//GEN-BEGIN:_buildDto_RealPrinterName_1_be
        row.setRealPrinterName(printerDefinition.getRealPrinterName());
        // .//GEN-END:_buildDto_RealPrinterName_1_be
        // .//GEN-BEGIN:_buildDto_OutputType_1_be
        row.setOutputType(printerDefinition.getOutputType());
        // .//GEN-END:_buildDto_OutputType_1_be
        // .//GEN-BEGIN:_buildDto_ScaleToPageSize_1_be
        row.setScaleToPageSize(printerDefinition.getScaleToPageSize());
        // .//GEN-END:_buildDto_ScaleToPageSize_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 : PrinterDefinition(org.jaffa.modules.printing.domain.PrinterDefinition) PrinterDefinitionFinderOutDto(org.jaffa.modules.printing.components.printerdefinitionfinder.dto.PrinterDefinitionFinderOutDto) PrinterDefinitionFinderOutRowDto(org.jaffa.modules.printing.components.printerdefinitionfinder.dto.PrinterDefinitionFinderOutRowDto)

Example 9 with PrinterDefinition

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

the class PrinterDefinitionLookupTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private PrinterDefinitionLookupOutDto buildDto(UOW uow, Collection results, PrinterDefinitionLookupInDto input) throws UOWException {
    PrinterDefinitionLookupOutDto output = new PrinterDefinitionLookupOutDto();
    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;
        }
        PrinterDefinitionLookupOutRowDto row = new PrinterDefinitionLookupOutRowDto();
        PrinterDefinition printerDefinition = (PrinterDefinition) 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_PrinterId_1_be
        row.setPrinterId(printerDefinition.getPrinterId());
        // .//GEN-END:_buildDto_PrinterId_1_be
        // .//GEN-BEGIN:_buildDto_Description_1_be
        row.setDescription(printerDefinition.getDescription());
        // .//GEN-END:_buildDto_Description_1_be
        // .//GEN-BEGIN:_buildDto_SiteCode_1_be
        row.setSiteCode(printerDefinition.getSiteCode());
        // .//GEN-END:_buildDto_SiteCode_1_be
        // .//GEN-BEGIN:_buildDto_LocationCode_1_be
        row.setLocationCode(printerDefinition.getLocationCode());
        // .//GEN-END:_buildDto_LocationCode_1_be
        // .//GEN-BEGIN:_buildDto_Remote_1_be
        row.setRemote(printerDefinition.getRemote());
        // .//GEN-END:_buildDto_Remote_1_be
        // .//GEN-BEGIN:_buildDto_RealPrinterName_1_be
        row.setRealPrinterName(printerDefinition.getRealPrinterName());
        // .//GEN-END:_buildDto_RealPrinterName_1_be
        // .//GEN-BEGIN:_buildDto_OutputType_1_be
        row.setOutputType(printerDefinition.getOutputType());
        // .//GEN-END:_buildDto_OutputType_1_be
        // .//GEN-BEGIN:_buildDto_ScaleToPageSize_1_be
        row.setScaleToPageSize(printerDefinition.getScaleToPageSize());
        // .//GEN-END:_buildDto_ScaleToPageSize_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 : PrinterDefinition(org.jaffa.modules.printing.domain.PrinterDefinition) PrinterDefinitionLookupOutDto(org.jaffa.modules.printing.components.printerdefinitionlookup.dto.PrinterDefinitionLookupOutDto) PrinterDefinitionLookupOutRowDto(org.jaffa.modules.printing.components.printerdefinitionlookup.dto.PrinterDefinitionLookupOutRowDto)

Example 10 with PrinterDefinition

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

the class PrinterDefinitionMaintenanceTx method load.

// .//GEN-END:_preprocessDelete_2_be
// .//GEN-BEGIN:_loadDelete_1_be
/**
 * Retrieve the domain object.
 */
private PrinterDefinition load(UOW uow, PrinterDefinitionMaintenanceDeleteInDto input) throws FrameworkException, ApplicationExceptions {
    PrinterDefinition domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(PrinterDefinitionMeta.getName());
    // .//GEN-END:_loadDelete_1_be
    // Add custom criteria//GEN-FIRST:_loadDelete_1
    // .//GEN-LAST:_loadDelete_1
    // .//GEN-BEGIN:_loadDelete_2_be
    criteria.addCriteria(PrinterDefinitionMeta.PRINTER_ID, input.getPrinterId());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (PrinterDefinition) itr.next();
    // .//GEN-BEGIN:_loadDelete_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(PrinterDefinitionMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : PrinterDefinition(org.jaffa.modules.printing.domain.PrinterDefinition) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) Criteria(org.jaffa.persistence.Criteria)

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