Search in sources :

Example 21 with MandatoryFieldException

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

the class FormGroupMaintenanceForm method doValidate0.

// .//GEN-END:_doValidate_2_be
// .//GEN-BEGIN:_doValidateMain_1_be
/**
 * This method should be invoked to ensure a valid state of the FormBean. It will validate the data in the models and set the corresponding properties.
 * Errors will be raised in the FormBean, if any validation fails.
 * @param request The request stream
 * @return A true indicates validations went through successfully.
 */
public boolean doValidate0(HttpServletRequest request) {
    boolean valid = true;
    try {
        String htmlString = getFormNameWM().getValue();
        if (htmlString != null && htmlString.length() == 0)
            htmlString = null;
        java.lang.String value = (java.lang.String) FieldValidator.validateData(htmlString, (StringFieldMetaData) FormGroupMeta.META_FORM_NAME, true);
        setFormName(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((StringFieldMetaData) FormGroupMeta.META_FORM_NAME).getLabelToken(), e);
    }
    try {
        String htmlString = getDescriptionWM().getValue();
        if (htmlString != null && htmlString.length() == 0)
            htmlString = null;
        java.lang.String value = (java.lang.String) FieldValidator.validateData(htmlString, (StringFieldMetaData) FormGroupMeta.META_DESCRIPTION, true);
        if (value == null)
            throw new MandatoryFieldException(((StringFieldMetaData) FormGroupMeta.META_DESCRIPTION).getLabelToken());
        setDescription(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((StringFieldMetaData) FormGroupMeta.META_DESCRIPTION).getLabelToken(), e);
    }
    try {
        java.lang.String value = getFormTypeWM().getValue();
        value = FieldValidator.validate(value, (StringFieldMetaData) FormGroupMeta.META_FORM_TYPE, true);
        setFormType(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((StringFieldMetaData) FormGroupMeta.META_FORM_TYPE).getLabelToken(), e);
    }
    // .//GEN-BEGIN:_doValidateMain_2_be
    return valid;
}
Also used : MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException)

Example 22 with MandatoryFieldException

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

the class FormGroupViewerComponent method display.

// .//GEN-END:_FormGroupViewerOutDto_1_be
// .//GEN-BEGIN:_display_1_be
/**
 * This retrieves the details for the FormGroup.
 * @throws ApplicationExceptions This will be thrown in case any invalid data has been set, or if no data has been set.
 * @throws FrameworkException Indicates some system error.
 * @return The FormKey for the View screen.
 */
public FormKey display() throws ApplicationExceptions, FrameworkException {
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_display_2_be
    if (getFormName() == null) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(new MandatoryFieldException(FormGroupMeta.META_FORM_NAME.getLabelToken()));
    }
    if (appExps != null && appExps.size() > 0)
        throw appExps;
    doInquiry();
    return getViewerFormKey();
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException)

Example 23 with MandatoryFieldException

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

the class FormSelectionMaintenanceComponent method doInquiry.

// .//GEN-END:value6_1_be
// .//GEN-BEGIN:_doInquiry_1_be
/**
 * This performs the actual query to obtain the FinderOutDto.
 * @throws ApplicationExceptions This will be thrown in case any invalid data has been set.
 * @throws FrameworkException Indicates some system error.
 * @return the FinderOutDto object.
 */
protected FinderOutDto doInquiry() throws ApplicationExceptions, FrameworkException {
    ApplicationExceptions appExps = null;
    FormSelectionMaintenanceInDto inputDto = new FormSelectionMaintenanceInDto();
    /**
     *  Check that a proper form Event was found.
     *  Give a message that no events are defined for the form preview link.
     *  Conditions are:
     *  getEvent().startsWith("???") indicates the event label was not found.
     *  getEvent().equals("") indicates the event label was found but no event was defined.
     */
    if (getAutoDisplayAll()) {
        if (getEvent() == null || getEvent().startsWith("???") || getEvent().equals("")) {
            throw new ApplicationExceptions(new FormSelectionException(FormSelectionException.FORM_PREVIEW_EVENT_NOT_DEFINED) {
            });
        }
    }
    // Check for Mandatory fields (Event & Key1/Voucher are mandatory)
    if (getEvent() == null) {
        if (appExps == null) {
            appExps = new ApplicationExceptions();
        }
        appExps.add(new MandatoryFieldException("[label.Jaffa.Printing.FormSelection.Event]"));
    }
    if (getKey1() == null) {
        if (appExps == null) {
            appExps = new ApplicationExceptions();
        }
        appExps.add(new MandatoryFieldException("[label.Jaffa.Printing.FormSelection.Key1]"));
    }
    if (appExps != null && appExps.size() > 0) {
        throw appExps;
    }
    inputDto.setDefaultPrinters(getDefaultPrinters());
    // .//GEN-LAST:_doInquiry_1
    // .//GEN-BEGIN:_doInquiry_2_be
    inputDto.setMaxRecords(getMaxRecords());
    if (getEvent() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getEventDd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getEventDd())) {
        inputDto.setEvent(StringCriteriaField.getStringCriteriaField(getEventDd(), getEvent(), null));
    }
    if (getKey1() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey1Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey1Dd())) {
        inputDto.setKey1(StringCriteriaField.getStringCriteriaField(getKey1Dd(), getKey1(), null));
    }
    if (getKey2() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey2Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey2Dd())) {
        inputDto.setKey2(StringCriteriaField.getStringCriteriaField(getKey2Dd(), getKey2(), null));
    }
    if (getKey3() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey3Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey3Dd())) {
        inputDto.setKey3(StringCriteriaField.getStringCriteriaField(getKey3Dd(), getKey3(), null));
    }
    if (getKey4() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey4Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey4Dd())) {
        inputDto.setKey4(StringCriteriaField.getStringCriteriaField(getKey4Dd(), getKey4(), null));
    }
    if (getKey5() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey5Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey5Dd())) {
        inputDto.setKey5(StringCriteriaField.getStringCriteriaField(getKey5Dd(), getKey5(), null));
    }
    if (getKey6() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getKey6Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getKey6Dd())) {
        inputDto.setKey6(StringCriteriaField.getStringCriteriaField(getKey6Dd(), getKey6(), null));
    }
    if (getValue1() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue1Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue1Dd())) {
        inputDto.setValue1(StringCriteriaField.getStringCriteriaField(getValue1Dd(), getValue1(), null));
    }
    if (getValue2() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue2Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue2Dd())) {
        inputDto.setValue2(StringCriteriaField.getStringCriteriaField(getValue2Dd(), getValue2(), null));
    }
    if (getValue3() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue3Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue3Dd())) {
        inputDto.setValue3(StringCriteriaField.getStringCriteriaField(getValue3Dd(), getValue3(), null));
    }
    if (getValue4() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue4Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue4Dd())) {
        inputDto.setValue4(StringCriteriaField.getStringCriteriaField(getValue4Dd(), getValue4(), null));
    }
    if (getValue5() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue5Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue5Dd())) {
        inputDto.setValue5(StringCriteriaField.getStringCriteriaField(getValue5Dd(), getValue5(), null));
    }
    if (getValue6() != null || CriteriaField.RELATIONAL_IS_NULL.equals(getValue6Dd()) || CriteriaField.RELATIONAL_IS_NOT_NULL.equals(getValue6Dd())) {
        inputDto.setValue6(StringCriteriaField.getStringCriteriaField(getValue6Dd(), getValue6(), null));
    }
    // throw ApplicationExceptions, if any parsing errors occured
    if (appExps != null && appExps.size() > 0) {
        throw appExps;
    }
    inputDto.setHeaderDto(getHeaderDto());
    addSortCriteria(inputDto);
    // perform the inquiry
    if (m_tx == null) {
        m_tx = (IFormSelectionMaintenance) Factory.createObject(IFormSelectionMaintenance.class);
    }
    FinderOutDto finderOutDto = m_tx.find(inputDto);
    // .//GEN-END:_doInquiry_2_be
    // Add custom code after the Transaction//GEN-FIRST:_doInquiry_2
    finderOutDto = m_tx.findOutDto(inputDto);
    // .//GEN-BEGIN:_doInquiry_3_be
    return finderOutDto;
}
Also used : FormSelectionException(org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException) ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException) FormSelectionMaintenanceInDto(org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceInDto)

Example 24 with MandatoryFieldException

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

the class FormTemplateViewerComponent method display.

// .//GEN-END:_FormTemplateViewerOutDto_1_be
// .//GEN-BEGIN:_display_1_be
/**
 * This retrieves the details for the FormTemplate.
 * @throws ApplicationExceptions This will be thrown in case any invalid data has been set, or if no data has been set.
 * @throws FrameworkException Indicates some system error.
 * @return The FormKey for the View screen.
 */
public FormKey display() throws ApplicationExceptions, FrameworkException {
    ApplicationExceptions appExps = null;
    // .//GEN-BEGIN:_display_2_be
    if (getFormId() == null) {
        if (appExps == null)
            appExps = new ApplicationExceptions();
        appExps.add(new MandatoryFieldException(FormTemplateMeta.META_FORM_ID.getLabelToken()));
    }
    if (appExps != null && appExps.size() > 0)
        throw appExps;
    doInquiry();
    return getViewerFormKey();
}
Also used : ApplicationExceptions(org.jaffa.exceptions.ApplicationExceptions) MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException)

Example 25 with MandatoryFieldException

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

the class FormUsageMaintenanceForm method doValidate0.

// .//GEN-END:_doValidate_2_be
// .//GEN-BEGIN:_doValidateMain_1_be
/**
 * This method should be invoked to ensure a valid state of the FormBean. It will validate the data in the models and set the corresponding properties.
 * Errors will be raised in the FormBean, if any validation fails.
 * @param request The request stream
 * @return A true indicates validations went through successfully.
 */
public boolean doValidate0(HttpServletRequest request) {
    boolean valid = true;
    try {
        String htmlString = getFormNameWM().getValue();
        if (htmlString != null && htmlString.length() == 0)
            htmlString = null;
        java.lang.String value = (java.lang.String) FieldValidator.validateData(htmlString, (StringFieldMetaData) FormUsageMeta.META_FORM_NAME, true);
        if (value == null)
            throw new MandatoryFieldException(((StringFieldMetaData) FormUsageMeta.META_FORM_NAME).getLabelToken());
        setFormName(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((StringFieldMetaData) FormUsageMeta.META_FORM_NAME).getLabelToken(), e);
    }
    try {
        String htmlString = getEventNameWM().getValue();
        if (htmlString != null && htmlString.length() == 0)
            htmlString = null;
        java.lang.String value = (java.lang.String) FieldValidator.validateData(htmlString, (StringFieldMetaData) FormUsageMeta.META_EVENT_NAME, true);
        if (value == null)
            throw new MandatoryFieldException(((StringFieldMetaData) FormUsageMeta.META_EVENT_NAME).getLabelToken());
        setEventName(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((StringFieldMetaData) FormUsageMeta.META_EVENT_NAME).getLabelToken(), e);
    }
    try {
        String htmlString = getFormAlternateWM().getValue();
        if (htmlString != null && htmlString.length() == 0)
            htmlString = null;
        java.lang.String value = (java.lang.String) FieldValidator.validateData(htmlString, (StringFieldMetaData) FormUsageMeta.META_FORM_ALTERNATE, true);
        setFormAlternate(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((StringFieldMetaData) FormUsageMeta.META_FORM_ALTERNATE).getLabelToken(), e);
    }
    try {
        String htmlString = getCopiesWM().getValue();
        if (htmlString != null && htmlString.length() == 0)
            htmlString = null;
        java.lang.Long value = (java.lang.Long) FieldValidator.validateData(htmlString, (IntegerFieldMetaData) FormUsageMeta.META_COPIES, true);
        setCopies(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((IntegerFieldMetaData) FormUsageMeta.META_COPIES).getLabelToken(), e);
    }
    try {
        org.jaffa.datatypes.DateTime value = getCreatedOnWM().getValue();
        value = FieldValidator.validate(value, (DateTimeFieldMetaData) FormUsageMeta.META_CREATED_ON, true);
        setCreatedOn(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((DateTimeFieldMetaData) FormUsageMeta.META_CREATED_ON).getLabelToken(), e);
    }
    try {
        String htmlString = getCreatedByWM().getValue();
        if (htmlString != null && htmlString.length() == 0)
            htmlString = null;
        java.lang.String value = (java.lang.String) FieldValidator.validateData(htmlString, (StringFieldMetaData) FormUsageMeta.META_CREATED_BY, true);
        setCreatedBy(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((StringFieldMetaData) FormUsageMeta.META_CREATED_BY).getLabelToken(), e);
    }
    try {
        org.jaffa.datatypes.DateTime value = getLastChangedOnWM().getValue();
        value = FieldValidator.validate(value, (DateTimeFieldMetaData) FormUsageMeta.META_LAST_CHANGED_ON, true);
        setLastChangedOn(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((DateTimeFieldMetaData) FormUsageMeta.META_LAST_CHANGED_ON).getLabelToken(), e);
    }
    try {
        String htmlString = getLastChangedByWM().getValue();
        if (htmlString != null && htmlString.length() == 0)
            htmlString = null;
        java.lang.String value = (java.lang.String) FieldValidator.validateData(htmlString, (StringFieldMetaData) FormUsageMeta.META_LAST_CHANGED_BY, true);
        setLastChangedBy(value);
    } catch (ValidationException e) {
        valid = false;
        raiseError(request, ((StringFieldMetaData) FormUsageMeta.META_LAST_CHANGED_BY).getLabelToken(), e);
    }
    // .//GEN-BEGIN:_doValidateMain_2_be
    return valid;
}
Also used : MandatoryFieldException(org.jaffa.datatypes.exceptions.MandatoryFieldException) org.jaffa.datatypes(org.jaffa.datatypes)

Aggregations

MandatoryFieldException (org.jaffa.datatypes.exceptions.MandatoryFieldException)31 ApplicationExceptions (org.jaffa.exceptions.ApplicationExceptions)22 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ActionMessage (org.apache.struts.action.ActionMessage)2 FormSelectionException (org.jaffa.modules.printing.components.formselectionmaintenance.FormSelectionException)2 Iterator (java.util.Iterator)1 IAttachmentData (org.jaffa.components.attachment.apis.IAttachmentData)1 IVoucherGenerator (org.jaffa.components.voucher.IVoucherGenerator)1 org.jaffa.datatypes (org.jaffa.datatypes)1 ApplicationException (org.jaffa.exceptions.ApplicationException)1 FrameworkException (org.jaffa.exceptions.FrameworkException)1 FieldMetaData (org.jaffa.metadata.FieldMetaData)1 FormSelectionMaintenanceInDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceInDto)1 FormSelectionMaintenanceOutDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutDto)1 FormSelectionMaintenanceOutRowDto (org.jaffa.modules.printing.components.formselectionmaintenance.dto.FormSelectionMaintenanceOutRowDto)1 DomainObjectValidationException (org.jaffa.persistence.exceptions.DomainObjectValidationException)1 CheckBoxModel (org.jaffa.presentation.portlet.widgets.model.CheckBoxModel)1 EditBoxModel (org.jaffa.presentation.portlet.widgets.model.EditBoxModel)1 GridModel (org.jaffa.presentation.portlet.widgets.model.GridModel)1 GridModelRow (org.jaffa.presentation.portlet.widgets.model.GridModelRow)1