Search in sources :

Example 1 with IAdditionalData

use of org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalData in project jaffa-framework by jaffa-projects.

the class FormSelectionMaintenanceComponent method validateFields.

protected void validateFields(GridModelRow row, ApplicationExceptions appExps, boolean showForm) throws ApplicationExceptions, FrameworkException {
    String additionalComponent = null;
    CheckBoxModel checkBoxModel = (CheckBoxModel) row.get("select");
    if ((checkBoxModel != null && checkBoxModel.getState()) || showForm) {
        // Check copies are greater then zero
        EditBoxModel mCopies = (EditBoxModel) row.get("copies");
        if (mCopies != null && !showForm) {
            if (mCopies.getValue() != null && mCopies.getValue().length() > 0) {
                int iCopies = Integer.parseInt(mCopies.getValue());
                if (iCopies < 1) {
                    appExps.add(new FormSelectionException(FormSelectionException.INVALID_COPIES));
                }
            } else {
                appExps.add(new FormSelectionException(FormSelectionException.INVALID_COPIES));
            }
        }
        if (!showForm) {
            // check either printer, email or publish has value
            EditBoxModel mPrinter = (EditBoxModel) row.get("printer");
            EditBoxModel mEmail = (EditBoxModel) row.get("email");
            CheckBoxModel mPublish = (CheckBoxModel) row.get("publish");
            if ((mPrinter.getValue() == null) && (mEmail.getValue() == null) && (mPublish.getState() != true) && !showForm) {
                appExps.add(new FormSelectionException(FormSelectionException.INVALID_OUTPUT_DESTINATION));
            }
        }
        // Validate AdditionalData exist or not
        try {
            FormSelectionMaintenanceOutRowDto rowDto = (FormSelectionMaintenanceOutRowDto) row.get("object");
            additionalComponent = rowDto.getAdditionalDataComponent();
            if (additionalComponent != null) {
                Component comp = (Component) run(additionalComponent);
                BeanUtils.setProperty(comp, getKey1(), getValue1());
                if (getKey2() != null) {
                    BeanUtils.setProperty(comp, getKey2(), getValue2());
                }
                if (getKey3() != null) {
                    BeanUtils.setProperty(comp, getKey3(), getValue3());
                }
                if (getKey4() != null) {
                    BeanUtils.setProperty(comp, getKey4(), getValue4());
                }
                if (getKey5() != null) {
                    BeanUtils.setProperty(comp, getKey5(), getValue5());
                }
                if (getKey6() != null) {
                    BeanUtils.setProperty(comp, getKey6(), getValue6());
                }
                if (comp instanceof IAdditionalData) {
                    ((IAdditionalData) comp).validate();
                } else {
                    if (log.isDebugEnabled()) {
                        log.debug("Additional Data Interface not implemented ");
                    }
                }
            }
        } catch (SecurityException se) {
            log.error("SecurityException Occurred ", se);
            appExps.add(new FormSelectionException(FormSelectionException.SECURITY_EXCEPTION));
        } catch (IllegalAccessException e) {
            log.error("IllegalAccessException Occurred ", e);
        } catch (InvocationTargetException e) {
            log.error("InvocationTargetException Occurred ", e);
        } catch (IllegalArgumentException e) {
            log.error("IllegalArgumentException Occurred ", e);
        } catch (ApplicationExceptions applicationException) {
            log.debug("Catch : Application Exception from additional data component");
            if (applicationException != null && applicationException.size() > 0) {
                for (Iterator i = applicationException.iterator(); i.hasNext(); ) {
                    ApplicationException appEx = (ApplicationException) i.next();
                    appExps.add(appEx);
                }
            }
        } catch (FrameworkException frameworkException) {
            throw frameworkException;
        }
    }
}
Also used : FormSelectionException(org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) FrameworkException(org.jaffa.exceptions.FrameworkException) org.jaffa.components.maint(org.jaffa.components.maint) InvocationTargetException(java.lang.reflect.InvocationTargetException) CheckBoxModel(org.jaffa.presentation.portlet.widgets.model.CheckBoxModel) ApplicationException(org.jaffa.exceptions.ApplicationException) FormSelectionMaintenanceOutRowDto(org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto) EditBoxModel(org.jaffa.presentation.portlet.widgets.model.EditBoxModel) Iterator(java.util.Iterator) IAdditionalData(org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalData) Component(org.jaffa.presentation.portlet.component.Component) RiaWrapperComponent(org.jaffa.presentation.portlet.component.RiaWrapperComponent)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Iterator (java.util.Iterator)1 org.jaffa.components.maint (org.jaffa.components.maint)1 ApplicationException (org.jaffa.exceptions.ApplicationException)1 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 FormSelectionException (org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException)1 IAdditionalData (org.jaffa.modules.printing.components.formselectionmaintenance.IAdditionalData)1 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)1 Component (org.jaffa.presentation.portlet.component.Component)1 RiaWrapperComponent (org.jaffa.presentation.portlet.component.RiaWrapperComponent)1 CheckBoxModel (org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)1 EditBoxModel (org.jaffa.presentation.portlet.widgets.model.EditBoxModel)1