Search in sources :

Example 11 with PrinterOutputType

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

the class PrinterOutputTypeMaintenanceTx method load.

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

Example 12 with PrinterOutputType

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

the class PrinterOutputTypeFinderTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private PrinterOutputTypeFinderOutDto buildDto(UOW uow, Collection results, PrinterOutputTypeFinderInDto input) throws UOWException {
    PrinterOutputTypeFinderOutDto output = new PrinterOutputTypeFinderOutDto();
    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;
        }
        PrinterOutputTypeFinderOutRowDto row = new PrinterOutputTypeFinderOutRowDto();
        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
        // 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 : PrinterOutputTypeFinderOutDto(org.jaffa.modules.printing.components.printeroutputtypefinder.dto.PrinterOutputTypeFinderOutDto) PrinterOutputType(org.jaffa.modules.printing.domain.PrinterOutputType) PrinterOutputTypeFinderOutRowDto(org.jaffa.modules.printing.components.printeroutputtypefinder.dto.PrinterOutputTypeFinderOutRowDto)

Example 13 with PrinterOutputType

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

the class PrinterOutputTypeMaintenanceTx method create.

// .//GEN-END:_prevalidateCreate_1_be
// .//GEN-BEGIN:_create_1_be
/**
 * Persists 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 PrinterOutputTypeMaintenanceRetrieveOutDto create(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, false);
        uow.add(domain);
        domain = postCreate(uow, input, domain, false);
        // Commit the changes
        uow.commit();
        // Print Debug Information for the output
        if (log.isDebugEnabled())
            log.debug("Successfully created the domain object. Now retrieving the object details.");
        if (input.getOutputType() == null) {
            if (log.isDebugEnabled())
                log.debug("The Key is not set completely. Probably using AutoGenerated keys. Cannot re-retrieve the object details. Returning NULL instead");
            return null;
        }
        // Build the outbound dto by performing a retrieve
        PrinterOutputTypeMaintenanceRetrieveInDto retrieveInDto = new PrinterOutputTypeMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setOutputType(input.getOutputType());
        PrinterOutputTypeMaintenanceRetrieveOutDto 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 : 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 14 with PrinterOutputType

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

the class PrinterOutputTypeMaintenanceTx method retrieve.

// .//GEN-END:_create_1_be
// .//GEN-BEGIN:_retrieve_1_be
/**
 * Returns the details for PrinterOutputType.
 * @param input The criteria based on which an object will be retrieved.
 * @throws ApplicationExceptions This will be thrown if the criteria contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The object details. A null indicates, the object was not found.
 */
public PrinterOutputTypeMaintenanceRetrieveOutDto retrieve(PrinterOutputTypeMaintenanceRetrieveInDto 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);
        // Convert the domain objects into the outbound dto
        PrinterOutputTypeMaintenanceRetrieveOutDto output = buildRetrieveOutDto(uow, input, domain);
        // 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 15 with PrinterOutputType

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

the class PrinterOutputTypeMaintenanceTx method update.

// .//GEN-END:_prevalidateUpdate_1_be
// .//GEN-BEGIN:_update_1_be
/**
 * Updates 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 PrinterOutputTypeMaintenanceRetrieveOutDto update(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, 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
        PrinterOutputTypeMaintenanceRetrieveInDto retrieveInDto = new PrinterOutputTypeMaintenanceRetrieveInDto();
        retrieveInDto.setHeaderDto(input.getHeaderDto());
        retrieveInDto.setOutputType(input.getOutputType());
        PrinterOutputTypeMaintenanceRetrieveOutDto 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 : 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)

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