Index: /test/api/org/openmrs/EncounterTypeTest.java =================================================================== --- /test/api/org/openmrs/EncounterTypeTest.java (revision 14891) +++ /test/api/org/openmrs/EncounterTypeTest.java (working copy) @@ -117,5 +117,4 @@ public void hashCode_shouldGetHashCodeEvenWithNullAttributes() throws Exception { new EncounterType().hashCode(); } - } Index: /test/api/org/openmrs/validator/PersonAttributeTypeValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/PersonAttributeTypeValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/PersonAttributeTypeValidatorTest.java (working copy) @@ -30,14 +30,14 @@ * @see {@link PersonAttributeTypeValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if name is null", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfNameIsNull() throws Exception { + @Verifies(value = "should fail validation if unlocalized name is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedNameIsNullOrEmptyOrWhitespace() throws Exception { PersonAttributeType type = new PersonAttributeType(); Errors errors = new BindException(type, "patObj"); new PersonAttributeTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); } /** Index: /test/api/org/openmrs/validator/RoleValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/RoleValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/RoleValidatorTest.java (working copy) @@ -18,7 +18,7 @@ @Test @Verifies(value = "should fail validation if role is null or empty or whitespace", method = "validate(Object,Errors)") public void validate_shouldFailValidationIfRoleIsNullOrEmptyOrWhitespace() throws Exception { - Role role = new Role(); + Role role = new Role(); role.setRole(null); role.setDescription("some text"); //TODO: change/fix this test when it is decided whether to change the validator behavior to avoid throwing an NPE @@ -41,25 +41,25 @@ * @see {@link RoleValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if description is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfDescriptionIsNullOrEmptyOrWhitespace() throws Exception { + @Verifies(value = "should fail validation if unlocalized description is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedDescriptionIsNullOrEmptyOrWhitespace() throws Exception { Role role = new Role(); role.setRole("Bowling race car driver"); role.setDescription(null); Errors errors = new BindException(role, "type"); new RoleValidator().validate(role, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); role.setDescription(""); errors = new BindException(role, "role"); new RoleValidator().validate(role, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); role.setDescription(" "); errors = new BindException(role, "role"); new RoleValidator().validate(role, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); } /** Index: /test/api/org/openmrs/validator/SchedulerFormValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/SchedulerFormValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/SchedulerFormValidatorTest.java (working copy) @@ -16,8 +16,8 @@ * @see {@link SchedulerFormValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if name is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfNameIsNullOrEmptyOrWhitespace() throws Exception { + @Verifies(value = "should fail validation if unlocalized name is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedNameIsNullOrEmptyOrWhitespace() throws Exception { TaskDefinition def = new TaskDefinition(); def.setName(null); def.setRepeatInterval(3600000L); @@ -25,17 +25,17 @@ Errors errors = new BindException(def, "def"); new SchedulerFormValidator().validate(def, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); def.setName(""); errors = new BindException(def, "def"); new SchedulerFormValidator().validate(def, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); def.setName(" "); errors = new BindException(def, "def"); new SchedulerFormValidator().validate(def, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); } /** Index: /test/api/org/openmrs/validator/FormValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/FormValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/FormValidatorTest.java (working copy) @@ -30,15 +30,15 @@ * @see {@link FormValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if name is null", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfNameIsNull() throws Exception { + @Verifies(value = "should fail validation if unlocalized name is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedNameIsNullOrEmptyOrWhitespace() throws Exception { Form form = new Form(); form.setVersion("1.0"); Errors errors = new BindException(form, "form"); new FormValidator().validate(form, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); Assert.assertFalse(errors.hasFieldErrors("version")); } @@ -54,7 +54,7 @@ Errors errors = new BindException(form, "form"); new FormValidator().validate(form, errors); - Assert.assertFalse(errors.hasFieldErrors("name")); + Assert.assertFalse(errors.hasFieldErrors("localizedName.unlocalizedValue")); Assert.assertTrue(errors.hasFieldErrors("version")); } @@ -71,7 +71,7 @@ Errors errors = new BindException(form, "form"); new FormValidator().validate(form, errors); - Assert.assertFalse(errors.hasFieldErrors("name")); + Assert.assertFalse(errors.hasFieldErrors("localizedName.unlocalizedValue")); Assert.assertTrue(errors.hasFieldErrors("version")); } @@ -89,7 +89,7 @@ Errors errors = new BindException(form, "form"); new FormValidator().validate(form, errors); - Assert.assertFalse(errors.hasFieldErrors("name")); + Assert.assertFalse(errors.hasFieldErrors("localizedName.unlocalizedValue")); Assert.assertFalse(errors.hasFieldErrors("version")); Assert.assertTrue(errors.hasFieldErrors("retireReason")); } Index: /test/api/org/openmrs/validator/EncounterTypeValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/EncounterTypeValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/EncounterTypeValidatorTest.java (working copy) @@ -16,50 +16,50 @@ * @see {@link EncounterTypeValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if name is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfNameIsNullOrEmptyOrWhitespace() throws Exception { + @Verifies(value = "should fail validation if unlocalized name is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedNameIsNullOrEmptyOrWhitespace() throws Exception { EncounterType type = new EncounterType(); type.setName(null); type.setDescription("Aaaaah"); Errors errors = new BindException(type, "type"); new EncounterTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); type.setName(""); errors = new BindException(type, "type"); new EncounterTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); type.setName(" "); errors = new BindException(type, "type"); new EncounterTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); } /** * @see {@link EncounterTypeValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if description is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfDescriptionIsNullOrEmptyOrWhitespace() throws Exception { + @Verifies(value = "should fail validation if unlocalized description is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedDescriptionIsNullOrEmptyOrWhitespace() throws Exception { EncounterType type = new EncounterType(); type.setName("CLOSE"); type.setDescription(null); Errors errors = new BindException(type, "type"); new EncounterTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); type.setDescription(""); errors = new BindException(type, "type"); new EncounterTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); type.setDescription(" "); errors = new BindException(type, "type"); new EncounterTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); } /** Index: /test/api/org/openmrs/validator/ProgramValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/ProgramValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/ProgramValidatorTest.java (working copy) @@ -18,25 +18,25 @@ * @see {@link ProgramValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if name is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfNameIsNullOrEmptyOrWhitespace() throws Exception { + @Verifies(value = "should fail validation if unlocalized name is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedNameIsNullOrEmptyOrWhitespace() throws Exception { Program prog = new Program(); prog.setName(null); prog.setConcept(Context.getConceptService().getConcept(3)); Errors errors = new BindException(prog, "prog"); new ProgramValidator().validate(prog, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); prog.setName(""); errors = new BindException(prog, "prog"); new ProgramValidator().validate(prog, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); prog.setName(" "); errors = new BindException(prog, "prog"); new ProgramValidator().validate(prog, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); } /** Index: /test/api/org/openmrs/validator/LocationValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/LocationValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/LocationValidatorTest.java (working copy) @@ -30,16 +30,16 @@ * @see {@link LocationValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if name is null or empty", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfNameIsNullOrEmpty() throws Exception { + @Verifies(value = "should fail validation if unlocalized name is null or empty", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedNameIsNullOrEmpty() throws Exception { Location location = new Location(); location.setDescription("desc"); Errors errors = new BindException(location, "location"); new LocationValidator().validate(location, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); - Assert.assertFalse(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); + Assert.assertFalse(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); } /** @@ -54,8 +54,8 @@ Errors errors = new BindException(location, "location"); new LocationValidator().validate(location, errors); - Assert.assertFalse(errors.hasFieldErrors("name")); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertFalse(errors.hasFieldErrors("localizedName.unlocalizedValue")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); } /** Index: /test/api/org/openmrs/validator/PatientIdentifierTypeValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/PatientIdentifierTypeValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/PatientIdentifierTypeValidatorTest.java (working copy) @@ -16,8 +16,8 @@ * */ @Test - @Verifies(value = "should fail validation if name is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfNameIsNullOrEmptyOrWhitespace() + @Verifies(value = "should fail validation if unlocalized name is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedNameIsNullOrEmptyOrWhitespace() throws Exception { PatientIdentifierType type = new PatientIdentifierType(); type.setName(null); @@ -25,17 +25,17 @@ Errors errors = new BindException(type, "type"); new PatientIdentifierTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); type.setName(""); errors = new BindException(type, "type"); new PatientIdentifierTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); type.setName(" "); errors = new BindException(type, "type"); new PatientIdentifierTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); } /** @@ -52,17 +52,17 @@ Errors errors = new BindException(type, "type"); new PatientIdentifierTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); type.setDescription(""); errors = new BindException(type, "type"); new PatientIdentifierTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); type.setDescription(" "); errors = new BindException(type, "type"); new PatientIdentifierTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); } /** Index: /test/api/org/openmrs/validator/OrderTypeValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/OrderTypeValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/OrderTypeValidatorTest.java (working copy) @@ -16,8 +16,8 @@ * */ @Test - @Verifies(value = "should fail validation if name is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfNameIsNullOrEmptyOrWhitespace() + @Verifies(value = "should fail validation if unlocalized name is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedNameIsNullOrEmptyOrWhitespace() throws Exception { OrderType type = new OrderType(); type.setName(null); @@ -25,17 +25,17 @@ Errors errors = new BindException(type, "type"); new OrderTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); type.setName(""); errors = new BindException(type, "type"); new OrderTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); type.setName(" "); errors = new BindException(type, "type"); new OrderTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); } /** @@ -43,8 +43,8 @@ * */ @Test - @Verifies(value = "should fail validation if description is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfDescriptionIsNullOrEmptyOrWhitespace() + @Verifies(value = "should fail validation if unlocalized description is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedDescriptionIsNullOrEmptyOrWhitespace() throws Exception { OrderType type = new OrderType(); type.setName("restraining"); @@ -52,17 +52,17 @@ Errors errors = new BindException(type, "type"); new OrderTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); type.setDescription(""); errors = new BindException(type, "type"); new OrderTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); type.setDescription(" "); errors = new BindException(type, "type"); new OrderTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); } /** Index: /test/api/org/openmrs/validator/ConceptClassValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/ConceptClassValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/ConceptClassValidatorTest.java (working copy) @@ -16,50 +16,50 @@ * @see {@link ConceptClassValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if user is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfUserIsNullOrEmptyOrWhitespace() throws Exception { + @Verifies(value = "should fail validation if unlocalized name is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedNameIsNullOrEmptyOrWhitespace() throws Exception { ConceptClass cc = new ConceptClass(); cc.setName(null); cc.setDescription("some text"); Errors errors = new BindException(cc, "cc"); new ConceptClassValidator().validate(cc, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); cc.setName(""); errors = new BindException(cc, "cc"); new ConceptClassValidator().validate(cc, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); cc.setName(" "); errors = new BindException(cc, "cc"); new ConceptClassValidator().validate(cc, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); } /** * @see {@link ConceptClassValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if description is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfDescriptionIsNullOrEmptyOrWhitespace() throws Exception { + @Verifies(value = "should fail validation if unlocalized description is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedDescriptionIsNullOrEmptyOrWhitespace() throws Exception { ConceptClass cc = new ConceptClass(); cc.setName("name"); cc.setDescription(null); Errors errors = new BindException(cc, "cc"); new ConceptClassValidator().validate(cc, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); cc.setDescription(""); errors = new BindException(cc, "cc"); new ConceptClassValidator().validate(cc, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); cc.setDescription(" "); errors = new BindException(cc, "cc"); new ConceptClassValidator().validate(cc, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); } Index: /test/api/org/openmrs/validator/FieldTypeValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/FieldTypeValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/FieldTypeValidatorTest.java (working copy) @@ -25,17 +25,17 @@ Errors errors = new BindException(type, "type"); new FieldTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); type.setName(""); errors = new BindException(type, "type"); new FieldTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); type.setName(" "); errors = new BindException(type, "type"); new FieldTypeValidator().validate(type, errors); - Assert.assertTrue(errors.hasFieldErrors("name")); + Assert.assertTrue(errors.hasFieldErrors("localizedName.unlocalizedValue")); } /** Index: /test/api/org/openmrs/validator/PrivilegeValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/PrivilegeValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/PrivilegeValidatorTest.java (working copy) @@ -41,25 +41,25 @@ * @see {@link PrivilegeValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if description is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfDescriptionIsNullOrEmptyOrWhitespace() throws Exception { + @Verifies(value = "should fail validation if unlocalized description is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedDescriptionIsNullOrEmptyOrWhitespace() throws Exception { Privilege priv = new Privilege(); priv.setPrivilege("Wallhacking"); priv.setDescription(null); Errors errors = new BindException(priv, "priv"); new PrivilegeValidator().validate(priv, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); priv.setDescription(""); errors = new BindException(priv, "priv"); new PrivilegeValidator().validate(priv, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); priv.setDescription(" "); errors = new BindException(priv, "priv"); new PrivilegeValidator().validate(priv, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); } /** Index: /test/api/org/openmrs/validator/ConceptDatatypeValidatorTest.java =================================================================== --- /test/api/org/openmrs/validator/ConceptDatatypeValidatorTest.java (revision 14891) +++ /test/api/org/openmrs/validator/ConceptDatatypeValidatorTest.java (working copy) @@ -41,25 +41,25 @@ * @see {@link ConceptDatatypeValidator#validate(Object,Errors)} */ @Test - @Verifies(value = "should fail validation if description is null or empty or whitespace", method = "validate(Object,Errors)") - public void validate_shouldFailValidationIfDescriptionIsNullOrEmptyOrWhitespace() throws Exception { + @Verifies(value = "should fail validation if unlocalized description is null or empty or whitespace", method = "validate(Object,Errors)") + public void validate_shouldFailValidationIfUnlocalizedDescriptionIsNullOrEmptyOrWhitespace() throws Exception { ConceptDatatype cd = new ConceptDatatype(); cd.setName("name"); cd.setDescription(null); Errors errors = new BindException(cd, "cd"); new ConceptDatatypeValidator().validate(cd, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); cd.setDescription(""); errors = new BindException(cd, "cd"); new ConceptDatatypeValidator().validate(cd, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); cd.setDescription(" "); errors = new BindException(cd, "cd"); new ConceptDatatypeValidator().validate(cd, errors); - Assert.assertTrue(errors.hasFieldErrors("description")); + Assert.assertTrue(errors.hasFieldErrors("localizedDescription.unlocalizedValue")); } /** Index: /test/api/org/openmrs/api/include/EncounterServiceTest-initialData.xml =================================================================== --- /test/api/org/openmrs/api/include/EncounterServiceTest-initialData.xml (revision 14891) +++ /test/api/org/openmrs/api/include/EncounterServiceTest-initialData.xml (working copy) @@ -14,7 +14,7 @@ - + Index: /test/api/org/openmrs/api/db/include/SerializedObjectDAOTest-initialData.xml =================================================================== --- /test/api/org/openmrs/api/db/include/SerializedObjectDAOTest-initialData.xml (revision 14891) +++ /test/api/org/openmrs/api/db/include/SerializedObjectDAOTest-initialData.xml (working copy) @@ -1,6 +1,6 @@ - - - + + + Index: /test/api/org/openmrs/api/EncounterServiceTest.java =================================================================== --- /test/api/org/openmrs/api/EncounterServiceTest.java (revision 14891) +++ /test/api/org/openmrs/api/EncounterServiceTest.java (working copy) @@ -1073,15 +1073,15 @@ EncounterService encounterService = Context.getEncounterService(); List types = encounterService.findEncounterTypes("Test Enc"); - // make sure the order is id 2, 3, 1 + // make sure the order is id 2, 1, 3 assertEquals(2, types.get(0).getEncounterTypeId().intValue()); - assertEquals(3, types.get(1).getEncounterTypeId().intValue()); - assertEquals(1, types.get(2).getEncounterTypeId().intValue()); + assertEquals(1, types.get(1).getEncounterTypeId().intValue()); + assertEquals(3, types.get(2).getEncounterTypeId().intValue()); // this test expects that id #2 and id #3 have the same name and that // id #3 is retired - assertEquals(types.get(0).getName(), types.get(1).getName()); - assertTrue(types.get(1).isRetired()); + assertEquals(types.get(0).getName(), types.get(2).getName()); + assertTrue(types.get(2).isRetired()); } /** @@ -1297,6 +1297,15 @@ List encounters = encounterService.getEncountersByPatient("12345", true); assertEquals(3, encounters.size()); } + + /** + * @see {@link EncounterService#getEncountersByPatient(String,boolean)} + */ + @Test(expected = IllegalArgumentException.class) + @Verifies(value = "should throw error if given null parameter", method = "getEncountersByPatient(String,boolean)") + public void getEncountersByPatient_shouldThrowErrorIfGivenNullParameter() throws Exception { + Context.getEncounterService().getEncountersByPatient(null, false); + } /** * @see {@link EncounterService#getEncountersByPatient(String,boolean)} Index: /metadata/model/liquibase-update-to-latest.xml =================================================================== --- /metadata/model/liquibase-update-to-latest.xml (revision 14891) +++ /metadata/model/liquibase-update-to-latest.xml (working copy) @@ -3514,7 +3514,7 @@ - + @@ -3688,4 +3688,272 @@ - + + + + + + + Adding 'concept_name_type' column to concept_name table + + + + + + + + + + + + Adding 'locale_preferred' column to concept_name table + + + + + + + + + + Dropping foreign key constraint on concept_name_tag_map.concept_name_tag_id + + + + + + + + SELECT count(*) FROM concept_name_tag WHERE concept_name_tag_id = 4 + + + + Converting preferred names to FULLY_SPECIFIED names + + + concept_name_id IN (SELECT concept_name_id FROM concept_name_tag_map WHERE concept_name_tag_id = 4) + + + concept_name_tag_id = 4 + + + concept_name_tag_id = 4 + + + + + + + + SELECT count(*) FROM concept_name_tag WHERE concept_name_tag_id = 2 + + + + Setting the concept name type for short names + + + concept_name_id IN (SELECT concept_name_id FROM concept_name_tag_map WHERE concept_name_tag_id = 2) + + + concept_name_tag_id = 2 + + + concept_name_tag_id = 2 + + + + + + + + SELECT count(*) FROM concept_name_tag WHERE tag like 'preferred\___' + + + + + Converting concept names with country specific concept name tags to preferred names + + + + + concept_name_id IN (SELECT concept_name_id FROM concept_name_tag cnt, concept_name_tag_map cntm + WHERE cnt.concept_name_tag_id = cntm.concept_name_tag_id AND cnt.tag LIKE 'preferred\___') + + + + + concept_name_tag_id IN (SELECT concept_name_tag_id FROM concept_name_tag WHERE tag LIKE 'preferred\___') + + + tag LIKE 'preferred\___' + + + + + + + SELECT count(*) FROM concept_name_tag WHERE concept_name_tag_id IN (1,3) + + + + Deleting 'default' and 'synonym' concept name tags + + concept_name_tag_id IN (1,3) + + + concept_name_tag_id IN (1,3) + + + + + + SELECT count(*) FROM concept WHERE retired = 0 + + Validating and attempting to fix invalid concepts and ConceptNames + + + + + + + + + + Restoring foreign key constraint on concept_name_tag_map.concept_name_tag_id + + + + + + Modify the error_details column of hl7_in_error to hold + stacktraces + + + + + + + + + + + + + + Add an index to the person_name.family_name2 to speed up patient and person searches + + + + + + + + Change the width of name column to varchar(1024) for all metadata + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Change the width of description column to text for all metadata + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/OrderType.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/OrderType.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/OrderType.hbm.xml (working copy) @@ -17,10 +17,10 @@ - - + + Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/Field.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/Field.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/Field.hbm.xml (working copy) @@ -16,10 +16,11 @@ - + - + Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/Privilege.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/Privilege.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/Privilege.hbm.xml (working copy) @@ -17,8 +17,8 @@ - + Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/ConceptDatatype.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/ConceptDatatype.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/ConceptDatatype.hbm.xml (working copy) @@ -19,10 +19,10 @@ + + - - Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/PersonAttributeType.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/PersonAttributeType.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/PersonAttributeType.hbm.xml (working copy) @@ -18,11 +18,11 @@ - + - + Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/Role.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/Role.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/Role.hbm.xml (working copy) @@ -18,8 +18,8 @@ - + Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/Form.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/Form.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/Form.hbm.xml (working copy) @@ -16,8 +16,8 @@ - + @@ -28,8 +28,8 @@ - + Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/LocationTag.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/LocationTag.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/LocationTag.hbm.xml (working copy) @@ -12,8 +12,10 @@ - - + + Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/EncounterType.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/EncounterType.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/EncounterType.hbm.xml (working copy) @@ -12,11 +12,11 @@ - - - + + + - - - + + + Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/PatientIdentifierType.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/PatientIdentifierType.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/PatientIdentifierType.hbm.xml (working copy) @@ -21,19 +21,21 @@ + + - - - - + + Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/ConceptClass.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/ConceptClass.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/ConceptClass.hbm.xml (working copy) @@ -17,10 +17,10 @@ - - + + Index: /metadata/api/hibernate/org/openmrs/api/db/hibernate/FieldType.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/api/db/hibernate/FieldType.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/api/db/hibernate/FieldType.hbm.xml (working copy) @@ -30,19 +30,19 @@ + + - - - + - - + + + + + + - - - - - - + + - + + Index: /metadata/api/hibernate/org/openmrs/hl7/db/hibernate/HL7Source.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/hl7/db/hibernate/HL7Source.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/hl7/db/hibernate/HL7Source.hbm.xml (working copy) @@ -17,9 +17,13 @@ + + + Index: /metadata/api/hibernate/org/openmrs/scheduler/db/hibernate/TaskDefinition.hbm.xml =================================================================== --- /metadata/api/hibernate/org/openmrs/scheduler/db/hibernate/TaskDefinition.hbm.xml (revision 14891) +++ /metadata/api/hibernate/org/openmrs/scheduler/db/hibernate/TaskDefinition.hbm.xml (working copy) @@ -17,15 +17,16 @@ column="uuid" length="38" unique="true" /> - + not-null="true" + length="1024" /> - + length="65536" /> - openmrs-trunk + metadata-localization Index: /src/api/org/openmrs/Drug.java =================================================================== --- /src/api/org/openmrs/Drug.java (revision 14891) +++ /src/api/org/openmrs/Drug.java (working copy) @@ -18,7 +18,7 @@ /** * Drug */ -public class Drug extends BaseOpenmrsMetadata implements java.io.Serializable { +public class Drug extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 285L; @@ -59,7 +59,8 @@ * @param obj * @return boolean true/false whether or not they are the same objects */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj == null || !(obj instanceof Drug)) return false; @@ -67,7 +68,8 @@ return (this.drugId.equals(drug.getDrugId())); } - public int hashCode() { + @Override + public int hashCode() { if (this.getDrugId() == null) return super.hashCode(); return this.getDrugId().hashCode(); Index: /src/api/org/openmrs/EncounterType.java =================================================================== --- /src/api/org/openmrs/EncounterType.java (revision 14891) +++ /src/api/org/openmrs/EncounterType.java (working copy) @@ -13,12 +13,13 @@ */ package org.openmrs; + /** * An EncounterType defines how a certain kind of {@link Encounter}. * * @see Encounter */ -public class EncounterType extends BaseOpenmrsMetadata implements java.io.Serializable { +public class EncounterType extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 789L; @@ -61,7 +62,8 @@ * @should have equal encounter type objects with no encounterTypeId * @should not have equal encounter type objects when one has null encounterTypeId */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj == null || !(obj instanceof EncounterType)) return false; @@ -76,7 +78,8 @@ * @see java.lang.Object#hashCode() * @should get hashCode even with null attributes */ - public int hashCode() { + @Override + public int hashCode() { if (this.getEncounterTypeId() == null) return super.hashCode(); return this.getEncounterTypeId().hashCode(); Index: /src/api/org/openmrs/validator/PersonAttributeTypeValidator.java =================================================================== --- /src/api/org/openmrs/validator/PersonAttributeTypeValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/PersonAttributeTypeValidator.java (working copy) @@ -40,13 +40,14 @@ /** * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) - * @should fail validation if name is null + * @should fail validation if unlocalized name is null or empty or whitespace * @should fail validation if name already in use * @should pass validation if all fields are correct */ public void validate(Object obj, Errors errors) { PersonAttributeType patObj = (PersonAttributeType) obj; - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "PersonAttributeType.error.nameEmpty"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", + "LocalizedName.unlocalizedName.empty"); PersonService ps = Context.getPersonService(); PersonAttributeType pat = ps.getPersonAttributeTypeByName(patObj.getName()); Index: /src/api/org/openmrs/validator/RoleValidator.java =================================================================== --- /src/api/org/openmrs/validator/RoleValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/RoleValidator.java (working copy) @@ -49,7 +49,7 @@ * org.springframework.validation.Errors) * @should throw NullPointerException if role is null * @should fail validation if role is empty or whitespace - * @should fail validation if description is null or empty or whitespace + * @should fail validation if unlocalized description is null or empty or whitespace * @should fail validation if role has leading or trailing space * @should pass validation if all required fields have proper values */ @@ -59,7 +59,8 @@ errors.rejectValue("role", "error.general"); } else { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "role", "error.role"); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.description"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedDescription.unlocalizedValue", + "LocalizedDescription.unlocalizedDescription.empty"); // reject any role that has a leading or trailing space if (!role.getRole().equals(role.getRole().trim())) { Index: /src/api/org/openmrs/validator/SchedulerFormValidator.java =================================================================== --- /src/api/org/openmrs/validator/SchedulerFormValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/SchedulerFormValidator.java (working copy) @@ -42,7 +42,7 @@ * * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) - * @should fail validation if name is null or empty or whitespace + * @should fail validation if unlocalized name is null or empty or whitespace * @should fail validation if taskClass is empty or whitespace * @should fail validation if repeatInterval is null or empty or whitespace * @should fail validation if class is not instance of Task @@ -58,8 +58,8 @@ errors.rejectValue("task", "error.general"); } else { //Won't work without name and description properties on Task Definition - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "Scheduler.taskForm.required", new Object[] { - "Task name", taskDefinition.getName() }); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", + "Scheduler.taskForm.required", new Object[] { "Task name", taskDefinition.getName() }); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "taskClass", "Scheduler.taskForm.required", new Object[] { "Task class", taskDefinition.getTaskClass() }); Index: /src/api/org/openmrs/validator/FormValidator.java =================================================================== --- /src/api/org/openmrs/validator/FormValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/FormValidator.java (working copy) @@ -46,7 +46,7 @@ * * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) - * @should fail validation if name is null + * @should fail validation if unlocalized name is null or empty or whitespace * @should fail validation if version is null * @should fail validation if version does not match regex * @should fail validation if retiredReason is null @@ -58,7 +58,8 @@ if (form == null) { errors.rejectValue("form", "error.general"); } else { - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", + "LocalizedName.unlocalizedName.empty"); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "version", "error.null"); Index: /src/api/org/openmrs/validator/LocationTagValidator.java =================================================================== --- /src/api/org/openmrs/validator/LocationTagValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/LocationTagValidator.java (working copy) @@ -43,7 +43,8 @@ public void validate(Object target, Errors errors) { if (target != null) { LocationTag locationTag = (LocationTag) target; - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "LocationTag.error.name.required"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", + "LocalizedName.unlocalizedName.empty"); } } Index: /src/api/org/openmrs/validator/EncounterTypeValidator.java =================================================================== --- /src/api/org/openmrs/validator/EncounterTypeValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/EncounterTypeValidator.java (working copy) @@ -47,8 +47,8 @@ * * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) - * @should fail validation if name is null or empty or whitespace - * @should fail validation if description is null or empty or whitespace + * @should fail validation if unlocalized name is null or empty or whitespace + * @should fail validation if unlocalized description is null or empty or whitespace * @should pass validation if all required fields have proper values */ public void validate(Object obj, Errors errors) { @@ -56,8 +56,10 @@ if (encounterType == null) { errors.rejectValue("encounterType", "error.general"); } else { - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name"); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.description"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", + "LocalizedName.unlocalizedName.empty"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedDescription.unlocalizedValue", + "LocalizedDescription.unlocalizedDescription.empty"); } } Index: /src/api/org/openmrs/validator/ProgramValidator.java =================================================================== --- /src/api/org/openmrs/validator/ProgramValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/ProgramValidator.java (working copy) @@ -49,7 +49,7 @@ * * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) - * @should fail validation if name is null or empty or whitespace + * @should fail validation if unlocalized name is null or empty or whitespace * @should fail validation if program name already in use * @should fail validation if concept is null or empty or whitespace * @should pass validation if all required fields have proper values @@ -59,7 +59,7 @@ if (p == null) { errors.rejectValue("program", "error.general"); } else { - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", "error.name"); List programs = Context.getProgramWorkflowService().getAllPrograms(false); for (Program program : programs) { if (program.getName().equals(p.getName()) && !program.getProgramId().equals(p.getProgramId())) { Index: /src/api/org/openmrs/validator/LocationValidator.java =================================================================== --- /src/api/org/openmrs/validator/LocationValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/LocationValidator.java (working copy) @@ -48,8 +48,8 @@ * * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) - * @should fail validation if name is null or empty - * @should fail validation if description is null or empty + * @should fail validation if unlocalized name is null or empty + * @should fail validation if unlocalized description is null or empty * @should fail validation if retired and retireReason is null or empty * @should set retired to false if retireReason is null or empty * @should pass validation if all fields are correct @@ -60,8 +60,10 @@ if (location == null) { errors.rejectValue("location", "error.general"); } else { - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name"); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.description"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", + "LocalizedName.unlocalizedName.empty"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedDescription.unlocalizedValue", + "LocalizedDescription.unlocalizedDescription.empty"); if (location.isRetired()) { if (!StringUtils.hasLength(location.getRetireReason())) { Index: /src/api/org/openmrs/validator/PatientIdentifierTypeValidator.java =================================================================== --- /src/api/org/openmrs/validator/PatientIdentifierTypeValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/PatientIdentifierTypeValidator.java (working copy) @@ -47,8 +47,8 @@ * * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) - * @should fail validation if name is null or empty or whitespace - * @should fail validation if description is null or empty or whitespace + * @should fail validation if unlocalized name is null or empty or whitespace + * @should fail validation if unlocalized description is null or empty or whitespace * @should pass validation if all required fields have proper values */ public void validate(Object obj, Errors errors) { @@ -56,8 +56,10 @@ if (identifierType == null) { errors.rejectValue("identifierType", "error.general"); } else { - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name"); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.description"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", + "LocalizedName.unlocalizedName.empty"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedDescription.unlocalizedValue", + "LocalizedDescription.unlocalizedDescription.empty"); } } Index: /src/api/org/openmrs/validator/OrderTypeValidator.java =================================================================== --- /src/api/org/openmrs/validator/OrderTypeValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/OrderTypeValidator.java (working copy) @@ -47,7 +47,7 @@ * * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) - * @should fail validation if name is null or empty or whitespace + * @should fail validation if unlocalized name is null or empty or whitespace * @should fail validation if description is null or empty or whitespace * @should pass validation if all required fields have proper values */ @@ -56,8 +56,10 @@ if (orderType == null) { errors.rejectValue("orderType", "error.general"); } else { - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name"); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.description"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", + "LocalizedName.unlocalizedName.empty"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedDescription.unlocalizedValue", + "LocalizedDescription.unlocalizedDescription.empty"); } //log.debug("errors: " + errors.getAllErrors().toString()); } Index: /src/api/org/openmrs/validator/ConceptClassValidator.java =================================================================== --- /src/api/org/openmrs/validator/ConceptClassValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/ConceptClassValidator.java (working copy) @@ -47,7 +47,7 @@ * * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) - * @should fail validation if user is null or empty or whitespace + * @should fail validation if unlocalized name is null or empty or whitespace * @should fail validation if description is null or empty or whitespace * @should pass validation if all required fields have proper values */ @@ -56,8 +56,10 @@ if (cc == null) { errors.rejectValue("conceptClass", "error.general"); } else { - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name"); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.description"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", + "LocalizedName.unlocalizedName.empty"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedDescription.unlocalizedValue", + "LocalizedDescription.unlocalizedDescription.empty"); } } Index: /src/api/org/openmrs/validator/FieldTypeValidator.java =================================================================== --- /src/api/org/openmrs/validator/FieldTypeValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/FieldTypeValidator.java (working copy) @@ -47,7 +47,7 @@ * * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) - * @should fail validation if name is null or empty or whitespace + * @should fail validation if unlocalized name is null or empty or whitespace * @should pass validation if all required fields have proper values */ public void validate(Object obj, Errors errors) { @@ -55,7 +55,8 @@ if (fieldType == null) { errors.rejectValue("fieldType", "error.general"); } else { - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedName.unlocalizedValue", + "LocalizedName.unlocalizedName.empty"); } } Index: /src/api/org/openmrs/validator/PrivilegeValidator.java =================================================================== --- /src/api/org/openmrs/validator/PrivilegeValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/PrivilegeValidator.java (working copy) @@ -48,7 +48,7 @@ * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) * @should fail validation if privilege is null or empty or whitespace - * @should fail validation if description is null or empty or whitespace + * @should fail validation if unlocalized description is null or empty or whitespace * @should pass validation if all required fields have proper values */ public void validate(Object obj, Errors errors) { @@ -57,7 +57,8 @@ errors.rejectValue("privilege", "error.general"); } else { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "privilege", "error.privilege"); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.description"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedDescription.unlocalizedValue", + "LocalizedDescription.unlocalizedDescription.empty"); } } Index: /src/api/org/openmrs/validator/ConceptDatatypeValidator.java =================================================================== --- /src/api/org/openmrs/validator/ConceptDatatypeValidator.java (revision 14891) +++ /src/api/org/openmrs/validator/ConceptDatatypeValidator.java (working copy) @@ -48,7 +48,7 @@ * @see org.springframework.validation.Validator#validate(java.lang.Object, * org.springframework.validation.Errors) * @should fail validation if name is null or empty or whitespace - * @should fail validation if description is null or empty or whitespace + * @should fail validation if unlocalized description is null or empty or whitespace * @should pass validation if all required fields have proper values */ public void validate(Object obj, Errors errors) { @@ -57,7 +57,8 @@ errors.rejectValue("conceptDatatype", "error.general"); } else { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "error.name"); - ValidationUtils.rejectIfEmptyOrWhitespace(errors, "description", "error.description"); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "localizedDescription.unlocalizedValue", + "LocalizedDescription.unlocalizedDescription.empty"); } } Index: /src/api/org/openmrs/ConceptSource.java =================================================================== --- /src/api/org/openmrs/ConceptSource.java (revision 14891) +++ /src/api/org/openmrs/ConceptSource.java (working copy) @@ -24,7 +24,7 @@ * ICD9, ICD10, SNOMED, or any other OpenMRS implementation */ @Root -public class ConceptSource extends BaseOpenmrsMetadata implements Voidable, java.io.Serializable { +public class ConceptSource extends BaseLocalizedMetadata implements Voidable, java.io.Serializable { public static final long serialVersionUID = 375L; @@ -48,7 +48,8 @@ /** * @see java.lang.Object#equals(java.lang.Object) */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj instanceof ConceptSource) { if (conceptSourceId == null) return false; @@ -62,7 +63,8 @@ /** * @see java.lang.Object#hashCode() */ - public int hashCode() { + @Override + public int hashCode() { if (this.getConceptSourceId() == null) return super.hashCode(); return conceptSourceId.hashCode(); @@ -84,12 +86,14 @@ this.conceptSourceId = conceptSourceId; } - @Element + @Override + @Element public User getCreator() { return super.getCreator(); } - @Element + @Override + @Element public void setCreator(User creator) { super.setCreator(creator); } @@ -97,7 +101,8 @@ /** * @return Returns the dateCreated. */ - @Element + @Override + @Element public Date getDateCreated() { return super.getDateCreated(); } @@ -105,7 +110,8 @@ /** * @param dateCreated The dateCreated to set. */ - @Element + @Override + @Element public void setDateCreated(Date dateCreated) { super.setDateCreated(dateCreated); } @@ -128,12 +134,14 @@ setDateRetired(dateVoided); } - @Element(data = true) + @Override + @Element(data = true) public String getDescription() { return super.getDescription(); } - @Element(data = true) + @Override + @Element(data = true) public void setDescription(String description) { super.setDescription(description); } @@ -154,12 +162,14 @@ this.hl7Code = hl7Code; } - @Element(data = true) + @Override + @Element(data = true) public String getName() { return super.getName(); } - @Element(data = true) + @Override + @Element(data = true) public void setName(String name) { super.setName(name); } Index: /src/api/org/openmrs/OrderType.java =================================================================== --- /src/api/org/openmrs/OrderType.java (revision 14891) +++ /src/api/org/openmrs/OrderType.java (working copy) @@ -18,7 +18,7 @@ * * @see Order */ -public class OrderType extends BaseOpenmrsMetadata implements java.io.Serializable { +public class OrderType extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 23232L; @@ -52,7 +52,8 @@ /** * @see java.lang.Object#equals(java.lang.Object) */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj instanceof OrderType) { OrderType o = (OrderType) obj; if (o != null) @@ -64,7 +65,8 @@ /** * @see java.lang.Object#hashCode() */ - public int hashCode() { + @Override + public int hashCode() { if (this.getOrderTypeId() == null) return super.hashCode(); return this.getOrderTypeId().hashCode(); Index: /src/api/org/openmrs/Field.java =================================================================== --- /src/api/org/openmrs/Field.java (revision 14891) +++ /src/api/org/openmrs/Field.java (working copy) @@ -21,7 +21,7 @@ * * @version 1.0 */ -public class Field extends BaseOpenmrsMetadata implements java.io.Serializable { +public class Field extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 4454L; @@ -60,7 +60,8 @@ * @param obj * @return boolean true/false whether or not they are the same objects */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj == null || !(obj instanceof Field) || fieldId == null) return false; @@ -68,7 +69,8 @@ return (this.fieldId.equals(field.getFieldId())); } - public int hashCode() { + @Override + public int hashCode() { if (this.getFieldId() == null) return super.hashCode(); return this.getFieldId().hashCode(); Index: /src/api/org/openmrs/OpenmrsMetadata.java =================================================================== --- /src/api/org/openmrs/OpenmrsMetadata.java (revision 14891) +++ /src/api/org/openmrs/OpenmrsMetadata.java (working copy) @@ -44,4 +44,5 @@ * @param description the description to set */ public void setDescription(String description); + } Index: /src/api/org/openmrs/Location.java =================================================================== --- /src/api/org/openmrs/Location.java (revision 14891) +++ /src/api/org/openmrs/Location.java (working copy) @@ -27,9 +27,9 @@ * Locations support a single hierarchy, such that each location may have one parent location. * * A non-geographical grouping of locations, such as "All Community Health Centers" is not a location, and - * should be modeled using {@link LocationTag}s. + * should be modeled using {@link LocationTag}s. */ -public class Location extends BaseOpenmrsMetadata implements java.io.Serializable, Attributable { +public class Location extends BaseLocalizedMetadata implements java.io.Serializable, Attributable { public static final long serialVersionUID = 455634L; Index: /src/api/org/openmrs/ConceptClass.java =================================================================== --- /src/api/org/openmrs/ConceptClass.java (revision 14891) +++ /src/api/org/openmrs/ConceptClass.java (working copy) @@ -20,7 +20,7 @@ * ConceptClass */ @Root(strict = false) -public class ConceptClass extends BaseOpenmrsMetadata implements java.io.Serializable { +public class ConceptClass extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 33473L; @@ -39,7 +39,8 @@ this.conceptClassId = conceptClassId; } - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj instanceof ConceptClass) { ConceptClass c = (ConceptClass) obj; return (this.conceptClassId.equals(c.getConceptClassId())); @@ -47,7 +48,8 @@ return false; } - public int hashCode() { + @Override + public int hashCode() { if (this.getConceptClassId() == null) return super.hashCode(); return this.getConceptClassId().hashCode(); @@ -84,5 +86,4 @@ setConceptClassId(id); } - } Index: /src/api/org/openmrs/FieldType.java =================================================================== --- /src/api/org/openmrs/FieldType.java (revision 14891) +++ /src/api/org/openmrs/FieldType.java (working copy) @@ -16,7 +16,7 @@ /** * FieldType */ -public class FieldType extends BaseOpenmrsMetadata implements java.io.Serializable { +public class FieldType extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 35467L; @@ -43,7 +43,8 @@ * @param obj * @return boolean true/false whether or not they are the same objects */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj instanceof FieldType) { FieldType f = (FieldType) obj; return (fieldTypeId.equals(f.getFieldTypeId())); @@ -51,7 +52,8 @@ return false; } - public int hashCode() { + @Override + public int hashCode() { if (this.getFieldTypeId() == null) return super.hashCode(); return this.getFieldTypeId().hashCode(); @@ -104,5 +106,4 @@ setFieldTypeId(id); } - } Index: /src/api/org/openmrs/PersonAttributeType.java =================================================================== --- /src/api/org/openmrs/PersonAttributeType.java (revision 14891) +++ /src/api/org/openmrs/PersonAttributeType.java (working copy) @@ -21,7 +21,7 @@ * PersonAttributeType */ @Root(strict = false) -public class PersonAttributeType extends BaseOpenmrsMetadata implements java.io.Serializable { +public class PersonAttributeType extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 2112313431211L; @@ -49,7 +49,8 @@ /** * @see java.lang.Object#hashCode() */ - public int hashCode() { + @Override + public int hashCode() { if (this.getPersonAttributeTypeId() == null) return super.hashCode(); return 7 * this.getPersonAttributeTypeId().hashCode(); @@ -61,7 +62,8 @@ * @param obj * @return boolean true/false whether or not they are the same objects */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj instanceof PersonAttributeType) { PersonAttributeType p = (PersonAttributeType) obj; if (p != null) @@ -160,7 +162,8 @@ /** * @see java.lang.Object#toString() */ - public String toString() { + @Override + public String toString() { return getName(); } Index: /src/api/org/openmrs/util/MetadataComparator.java =================================================================== --- /src/api/org/openmrs/util/MetadataComparator.java (revision 14891) +++ /src/api/org/openmrs/util/MetadataComparator.java (working copy) @@ -16,20 +16,24 @@ import java.util.Comparator; import java.util.Locale; +import org.openmrs.LocalizedMetadata; import org.openmrs.OpenmrsMetadata; /** - * A comparator that sorts first based on non-retired, and second based on name. (Locale is - * currently not used, but will be when we add the ability to localize metadata.) + * A comparator that sorts first based on non-retired, and second based on name.
+ * Compare name within the specified locale(specified by constructor's passed argument 'locale'). + * * @since 1.7 */ public class MetadataComparator implements Comparator { + private Locale locale; + /** * @param locale */ public MetadataComparator(Locale locale) { - // locale is currently not used + this.locale = locale; } /** @@ -38,9 +42,30 @@ @Override public int compare(OpenmrsMetadata left, OpenmrsMetadata right) { int temp = OpenmrsUtil.compareWithNullAsLowest(left.isRetired(), right.isRetired()); - if (temp == 0) - temp = OpenmrsUtil.compareWithNullAsLowest(left.getName(), right.getName()); + if (temp == 0) { + if (left instanceof LocalizedMetadata && right instanceof LocalizedMetadata) { + Locale locale = getLocale(); + temp = OpenmrsUtil.compareWithNullAsLowest(((LocalizedMetadata) left).getLocalizedName().getValue(locale), + ((LocalizedMetadata) right).getLocalizedName().getValue(locale)); + } else { + temp = OpenmrsUtil.compareWithNullAsLowest(left.getName(), right.getName()); + } + } return temp; } + /** + * @return the locale + */ + public Locale getLocale() { + return locale; + } + + /** + * @param locale the locale to set + */ + public void setLocale(Locale locale) { + this.locale = locale; + } + } Index: /src/api/org/openmrs/RelationshipType.java =================================================================== --- /src/api/org/openmrs/RelationshipType.java (revision 14891) +++ /src/api/org/openmrs/RelationshipType.java (working copy) @@ -42,9 +42,9 @@ private Integer relationshipTypeId; - private String aIsToB; + private LocalizedString localizedAIsToB; - private String bIsToA; + private LocalizedString localizedBIsToA; private Integer weight = 0; @@ -68,7 +68,8 @@ * @return boolean true/false whether or not they are the same objects * @see java.lang.Object#equals(java.lang.Object) */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (relationshipTypeId != null && obj instanceof RelationshipType) { RelationshipType m = (RelationshipType) obj; return (relationshipTypeId.equals(m.getRelationshipTypeId())); @@ -79,7 +80,8 @@ /** * @see java.lang.Object#hashCode() */ - public int hashCode() { + @Override + public int hashCode() { if (this.getRelationshipTypeId() == null) return super.hashCode(); return this.getRelationshipTypeId().hashCode(); @@ -115,7 +117,39 @@ this.weight = weight; } + /** + * @return the localizedAIsToB + */ + public LocalizedString getLocalizedAIsToB() { + if (localizedAIsToB == null) + localizedAIsToB = new LocalizedString(); + return localizedAIsToB; + } + /** + * @param localizedAIsToB the localizedAIsToB to set + */ + public void setLocalizedAIsToB(LocalizedString localizedAIsToB) { + this.localizedAIsToB = localizedAIsToB; + } + + /** + * @return the localizedBIsToA + */ + public LocalizedString getLocalizedBIsToA() { + if (localizedBIsToA == null) + localizedBIsToA = new LocalizedString(); + return localizedBIsToA; + } + + /** + * @param localizedBIsToA the localizedBIsToA to set + */ + public void setLocalizedBIsToA(LocalizedString localizedBIsToA) { + this.localizedBIsToA = localizedBIsToA; + } + + /** * The java bean specifications says that if an attribute has the second letter capitalized (as * the "I" is), the initial "a" is not to be capitalized. Both Spring and Hibernate use this * "getter" definition @@ -123,28 +157,36 @@ * @return the aIsToB */ public String getaIsToB() { - return aIsToB; + return getLocalizedAIsToB().getValue(); } /** * @param aisToB the aIsToB to set */ public void setaIsToB(String aisToB) { - aIsToB = aisToB; + getLocalizedAIsToB().setUnlocalizedValue(aisToB); } /** * @return the bIsToA */ public String getbIsToA() { - return bIsToA; + return getLocalizedBIsToA().getValue(); } /** + * @param bisToA the bIsToA to set + */ + public void setbIsToA(String bisToA) { + getLocalizedBIsToA().setUnlocalizedValue(bisToA); + } + + /** * @deprecated use isPreferred(). This method is kept around for Spring/Hibernate's use * @return the preferred status */ - @SuppressWarnings("unused") + @Deprecated + @SuppressWarnings("unused") private Boolean getPreferred() { return isPreferred(); } @@ -169,17 +211,13 @@ this.preferred = preferred; } - /** - * @param bisToA the bIsToA to set - */ - public void setbIsToA(String bisToA) { - bIsToA = bisToA; - } + /** * @see java.lang.Object#toString() */ - public String toString() { + @Override + public String toString() { return getaIsToB() + "/" + getbIsToA(); } @@ -200,4 +238,19 @@ } + /** + * @see org.openmrs.BaseOpenmrsMetadata#getName() + */ + @Override + public String getName() { + return getaIsToB() + "-" + getbIsToA(); + } + + /** + * @see org.openmrs.BaseOpenmrsMetadata#setName(java.lang.String) + */ + @Override + public void setName(String name) { + throw new UnsupportedOperationException(); + } } Index: /src/api/org/openmrs/LocationTag.java =================================================================== --- /src/api/org/openmrs/LocationTag.java (revision 14891) +++ /src/api/org/openmrs/LocationTag.java (working copy) @@ -19,7 +19,7 @@ * @see Location * @since 1.5 */ -public class LocationTag extends BaseOpenmrsMetadata implements java.io.Serializable { +public class LocationTag extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 7654L; @@ -54,7 +54,8 @@ * @param obj The LocationTag object to be compared. * @return Returns true if the objects share the same locationTagId, false otherwise. */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj == null || !(obj instanceof LocationTag)) return false; @@ -68,7 +69,8 @@ /** * @see java.lang.Object#hashCode() */ - public int hashCode() { + @Override + public int hashCode() { if (this.getLocationTagId() == null) return super.hashCode(); return this.getLocationTagId().hashCode(); @@ -108,7 +110,8 @@ setName(tag); } - public String toString() { + @Override + public String toString() { return getName(); } Index: /src/api/org/openmrs/Form.java =================================================================== --- /src/api/org/openmrs/Form.java (revision 14891) +++ /src/api/org/openmrs/Form.java (working copy) @@ -23,7 +23,7 @@ * * @version 1.0 */ -public class Form extends BaseOpenmrsMetadata implements java.io.Serializable { +public class Form extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 845634L; @@ -70,7 +70,8 @@ * @should have equal form objects with no formId * @should not have equal form objects when one has null formId */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj instanceof Form) { Form f = (Form) obj; if (this.getFormId() != null && f.getFormId() != null) @@ -85,7 +86,8 @@ * @see java.lang.Object#hashCode() * @should get hashCode even with null attributes */ - public int hashCode() { + @Override + public int hashCode() { if (this.getFormId() == null) return super.hashCode(); return this.getFormId().hashCode(); @@ -265,7 +267,8 @@ } } - public String toString() { + @Override + public String toString() { if (formId == null) return ""; return formId.toString(); @@ -292,7 +295,8 @@ /** * @deprecated use {@link #setRetireReason(String)} */ - public void setRetiredReason(String reason) { + @Deprecated + public void setRetiredReason(String reason) { setRetireReason(reason); } @@ -300,7 +304,8 @@ /** * @deprecated use {@link #getRetireReason()} */ - public String getRetiredReason() { + @Deprecated + public String getRetiredReason() { return getRetireReason(); } Index: /src/api/org/openmrs/Program.java =================================================================== --- /src/api/org/openmrs/Program.java (revision 14891) +++ /src/api/org/openmrs/Program.java (working copy) @@ -24,7 +24,7 @@ * Program */ @Root -public class Program extends BaseOpenmrsMetadata implements java.io.Serializable { +public class Program extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 3214567L; @@ -104,7 +104,8 @@ } /** @see Object#equals(Object) */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj != null && obj instanceof Program) { Program p = (Program) obj; if (this.getProgramId() != null) { @@ -115,7 +116,8 @@ } /** @see Object#toString() */ - public String toString() { + @Override + public String toString() { return "Program(id=" + getProgramId() + ", concept=" + getConcept() + ", workflows=" + getWorkflows() + ")"; } Index: /src/api/org/openmrs/PatientIdentifierType.java =================================================================== --- /src/api/org/openmrs/PatientIdentifierType.java (revision 14891) +++ /src/api/org/openmrs/PatientIdentifierType.java (working copy) @@ -16,7 +16,7 @@ /** * PatientIdentifierType */ -public class PatientIdentifierType extends BaseOpenmrsMetadata implements java.io.Serializable { +public class PatientIdentifierType extends BaseLocalizedMetadata implements java.io.Serializable { public static final long serialVersionUID = 211231L; @@ -43,7 +43,8 @@ this.patientIdentifierTypeId = patientIdentifierTypeId; } - public int hashCode() { + @Override + public int hashCode() { if (this.getPatientIdentifierTypeId() == null) return super.hashCode(); return this.getPatientIdentifierTypeId().hashCode(); @@ -55,7 +56,8 @@ * @param obj * @return boolean true/false whether or not they are the same objects */ - public boolean equals(Object obj) { + @Override + public boolean equals(Object obj) { if (obj instanceof PatientIdentifierType) { PatientIdentifierType p = (PatientIdentifierType) obj; if (getPatientIdentifierTypeId() != null && p != null) @@ -127,7 +129,8 @@ * @deprecated No need to know if it has a check digit now that any validator algorithm can be * chosen. */ - public Boolean getCheckDigit() { + @Deprecated + public Boolean getCheckDigit() { return hasCheckDigit(); } @@ -136,7 +139,8 @@ * @deprecated No need to know if it has a check digit now that any validator algorithm can be * chosen. */ - public Boolean hasCheckDigit() { + @Deprecated + public Boolean hasCheckDigit() { return checkDigit; } @@ -144,7 +148,8 @@ * @param checkDigit The checkdigit to set. * @deprecated No need for this field now that any validator algorithm can be chosen. */ - public void setCheckDigit(Boolean checkDigit) { + @Deprecated + public void setCheckDigit(Boolean checkDigit) { this.checkDigit = checkDigit; } @@ -169,7 +174,8 @@ * * @see java.lang.Object#toString() */ - public String toString() { + @Override + public String toString() { return getName(); } Index: /src/api/org/openmrs/BaseOpenmrsMetadata.java =================================================================== --- /src/api/org/openmrs/BaseOpenmrsMetadata.java (revision 14891) +++ /src/api/org/openmrs/BaseOpenmrsMetadata.java (working copy) @@ -30,7 +30,7 @@ private String name; - private String description; + private LocalizedString localizedDescription; private User creator; @@ -73,17 +73,33 @@ } /** + * @see org.openmrs.LocalizedMetadata#getLocalizedDescription() + */ + public LocalizedString getLocalizedDescription() { + if (localizedDescription == null) + localizedDescription = new LocalizedString(); + return localizedDescription; + } + + /** + * @see org.openmrs.LocalizedMetadata#setLocalizedDescription(org.openmrs.LocalizedString) + */ + public void setLocalizedDescription(LocalizedString localizedDescription) { + this.localizedDescription = localizedDescription; + } + + /** * @return the description */ public String getDescription() { - return description; + return getLocalizedDescription().getValue(); } /** * @param description the description to set */ public void setDescription(String description) { - this.description = description; + getLocalizedDescription().setUnlocalizedValue(description); } /** Index: /src/api/org/openmrs/api/db/hibernate/HibernateUtil.java =================================================================== --- /src/api/org/openmrs/api/db/hibernate/HibernateUtil.java (revision 14891) +++ /src/api/org/openmrs/api/db/hibernate/HibernateUtil.java (working copy) @@ -19,10 +19,16 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.hibernate.Criteria; import org.hibernate.SessionFactory; +import org.hibernate.criterion.Criterion; +import org.hibernate.criterion.Expression; +import org.hibernate.criterion.MatchMode; import org.hibernate.dialect.Dialect; import org.hibernate.dialect.HSQLDialect; import org.hibernate.engine.SessionFactoryImplementor; +import org.openmrs.OpenmrsMetadata; +import org.openmrs.util.LocalizedStringUtil; /** * This class holds common methods and utilities that are used across the hibernate related classes @@ -108,4 +114,114 @@ return oldString; } + /** + * Add equal criterion for the localized column of {@link OpenmrsMetadata} object. + * + * @param value - value to match + * @param propertyName - column to match in + * @param criteria - criteria to append search conditions + * @see #getEqCriterionForLocalizedColumn(String, String) + * @since 1.9 + */ + public static void addEqCriterionForLocalizedColumn(String value, String propertyName, Criteria criteria) { + criteria.add(getEqCriterionForLocalizedColumn(value, propertyName)); + } + + /** + * Add like criterion for the localized column of {@link OpenmrsMetadata} object. + * + * @param value - value to match + * @param propertyName - column to match in + * @param criteria - criteria to append search conditions + * @param caseSensitive - if caseSensitive is false, do sql query similar to hibernate's "ilike" + * @param mode - specify match mode, match from start, end, anywhere, or exact + * @see #getLikeCriterionForLocalizedColumn(String, String, boolean, MatchMode) + * @since 1.9 + */ + public static void addLikeCriterionForLocalizedColumn(String value, String propertyName, Criteria criteria, + boolean caseSensitive, MatchMode mode) { + criteria.add(getLikeCriterionForLocalizedColumn(value, propertyName, caseSensitive, mode)); + } + + /** + * Get equal criterion for the localized column of {@link OpenmrsMetadata} object. + * + * @param value - value to match + * @param propertyName - column to match in + * @return criterion to be used as hibernate's equal query + * @since 1.9 + * @should return correct criterion when has unlocalized value only + * @should return correct criterion when has localized values only + * @should return correct criterion when has unlocalized and localized values + */ + public static Criterion getEqCriterionForLocalizedColumn(String value, String propertyName) { + Criterion leftExp = Expression.eq(propertyName, value); + String searchValue = LocalizedStringUtil.PARTITION + LocalizedStringUtil.escapeDelimiter(value) + + LocalizedStringUtil.SPLITTER; + Criterion rightExp = Expression.like(propertyName, searchValue, MatchMode.ANYWHERE); + return Expression.or(leftExp, rightExp); + } + + /** + * Get like criterion for the localized column of {@link OpenmrsMetadata} object. + * + * @param value - value to match + * @param propertyName - column to match in + * @param caseSensitive - if caseSensitive is false, return sql query similar to hibernate's + * "ilike" + * @param mode - specify match mode, match from start, end, anywhere, or exact + * @return criterion to be used as hibernate's like or ilike query + * @since 1.9 + * @should return correct criterion when has unlocalized value only + * @should return correct criterion when has localized values only + * @should return correct criterion when has unlocalized and localized values + */ + public static Criterion getLikeCriterionForLocalizedColumn(String value, String propertyName, boolean caseSensitive, + MatchMode mode) { + Criterion leftExp = null; + Criterion rigthExp = null; + String searchValue = null; + + if (MatchMode.START.equals(mode)) { + searchValue = LocalizedStringUtil.PARTITION + LocalizedStringUtil.escapeDelimiter(value); + if (caseSensitive == true) { + // append expression for unlocalized metadata + leftExp = Expression.like(propertyName, value, mode); + // append expression for localized metadata + rigthExp = Expression.like(propertyName, searchValue, MatchMode.ANYWHERE); + } else { + leftExp = Expression.ilike(propertyName, value, mode); + rigthExp = Expression.ilike(propertyName, searchValue, MatchMode.ANYWHERE); + } + return Expression.or(leftExp, rigthExp); + } else if (MatchMode.END.equals(mode)) { + searchValue = LocalizedStringUtil.escapeDelimiter(value) + LocalizedStringUtil.SPLITTER; + if (caseSensitive == true) { + leftExp = Expression.like(propertyName, value, mode); + rigthExp = Expression.like(propertyName, searchValue, MatchMode.ANYWHERE); + } else { + leftExp = Expression.ilike(propertyName, value, mode); + rigthExp = Expression.ilike(propertyName, searchValue, MatchMode.ANYWHERE); + } + return Expression.or(leftExp, rigthExp); + } else if (MatchMode.ANYWHERE.equals(mode)) { + if (caseSensitive == true)// use one expression + leftExp = Expression.like(propertyName, value, mode); + else + leftExp = Expression.ilike(propertyName, value, mode); + return leftExp; + } else {/*MatchMode.EXACT.equals(mode)*/ + searchValue = LocalizedStringUtil.PARTITION + LocalizedStringUtil.escapeDelimiter(value) + + LocalizedStringUtil.SPLITTER; + if (caseSensitive == true) { + leftExp = Expression.like(propertyName, value, mode); + rigthExp = Expression.like(propertyName, searchValue, MatchMode.ANYWHERE); + + } else { + leftExp = Expression.ilike(propertyName, value, mode); + rigthExp = Expression.ilike(propertyName, searchValue, MatchMode.ANYWHERE); + } + return Expression.or(leftExp, rigthExp); + } + } } Index: /src/api/org/openmrs/api/db/hibernate/HibernateConceptDAO.java =================================================================== --- /src/api/org/openmrs/api/db/hibernate/HibernateConceptDAO.java (revision 14891) +++ /src/api/org/openmrs/api/db/hibernate/HibernateConceptDAO.java (working copy) @@ -377,7 +377,7 @@ else sql += " asc"; Query query = sessionFactory.getCurrentSession().createQuery(sql); - return (List) query.list(); + return query.list(); } /** @@ -406,8 +406,8 @@ if (concept != null) searchCriteria.add(Expression.eq("drug.concept", concept)); if (drugName != null) - searchCriteria.add(Expression.eq("drug.name", drugName)); - return (List) searchCriteria.list(); + HibernateUtil.addEqCriterionForLocalizedColumn(drugName, "localizedName", searchCriteria); + return searchCriteria.list(); } /** @@ -425,11 +425,12 @@ searchCriteria.add(Expression.eq("drug.retired", false)); Iterator word = words.iterator(); - searchCriteria.add(Expression.like("name", word.next(), MatchMode.ANYWHERE)); + HibernateUtil.addLikeCriterionForLocalizedColumn(word.next(), "localizedName", searchCriteria, true, + MatchMode.ANYWHERE); while (word.hasNext()) { String w = word.next(); log.debug(w); - searchCriteria.add(Expression.like("name", w, MatchMode.ANYWHERE)); + HibernateUtil.addLikeCriterionForLocalizedColumn(w, "name", searchCriteria, true, MatchMode.ANYWHERE); } searchCriteria.addOrder(Order.asc("drug.concept")); conceptDrugs = searchCriteria.list(); @@ -452,7 +453,7 @@ public List getConceptClasses(String name) throws DAOException { Criteria crit = sessionFactory.getCurrentSession().createCriteria(ConceptClass.class); if (name != null) - crit.add(Expression.eq("name", name)); + HibernateUtil.addEqCriterionForLocalizedColumn(name, "localizedName", crit); return crit.list(); } @@ -1220,7 +1221,8 @@ // join to conceptSource and match to the hl7Code or name criteria.createAlias("source", "conceptSource"); - criteria.add(Expression.or(Expression.eq("conceptSource.name", mappingCode), Expression.eq("conceptSource.hl7Code", + criteria.add(Expression.or(Expression.eq("conceptSource.localizedName", mappingCode), Expression.eq( + "conceptSource.hl7Code", mappingCode))); return (Concept) criteria.uniqueResult(); @@ -1358,8 +1360,12 @@ */ public ConceptSource getConceptSourceByName(String conceptSourceName) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(ConceptSource.class, "source"); - criteria.add(Expression.eq("source.name", conceptSourceName)); - return (ConceptSource) criteria.uniqueResult(); + HibernateUtil.addEqCriterionForLocalizedColumn(conceptSourceName, "localizedName", criteria); + List cSources = criteria.list(); + if (null == cSources || cSources.isEmpty()) { + return null; + } + return cSources.get(0); } /** Index: /src/api/org/openmrs/api/db/hibernate/HibernateEncounterDAO.java =================================================================== --- /src/api/org/openmrs/api/db/hibernate/HibernateEncounterDAO.java (revision 14891) +++ /src/api/org/openmrs/api/db/hibernate/HibernateEncounterDAO.java (working copy) @@ -15,6 +15,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -35,8 +36,10 @@ import org.openmrs.PatientIdentifierType; import org.openmrs.User; import org.openmrs.api.EncounterService; +import org.openmrs.api.context.Context; import org.openmrs.api.db.DAOException; import org.openmrs.api.db.EncounterDAO; +import org.openmrs.util.MetadataComparator; /** * Hibernate specific dao for the {@link EncounterService} All calls should be made on the @@ -160,13 +163,16 @@ /** * @see org.openmrs.api.EncounterService#getEncounterType(java.lang.String) */ + @SuppressWarnings("unchecked") public EncounterType getEncounterType(String name) throws DAOException { Criteria crit = sessionFactory.getCurrentSession().createCriteria(EncounterType.class); crit.add(Expression.eq("retired", false)); - crit.add(Expression.eq("name", name)); - EncounterType encounterType = (EncounterType) crit.uniqueResult(); - - return encounterType; + HibernateUtil.addEqCriterionForLocalizedColumn(name, "localizedName", crit); + List types = crit.list(); + if (null == types || types.isEmpty()) { + return null; + } + return types.get(0); } /** @@ -174,15 +180,15 @@ */ @SuppressWarnings("unchecked") public List getAllEncounterTypes(Boolean includeRetired) throws DAOException { - Criteria criteria = sessionFactory.getCurrentSession().createCriteria(EncounterType.class); - - criteria.addOrder(Order.asc("name")); - if (includeRetired == false) criteria.add(Expression.eq("retired", false)); + List results = criteria.list(); - return criteria.list(); + // do java sorting on the return value of "getName()", + // because maybe both unlocalized and localized object are in returned list + Collections.sort(results, new MetadataComparator(Context.getLocale())); + return results; } /** @@ -190,10 +196,12 @@ */ @SuppressWarnings("unchecked") public List findEncounterTypes(String name) throws DAOException { - return sessionFactory.getCurrentSession().createCriteria(EncounterType.class) - // 'ilike' case insensitive search - .add(Expression.ilike("name", name, MatchMode.START)).addOrder(Order.asc("name")).addOrder( - Order.asc("retired")).list(); + List results = null; + Criteria crit = sessionFactory.getCurrentSession().createCriteria(EncounterType.class); + HibernateUtil.addLikeCriterionForLocalizedColumn(name, "localizedName", crit, false, MatchMode.START); + results = crit.list(); + Collections.sort(results, new MetadataComparator(Context.getLocale())); + return results; } /** Index: /src/api/org/openmrs/api/db/hibernate/HibernateProgramWorkflowDAO.java =================================================================== --- /src/api/org/openmrs/api/db/hibernate/HibernateProgramWorkflowDAO.java (revision 14891) +++ /src/api/org/openmrs/api/db/hibernate/HibernateProgramWorkflowDAO.java (working copy) @@ -14,6 +14,7 @@ package org.openmrs.api.db.hibernate; import java.util.Collection; +import java.util.Collections; import java.util.Date; import java.util.List; @@ -24,7 +25,6 @@ import org.hibernate.SessionFactory; import org.hibernate.criterion.Expression; import org.hibernate.criterion.MatchMode; -import org.hibernate.criterion.Order; import org.openmrs.Cohort; import org.openmrs.Concept; import org.openmrs.ConceptStateConversion; @@ -34,8 +34,10 @@ import org.openmrs.Program; import org.openmrs.ProgramWorkflow; import org.openmrs.ProgramWorkflowState; +import org.openmrs.api.context.Context; import org.openmrs.api.db.DAOException; import org.openmrs.api.db.ProgramWorkflowDAO; +import org.openmrs.util.MetadataComparator; /** * Hibernate specific ProgramWorkflow related functions.
@@ -101,9 +103,10 @@ @SuppressWarnings("unchecked") public List findPrograms(String nameFragment) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Program.class, "program"); - criteria.add(Expression.ilike("name", nameFragment, MatchMode.ANYWHERE)); - criteria.addOrder(Order.asc("name")); - return criteria.list(); + HibernateUtil.addLikeCriterionForLocalizedColumn(nameFragment, "localizedName", criteria, false, MatchMode.ANYWHERE); + List programs = (List) criteria.list(); + Collections.sort(programs, new MetadataComparator(Context.getLocale())); + return programs; } /** Index: /src/api/org/openmrs/api/db/hibernate/HibernateFormDAO.java =================================================================== --- /src/api/org/openmrs/api/db/hibernate/HibernateFormDAO.java (revision 14891) +++ /src/api/org/openmrs/api/db/hibernate/HibernateFormDAO.java (working copy) @@ -14,6 +14,7 @@ package org.openmrs.api.db.hibernate; import java.util.Collection; +import java.util.Collections; import java.util.List; import org.apache.commons.logging.Log; @@ -21,12 +22,12 @@ import org.hibernate.Criteria; import org.hibernate.Query; import org.hibernate.SessionFactory; +import org.hibernate.criterion.Criterion; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Expression; import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.Order; import org.hibernate.criterion.Projections; -import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Subqueries; import org.openmrs.Concept; import org.openmrs.EncounterType; @@ -36,8 +37,10 @@ import org.openmrs.Form; import org.openmrs.FormField; import org.openmrs.api.APIException; +import org.openmrs.api.context.Context; import org.openmrs.api.db.DAOException; import org.openmrs.api.db.FormDAO; +import org.openmrs.util.MetadataComparator; /** * Hibernate specific Form related functions This class should not be used directly. All calls @@ -110,9 +113,10 @@ @SuppressWarnings("unchecked") public List getFields(String search) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Field.class); - criteria.add(Restrictions.like("name", search, MatchMode.ANYWHERE)); - criteria.addOrder(Order.asc("name")); - return criteria.list(); + HibernateUtil.addLikeCriterionForLocalizedColumn(search, "localizedName", criteria, true, MatchMode.ANYWHERE); + List fields = criteria.list(); + Collections.sort(fields, new MetadataComparator(Context.getLocale())); + return fields; } /** @@ -122,8 +126,9 @@ public List getFieldsByConcept(Concept concept) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Field.class); criteria.add(Expression.eq("concept", concept)); - criteria.addOrder(Order.asc("name")); - return criteria.list(); + List fields = criteria.list(); + Collections.sort(fields, new MetadataComparator(Context.getLocale())); + return fields; } /** @@ -235,10 +240,11 @@ if (includeRetired == false) crit.add(Expression.eq("retired", false)); - crit.addOrder(Order.asc("name")); - crit.addOrder(Order.asc("formId")); - - return crit.list(); + List
forms = crit.list(); + // do java sorting on the return value of "getName()", + // because maybe both unlocalized and localized object are in returned list + Collections.sort(forms, new MetadataComparator(Context.getLocale())); + return forms; } /** @@ -341,13 +347,18 @@ /** * @see org.openmrs.api.db.FormDAO#getForm(java.lang.String, java.lang.String) */ + @SuppressWarnings("unchecked") public Form getForm(String name, String version) throws DAOException { Criteria crit = sessionFactory.getCurrentSession().createCriteria(Form.class); - crit.add(Expression.eq("name", name)); + HibernateUtil.addEqCriterionForLocalizedColumn(name, "localizedName", crit); crit.add(Expression.eq("version", version)); - return (Form) crit.uniqueResult(); + List forms = crit.list(); + if (null == forms || forms.isEmpty()) { + return null; + } + return forms.get(0); } /** @@ -363,8 +374,11 @@ Criteria crit = sessionFactory.getCurrentSession().createCriteria(Form.class, "form"); if (partialName != null && !"".equals(partialName)) { - crit.add(Expression.or(Expression.like("name", partialName, MatchMode.START), Expression.like("name", " " - + partialName, MatchMode.ANYWHERE))); + Criterion lhs = HibernateUtil.getLikeCriterionForLocalizedColumn(partialName, "localizedName", true, + MatchMode.START); + Criterion rhs = HibernateUtil.getLikeCriterionForLocalizedColumn(" " + partialName, "localizedName", true, + MatchMode.ANYWHERE); + crit.add(Expression.or(lhs, rhs)); } if (published != null) crit.add(Expression.eq("published", published)); @@ -380,7 +394,7 @@ crit.add(Expression.in("formField", containingAnyFormField)); // TODO junit test - //select * from form where len(containingallformfields) = (select count(*) from form_field ff where ff.form_id = form_id and form_field_id in (containingallformfields); + //select * from form where len(containingallformfields) = (select count(*) from form_field ff where ff.form_id = form_id and form_field_id in (containingallformfields); if (!containingAllFormFields.isEmpty()) { DetachedCriteria detachedCrit = DetachedCriteria.forClass(FormField.class, "ff"); detachedCrit.setProjection(Projections.count("formFieldId")); @@ -443,7 +457,7 @@ public List getFormsByName(String name) throws DAOException { Criteria crit = sessionFactory.getCurrentSession().createCriteria(Form.class); - crit.add(Expression.eq("name", name)); + HibernateUtil.addEqCriterionForLocalizedColumn(name, "localizedName", crit); crit.add(Expression.eq("retired", false)); crit.addOrder(Order.desc("version")); Index: /src/api/org/openmrs/api/db/hibernate/HibernatePatientDAO.java =================================================================== --- /src/api/org/openmrs/api/db/hibernate/HibernatePatientDAO.java (revision 14891) +++ /src/api/org/openmrs/api/db/hibernate/HibernatePatientDAO.java (working copy) @@ -17,6 +17,7 @@ import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -28,15 +29,16 @@ import org.hibernate.Query; import org.hibernate.SessionFactory; import org.hibernate.criterion.Expression; -import org.hibernate.criterion.Order; import org.openmrs.Location; import org.openmrs.Patient; import org.openmrs.PatientIdentifier; import org.openmrs.PatientIdentifierType; import org.openmrs.Person; import org.openmrs.PersonName; +import org.openmrs.api.context.Context; import org.openmrs.api.db.DAOException; import org.openmrs.api.db.PatientDAO; +import org.openmrs.util.MetadataComparator; /** * Hibernate specific database methods for the PatientService @@ -281,12 +283,15 @@ // TODO test this method Criteria criteria = sessionFactory.getCurrentSession().createCriteria(PatientIdentifierType.class); - criteria.addOrder(Order.asc("name")); if (includeRetired == false) criteria.add(Expression.eq("retired", false)); - return criteria.list(); + List pits = criteria.list(); + // do java sorting on the return value of "getName()", + // because maybe both unlocalized and localized object are in returned list + Collections.sort(pits, new MetadataComparator(Context.getLocale())); + return pits; } /** @@ -299,10 +304,9 @@ // TODO test this method Criteria criteria = sessionFactory.getCurrentSession().createCriteria(PatientIdentifierType.class); - criteria.addOrder(Order.asc("name")); if (name != null) - criteria.add(Expression.eq("name", name)); + HibernateUtil.addEqCriterionForLocalizedColumn(name, "localizedName", criteria); if (format != null) criteria.add(Expression.eq("format", format)); @@ -315,7 +319,11 @@ criteria.add(Expression.eq("retired", false)); - return criteria.list(); + List pits = criteria.list(); + // do java sorting on the return value of "getName()", + // because maybe both unlocalized and localized object are in returned list + Collections.sort(pits, new MetadataComparator(Context.getLocale())); + return pits; } /** Index: /src/api/org/openmrs/api/db/hibernate/HibernatePersonDAO.java =================================================================== --- /src/api/org/openmrs/api/db/hibernate/HibernatePersonDAO.java (revision 14891) +++ /src/api/org/openmrs/api/db/hibernate/HibernatePersonDAO.java (working copy) @@ -13,6 +13,7 @@ */ package org.openmrs.api.db.hibernate; +import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -23,11 +24,11 @@ import org.hibernate.Query; import org.hibernate.SQLQuery; import org.hibernate.SessionFactory; +import org.hibernate.criterion.Criterion; import org.hibernate.criterion.Expression; import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.Order; -import org.hibernate.criterion.Restrictions; -import org.hibernate.type.StringType; +import org.openmrs.LocalizedString; import org.openmrs.Person; import org.openmrs.PersonAddress; import org.openmrs.PersonAttribute; @@ -171,8 +172,8 @@ } else { // This is simply an alternative method of name matching which scales better - // for large names, although it is hard to imagine getting names with more than - // six or so tokens. This can be easily updated to attain more desirable + // for large names, although it is hard to imagine getting names with more than + // six or so tokens. This can be easily updated to attain more desirable // results; it is just a working alternative to throwing an exception. q += "("; @@ -361,7 +362,7 @@ Criteria criteria = sessionFactory.getCurrentSession().createCriteria(PersonAttributeType.class, "r"); if (exactName != null) - criteria.add(Expression.eq("name", exactName)); + HibernateUtil.addEqCriterionForLocalizedColumn(exactName, "localizedName", criteria); if (format != null) criteria.add(Expression.eq("format", format)); @@ -443,13 +444,25 @@ public List getRelationshipTypes(String relationshipTypeName, Boolean preferred) throws DAOException { Criteria criteria = sessionFactory.getCurrentSession().createCriteria(RelationshipType.class); - criteria.add(Restrictions.sqlRestriction("CONCAT(a_Is_To_B, CONCAT('/', b_Is_To_A)) like (?)", relationshipTypeName, - new StringType())); - - if (preferred != null) - criteria.add(Expression.eq("preferred", preferred)); - - return criteria.list(); + // criteria.add(Restrictions.sqlRestriction("CONCAT(a_Is_To_B, CONCAT('/', b_Is_To_A)) like (?)", relationshipTypeName, + // new StringType())); + String[] arr = relationshipTypeName.split("/"); + if (arr.length != 2) { + return new ArrayList();//return a empty list + } else { + String aIsToB = arr[0]; + String bIsToA = arr[1]; + Criterion aIsToBCrit = HibernateUtil.getLikeCriterionForLocalizedColumn(aIsToB, "localizedAIsToB", true, + MatchMode.ANYWHERE); + Criterion bIsToACrit = HibernateUtil.getLikeCriterionForLocalizedColumn(bIsToA, "localizedBIsToA", true, + MatchMode.ANYWHERE); + criteria.add(Expression.and(aIsToBCrit, bIsToACrit)); + + if (preferred != null) + criteria.add(Expression.eq("preferred", preferred)); + + return criteria.list(); + } } /** @@ -559,7 +572,9 @@ SQLQuery sql = sessionFactory.getCurrentSession().createSQLQuery( "select name from person_attribute_type where person_attribute_type_id = :personAttributeTypeId"); sql.setInteger("personAttributeTypeId", personAttributeType.getId()); - return (String) sql.uniqueResult(); + String serializedName = (String) sql.uniqueResult(); + LocalizedString ls = LocalizedString.valueOf(serializedName); + return ls == null ? null : ls.getValue(); } /** Index: /src/api/org/openmrs/api/db/hibernate/HibernateLocationDAO.java =================================================================== --- /src/api/org/openmrs/api/db/hibernate/HibernateLocationDAO.java (revision 14891) +++ /src/api/org/openmrs/api/db/hibernate/HibernateLocationDAO.java (working copy) @@ -13,16 +13,18 @@ */ package org.openmrs.api.db.hibernate; +import java.util.Collections; import java.util.List; import org.hibernate.Criteria; import org.hibernate.SessionFactory; import org.hibernate.criterion.Expression; import org.hibernate.criterion.MatchMode; -import org.hibernate.criterion.Order; import org.openmrs.Location; import org.openmrs.LocationTag; +import org.openmrs.api.context.Context; import org.openmrs.api.db.LocationDAO; +import org.openmrs.util.MetadataComparator; /** * Hibernate location-related database functions @@ -44,7 +46,7 @@ public Location saveLocation(Location location) { if (location.getChildLocations() != null && location.getLocationId() != null) { // hibernate has a problem updating child collections - // if the parent object was already saved so we do it + // if the parent object was already saved so we do it // explicitly here for (Location child : location.getChildLocations()) if (child.getLocationId() == null) @@ -67,8 +69,8 @@ */ @SuppressWarnings("unchecked") public Location getLocation(String name) { - Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Location.class).add( - Expression.eq("name", name)); + Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Location.class); + HibernateUtil.addEqCriterionForLocalizedColumn(name, "localizedName", criteria); List locations = criteria.list(); if (null == locations || locations.isEmpty()) { @@ -86,8 +88,9 @@ if (!includeRetired) { criteria.add(Expression.like("retired", false)); } - criteria.addOrder(Order.asc("name")); - return criteria.list(); + List locations = criteria.list(); + Collections.sort(locations, new MetadataComparator(Context.getLocale())); + return locations; } /** @@ -98,9 +101,11 @@ if (search == null || search.equals("")) return getAllLocations(true); - return sessionFactory.getCurrentSession().createCriteria(Location.class) - // 'ilike' case insensitive search - .add(Expression.ilike("name", search, MatchMode.START)).addOrder(Order.asc("name")).list(); + Criteria crit = sessionFactory.getCurrentSession().createCriteria(Location.class); + HibernateUtil.addLikeCriterionForLocalizedColumn(search, "localizedName", crit, false, MatchMode.START); + List locations = crit.list(); + Collections.sort(locations, new MetadataComparator(Context.getLocale())); + return locations; } /** @@ -130,8 +135,8 @@ */ @SuppressWarnings("unchecked") public LocationTag getLocationTagByName(String tag) { - Criteria criteria = sessionFactory.getCurrentSession().createCriteria(LocationTag.class).add( - Expression.eq("name", tag)); + Criteria criteria = sessionFactory.getCurrentSession().createCriteria(LocationTag.class); + HibernateUtil.addEqCriterionForLocalizedColumn(tag, "localizedName", criteria); List tags = criteria.list(); if (null == tags || tags.isEmpty()) { @@ -149,8 +154,9 @@ if (!includeRetired) { criteria.add(Expression.like("retired", false)); } - criteria.addOrder(Order.asc("name")); - return criteria.list(); + List tags = criteria.list(); + Collections.sort(tags, new MetadataComparator(Context.getLocale())); + return tags; } /** @@ -158,9 +164,11 @@ */ @SuppressWarnings("unchecked") public List getLocationTags(String search) { - return sessionFactory.getCurrentSession().createCriteria(LocationTag.class) - // 'ilike' case insensitive search - .add(Expression.ilike("name", search, MatchMode.START)).addOrder(Order.asc("name")).list(); + Criteria crit = sessionFactory.getCurrentSession().createCriteria(LocationTag.class); + HibernateUtil.addLikeCriterionForLocalizedColumn(search, "localizedName", crit, false, MatchMode.START); + List tags = crit.list(); + Collections.sort(tags, new MetadataComparator(Context.getLocale())); + return tags; } /** Index: /src/api/org/openmrs/scheduler/db/hibernate/HibernateSchedulerDAO.java =================================================================== --- /src/api/org/openmrs/scheduler/db/hibernate/HibernateSchedulerDAO.java (revision 14891) +++ /src/api/org/openmrs/scheduler/db/hibernate/HibernateSchedulerDAO.java (working copy) @@ -19,8 +19,8 @@ import org.apache.commons.logging.LogFactory; import org.hibernate.Criteria; import org.hibernate.SessionFactory; -import org.hibernate.criterion.Expression; import org.openmrs.api.db.DAOException; +import org.openmrs.api.db.hibernate.HibernateUtil; import org.openmrs.scheduler.Schedule; import org.openmrs.scheduler.TaskDefinition; import org.openmrs.scheduler.db.SchedulerDAO; @@ -90,12 +90,15 @@ * @return task with given public name * @throws DAOException */ + @SuppressWarnings("unchecked") public TaskDefinition getTaskByName(String name) throws DAOException { - Criteria crit = sessionFactory.getCurrentSession().createCriteria(TaskDefinition.class).add( - Expression.eq("name", name)); + Criteria crit = sessionFactory.getCurrentSession().createCriteria(TaskDefinition.class); + HibernateUtil.addEqCriterionForLocalizedColumn(name, "localizedName", crit); + List tasks = crit.list(); + TaskDefinition task = null; + if (tasks != null && !tasks.isEmpty()) + task = tasks.get(0); - TaskDefinition task = (TaskDefinition) crit.uniqueResult(); - if (task == null) { log.warn("Task '" + name + "' not found"); throw new ObjectRetrievalFailureException(TaskDefinition.class, name); @@ -189,5 +192,5 @@ * @param schedule schedule to be deleted * @throws DAOException */ - //public void deleteSchedule(Schedule schedule) throws DAOException; + //public void deleteSchedule(Schedule schedule) throws DAOException; } Index: /src/api/org/openmrs/scheduler/TaskDefinition.java =================================================================== --- /src/api/org/openmrs/scheduler/TaskDefinition.java (revision 14891) +++ /src/api/org/openmrs/scheduler/TaskDefinition.java (working copy) @@ -19,13 +19,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.openmrs.BaseOpenmrsMetadata; +import org.openmrs.BaseLocalizedMetadata; import org.openmrs.User; /** * Represents the metadata for a task that can be scheduled. */ -public class TaskDefinition extends BaseOpenmrsMetadata { +public class TaskDefinition extends BaseLocalizedMetadata { private Log log = LogFactory.getLog(this.getClass()); @@ -168,7 +168,7 @@ */ public void setLastExecutionTime(Date lastExecutionTime) { this.lastExecutionTime = lastExecutionTime; - } + } /** * Gets the number of seconds until task is executed again. @@ -330,7 +330,8 @@ /** * @deprecated use {@link #getCreator()} */ - public Object getCreatedBy() { + @Deprecated + public Object getCreatedBy() { // TODO Auto-generated method stub return null; } @@ -338,7 +339,8 @@ /** * @deprecated use {@link #setCreator(User)} */ - public void setCreatedBy(User authenticatedUser) { + @Deprecated + public void setCreatedBy(User authenticatedUser) { // TODO Auto-generated method stub } Index: /src/web/org/openmrs/web/controller/encounter/LocationFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/encounter/LocationFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/encounter/LocationFormController.java (working copy) @@ -25,11 +25,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.openmrs.LocalizedString; import org.openmrs.Location; import org.openmrs.LocationTag; import org.openmrs.api.APIException; import org.openmrs.api.LocationService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.propertyeditor.LocationEditor; import org.openmrs.propertyeditor.LocationTagEditor; import org.openmrs.util.MetadataComparator; @@ -53,12 +55,14 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); binder.registerCustomEditor(Location.class, new LocationEditor()); binder.registerCustomEditor(LocationTag.class, new LocationTagEditor()); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -83,7 +87,8 @@ * @should retire location * @should not retire location if reason is empty */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -129,7 +134,8 @@ * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) * @should return valid location given valid locationId */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { Location location = null; Index: /src/web/org/openmrs/web/controller/encounter/LocationTagController.java =================================================================== --- /src/web/org/openmrs/web/controller/encounter/LocationTagController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/encounter/LocationTagController.java (working copy) @@ -17,9 +17,11 @@ import java.util.Collections; import java.util.List; +import org.openmrs.LocalizedString; import org.openmrs.Location; import org.openmrs.LocationTag; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.propertyeditor.LocationTagEditor; import org.openmrs.util.MetadataComparator; import org.openmrs.validator.LocationTagValidator; @@ -53,6 +55,7 @@ @InitBinder public void initBinder(WebDataBinder wdb) { wdb.registerCustomEditor(LocationTag.class, new LocationTagEditor()); + wdb.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -69,18 +72,21 @@ * Add a new LocationTag (quickly, without a dedicated page) */ @RequestMapping("/admin/locations/locationTagAdd") - public String add(@RequestParam("name") String name, - @RequestParam("description") String description, + public String add(@RequestParam("localizedName") String localizedName, + @RequestParam("localizedDescription") String localizedDescription, WebRequest request) { - - if (!StringUtils.hasText(name)) { + LocalizedString lsName = LocalizedString.valueOf(localizedName); + LocalizedString lsDescription = LocalizedString.valueOf(localizedDescription); + if (lsName == null || !StringUtils.hasText(lsName.getUnlocalizedValue())) { request.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, Context.getMessageSourceService().getMessage( - "LocationTag.error.name.required"), WebRequest.SCOPE_SESSION); - } else if (Context.getLocationService().getLocationTagByName(name) != null) { + "LocalizedName.unlocalizedName.empty"), WebRequest.SCOPE_SESSION); + } else if (Context.getLocationService().getLocationTagByName(lsName.getValue()) != null) { request.setAttribute(WebConstants.OPENMRS_ERROR_ATTR, Context.getMessageSourceService().getMessage( "LocationTag.error.name.duplicate"), WebRequest.SCOPE_SESSION); } else { - LocationTag tag = new LocationTag(name, description); + LocationTag tag = new LocationTag(); + tag.setLocalizedName(lsName); + tag.setLocalizedDescription(lsDescription); Context.getLocationService().saveLocationTag(tag); request.setAttribute(WebConstants.OPENMRS_MSG_ATTR, Context.getMessageSourceService().getMessage( "LocationTag.saved"), WebRequest.SCOPE_SESSION); Index: /src/web/org/openmrs/web/controller/encounter/EncounterTypeFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/encounter/EncounterTypeFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/encounter/EncounterTypeFormController.java (working copy) @@ -24,6 +24,7 @@ import org.openmrs.api.APIException; import org.openmrs.api.EncounterService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.dao.DataIntegrityViolationException; @@ -46,10 +47,12 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); + binder.registerCustomEditor(org.openmrs.LocalizedString.class, new LocalizedStringEditor()); } /** @@ -60,7 +63,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -120,7 +124,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { EncounterType encounterType = null; Index: /src/web/org/openmrs/web/controller/concept/ConceptSourceFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/concept/ConceptSourceFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/concept/ConceptSourceFormController.java (working copy) @@ -25,8 +25,10 @@ import org.apache.commons.logging.LogFactory; import org.openmrs.ConceptSource; import org.openmrs.ImplementationId; +import org.openmrs.LocalizedString; import org.openmrs.api.ConceptService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.validation.BindException; @@ -48,9 +50,11 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -61,7 +65,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -84,7 +89,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { ConceptSource conceptSource = null; Index: /src/web/org/openmrs/web/controller/concept/ConceptDrugFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/concept/ConceptDrugFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/concept/ConceptDrugFormController.java (working copy) @@ -24,8 +24,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openmrs.Drug; +import org.openmrs.LocalizedString; import org.openmrs.api.ConceptService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.util.OpenmrsConstants; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; @@ -48,12 +50,14 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); binder.registerCustomEditor(java.lang.Double.class, new CustomNumberEditor(java.lang.Double.class, true)); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -64,7 +68,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -107,7 +112,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { Drug drug = null; @@ -129,7 +135,8 @@ * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest, * java.lang.Object, org.springframework.validation.Errors) */ - protected Map referenceData(HttpServletRequest request, Object obj, Errors errs) throws Exception { + @Override + protected Map referenceData(HttpServletRequest request, Object obj, Errors errs) throws Exception { Drug drug = (Drug) obj; Index: /src/web/org/openmrs/web/controller/concept/ConceptClassFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/concept/ConceptClassFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/concept/ConceptClassFormController.java (working copy) @@ -23,6 +23,7 @@ import org.openmrs.ConceptClass; import org.openmrs.api.ConceptService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.validation.BindException; @@ -43,10 +44,12 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); + binder.registerCustomEditor(org.openmrs.LocalizedString.class, new LocalizedStringEditor()); } /** @@ -57,7 +60,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -80,7 +84,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { ConceptClass conceptClass = null; Index: /src/web/org/openmrs/web/controller/concept/ConceptDatatypeFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/concept/ConceptDatatypeFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/concept/ConceptDatatypeFormController.java (working copy) @@ -21,8 +21,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openmrs.ConceptDatatype; +import org.openmrs.LocalizedString; import org.openmrs.api.ConceptService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.validation.BindException; @@ -43,10 +45,12 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -57,7 +61,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -80,7 +85,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { ConceptDatatype cd = null; Index: /src/web/org/openmrs/web/controller/form/FieldFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/form/FieldFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/form/FieldFormController.java (working copy) @@ -25,8 +25,10 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openmrs.Field; +import org.openmrs.LocalizedString; import org.openmrs.api.FormService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.util.OpenmrsConstants; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; @@ -42,12 +44,15 @@ /** Logger for this class and subclasses */ protected final Log log = LogFactory.getLog(getClass()); - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } - protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse reponse, Object obj, + @Override + protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse reponse, Object obj, BindException errors) throws Exception { Field field = (Field) obj; @@ -65,7 +70,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -90,7 +96,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { Field field = null; @@ -107,7 +114,8 @@ return field; } - protected Map referenceData(HttpServletRequest request, Object obj, Errors errors) throws Exception { + @Override + protected Map referenceData(HttpServletRequest request, Object obj, Errors errors) throws Exception { Field field = (Field) obj; Locale locale = Context.getLocale(); Index: /src/web/org/openmrs/web/controller/form/FormFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/form/FormFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/form/FormFormController.java (working copy) @@ -32,9 +32,11 @@ import org.openmrs.FieldType; import org.openmrs.Form; import org.openmrs.FormField; +import org.openmrs.LocalizedString; import org.openmrs.api.FormService; import org.openmrs.api.context.Context; import org.openmrs.propertyeditor.EncounterTypeEditor; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.util.FormUtil; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; @@ -53,11 +55,13 @@ /** Logger for this class and subclasses */ protected final Log log = LogFactory.getLog(getClass()); - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); // NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); binder.registerCustomEditor(EncounterType.class, new EncounterTypeEditor()); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -68,7 +72,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -155,7 +160,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { Form form = null; @@ -177,7 +183,8 @@ return form; } - protected Map referenceData(HttpServletRequest request, Object obj, Errors errors) throws Exception { + @Override + protected Map referenceData(HttpServletRequest request, Object obj, Errors errors) throws Exception { Map map = new HashMap(); Index: /src/web/org/openmrs/web/controller/form/FieldTypeFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/form/FieldTypeFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/form/FieldTypeFormController.java (working copy) @@ -23,8 +23,10 @@ import org.openmrs.FieldType; import org.openmrs.api.FormService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.web.WebConstants; import org.springframework.validation.BindException; +import org.springframework.web.bind.ServletRequestDataBinder; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.SimpleFormController; import org.springframework.web.servlet.view.RedirectView; @@ -35,6 +37,19 @@ protected final Log log = LogFactory.getLog(getClass()); /** + * Register {@link LocalizedStringEditor} to transform between request parameters and + * LocalizedString object + * + * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, + * org.springframework.web.bind.ServletRequestDataBinder) + */ + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + super.initBinder(request, binder); + binder.registerCustomEditor(org.openmrs.LocalizedString.class, new LocalizedStringEditor()); + } + + /** * The onSubmit function receives the form/command object that was modified by the input form * and saves it to the db * @@ -42,7 +57,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -65,7 +81,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { FieldType fieldType = null; Index: /src/web/org/openmrs/web/controller/patient/PatientIdentifierTypeFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/patient/PatientIdentifierTypeFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/patient/PatientIdentifierTypeFormController.java (working copy) @@ -24,11 +24,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.openmrs.LocalizedString; import org.openmrs.PatientIdentifierType; import org.openmrs.api.APIException; import org.openmrs.api.PatientService; import org.openmrs.api.context.Context; import org.openmrs.patient.IdentifierValidator; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.dao.DataIntegrityViolationException; @@ -52,10 +54,12 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -66,7 +70,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -134,7 +139,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { PatientIdentifierType identifierType = null; @@ -156,7 +162,8 @@ * * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest) */ - protected Map referenceData(HttpServletRequest request, Object obj, Errors err) throws Exception { + @Override + protected Map referenceData(HttpServletRequest request, Object obj, Errors err) throws Exception { Map toReturn = new LinkedHashMap(); Collection pivs = Context.getPatientService().getAllIdentifierValidators(); Index: /src/web/org/openmrs/web/controller/person/PersonAttributeTypeFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/person/PersonAttributeTypeFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/person/PersonAttributeTypeFormController.java (working copy) @@ -27,11 +27,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.openmrs.LocalizedString; import org.openmrs.PersonAttributeType; import org.openmrs.Privilege; import org.openmrs.api.APIException; import org.openmrs.api.PersonService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.propertyeditor.PrivilegeEditor; import org.openmrs.web.WebConstants; import org.openmrs.web.taglib.fieldgen.FieldGenHandlerFactory; @@ -60,11 +62,13 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); binder.registerCustomEditor(Privilege.class, new PrivilegeEditor()); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -75,7 +79,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -134,7 +139,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { PersonAttributeType attrType = null; @@ -155,7 +161,8 @@ * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest, * java.lang.Object, org.springframework.validation.Errors) */ - protected Map referenceData(HttpServletRequest request, Object obj, Errors errors) throws Exception { + @Override + protected Map referenceData(HttpServletRequest request, Object obj, Errors errors) throws Exception { Map map = new HashMap(); @@ -167,7 +174,7 @@ Set formats = new TreeSet(FieldGenHandlerFactory.getSingletonInstance().getHandlers().keySet()); - // these formats are handled directly by the FieldGenTag.java class and so aren't in the + // these formats are handled directly by the FieldGenTag.java class and so aren't in the // "handlers" list in openmrs-servlet.xml formats.add("java.lang.Character"); formats.add("java.lang.Integer"); Index: /src/web/org/openmrs/web/controller/person/RelationshipTypeFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/person/RelationshipTypeFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/person/RelationshipTypeFormController.java (working copy) @@ -20,10 +20,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.openmrs.LocalizedString; import org.openmrs.RelationshipType; import org.openmrs.api.APIException; import org.openmrs.api.PersonService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.dao.DataIntegrityViolationException; @@ -46,10 +48,12 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -64,10 +68,10 @@ RelationshipType type = (RelationshipType) command; if (type.getaIsToB() == null || type.getaIsToB().equals("")) - errors.rejectValue("aIsToB", "RelationshipType.aIsToB.required"); + errors.rejectValue("localizedAIsToB.unlocalizedValue", "RelationshipType.aIsToB.required"); if (type.getbIsToA() == null || type.getbIsToA().equals("")) - errors.rejectValue("bIsToA", "RelationshipType.bIsToA.required"); + errors.rejectValue("localizedBIsToA.unlocalizedValue", "RelationshipType.bIsToA.required"); return super.processFormSubmission(request, response, type, errors); } @@ -80,7 +84,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -140,7 +145,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { RelationshipType identifierType = null; Index: /src/web/org/openmrs/web/controller/program/ProgramFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/program/ProgramFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/program/ProgramFormController.java (working copy) @@ -21,10 +21,12 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openmrs.Concept; +import org.openmrs.LocalizedString; import org.openmrs.Program; import org.openmrs.api.ProgramWorkflowService; import org.openmrs.api.context.Context; import org.openmrs.propertyeditor.ConceptEditor; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.propertyeditor.WorkflowCollectionEditor; import org.openmrs.web.WebConstants; import org.springframework.validation.BindException; @@ -38,7 +40,8 @@ /** Logger for this class and subclasses */ protected final Log log = LogFactory.getLog(getClass()); - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); // this depends on this form being a "session-form" (defined in openrms-servlet.xml) @@ -46,6 +49,7 @@ binder.registerCustomEditor(Concept.class, new ConceptEditor()); binder.registerCustomEditor(java.util.Collection.class, "allWorkflows", new WorkflowCollectionEditor(program)); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -54,7 +58,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { log.debug("called formBackingObject"); Program program = null; @@ -81,7 +86,8 @@ * org.springframework.validation.BindException) * @should save workflows with program */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { log.debug("about to save " + obj); Index: /src/web/org/openmrs/web/controller/order/OrderTypeFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/order/OrderTypeFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/order/OrderTypeFormController.java (working copy) @@ -23,6 +23,7 @@ import org.openmrs.OrderType; import org.openmrs.api.OrderService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.validation.BindException; @@ -43,10 +44,12 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); + binder.registerCustomEditor(org.openmrs.LocalizedString.class, new LocalizedStringEditor()); } /** @@ -57,7 +60,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -80,7 +84,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { OrderType orderType = null; Index: /src/web/org/openmrs/web/controller/user/RoleFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/user/RoleFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/user/RoleFormController.java (working copy) @@ -27,11 +27,13 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.openmrs.LocalizedString; import org.openmrs.Privilege; import org.openmrs.Role; import org.openmrs.api.APIException; import org.openmrs.api.UserService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.propertyeditor.PrivilegeEditor; import org.openmrs.propertyeditor.RoleEditor; import org.openmrs.util.OpenmrsConstants; @@ -56,12 +58,14 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); binder.registerCustomEditor(Privilege.class, new PrivilegeEditor()); binder.registerCustomEditor(Role.class, new RoleEditor()); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -69,7 +73,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - @SuppressWarnings("unchecked") + @Override + @SuppressWarnings("unchecked") protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { @@ -94,7 +99,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -121,7 +127,8 @@ * @see org.springframework.web.servlet.mvc.SimpleFormController#referenceData(javax.servlet.http.HttpServletRequest, * java.lang.Object, org.springframework.validation.Errors) */ - protected Map referenceData(HttpServletRequest request, Object object, Errors errors) throws Exception { + @Override + protected Map referenceData(HttpServletRequest request, Object object, Errors errors) throws Exception { Map map = new HashMap(); @@ -159,7 +166,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { Role role = null; Index: /src/web/org/openmrs/web/controller/user/PrivilegeFormController.java =================================================================== --- /src/web/org/openmrs/web/controller/user/PrivilegeFormController.java (revision 14891) +++ /src/web/org/openmrs/web/controller/user/PrivilegeFormController.java (working copy) @@ -20,9 +20,11 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.openmrs.LocalizedString; import org.openmrs.Privilege; import org.openmrs.api.UserService; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.validation.BindException; @@ -43,10 +45,12 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -57,7 +61,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object obj, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -80,7 +85,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { Privilege privilege = null; Index: /src/web/org/openmrs/web/taglib/ForEachRecordTag.java =================================================================== --- /src/web/org/openmrs/web/taglib/ForEachRecordTag.java (revision 14891) +++ /src/web/org/openmrs/web/taglib/ForEachRecordTag.java (working copy) @@ -34,6 +34,7 @@ import org.openmrs.Form; import org.openmrs.ProgramWorkflowState; import org.openmrs.Role; +import org.openmrs.api.AdministrationService; import org.openmrs.api.ConceptService; import org.openmrs.api.EncounterService; import org.openmrs.api.LocationService; @@ -61,7 +62,8 @@ private Iterator records; - public int doStartTag() { + @Override + public int doStartTag() { records = null; @@ -137,6 +139,9 @@ records = c.getAnswers().iterator(); else records = new ArrayList().iterator(); + } else if (name.equals("allowedLocale")) { + AdministrationService as = Context.getAdministrationService(); + records = as.getAllowedLocales().iterator(); } else { try { Class cls = Context.loadClass(name); @@ -161,7 +166,8 @@ /** * @see javax.servlet.jsp.tagext.BodyTag#doInitBody() */ - public void doInitBody() throws JspException { + @Override + public void doInitBody() throws JspException { if (records.hasNext()) { Object obj = records.next(); iterate(obj); @@ -171,7 +177,8 @@ /** * @see javax.servlet.jsp.tagext.IterationTag#doAfterBody() */ - public int doAfterBody() throws JspException { + @Override + public int doAfterBody() throws JspException { if (records.hasNext()) { Object obj = records.next(); iterate(obj); @@ -203,7 +210,8 @@ /** * @see javax.servlet.jsp.tagext.Tag#doEndTag() */ - public int doEndTag() throws JspException { + @Override + public int doEndTag() throws JspException { try { if (getBodyContent() != null && records != null) getBodyContent().writeOut(getBodyContent().getEnclosingWriter()); Index: /src/web/org/openmrs/scheduler/web/controller/SchedulerFormController.java =================================================================== --- /src/web/org/openmrs/scheduler/web/controller/SchedulerFormController.java (revision 14891) +++ /src/web/org/openmrs/scheduler/web/controller/SchedulerFormController.java (working copy) @@ -25,7 +25,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.openmrs.LocalizedString; import org.openmrs.api.context.Context; +import org.openmrs.propertyeditor.LocalizedStringEditor; import org.openmrs.scheduler.TaskDefinition; import org.openmrs.web.WebConstants; import org.springframework.beans.propertyeditors.CustomDateEditor; @@ -56,12 +58,14 @@ * @see org.springframework.web.servlet.mvc.BaseCommandController#initBinder(javax.servlet.http.HttpServletRequest, * org.springframework.web.bind.ServletRequestDataBinder) */ - protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { + @Override + protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { super.initBinder(request, binder); //NumberFormat nf = NumberFormat.getInstance(new Locale("en_US")); binder.registerCustomEditor(java.lang.Integer.class, new CustomNumberEditor(java.lang.Integer.class, true)); binder.registerCustomEditor(java.lang.Long.class, new CustomNumberEditor(java.lang.Long.class, true)); binder.registerCustomEditor(java.util.Date.class, new CustomDateEditor(DEFAULT_DATE_FORMAT, true)); + binder.registerCustomEditor(LocalizedString.class, new LocalizedStringEditor()); } /** @@ -114,7 +118,8 @@ * javax.servlet.http.HttpServletResponse, java.lang.Object, * org.springframework.validation.BindException) */ - protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, + @Override + protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { HttpSession httpSession = request.getSession(); @@ -142,7 +147,8 @@ * * @see org.springframework.web.servlet.mvc.AbstractFormController#formBackingObject(javax.servlet.http.HttpServletRequest) */ - protected Object formBackingObject(HttpServletRequest request) throws ServletException { + @Override + protected Object formBackingObject(HttpServletRequest request) throws ServletException { TaskDefinition task = new TaskDefinition(); Index: /build.xml =================================================================== --- /build.xml (revision 14891) +++ /build.xml (working copy) @@ -3,7 +3,7 @@ - + Index: /.classpath =================================================================== --- /.classpath (revision 14891) +++ /.classpath (working copy) @@ -65,19 +65,19 @@ - + - + - + - - + + Index: /web/WEB-INF/view/admin/encounters/encounterTypeForm.jsp =================================================================== --- /web/WEB-INF/view/admin/encounters/encounterTypeForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/encounters/encounterTypeForm.jsp (working copy) @@ -36,24 +36,10 @@
- - - - - - - - + + + + Index: /web/WEB-INF/view/admin/forms/include/fieldEdit.jsp =================================================================== --- /web/WEB-INF/view/admin/forms/include/fieldEdit.jsp (revision 14891) +++ /web/WEB-INF/view/admin/forms/include/fieldEdit.jsp (working copy) @@ -1,36 +1,10 @@
- - - ${status.errorMessage} - -
- - - ${status.errorMessage} - -
+ + + + - - - - - - - -
- - - - - - - ${status.errorMessage} - - - -
- - - - - - - ${status.errorMessage} - - - -
Index: /web/WEB-INF/view/admin/forms/fieldTypeForm.jsp =================================================================== --- /web/WEB-INF/view/admin/forms/fieldTypeForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/forms/fieldTypeForm.jsp (working copy) @@ -9,19 +9,17 @@ + + + - - - - - - - - + + + Index: /web/WEB-INF/view/admin/forms/formEditForm.jsp =================================================================== --- /web/WEB-INF/view/admin/forms/formEditForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/forms/formEditForm.jsp (working copy) @@ -37,25 +37,11 @@
checked />
+ + + + - - - - - - - -
- - - ${status.errorMessage} - -
- - - ${status.errorMessage} - -
Index: /web/WEB-INF/view/admin/patients/patientIdentifierTypeForm.jsp =================================================================== --- /web/WEB-INF/view/admin/patients/patientIdentifierTypeForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/patients/patientIdentifierTypeForm.jsp (working copy) @@ -22,25 +22,11 @@
+ + + + - - - - - - - -
- - - ${status.errorMessage} - -
- - - ${status.errorMessage} - -
Index: /web/WEB-INF/view/admin/programs/programForm.jsp =================================================================== --- /web/WEB-INF/view/admin/programs/programForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/programs/programForm.jsp (working copy) @@ -91,25 +91,16 @@ + + + + + ${status.errorMessage} + + + + - - - - - - - -
- - - ${status.errorMessage} - -
- - - ${status.errorMessage} - -
Index: /web/WEB-INF/view/admin/locations/locationTag.jsp =================================================================== --- /web/WEB-INF/view/admin/locations/locationTag.jsp (revision 14891) +++ /web/WEB-INF/view/admin/locations/locationTag.jsp (working copy) @@ -1,86 +1,509 @@ -<%@ include file="/WEB-INF/template/include.jsp" %> - - - -<%@ include file="/WEB-INF/template/header.jsp" %> -<%@ include file="localHeader.jsp" %> - - - -

- - - - - - -
-
- -
- - - - - - - - - class="retired" > - - - - - - - - - -
- - ${locationTag.name} - - - ${locationTag.description} - - - - -
- - - - - - -<%@ include file="/WEB-INF/template/footer.jsp" %> +<%@ include file="/WEB-INF/template/include.jsp" %> + + + +<%@ include file="/WEB-INF/template/header.jsp" %> +<%@ include file="localHeader.jsp" %> + + + + + + + + +

+ + + + + + +
+
+ +
+ + + + + + + + + class="retired" > + + + + + + + + + +
+ + ${locationTag.name} + + + ${locationTag.description} + + + + +
+ + + + + + +<%@ include file="/WEB-INF/template/footer.jsp" %> Index: /web/WEB-INF/view/admin/locations/locationTagEdit.jsp =================================================================== --- /web/WEB-INF/view/admin/locations/locationTagEdit.jsp (revision 14891) +++ /web/WEB-INF/view/admin/locations/locationTagEdit.jsp (working copy) @@ -5,6 +5,340 @@ <%@ include file="/WEB-INF/template/header.jsp"%> <%@ include file="localHeader.jsp" %> + + + +

@@ -29,23 +363,167 @@
+ + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
* - + + + ${status.errorMessage} +
+ + + + + + + + + + +
+
+
+
+ + + + + + + + +
+
+ +
+
+ + + + + ${status.errorMessage} + + + +
- +    + + ${record.displayName}   +
+ + + ${status.errorMessage} + +
Index: /web/WEB-INF/view/admin/locations/locationForm.jsp =================================================================== --- /web/WEB-INF/view/admin/locations/locationForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/locations/locationForm.jsp (working copy) @@ -36,25 +36,11 @@
- - - - - - - - + + + + Index: /web/WEB-INF/view/admin/orders/orderTypeForm.jsp =================================================================== --- /web/WEB-INF/view/admin/orders/orderTypeForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/orders/orderTypeForm.jsp (working copy) @@ -13,24 +13,10 @@
- - - ${status.errorMessage} - -
- - - ${status.errorMessage} - -
- - - - - - - - + + + + Index: /web/WEB-INF/view/admin/users/roleForm.jsp =================================================================== --- /web/WEB-INF/view/admin/users/roleForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/users/roleForm.jsp (working copy) @@ -29,6 +29,18 @@ return confirm(''); } + + /* + * escape ":" or ";" occur in passed text + * Note: this method is used by localizedDescription portlet, @see localizedDescription.jsp + */ + function escapeDelimter(text) { + var reg = new RegExp(":", "g"); + text = text.replace(reg, "\\:"); + reg = new RegExp(";", "g"); + text = text.replace(reg, "\\;"); + return text; + }

@@ -54,15 +66,9 @@
- - - - + + + Index: /web/WEB-INF/view/admin/users/privilegeForm.jsp =================================================================== --- /web/WEB-INF/view/admin/users/privilegeForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/users/privilegeForm.jsp (working copy) @@ -5,6 +5,20 @@ <%@ include file="/WEB-INF/template/header.jsp" %> <%@ include file="localHeader.jsp" %> + +

@@ -24,15 +38,9 @@ - - - - + + +
- - - ${status.errorMessage} - -
- - - ${status.errorMessage} - -
- - - ${status.errorMessage} - -
- - - ${status.errorMessage} - -
"> Index: /web/WEB-INF/view/admin/person/relationshipTypeForm.jsp =================================================================== --- /web/WEB-INF/view/admin/person/relationshipTypeForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/person/relationshipTypeForm.jsp (working copy) @@ -17,38 +17,312 @@ + + + + +

+ + + + - + - - + + + + + + + + + + +
+
+ +
+ + + + + + + - - + + + + + + + + + + + Index: /web/WEB-INF/view/admin/person/personAttributeTypeForm.jsp =================================================================== --- /web/WEB-INF/view/admin/person/personAttributeTypeForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/person/personAttributeTypeForm.jsp (working copy) @@ -22,16 +22,13 @@
- - + + + + ${status.errorMessage}
- - - ${status.errorMessage} + + + + + + + + + + +
+
+
-
- - + + + + + ${status.errorMessage}
+ + + + + + + + + + +
+
+
+
+ + + + + + + + +
+
+ +
+
+ + + + + ${status.errorMessage} + - - - - + + + - - - -
- - - ${status.errorMessage} - -
@@ -69,16 +66,10 @@
- - - ${status.errorMessage} - -
Index: /web/WEB-INF/view/admin/concepts/conceptClassForm.jsp =================================================================== --- /web/WEB-INF/view/admin/concepts/conceptClassForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/concepts/conceptClassForm.jsp (working copy) @@ -11,24 +11,10 @@ - - - - - - - - + + + + Index: /web/WEB-INF/view/admin/concepts/conceptDatatypeForm.jsp =================================================================== --- /web/WEB-INF/view/admin/concepts/conceptDatatypeForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/concepts/conceptDatatypeForm.jsp (working copy) @@ -5,6 +5,47 @@ <%@ include file="/WEB-INF/template/header.jsp" %> <%@ include file="localHeader.jsp" %> + + + +

@@ -20,6 +61,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
- - - ${status.errorMessage} - -
- - - ${status.errorMessage} - -
+ + + + + ${status.errorMessage} + +
+ + +    + + ${record.displayName}   + +
+ + + ${status.errorMessage} + +
Index: /web/WEB-INF/view/admin/concepts/conceptSourceForm.jsp =================================================================== --- /web/WEB-INF/view/admin/concepts/conceptSourceForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/concepts/conceptSourceForm.jsp (working copy) @@ -5,6 +5,341 @@ <%@ include file="/WEB-INF/template/header.jsp" %> <%@ include file="localHeader.jsp" %> + + + +

@@ -16,16 +351,68 @@ + + + - + - + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: /web/WEB-INF/view/admin/concepts/conceptDrugForm.jsp =================================================================== --- /web/WEB-INF/view/admin/concepts/conceptDrugForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/concepts/conceptDrugForm.jsp (working copy) @@ -70,17 +70,10 @@
- - + + + + ${status.errorMessage} + +
+ + + + + + + + + + +
+
+
+
+ + + + + + + + +
+
+ +
+
@@ -36,16 +423,108 @@
+ + + + + ${status.errorMessage} + +
+ +
- - - ${status.errorMessage} - + +    + + ${record.displayName}   + +
+ + + ${status.errorMessage} + +
+ + + - - - - + + + - - - - + + + - - - -
- - - ${status.errorMessage} - -
Index: /web/WEB-INF/view/admin/scheduler/schedulerForm.jsp =================================================================== --- /web/WEB-INF/view/admin/scheduler/schedulerForm.jsp (revision 14891) +++ /web/WEB-INF/view/admin/scheduler/schedulerForm.jsp (working copy) @@ -165,16 +165,10 @@ ${task.id}
- - - ${status.errorMessage} - -
@@ -183,16 +177,10 @@
- - - ${status.errorMessage} - -