Search in sources :

Example 11 with PrinterDefinition

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

the class PrinterDefinitionMaintenanceTx method load.

// .//GEN-END:_preprocessRetrieve_2_be
// .//GEN-BEGIN:_loadRetrieve_1_be
/**
 * Retrieve the domain object.
 */
private PrinterDefinition load(UOW uow, PrinterDefinitionMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
    PrinterDefinition domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(PrinterDefinitionMeta.getName());
    // .//GEN-END:_loadRetrieve_1_be
    // Add custom criteria//GEN-FIRST:_loadRetrieve_1
    // .//GEN-LAST:_loadRetrieve_1
    // .//GEN-BEGIN:_loadRetrieve_2_be
    criteria.addCriteria(PrinterDefinitionMeta.PRINTER_ID, input.getPrinterId());
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (PrinterDefinition) itr.next();
    // .//GEN-BEGIN:_loadRetrieve_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)

Example 12 with PrinterDefinition

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

the class PrinterDefinitionMaintenanceTx method delete.

/**
 * Deletes an existing instance of PrinterDefinition.
 * @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(PrinterDefinitionMaintenanceDeleteInDto 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
    PrinterDefinition domain = load(uow, input);
    // 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 : PrinterDefinition(org.jaffa.modules.printing.domain.PrinterDefinition)

Example 13 with PrinterDefinition

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

the class PrinterDefinitionMaintenanceTx method load.

// .//GEN-END:_preprocessUpdate_2_be
// .//GEN-BEGIN:_loadUpdate_1_be
/**
 * Retrieve the domain object.
 */
private PrinterDefinition load(UOW uow, PrinterDefinitionMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    PrinterDefinition domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(PrinterDefinitionMeta.getName());
    // .//GEN-END:_loadUpdate_1_be
    // Add custom criteria//GEN-FIRST:_loadUpdate_1
    // .//GEN-LAST:_loadUpdate_1
    // .//GEN-BEGIN:_loadUpdate_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:_loadUpdate_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)

Example 14 with PrinterDefinition

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

the class PrinterDefinitionMaintenanceTx method update.

// .//GEN-END:_prevalidateUpdate_1_be
// .//GEN-BEGIN:_update_1_be
/**
 * Updates 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 PrinterDefinitionMaintenanceRetrieveOutDto update(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, false);
        uow.update(domain);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully updated the domain object. Now retrieving the object details.");
        // Build the outbound dto by performing a retrieve
        PrinterDefinitionMaintenanceRetrieveInDto retrieveInDto = new PrinterDefinitionMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setPrinterId(input.getPrinterId());
        PrinterDefinitionMaintenanceRetrieveOutDto output = retrieve(retrieveInDto);
        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 15 with PrinterDefinition

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

the class PrinterDefinitionMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private PrinterDefinition createDomain(UOW uow, PrinterDefinitionMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    PrinterDefinition domain = new PrinterDefinition();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updatePrinterId(input.getPrinterId());
    } 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.updateSiteCode(input.getSiteCode());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateLocationCode(input.getLocationCode());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateRemote(input.getRemote());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateRealPrinterName(input.getRealPrinterName());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updatePrinterOption1(input.getPrinterOption1());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updatePrinterOption2(input.getPrinterOption2());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateOutputType(input.getOutputType());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateScaleToPageSize(input.getScaleToPageSize());
    } 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 : PrinterDefinition(org.jaffa.modules.printing.domain.PrinterDefinition) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException)

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