@Override
  public List<RemotableAttributeError> validateDocumentAttributeCriteria(
      ExtensionDefinition extensionDefinition, DocumentSearchCriteria documentSearchCriteria) {
    List<RemotableAttributeError> validationErrors = new ArrayList<RemotableAttributeError>();
    DictionaryValidationService validationService =
        KNSServiceLocator.getKNSDictionaryValidationService();

    // validate the document attribute values
    Map<String, List<String>> documentAttributeValues =
        documentSearchCriteria.getDocumentAttributeValues();
    for (String key : documentAttributeValues.keySet()) {
      List<String> values = documentAttributeValues.get(key);
      if (CollectionUtils.isNotEmpty(values)) {
        for (String value : values) {
          if (StringUtils.isNotBlank(value)) {
            validationService.validateAttributeFormat(
                documentSearchCriteria.getDocumentTypeName(), key, value, key);
          }
        }
      }
    }

    retrieveValidationErrorsFromGlobalVariables(validationErrors);

    return validationErrors;
  }
  /**
   * This method checks budget versions business rules.
   *
   * @param budgetParentDocument the document
   * @param runDatactionaryValidation if dd validation should be run
   * @return true if valid false if not
   * @throws NullPointerException if the proposalDevelopmentDocument is null
   */
  protected boolean processBudgetVersionsBusinessRule(
      final BudgetParentDocument budgetParentDocument, final boolean runDatactionaryValidation) {
    if (budgetParentDocument == null) {
      throw new NullPointerException("the parentDocument is null.");
    }

    boolean valid = true;
    final MessageMap errorMap = GlobalVariables.getMessageMap();
    boolean finalVersionFound = false;

    final DictionaryValidationService dictionaryValidationService =
        getKnsDictionaryValidationService();

    int index = 0;
    for (BudgetDocumentVersion budgetDocumentVersion :
        budgetParentDocument.getBudgetDocumentVersions()) {
      BudgetVersionOverview budgetVersion = budgetDocumentVersion.getBudgetVersionOverview();
      if (runDatactionaryValidation) {
        dictionaryValidationService.validateBusinessObject(budgetVersion, true);
      }
      if (budgetVersion.isFinalVersionFlag()) {
        if (finalVersionFound) {
          errorMap.putError("finalVersionFlag", KeyConstants.ERROR_MULTIPLE_FINAL_BUDGETS);
        } else {
          finalVersionFound = true;
        }
      }

      final String budgetStatusCompleteCode =
          getParameterService()
              .getParameterValueAsString(
                  BudgetDocument.class, Constants.BUDGET_STATUS_COMPLETE_CODE);

      if (budgetStatusCompleteCode.equalsIgnoreCase(budgetVersion.getBudgetStatus())) {
        if (!budgetVersion.isFinalVersionFlag()) {
          errorMap.putError(
              "budgetVersionOverview[" + index + "].budgetStatus",
              KeyConstants.ERROR_NO_FINAL_BUDGET);
          valid = false;
        }
      }
      index++;
    }

    return valid;
  }