Skip to content

Commit

Permalink
Revert "TRUNK-3850"
Browse files Browse the repository at this point in the history
This reverts commit 956e3f5.
  • Loading branch information
dkayiwa committed Feb 17, 2014
1 parent 9f8c016 commit 0e15769
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions api/src/main/java/org/openmrs/validator/ProgramValidator.java
Expand Up @@ -61,12 +61,14 @@ public void validate(Object obj, Errors errors) {
} else {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.description.required");
Program program = Context.getProgramWorkflowService().getProgramByName(p.getName());
if (program != null && !program.equals(p)) {
errors.rejectValue("name", "general.error.nameAlreadyInUse");

} else {
Context.evictFromSession(program);
List<Program> programs = Context.getProgramWorkflowService().getAllPrograms(false);
for (Program program : programs) {
if (program.getName().equals(p.getName()) && !program.getProgramId().equals(p.getProgramId())) {
errors.rejectValue("name", "general.error.nameAlreadyInUse");
break;
} else {
Context.evictFromSession(program);
}
}

ValidationUtils.rejectIfEmptyOrWhitespace(errors, "concept", "error.concept");
Expand Down

0 comments on commit 0e15769

Please sign in to comment.