Search in sources :

Example 6 with FieldConfigurationEntity

use of org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity in project head by mifos.

the class BaseActionForm method checkForMandatoryFields.

protected void checkForMandatoryFields(Short entityId, ActionErrors errors, HttpServletRequest request) {
    Map<Short, List<FieldConfigurationEntity>> entityMandatoryFieldMap = (Map<Short, List<FieldConfigurationEntity>>) request.getSession().getServletContext().getAttribute(Constants.FIELD_CONFIGURATION);
    List<FieldConfigurationEntity> mandatoryfieldList = entityMandatoryFieldMap.get(entityId);
    for (FieldConfigurationEntity fieldConfigurationEntity : mandatoryfieldList) {
        String propertyName = request.getParameter(fieldConfigurationEntity.getLabel());
        if (propertyName != null && !propertyName.equals("")) {
            String propertyValue = request.getParameter(propertyName);
            UserContext userContext = ((UserContext) request.getSession().getAttribute(LoginConstants.USERCONTEXT));
            if (propertyValue == null || propertyValue.equals("")) {
                errors.add(fieldConfigurationEntity.getLabel(), new ActionMessage(FieldConfigurationConstant.EXCEPTION_MANDATORY, FieldConfigurationHelper.getLocalSpecificFieldNames(fieldConfigurationEntity.getLabel(), userContext)));
            }
        }
    }
}
Also used : UserContext(org.mifos.security.util.UserContext) ActionMessage(org.apache.struts.action.ActionMessage) FieldConfigurationEntity(org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity) List(java.util.List) Map(java.util.Map)

Example 7 with FieldConfigurationEntity

use of org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity in project head by mifos.

the class FieldConfig method isFieldHidden.

public boolean isFieldHidden(String labelName) {
    if (labelName == null || labelName.equals("") || labelName.indexOf(".") == -1) {
        return false;
    }
    labelName = labelName.trim();
    String entityName = labelName.substring(0, labelName.indexOf("."));
    String fieldName = labelName.substring(labelName.indexOf(".") + 1);
    List<FieldConfigurationEntity> fieldList = getEntityFieldMap().get(getEntityMap().get(entityName));
    if (fieldList != null && fieldList.size() > 0) {
        for (FieldConfigurationEntity fieldConfigurationEntity : fieldList) {
            FieldConfigurationEntity parentfieldConfigurationEntity = fieldConfigurationEntity.getParentFieldConfig();
            if ((fieldConfigurationEntity.getHiddenFlag().equals(FieldConfigurationConstant.YES) || (parentfieldConfigurationEntity != null && parentfieldConfigurationEntity.getHiddenFlag().equals(FieldConfigurationConstant.YES))) && fieldConfigurationEntity.getFieldName().equals(fieldName)) {
                return true;
            }
        }
    }
    return false;
}
Also used : FieldConfigurationEntity(org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity)

Example 8 with FieldConfigurationEntity

use of org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity in project head by mifos.

the class FieldConfig method isFieldManadatory.

public boolean isFieldManadatory(String labelName) {
    if (labelName == null || labelName.equals("") || labelName.indexOf(".") == -1) {
        return false;
    }
    labelName = labelName.trim();
    String entityName = labelName.substring(0, labelName.indexOf("."));
    String fieldName = labelName.substring(labelName.indexOf(".") + 1);
    List<FieldConfigurationEntity> fieldList = getEntityFieldMap().get(getEntityMap().get(entityName));
    if (fieldList != null && fieldList.size() > 0) {
        for (FieldConfigurationEntity fieldConfigurationEntity : fieldList) {
            FieldConfigurationEntity parentfieldConfigurationEntity = fieldConfigurationEntity.getParentFieldConfig();
            if (parentfieldConfigurationEntity == null) {
                if (fieldConfigurationEntity.getMandatoryFlag().equals(FieldConfigurationConstant.YES) && fieldConfigurationEntity.getHiddenFlag().equals(FieldConfigurationConstant.NO) && fieldConfigurationEntity.getFieldName().equals(fieldName)) {
                    return true;
                }
            } else if ((parentfieldConfigurationEntity.getMandatoryFlag().equals(FieldConfigurationConstant.YES) && parentfieldConfigurationEntity.getHiddenFlag().equals(FieldConfigurationConstant.NO) && fieldConfigurationEntity.getFieldName().equals(fieldName) && fieldConfigurationEntity.getHiddenFlag().equals(FieldConfigurationConstant.NO)) || ((parentfieldConfigurationEntity.getMandatoryFlag().equals(FieldConfigurationConstant.NO) && parentfieldConfigurationEntity.getHiddenFlag().equals(FieldConfigurationConstant.NO) && fieldConfigurationEntity.getFieldName().equals(fieldName) && fieldConfigurationEntity.getHiddenFlag().equals(FieldConfigurationConstant.NO) && fieldConfigurationEntity.getMandatoryFlag().equals(FieldConfigurationConstant.YES)))) {
                return true;
            }
        }
    }
    return false;
}
Also used : FieldConfigurationEntity(org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity)

Example 9 with FieldConfigurationEntity

use of org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity in project head by mifos.

the class FieldConfig method getMandatoryFieldList.

private List<FieldConfigurationEntity> getMandatoryFieldList(Short entityId) {
    List<FieldConfigurationEntity> fieldList = getEntityFieldMap().get(entityId);
    List<FieldConfigurationEntity> mandatoryFieldList = new ArrayList<FieldConfigurationEntity>();
    for (FieldConfigurationEntity fieldConfigurationEntity : fieldList) {
        if (isFieldManadatory(fieldConfigurationEntity.getLabel())) {
            mandatoryFieldList.add(fieldConfigurationEntity);
        }
    }
    return mandatoryFieldList;
}
Also used : ArrayList(java.util.ArrayList) FieldConfigurationEntity(org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity)

Example 10 with FieldConfigurationEntity

use of org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity in project head by mifos.

the class AdminServiceFacadeWebTier method updateHiddenMandatoryFields.

@Override
public void updateHiddenMandatoryFields(MandatoryHiddenFieldsDto dto) {
    try {
        List<FieldConfigurationEntity> confFieldList = legacyFieldConfigurationDao.getAllConfigurationFieldList();
        mandatoryHiddenFieldService.updateMandatoryHiddenFields(dto, confFieldList);
    } catch (PersistenceException e) {
        throw new MifosRuntimeException(e);
    }
}
Also used : PersistenceException(org.mifos.framework.exceptions.PersistenceException) FieldConfigurationEntity(org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Aggregations

FieldConfigurationEntity (org.mifos.framework.components.fieldConfiguration.business.FieldConfigurationEntity)13 List (java.util.List)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 ActionMessage (org.apache.struts.action.ActionMessage)3 MifosRuntimeException (org.mifos.core.MifosRuntimeException)2 PersistenceException (org.mifos.framework.exceptions.PersistenceException)2 UserContext (org.mifos.security.util.UserContext)2 IOException (java.io.IOException)1 Test (org.junit.Test)1 MandatoryHiddenFieldsDto (org.mifos.dto.domain.MandatoryHiddenFieldsDto)1