Search in sources :

Example 6 with ApplicationExceptions

use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.

the class FormGroupMaintenanceTx method createFormUsageEntry.

// .//GEN-END:_deleteRelatedObjects_2_be
// All the custom code goes here//GEN-FIRST:_custom
// Add the related FormUsage
private void createFormUsageEntry(UOW uow, FormGroupMaintenanceUpdateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    ApplicationExceptions appExps = null;
    try {
        if (input.getFormName() != null) {
            Criteria criteria = new Criteria();
            criteria.setTable(FormUsageMeta.getName());
            criteria.addCriteria(FormUsageMeta.FORM_NAME, input.getFormName());
            Collection col = uow.query(criteria);
            // Iterator itr = col.iterator();
            for (int i = 0; i < input.getFormUsageCount(); i++) {
                boolean found = false;
                FormUsageDto inputFormUsageDto = input.getFormUsage(i);
                for (Iterator itr = col.iterator(); itr.hasNext(); ) {
                    FormUsage formusage = (FormUsage) itr.next();
                    if (inputFormUsageDto.getEventName().equals(formusage.getEventName())) {
                        try {
                            formusage.updateFormAlternate(inputFormUsageDto.getFormAlternate());
                        } catch (ValidationException e) {
                            if (appExps == null)
                                appExps = new ApplicationExceptions();
                            appExps.add(e);
                        }
                        try {
                            formusage.updateCopies(inputFormUsageDto.getCopies());
                        } catch (ValidationException e) {
                            if (appExps == null)
                                appExps = new ApplicationExceptions();
                            appExps.add(e);
                        }
                        if (appExps != null && appExps.size() > 0)
                            throw appExps;
                        if (!fromPrevalidate) {
                            if (log.isDebugEnabled())
                                log.debug("Creating FormUsage: " + formusage);
                            uow.update(formusage);
                            found = true;
                        }
                        break;
                    } else {
                        continue;
                    }
                }
                if (!found) {
                    FormUsage formUsage = new FormUsage();
                    formUsage.setEventName(inputFormUsageDto.getEventName());
                    formUsage.setFormName(input.getFormName());
                    formUsage.setFormAlternate(inputFormUsageDto.getFormAlternate());
                    formUsage.setCopies(inputFormUsageDto.getCopies());
                    if (!fromPrevalidate) {
                        if (log.isDebugEnabled())
                            log.debug("Creating FormUsage: " + formUsage);
                        uow.add(formUsage);
                    }
                }
            }
            for (Iterator itr = col.iterator(); itr.hasNext(); ) {
                boolean found = false;
                FormUsage formusage = (FormUsage) itr.next();
                for (int i = 0; i < input.getFormUsageCount(); i++) {
                    FormUsageDto inputFormUsageDto = input.getFormUsage(i);
                    if (formusage.getEventName().equals(inputFormUsageDto.getEventName())) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    if (!fromPrevalidate) {
                        if (log.isDebugEnabled())
                            log.debug("Creating FormUsage: " + formusage);
                        uow.delete(formusage);
                    }
                }
            }
        }
    } catch (ValidationException e) {
        throw new ApplicationExceptions(e);
    }
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) Criteria(org.jaffa.persistence.Criteria) FormUsage(org.jaffa.modules.printing.domain.FormUsage)

Example 7 with ApplicationExceptions

use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.

the class FormGroupMaintenanceTx method createDomain.

// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
 * Create the domain object.
 */
private FormGroup createDomain(UOW uow, FormGroupMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
    FormGroup domain = new FormGroup();
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_createDomain_2_be
    try {
        domain.updateFormName(input.getFormName());
    } 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.updateFormType(input.getFormType());
    } 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 : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) ValidationException(org.jaffa.datatypes.ValidationException) FormGroup(org.jaffa.modules.printing.domain.FormGroup)

Example 8 with ApplicationExceptions

use of org.jaffa.exceptions.ApplicationExceptions 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 9 with ApplicationExceptions

use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.

the class FormGroupMaintenanceComponent method doUpdate.

// .//GEN-END:_doCreate_3_be
// .//GEN-BEGIN:_doUpdate_1_be
/**
 * This will invoke the update method on the transaction to update an existing domain object.
 * @param performDirtyReadCheck this will determine if the Dirty Read check if to be performed prior to an update.
 * @throws ApplicationExceptions Indicates some functional error.
 * @throws FrameworkException Indicates some system error.
 */
protected void doUpdate(boolean performDirtyReadCheck) throws ApplicationExceptions, FrameworkException {
    FormGroupMaintenanceUpdateInDto input = new FormGroupMaintenanceUpdateInDto();
    if (getFormType() == null || getFormType().trim().equals("")) {
        throw new ApplicationExceptions(new MandatoryFieldException(FormGroupMeta.META_FORM_TYPE.getLabelToken()));
    }
    if (m_relatedObjectFormUsageDto != null)
        input.setFormUsage(m_relatedObjectFormUsageDto);
    // .//GEN-LAST:_doUpdate_1
    // .//GEN-BEGIN:_doUpdate_2_be
    input.setHeaderDto(getHeaderDto());
    input.setPerformDirtyReadCheck(new Boolean(performDirtyReadCheck));
    input.setFormName(getFormName());
    input.setDescription(getDescription());
    input.setFormType(getFormType());
    FormGroupMaintenanceRetrieveOutDto output = createTx().update(input);
    loadRetrieveOutDto(output);
// .//GEN-END:_doUpdate_2_be
// Add custom code//GEN-FIRST:_doUpdate_2
// .//GEN-LAST:_doUpdate_2
// .//GEN-BEGIN:_doUpdate_3_be
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException)

Example 10 with ApplicationExceptions

use of org.jaffa.exceptions.ApplicationExceptions in project jaffa-framework by jaffa-projects.

the class FormGroupViewerComponent method doInquiry.

// .//GEN-END:_display_2_be
// .//GEN-BEGIN:_inquiry_1_be
private void doInquiry() throws ApplicationExceptions, FrameworkException {
    FormGroupViewerInDto inputDto = new FormGroupViewerInDto();
    // .//GEN-END:_inquiry_1_be
    // Add custom code before building the input dto //GEN-FIRST:_inquiry_1
    // .//GEN-LAST:_inquiry_1
    // .//GEN-BEGIN:_inquiry_2_be
    inputDto.setFormName(m_formName);
    inputDto.setHeaderDto(createHeaderDto());
    // create the Tx
    if (m_tx == null)
        m_tx = (IFormGroupViewer) Factory.createObject(IFormGroupViewer.class);
    // .//GEN-END:_inquiry_2_be
    // Add custom code before invoking the Tx //GEN-FIRST:_inquiry_2
    // .//GEN-LAST:_inquiry_2
    // .//GEN-BEGIN:_inquiry_3_be
    // now get the details
    m_outputDto = m_tx.read(inputDto);
    // uncache the widgets
    getUserSession().getWidgetCache(getComponentId()).clear();
    // throw an exception if the output is null
    if (m_outputDto == null) {
        ApplicationExceptions appExps = new ApplicationExceptions();
        appExps.add(new DomainObjectNotFoundException(FormGroupMeta.getLabelToken()));
        throw appExps;
    }
}
Also used : FormGroupViewerInDto(org.jaffa.modules.printing.components.formgroupviewer.dto.FormGroupViewerInDto) IFormGroupViewer(org.jaffa.modules.printing.components.formgroupviewer.IFormGroupViewer) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) DomainObjectNotFoundException(org.jaffa.exceptions.DomainObjectNotFoundException)

Aggregations

ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)575 FrameworkException (org.jaffa.exceptions.FrameworkException)307 FormKey (org.jaffa.presentation.portlet.FormKey)205 ApplicationException (org.jaffa.exceptions.ApplicationException)116 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)104 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)103 UOW (org.jaffa.persistence.UOW)82 Criteria (org.jaffa.persistence.Criteria)66 DomainObjectNotFoundException (org.jaffa.exceptions.DomainObjectNotFoundException)59 MandatoryFieldException (org.jaffa.datatypes.exceptions.MandatoryFieldException)23 ValidationException (org.jaffa.datatypes.ValidationException)21 Iterator (java.util.Iterator)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)15 Method (java.lang.reflect.Method)15 FormTemplate (org.jaffa.modules.printing.domain.FormTemplate)15 DuplicateKeyException (org.jaffa.exceptions.DuplicateKeyException)14 OutputCommand (org.jaffa.modules.printing.domain.OutputCommand)11 MalformedURLException (java.net.MalformedURLException)10 UserRequest (org.jaffa.applications.jaffa.modules.user.domain.UserRequest)10 PrinterDefinition (org.jaffa.modules.printing.domain.PrinterDefinition)10