Search in sources :

Example 6 with FormGroup

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

the class FormGroupMaintenanceTx method load.

// .//GEN-END:_preprocessRetrieve_2_be
// .//GEN-BEGIN:_loadRetrieve_1_be
/**
 * Retrieve the domain object.
 */
private FormGroup load(UOW uow, FormGroupMaintenanceRetrieveInDto input) throws FrameworkException, ApplicationExceptions {
    FormGroup domain = null;
    Criteria criteria = new Criteria();
    criteria.setTable(FormGroupMeta.getName());
    // .//GEN-END:_loadRetrieve_1_be
    // Add custom criteria//GEN-FIRST:_loadRetrieve_1
    // .//GEN-LAST:_loadRetrieve_1
    // .//GEN-BEGIN:_loadRetrieve_2_be
    criteria.addCriteria(FormGroupMeta.FORM_NAME, input.getFormName());
    Iterator itr = uow.query(criteria).iterator();
    if (itr.hasNext())
        domain = (FormGroup) itr.next();
    // .//GEN-BEGIN:_loadRetrieve_3_be
    if (domain == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(FormGroupMeta.getLabelToken()));
        throw appExps;
    }
    return domain;
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException) FormGroup(org.jaffa.modules.printing.domain.FormGroup) Criteria(org.jaffa.persistence.Criteria)

Example 7 with FormGroup

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

the class FormSelectionMaintenanceTx method buildOutDto.

private FormSelectionMaintenanceOutDto buildOutDto(UOW uow, Collection results, FormSelectionMaintenanceInDto input) throws FrameworkException {
    FormSelectionMaintenanceOutDto output = new FormSelectionMaintenanceOutDto();
    // key=outputType, value=List of Printers
    Map<String, List<String>> printersPerOutputType = null;
    String variation = VariationContext.getVariation();
    String outputType = null;
    String[] keys = new String[6];
    if (input.getKey1() != null) {
        String[] keyArray = input.getKey1().getValues();
        keys[0] = keyArray[0];
    }
    if (input.getKey2() != null) {
        String[] keyArray = input.getKey2().getValues();
        keys[1] = keyArray[0];
    }
    if (input.getKey3() != null) {
        String[] keyArray = input.getKey3().getValues();
        keys[2] = keyArray[0];
    }
    if (input.getKey4() != null) {
        String[] keyArray = input.getKey4().getValues();
        keys[3] = keyArray[0];
    }
    if (input.getKey5() != null) {
        String[] keyArray = input.getKey5().getValues();
        keys[4] = keyArray[0];
    }
    if (input.getKey6() != null) {
        String[] keyArray = input.getKey6().getValues();
        keys[5] = keyArray[0];
    }
    if (log.isDebugEnabled())
        log.debug("Form Selection building OutDto using Event=" + input.getEvent() + ", key1=" + keys[0] + ", key2=" + keys[1] + ", key3=" + keys[2] + ", key4=" + keys[3] + ", key5=" + keys[4] + ", key6=" + keys[5] + ", variation=" + variation);
    for (Iterator i = results.iterator(); i.hasNext(); ) {
        FormUsage formUsage = (FormUsage) i.next();
        FormDefinition formDefinition = FormProcessor.findFormDefinition(uow, formUsage.getFormName(), formUsage.getFormAlternate(), variation, outputType, keys);
        if (formDefinition != null) {
            FormSelectionMaintenanceOutRowDto row = new FormSelectionMaintenanceOutRowDto();
            row.setFormName(formDefinition.getFormName());
            row.setCopies(formUsage.getCopies());
            if (input.getEvent() != null) {
                String[] mEvent = input.getEvent().getValues();
                row.setEvent(mEvent[0]);
            }
            if (keys[0] != null) {
                row.setKey1(keys[0]);
            }
            if (keys[1] != null) {
                row.setKey2(keys[1]);
            }
            if (keys[2] != null) {
                row.setKey3(keys[2]);
            }
            if (keys[3] != null) {
                row.setKey4(keys[3]);
            }
            if (keys[4] != null) {
                row.setKey5(keys[4]);
            }
            if (keys[5] != null) {
                row.setKey6(keys[5]);
            }
            if (input.getValue1() != null) {
                String[] mValue1 = input.getValue1().getValues();
                row.setValue1(mValue1[0]);
            }
            if (input.getValue2() != null) {
                String[] mValue2 = input.getValue2().getValues();
                row.setValue2(mValue2[0]);
            }
            if (input.getValue3() != null) {
                String[] mValue3 = input.getValue3().getValues();
                row.setValue3(mValue3[0]);
            }
            if (input.getValue4() != null) {
                String[] mValue4 = input.getValue4().getValues();
                row.setValue4(mValue4[0]);
            }
            if (input.getValue5() != null) {
                String[] mValue5 = input.getValue5().getValues();
                row.setValue5(mValue5[0]);
            }
            if (input.getValue6() != null) {
                String[] mValue6 = input.getValue6().getValues();
                row.setValue6(mValue6[0]);
            }
            // Use the form definition selected because it may have selected the "-RL" right-to-left alternate.
            if (formUsage.getFormAlternate() != null) {
                row.setFormAlternateName(formDefinition.getFormAlternate());
            }
            row.setVariation(formDefinition.getFormVariation());
            row.setAdditionalDataComponent(formDefinition.getAdditionalDataComponent());
            // Query on FormGroup to find FormType.
            Criteria criteria = new Criteria();
            criteria.setTable(FormGroupMeta.getName());
            criteria.addCriteria(FormGroupMeta.FORM_NAME, formUsage.getFormName());
            Collection col = uow.query(criteria);
            Iterator itr = col.iterator();
            if (itr.hasNext()) {
                FormGroup formGroup = (FormGroup) itr.next();
                row.setFormType(formGroup.getFormType());
            }
            // Default the printer if possible and only if it has not already been initialized
            if (row.getPrinter() == null && input.getDefaultPrinters() != null) {
                // Construct a Map of valid printers per outputType
                if (printersPerOutputType == null)
                    printersPerOutputType = determinePrintersPerOutputType(uow, input.getDefaultPrinters());
                // Get the first printer for an outputType
                List<String> printers = printersPerOutputType.get(formDefinition.getOutputType());
                if (printers != null && printers.size() >= 0)
                    row.setPrinter(printers.get(0));
            }
            if (row.getEmail() == null && (FormPrintFactory.ENGINE_TYPE_ITEXT.equals(row.getFormType()) || FormPrintFactory.ENGINE_TYPE_FOP.equals(row.getFormType())))
                row.setEmail(getUserEmail());
            output.addRows(row);
        }
    }
    return output;
}
Also used : FormGroup(org.jaffa.modules.printing.domain.FormGroup) Criteria(org.jaffa.persistence.Criteria) AtomicCriteria(org.jaffa.persistence.AtomicCriteria) FormSelectionMaintenanceOutRowDto(org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto) FormSelectionMaintenanceOutDto(org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto) FormDefinition(org.jaffa.modules.printing.domain.FormDefinition) FormUsage(org.jaffa.modules.printing.domain.FormUsage)

Example 8 with FormGroup

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

the class FormGroupFinderTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormGroupFinderOutDto buildDto(UOW uow, Collection results, FormGroupFinderInDto input) throws UOWException {
    FormGroupFinderOutDto output = new FormGroupFinderOutDto();
    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;
        }
        FormGroupFinderOutRowDto row = new FormGroupFinderOutRowDto();
        FormGroup formGroup = (FormGroup) 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_FormName_1_be
        row.setFormName(formGroup.getFormName());
        // .//GEN-END:_buildDto_FormName_1_be
        // .//GEN-BEGIN:_buildDto_Description_1_be
        row.setDescription(formGroup.getDescription());
        // .//GEN-END:_buildDto_Description_1_be
        // .//GEN-BEGIN:_buildDto_FormType_1_be
        row.setFormType(formGroup.getFormType());
        // .//GEN-END:_buildDto_FormType_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 : FormGroup(org.jaffa.modules.printing.domain.FormGroup) FormGroupFinderOutRowDto(org.jaffa.modules.printing.components.formgroupfinder.dto.FormGroupFinderOutRowDto) FormGroupFinderOutDto(org.jaffa.modules.printing.components.formgroupfinder.dto.FormGroupFinderOutDto)

Example 9 with FormGroup

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

the class FormGroupLookupTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormGroupLookupOutDto buildDto(UOW uow, Collection results, FormGroupLookupInDto input) throws UOWException {
    FormGroupLookupOutDto output = new FormGroupLookupOutDto();
    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;
        }
        FormGroupLookupOutRowDto row = new FormGroupLookupOutRowDto();
        FormGroup formGroup = (FormGroup) 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_FormName_1_be
        row.setFormName(formGroup.getFormName());
        // .//GEN-END:_buildDto_FormName_1_be
        // .//GEN-BEGIN:_buildDto_Description_1_be
        row.setDescription(formGroup.getDescription());
        // .//GEN-END:_buildDto_Description_1_be
        // .//GEN-BEGIN:_buildDto_FormType_1_be
        row.setFormType(formGroup.getFormType());
        // .//GEN-END:_buildDto_FormType_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        row.setCreatedOn(formGroup.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_CreatedBy_1_be
        row.setCreatedBy(formGroup.getCreatedBy());
        // .//GEN-END:_buildDto_CreatedBy_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedOn_1_be
        row.setLastChangedOn(formGroup.getLastChangedOn());
        // .//GEN-END:_buildDto_LastChangedOn_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedBy_1_be
        row.setLastChangedBy(formGroup.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 : FormGroupLookupOutDto(org.jaffa.modules.printing.components.formgrouplookup.dto.FormGroupLookupOutDto) FormGroup(org.jaffa.modules.printing.domain.FormGroup) FormGroupLookupOutRowDto(org.jaffa.modules.printing.components.formgrouplookup.dto.FormGroupLookupOutRowDto)

Example 10 with FormGroup

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

the class FormGroupMaintenanceTx method load.

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

Aggregations

FormGroup (org.jaffa.modules.printing.domain.FormGroup)16 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)9 ApplicationException (org.jaffa.exceptions.ApplicationException)5 FrameworkException (org.jaffa.exceptions.FrameworkException)5 UOW (org.jaffa.persistence.UOW)5 Criteria (org.jaffa.persistence.Criteria)4 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)3 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)2 ValidationException (org.jaffa.datatypes.ValidationException)1 FormGroupFinderOutDto (org.jaffa.modules.printing.components.formgroupfinder.dto.FormGroupFinderOutDto)1 FormGroupFinderOutRowDto (org.jaffa.modules.printing.components.formgroupfinder.dto.FormGroupFinderOutRowDto)1 FormGroupLookupOutDto (org.jaffa.modules.printing.components.formgrouplookup.dto.FormGroupLookupOutDto)1 FormGroupLookupOutRowDto (org.jaffa.modules.printing.components.formgrouplookup.dto.FormGroupLookupOutRowDto)1 FormGroupViewerOutDto (org.jaffa.modules.printing.components.formgroupviewer.dto.FormGroupViewerOutDto)1 FormSelectionMaintenanceOutDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto)1 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)1 FormDefinition (org.jaffa.modules.printing.domain.FormDefinition)1 FormUsage (org.jaffa.modules.printing.domain.FormUsage)1 AtomicCriteria (org.jaffa.persistence.AtomicCriteria)1