/** * Captures the error messages related to the form. * * @param enrollment the enrollment that was validated * @param messages the messages to select from * @return the list of errors related to the form */ protected List<FormError> selectErrors(EnrollmentType enrollment, StatusMessagesType messages) { List<FormError> errors = new ArrayList<FormError>(); List<StatusMessageType> ruleErrors = messages.getStatusMessage(); List<StatusMessageType> caughtMessages = new ArrayList<StatusMessageType>(); synchronized (ruleErrors) { for (StatusMessageType ruleError : ruleErrors) { int count = errors.size(); String path = ruleError.getRelatedElementPath(); if (path == null) { continue; } if (path.equals( "/ProviderInformation/AttachedDocuments/Document[name=\"Community Health Board DHS Contract\"]")) { errors.add(createError("dhsContract", ruleError.getMessage())); } if (errors.size() > count) { // caught caughtMessages.add(ruleError); } } // so it does not get processed anywhere again ruleErrors.removeAll(caughtMessages); } return errors.isEmpty() ? NO_ERRORS : errors; }
/** * Captures the error messages related to the form. * * @param enrollment the enrollment that was validated * @param messages the messages to select from * @return the list of errors related to the form */ protected List<FormError> selectErrors(EnrollmentType enrollment, StatusMessagesType messages) { List<FormError> errors = new ArrayList<FormError>(); List<StatusMessageType> ruleErrors = messages.getStatusMessage(); List<StatusMessageType> caughtMessages = new ArrayList<StatusMessageType>(); synchronized (ruleErrors) { for (StatusMessageType ruleError : ruleErrors) { int count = errors.size(); String path = ruleError.getRelatedElementPath(); if (path == null) { continue; } if (path.equals(AGREEMENTS)) { errors.add(createError("agreements", ruleError.getMessage())); } else if (path.equals(STATEMENT + "Name")) { errors.add(createError("name", ruleError.getMessage())); } else if (path.equals(STATEMENT + "Title")) { errors.add(createError("title", ruleError.getMessage())); } else if (path.equals(STATEMENT + "SignDate")) { errors.add(createError("date", ruleError.getMessage())); } if (errors.size() > count) { // caught caughtMessages.add(ruleError); } } // so it does not get processed anywhere again ruleErrors.removeAll(caughtMessages); } return errors.isEmpty() ? NO_ERRORS : errors; }