Search in sources :

Example 6 with OutputCommand

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

the class OutputCommandMaintenanceTx method load.

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

Example 7 with OutputCommand

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

the class OutputCommandMaintenanceTx method load.

// .//GEN-END:_preprocessUpdate_2_be
// .//GEN-BEGIN:_loadUpdate_1_be
/**
 * Retrieve the domain object.
 */
private OutputCommand load(UOW uow, OutputCommandMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
    OutputCommand domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(OutputCommandMeta.getName());
    // .//GEN-END:_loadUpdate_1_be
    // Add custom criteria//GEN-FIRST:_loadUpdate_1
    // .//GEN-LAST:_loadUpdate_1
    // .//GEN-BEGIN:_loadUpdate_2_be
    criteria.addCriteria(OutputCommandMeta.OUTPUT_COMMAND_ID, input.getOutputCommandId());
    criteria.setLocking(Criteria.LOCKING_PARANOID);
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (OutputCommand) itr.next();
    // .//GEN-BEGIN:_loadUpdate_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(OutputCommandMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) OutputCommand(org.jaffa.modules.printing.domain.OutputCommand) Criteria(org.jaffa.persistence.Criteria)

Example 8 with OutputCommand

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

the class OutputCommandMaintenanceTx method retrieve.

// .//GEN-END:_create_1_be
// .//GEN-BEGIN:_retrieve_1_be
/**
 * Returns the details for OutputCommand.
 * @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 OutputCommandMaintenanceRetrieveOutDto retrieve(OutputCommandMaintenanceRetrieveInDto 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
        OutputCommand domain = load(uow, input);
        // Convert the domain objects into the outbound dto
        OutputCommandMaintenanceRetrieveOutDto 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 : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ApplicationException(org.jaffa.exceptions.ApplicationException) FrameworkException(org.jaffa.exceptions.FrameworkException) OutputCommand(org.jaffa.modules.printing.domain.OutputCommand) UOW(org.jaffa.persistence.UOW)

Example 9 with OutputCommand

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

the class OutputCommandLookupTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private OutputCommandLookupOutDto buildDto(UOW uow, Collection results, OutputCommandLookupInDto input) throws UOWException {
    OutputCommandLookupOutDto output = new OutputCommandLookupOutDto();
    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;
        }
        OutputCommandLookupOutRowDto row = new OutputCommandLookupOutRowDto();
        OutputCommand outputCommand = (OutputCommand) 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_OutputCommandId_1_be
        row.setOutputCommandId(outputCommand.getOutputCommandId());
        // .//GEN-END:_buildDto_OutputCommandId_1_be
        // .//GEN-BEGIN:_buildDto_OutputType_1_be
        row.setOutputType(outputCommand.getOutputType());
        // .//GEN-END:_buildDto_OutputType_1_be
        // .//GEN-BEGIN:_buildDto_SequenceNo_1_be
        row.setSequenceNo(outputCommand.getSequenceNo());
        // .//GEN-END:_buildDto_SequenceNo_1_be
        // .//GEN-BEGIN:_buildDto_OsPattern_1_be
        row.setOsPattern(outputCommand.getOsPattern());
        // .//GEN-END:_buildDto_OsPattern_1_be
        // .//GEN-BEGIN:_buildDto_CommandLine_1_be
        row.setCommandLine(outputCommand.getCommandLine());
        // .//GEN-END:_buildDto_CommandLine_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        row.setCreatedOn(outputCommand.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_CreatedBy_1_be
        row.setCreatedBy(outputCommand.getCreatedBy());
        // .//GEN-END:_buildDto_CreatedBy_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedOn_1_be
        row.setLastChangedOn(outputCommand.getLastChangedOn());
        // .//GEN-END:_buildDto_LastChangedOn_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedBy_1_be
        row.setLastChangedBy(outputCommand.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 : OutputCommandLookupOutRowDto(org.jaffa.modules.printing.components.outputcommandlookup.dto.OutputCommandLookupOutRowDto) OutputCommand(org.jaffa.modules.printing.domain.OutputCommand) OutputCommandLookupOutDto(org.jaffa.modules.printing.components.outputcommandlookup.dto.OutputCommandLookupOutDto)

Example 10 with OutputCommand

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

the class OutputCommandMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private OutputCommand createDomain(UOW uow, OutputCommandMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    OutputCommand domain = new OutputCommand();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateOutputCommandId(input.getOutputCommandId());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateSequenceNo(input.getSequenceNo());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateOsPattern(input.getOsPattern());
    } catch (ValidationException e) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(e);
    }
    try {
        domain.updateCommandLine(input.getCommandLine());
    } 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);
    }
    // Add custom code//GEN-FIRST:_createDomain_2
    if (!fromPrevalidate)
        domain.adjustSequenceNoBeforeAdd(uow);
    // .//GEN-BEGIN:_createDomain_3_be
    if (appExps != null && appExps.size() > 0)
        throw appExps;
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) OutputCommand(org.jaffa.modules.printing.domain.OutputCommand)

Aggregations

OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)19 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)11 ApplicationException (org.jaffa.exceptions.ApplicationException)6 FrameworkException (org.jaffa.exceptions.FrameworkException)6 Criteria (org.jaffa.persistence.Criteria)6 UOW (org.jaffa.persistence.UOW)6 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)4 PrinterDefinition (org.jaffa.modules.printing.domain.PrinterDefinition)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 OutputCommandFinderOutDto (org.jaffa.modules.printing.components.outputcommandfinder.dto.OutputCommandFinderOutDto)1 OutputCommandFinderOutRowDto (org.jaffa.modules.printing.components.outputcommandfinder.dto.OutputCommandFinderOutRowDto)1 OutputCommandLookupOutDto (org.jaffa.modules.printing.components.outputcommandlookup.dto.OutputCommandLookupOutDto)1 OutputCommandLookupOutRowDto (org.jaffa.modules.printing.components.outputcommandlookup.dto.OutputCommandLookupOutRowDto)1 OutputCommandViewerOutDto (org.jaffa.modules.printing.components.outputcommandviewer.dto.OutputCommandViewerOutDto)1 org.jaffa.modules.printing.components.printeroutputtypemaintenance.dto (org.jaffa.modules.printing.components.printeroutputtypemaintenance.dto)1 OutputCommandDto (org.jaffa.modules.printing.components.printeroutputtypeviewer.dto.OutputCommandDto)1 PrinterOutputType (org.jaffa.modules.printing.domain.PrinterOutputType)1