Search in sources :

Example 1 with AttributeError

use of org.kuali.kfs.core.api.uif.AttributeError in project cu-kfs by CU-CommunityApps.

the class FinancialSystemSearchableAttribute method validateDocumentAttributeCriteria.

@Override
public List<AttributeError> validateDocumentAttributeCriteria(RuleAttribute ruleAttribute, DocumentSearchCriteria documentSearchCriteria) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("validateDocumentAttributeCriteria( " + ruleAttribute + ", " + documentSearchCriteria + " )");
    }
    // this list is irrelevant. the validation errors are put on the stack in the validationService.
    List<AttributeError> errors = super.validateDocumentAttributeCriteria(ruleAttribute, documentSearchCriteria);
    DictionaryValidationService validationService = SpringContext.getBean(DictionaryValidationService.class);
    Map<String, List<String>> paramMap = documentSearchCriteria.getDocumentAttributeValues();
    for (String key : paramMap.keySet()) {
        List<String> values = paramMap.get(key);
        if (values != null && !values.isEmpty()) {
            for (String value : values) {
                if (StringUtils.isNotEmpty(value)) {
                    if (magicFields.containsKey(key)) {
                        validationService.validateAttributeFormat(magicFields.get(key), key, value, key);
                    }
                }
            }
        }
    }
    retrieveValidationErrorsFromGlobalVariables(errors);
    return errors;
}
Also used : DictionaryValidationService(org.kuali.kfs.kns.service.DictionaryValidationService) AttributeError(org.kuali.kfs.core.api.uif.AttributeError) List(java.util.List) ArrayList(java.util.ArrayList) DocumentAttributeString(org.kuali.kfs.kew.api.document.attribute.DocumentAttributeString)

Example 2 with AttributeError

use of org.kuali.kfs.core.api.uif.AttributeError in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentRule method validateQualification.

protected boolean validateQualification(KimType typeInfo, SecurityRequestRoleQualification requestRoleQualification, String fieldKeyPrefix) {
    boolean success = true;
    KimTypeService kimTypeService = KimFrameworkServiceLocator.getKimTypeService(typeInfo);
    try {
        List<AttributeError> attributeErrors = kimTypeService.validateAttributes(typeInfo.getId(), requestRoleQualification.buildQualificationAttributeSet());
        if (!attributeErrors.isEmpty()) {
            success = false;
        }
        for (AttributeError entry : attributeErrors) {
            String attributeName = entry.getAttributeName();
            int qualificationDetailIndex = findQualificationRecordForAttribute(requestRoleQualification.getRoleQualificationDetails(), attributeName);
            String fieldKey = fieldKeyPrefix + KSRPropertyConstants.SECURITY_REQUEST_DOC_ROLE_QUAL_DETAILS + "[" + qualificationDetailIndex + "]." + KSRPropertyConstants.SECURITY_REQUEST_DOC_ROLE_ATTR_VALUE;
            String attributeError = entry.getMessage();
            String messageKey = StringUtils.substringBefore(attributeError, ":");
            String messageParameter = StringUtils.substringAfter(attributeError, ":");
            GlobalVariables.getMessageMap().putError(fieldKey, messageKey, messageParameter);
        }
    } catch (Exception e) {
        String input = KRADConstants.DOCUMENT_PROPERTY_NAME + "." + KRADConstants.DOCUMENT_HEADER_PROPERTY_NAME;
        GlobalVariables.getMessageMap().putInfo(input, KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_SERVICE_EXCEPTION, new String[] { "SOME FILLER TEXT" });
    }
    return success;
}
Also used : KimTypeService(org.kuali.kfs.kim.framework.type.KimTypeService) AttributeError(org.kuali.kfs.core.api.uif.AttributeError)

Example 3 with AttributeError

use of org.kuali.kfs.core.api.uif.AttributeError in project cu-kfs by CU-CommunityApps.

the class AttributeValidationHelper method convertErrorsForMappedFields.

public List<AttributeError> convertErrorsForMappedFields(String errorPath, List<AttributeError> localErrors) {
    List<AttributeError> errors = new ArrayList<>();
    if (errorPath == null) {
        errorPath = KFSConstants.EMPTY_STRING;
    } else if (StringUtils.isNotEmpty(errorPath)) {
        errorPath = errorPath + ".";
    }
    for (AttributeError error : localErrors) {
        KimAttribute attribute = getAttributeDefinitionByName(error.getAttributeName());
        String attributeDefnId = attribute == null ? "" : attribute.getId();
        errors.add(AttributeError.Builder.create(errorPath + "qualifier(" + attributeDefnId + ").attrVal", error.getErrors()).build());
    }
    return errors;
}
Also used : AttributeError(org.kuali.kfs.core.api.uif.AttributeError) ArrayList(java.util.ArrayList) KimAttribute(org.kuali.kfs.kim.impl.common.attribute.KimAttribute)

Aggregations

AttributeError (org.kuali.kfs.core.api.uif.AttributeError)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1 DocumentAttributeString (org.kuali.kfs.kew.api.document.attribute.DocumentAttributeString)1 KimTypeService (org.kuali.kfs.kim.framework.type.KimTypeService)1 KimAttribute (org.kuali.kfs.kim.impl.common.attribute.KimAttribute)1 DictionaryValidationService (org.kuali.kfs.kns.service.DictionaryValidationService)1