Search in sources :

Example 1 with FormDefinition

use of org.jaffa.modules.printing.domain.FormDefinition 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 2 with FormDefinition

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

the class FormDefinitionFinderTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormDefinitionFinderOutDto buildDto(UOW uow, Collection results, FormDefinitionFinderInDto input) throws UOWException {
    FormDefinitionFinderOutDto output = new FormDefinitionFinderOutDto();
    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;
        }
        FormDefinitionFinderOutRowDto row = new FormDefinitionFinderOutRowDto();
        FormDefinition formDefinition = (FormDefinition) 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_FormId_1_be
        row.setFormId(formDefinition.getFormId());
        // .//GEN-END:_buildDto_FormId_1_be
        // .//GEN-BEGIN:_buildDto_FormName_1_be
        row.setFormName(formDefinition.getFormName());
        // .//GEN-END:_buildDto_FormName_1_be
        // .//GEN-BEGIN:_buildDto_FormAlternate_1_be
        row.setFormAlternate(formDefinition.getFormAlternate());
        // .//GEN-END:_buildDto_FormAlternate_1_be
        // .//GEN-BEGIN:_buildDto_FormVariation_1_be
        row.setFormVariation(formDefinition.getFormVariation());
        // .//GEN-END:_buildDto_FormVariation_1_be
        // .//GEN-BEGIN:_buildDto_Description_1_be
        row.setDescription(formDefinition.getDescription());
        // .//GEN-END:_buildDto_Description_1_be
        // .//GEN-BEGIN:_buildDto_FormTemplate_1_be
        row.setFormTemplate(formDefinition.getFormTemplate());
        // .//GEN-END:_buildDto_FormTemplate_1_be
        // .//GEN-BEGIN:_buildDto_OutputType_1_be
        row.setOutputType(formDefinition.getOutputType());
        // .//GEN-END:_buildDto_OutputType_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 : FormDefinitionFinderOutRowDto(org.jaffa.modules.printing.components.formdefinitionfinder.dto.FormDefinitionFinderOutRowDto) FormDefinition(org.jaffa.modules.printing.domain.FormDefinition) FormDefinitionFinderOutDto(org.jaffa.modules.printing.components.formdefinitionfinder.dto.FormDefinitionFinderOutDto)

Example 3 with FormDefinition

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

the class FormDefinitionLookupTx method buildDto.

// .//GEN-END:_buildCriteria_3_be
// .//GEN-BEGIN:_buildDto_1_be
private FormDefinitionLookupOutDto buildDto(UOW uow, Collection results, FormDefinitionLookupInDto input) throws UOWException {
    FormDefinitionLookupOutDto output = new FormDefinitionLookupOutDto();
    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;
        }
        FormDefinitionLookupOutRowDto row = new FormDefinitionLookupOutRowDto();
        FormDefinition formDefinition = (FormDefinition) 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_FormId_1_be
        row.setFormId(formDefinition.getFormId());
        // .//GEN-END:_buildDto_FormId_1_be
        // .//GEN-BEGIN:_buildDto_FormName_1_be
        row.setFormName(formDefinition.getFormName());
        // .//GEN-END:_buildDto_FormName_1_be
        // .//GEN-BEGIN:_buildDto_FormAlternate_1_be
        row.setFormAlternate(formDefinition.getFormAlternate());
        // .//GEN-END:_buildDto_FormAlternate_1_be
        // .//GEN-BEGIN:_buildDto_FormVariation_1_be
        row.setFormVariation(formDefinition.getFormVariation());
        // .//GEN-END:_buildDto_FormVariation_1_be
        // .//GEN-BEGIN:_buildDto_OutputType_1_be
        row.setOutputType(formDefinition.getOutputType());
        // .//GEN-END:_buildDto_OutputType_1_be
        // .//GEN-BEGIN:_buildDto_FormTemplate_1_be
        row.setFormTemplate(formDefinition.getFormTemplate());
        // .//GEN-END:_buildDto_FormTemplate_1_be
        // .//GEN-BEGIN:_buildDto_FieldLayout_1_be
        row.setFieldLayout(formDefinition.getFieldLayout());
        // .//GEN-END:_buildDto_FieldLayout_1_be
        // .//GEN-BEGIN:_buildDto_Description_1_be
        row.setDescription(formDefinition.getDescription());
        // .//GEN-END:_buildDto_Description_1_be
        // .//GEN-BEGIN:_buildDto_Remarks_1_be
        row.setRemarks(formDefinition.getRemarks());
        // .//GEN-END:_buildDto_Remarks_1_be
        // .//GEN-BEGIN:_buildDto_DomFactory_1_be
        row.setDomFactory(formDefinition.getDomFactory());
        // .//GEN-END:_buildDto_DomFactory_1_be
        // .//GEN-BEGIN:_buildDto_DomClass_1_be
        row.setDomClass(formDefinition.getDomClass());
        // .//GEN-END:_buildDto_DomClass_1_be
        // .//GEN-BEGIN:_buildDto_DomKey1_1_be
        row.setDomKey1(formDefinition.getDomKey1());
        // .//GEN-END:_buildDto_DomKey1_1_be
        // .//GEN-BEGIN:_buildDto_DomKey2_1_be
        row.setDomKey2(formDefinition.getDomKey2());
        // .//GEN-END:_buildDto_DomKey2_1_be
        // .//GEN-BEGIN:_buildDto_DomKey3_1_be
        row.setDomKey3(formDefinition.getDomKey3());
        // .//GEN-END:_buildDto_DomKey3_1_be
        // .//GEN-BEGIN:_buildDto_DomKey4_1_be
        row.setDomKey4(formDefinition.getDomKey4());
        // .//GEN-END:_buildDto_DomKey4_1_be
        // .//GEN-BEGIN:_buildDto_DomKey5_1_be
        row.setDomKey5(formDefinition.getDomKey5());
        // .//GEN-END:_buildDto_DomKey5_1_be
        // .//GEN-BEGIN:_buildDto_DomKey6_1_be
        row.setDomKey6(formDefinition.getDomKey6());
        // .//GEN-END:_buildDto_DomKey6_1_be
        // .//GEN-BEGIN:_buildDto_AdditionalDataComponent_1_be
        row.setAdditionalDataComponent(formDefinition.getAdditionalDataComponent());
        // .//GEN-END:_buildDto_AdditionalDataComponent_1_be
        // .//GEN-BEGIN:_buildDto_FollowOnFormName_1_be
        row.setFollowOnFormName(formDefinition.getFollowOnFormName());
        // .//GEN-END:_buildDto_FollowOnFormName_1_be
        // .//GEN-BEGIN:_buildDto_FollowOnFormAlternate_1_be
        row.setFollowOnFormAlternate(formDefinition.getFollowOnFormAlternate());
        // .//GEN-END:_buildDto_FollowOnFormAlternate_1_be
        // .//GEN-BEGIN:_buildDto_CreatedOn_1_be
        row.setCreatedOn(formDefinition.getCreatedOn());
        // .//GEN-END:_buildDto_CreatedOn_1_be
        // .//GEN-BEGIN:_buildDto_CreatedBy_1_be
        row.setCreatedBy(formDefinition.getCreatedBy());
        // .//GEN-END:_buildDto_CreatedBy_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedOn_1_be
        row.setLastChangedOn(formDefinition.getLastChangedOn());
        // .//GEN-END:_buildDto_LastChangedOn_1_be
        // .//GEN-BEGIN:_buildDto_LastChangedBy_1_be
        row.setLastChangedBy(formDefinition.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 : FormDefinitionLookupOutRowDto(org.jaffa.modules.printing.components.formdefinitionlookup.dto.FormDefinitionLookupOutRowDto) FormDefinitionLookupOutDto(org.jaffa.modules.printing.components.formdefinitionlookup.dto.FormDefinitionLookupOutDto) FormDefinition(org.jaffa.modules.printing.domain.FormDefinition)

Example 4 with FormDefinition

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

the class FormDefinitionMaintenanceTx method retrieve.

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

Example 5 with FormDefinition

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

the class FormDefinitionMaintenanceTx method load.

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

Aggregations

FormDefinition (org.jaffa.modules.printing.domain.FormDefinition)17 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)9 FrameworkException (org.jaffa.exceptions.FrameworkException)6 ApplicationException (org.jaffa.exceptions.ApplicationException)5 UOW (org.jaffa.persistence.UOW)5 FormTemplate (org.jaffa.modules.printing.domain.FormTemplate)4 Criteria (org.jaffa.persistence.Criteria)4 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)3 InvalidForeignKeyException (org.jaffa.datatypes.exceptions.InvalidForeignKeyException)2 FormUsage (org.jaffa.modules.printing.domain.FormUsage)2 DateTime (org.jaffa.datatypes.DateTime)1 ValidationException (org.jaffa.datatypes.ValidationException)1 DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)1 RelatedDomainObjectFoundException (org.jaffa.exceptions.RelatedDomainObjectFoundException)1 FormDefinitionFinderOutDto (org.jaffa.modules.printing.components.formdefinitionfinder.dto.FormDefinitionFinderOutDto)1 FormDefinitionFinderOutRowDto (org.jaffa.modules.printing.components.formdefinitionfinder.dto.FormDefinitionFinderOutRowDto)1 FormDefinitionLookupOutDto (org.jaffa.modules.printing.components.formdefinitionlookup.dto.FormDefinitionLookupOutDto)1 FormDefinitionLookupOutRowDto (org.jaffa.modules.printing.components.formdefinitionlookup.dto.FormDefinitionLookupOutRowDto)1 FormDefinitionViewerOutDto (org.jaffa.modules.printing.components.formdefinitionviewer.dto.FormDefinitionViewerOutDto)1 FormSelectionMaintenanceOutDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto)1