From 93a46b038eed32327605d36291f289f654a7887a Mon Sep 17 00:00:00 2001 From: josephbate Date: Wed, 11 Sep 2024 00:51:09 +0300 Subject: [PATCH] Succefully Removed omod-1.8 --- omod-1.10/pom.xml | 14 - .../DrugOrderSubclassHandler1_10.java | 4 +- .../openmrs1_10/DrugResource1_10.java | 4 +- .../openmrs1_10/OrderResource1_10.java | 8 +- .../openmrs1_10/PersonResource1_10.java | 4 +- .../ProgramEnrollmentResource1_10.java | 4 +- .../openmrs1_10/ProgramResource1_10.java | 4 +- .../ProgramEnrollmentController1_10Test.java | 18 +- .../openmrs1_10/PersonResource1_10Test.java | 4 +- .../openmrs1_10/ProgramResource1_10Test.java | 10 +- omod-1.11/pom.xml | 14 - .../openmrs1_11/ObsController1_11Test.java | 4 +- .../openmrs1_11/ConceptResource1_11Test.java | 4 +- .../openmrs1_11/ObsResource1_11Test.java | 4 +- .../openmrs1_11/PersonResource1_11Test.java | 4 +- omod-1.12/pom.xml | 14 - omod-1.8/pom.xml | 81 -- .../openmrs1_8/AllergyResource1_8.java | 161 ---- .../ConceptDescriptionResource1_8.java | 215 ------ .../openmrs1_8/ConceptMapResource1_8.java | 191 ----- .../openmrs1_8/ConceptNameResource1_8.java | 233 ------ .../openmrs1_8/ConceptResource1_8.java | 716 ------------------ .../openmrs1_8/EncounterResource1_8.java | 291 ------- .../resource/openmrs1_8/FormResource1_8.java | 215 ------ .../openmrs1_8/LocationResource1_8.java | 304 -------- .../resource/openmrs1_8/ObsResource1_8.java | 575 -------------- .../openmrs1_8/PatientResource1_8.java | 370 --------- .../openmrs1_8/ProblemResource1_8.java | 161 ---- .../openmrs1_8/RelationshipResource1_8.java | 211 ------ .../openmrs1_8/ConceptSearchHandler1_8.java | 189 ----- .../openmrs1_8/EncounterSearchHandler1_8.java | 82 -- .../rest/validation/ValidateUtilTest.java | 37 - .../rest/web/RestTestConstants1_8.java | 103 --- .../openmrs1_8/PatientResource1_8Test.java | 72 -- ...tributeTypeResourceWithConcept1_8Test.java | 49 -- .../openmrs1_8/ServerLogResource1_8Test.java | 86 --- omod-1.9/pom.xml | 14 - .../ChangePasswordController1_9.java | 4 +- .../openmrs1_9/HL7MessageController1_9.java | 10 +- .../ObsComplexValueController1_9.java | 4 +- .../openmrs1_9/UserConverter1_9.java | 20 +- .../openmrs1_9/ActiveListTypeResource1_9.java | 6 +- .../openmrs1_9/AllergyResource1_9.java | 132 +++- .../BaseActiveListItemResource1_9.java | 4 +- .../openmrs1_9/CohortMemberResource1_9.java | 50 +- .../openmrs1_9/CohortResource1_9.java | 6 +- .../openmrs1_9/ConceptClassResource1_9.java | 6 +- .../ConceptDatatypeResource1_9.java | 6 +- .../ConceptDescriptionResource1_9.java | 197 ++++- .../openmrs1_9/ConceptMapResource1_9.java | 91 ++- .../openmrs1_9/ConceptNameResource1_9.java | 214 +++++- .../openmrs1_9/ConceptResource1_9.java | 694 ++++++++++++++++- .../openmrs1_9/ConceptSourceResource1_9.java | 6 +- .../DrugOrderSubclassHandler1_9.java | 20 +- .../resource/openmrs1_9/DrugResource1_9.java | 6 +- .../openmrs1_9/EncounterResource1_9.java | 244 +++++- .../openmrs1_9/EncounterTypeResource1_9.java | 6 +- .../openmrs1_9/FieldAnswerResource1_9.java | 8 +- .../resource/openmrs1_9/FieldResource1_9.java | 6 +- .../openmrs1_9/FieldTypeResource1_9.java | 6 +- .../openmrs1_9/FormFieldResource1_9.java | 8 +- .../resource/openmrs1_9/FormResource1_9.java | 181 ++++- .../openmrs1_9/FormResourceResource1_9.java | 6 +- .../openmrs1_9/HL7MessageResource1_9.java | 31 +- .../openmrs1_9/HL7SourceResource1_9.java | 6 +- .../openmrs1_9/LocationResource1_9.java | 256 ++++++- .../openmrs1_9/LocationTagResource1_9.java | 6 +- .../openmrs1_9/ModuleActionResource1_9.java | 6 +- .../openmrs1_9/ModuleResource1_9.java | 8 +- .../resource/openmrs1_9/ObsResource1_9.java | 541 ++++++++++++- .../openmrs1_9/ObsTreeResource1_9.java | 3 +- .../resource/openmrs1_9/OrderResource1_9.java | 8 +- .../PatientIdentifierResource1_9.java | 8 +- .../PatientIdentifierTypeResource1_9.java | 8 +- .../openmrs1_9/PatientResource1_9.java | 341 ++++++++- .../openmrs1_9/PatientStateResource1_9.java | 8 +- .../openmrs1_9/PersonAddressResource1_9.java | 13 +- .../PersonAttributeResource1_9.java | 8 +- .../PersonAttributeTypeResource1_9.java | 8 +- .../openmrs1_9/PersonNameResource1_9.java | 8 +- .../openmrs1_9/PersonResource1_9.java | 6 +- .../openmrs1_9/PrivilegeResource1_9.java | 6 +- .../openmrs1_9/ProblemResource1_9.java | 129 +++- .../ProgramEnrollmentResource1_9.java | 6 +- .../openmrs1_9/ProgramResource1_9.java | 6 +- .../ProgramWorkflowResource1_9.java | 6 +- .../ProgramWorkflowStateResource1_9.java | 8 +- .../openmrs1_9/RelationshipResource1_9.java | 186 ++++- .../RelationshipTypeResource1_9.java | 14 +- .../resource/openmrs1_9/RoleResource1_9.java | 6 +- .../openmrs1_9/ServerLogResource1_9.java | 6 +- .../SystemInformationResource1_9.java | 6 +- .../openmrs1_9/TaskActionResource1_9.java | 6 +- .../openmrs1_9/TaskDefinitionResource1_9.java | 6 +- .../resource/openmrs1_9/UserResource1_9.java | 60 +- .../resource/openmrs1_9/VisitResource1_9.java | 7 +- .../openmrs1_9/ConceptSearchHandler1_9.java | 166 +++- .../openmrs1_9/EncounterSearchHandler1_9.java | 8 +- .../openmrs1_9/FormSearchHandler1_9.java | 6 +- .../openmrs1_9/LocationSearchHandler.java | 78 ++ .../ObservationSearchHandler1_9.java | 16 +- .../PatientByIdentifierSearchHandler1_9.java | 6 +- .../RelationshipSearchHandler1_9.java | 6 +- .../openmrs1_9/UserSearchHandler1_9.java | 14 +- .../wrapper/openmrs1_9/CohortMember1_9.java | 10 +- .../openmrs1_9/IncomingHl7Message1_9.java | 10 +- .../openmrs1_9/UserAndPassword1_9.java | 8 +- .../rest/web/ClassHierarchyResourceTest.java | 6 +- .../rest/web/ConversionUtil1_9Test.java | 4 +- .../rest/web/DelegatingCrudResourceTest.java | 8 +- .../webservices/rest/web/HivDrugOrder.java | 0 .../rest/web/HivDrugOrderSubclassHandler.java | 2 +- .../rest/web/MockModuleFactoryWrapper.java | 0 .../rest/web/MockServerLogActionWrapper.java | 0 .../rest/web/MockTaskServiceWrapper.java | 0 .../rest/web/RestTestConstants1_9.java | 92 +++ .../controller/BaseRestControllerTest.java | 0 .../MainResourceControllerTest.java | 0 .../controller/RestControllerTestUtils.java | 0 .../openmrs1_9/AllergyController1_9Test.java | 21 +- .../ChangePasswordController1_9Test.java | 12 +- .../openmrs1_9/CohortController1_9Test.java | 8 +- .../CohortMemberController1_9Test.java | 8 +- .../ConceptClassController1_9Test.java | 8 +- .../openmrs1_9/ConceptController1_8Test.java | 6 +- .../ConceptDatatypeController1_9Test.java | 4 +- .../ConceptDescriptionController1_9Test.java | 13 +- .../ConceptMapController1_8Test.java | 18 +- .../ConceptSourceController1_9Test.java | 8 +- .../openmrs1_9/DrugController1_9Test.java | 4 +- .../EncounterController1_9Test.java | 2 +- .../EncounterTypeController1_9Test.java | 8 +- .../openmrs1_9/FieldController1_9Test.java | 4 +- .../FieldTypeController1_9Test.java | 8 +- .../openmrs1_9/FormController1_9Test.java | 8 +- .../FormFieldController1_9Test.java | 6 +- .../HL7MessageController1_9Test.java | 6 +- .../openmrs1_9/LocationController1_9Test.java | 4 +- .../LocationTagController1_9Test.java | 8 +- .../ModuleActionController1_9Test.java | 12 +- .../openmrs1_9/ModuleController1_9Test.java | 8 +- .../openmrs1_9/ObsController1_9Test.java | 6 +- .../openmrs1_9/OrderController1_9Test.java | 4 +- .../openmrs1_9/PatientController1_9Test.java | 4 +- .../PatientIdentifierController1_9Test.java | 16 +- ...atientIdentifierTypeController1_9Test.java | 8 +- .../PersonAddressController1_9Test.java | 20 +- .../PersonAttributeController1_9Test.java | 10 +- .../PersonAttributeTypeController1_9Test.java | 8 +- .../openmrs1_9/PersonController1_9Test.java | 4 +- .../PrivilegeController1_9Test.java | 8 +- .../openmrs1_9/ProblemController1_9Test.java | 10 +- .../openmrs1_9/ProgramController1_9Test.java | 8 +- .../ProgramEnrollmentController1_9Test.java | 18 +- .../RelationshipController1_9Test.java | 34 +- .../RelationshipTypeController1_9Test.java | 24 +- .../openmrs1_9/RoleController1_9Test.java | 8 +- .../ServerLogController1_9Test.java | 10 +- .../openmrs1_9/SessionController1_9Test.java | 20 +- .../TaskActionController1_9Test.java | 12 +- .../TaskDefinitionController1_9Test.java | 8 +- .../openmrs1_9/UserController1_9Test.java | 38 +- .../ActiveListTypeResource1_9Test.java | 4 +- .../openmrs1_9/AllergyResource1_9Test.java | 4 +- .../CohortMemberResource1_9Test.java | 16 +- .../openmrs1_9/CohortResource1_9Test.java | 10 +- .../ConceptClassResource1_8Test.java | 8 +- .../ConceptDatatypeResource1_9Test.java | 8 +- .../ConceptDescriptionResource1_9Test.java | 4 +- .../ConceptNameResource1_9Test.java | 4 +- .../ConceptNumericResource1_9Test.java | 4 +- .../openmrs1_9/ConceptResource1_9Test.java | 19 +- .../ConceptSearchResource1_9Test.java | 4 +- .../ConceptSourceResource1_9Test.java | 8 +- ...reatePatientIdentifierResource1_9Test.java | 5 +- .../openmrs1_9/DrugResource1_9Test.java | 10 +- .../EncounterTypeResource1_9Test.java | 8 +- .../FieldAnswerResource1_9Test.java | 10 +- .../openmrs1_9/FieldResource1_9Test.java | 8 +- .../openmrs1_9/FieldTypeResource1_9Test.java | 8 +- .../openmrs1_9/FormFieldResource1_9Test.java | 8 +- .../openmrs1_9}/FormResource1_8Test.java | 8 +- .../openmrs1_9/HL7MessageResource1_9Test.java | 16 +- .../openmrs1_9/HL7SourceResource1_9Test.java | 10 +- .../openmrs1_9/ModuleResource1_9Test.java | 6 +- .../openmrs1_9/ObsResource1_9Test.java | 61 +- .../openmrs1_9/OrderResource1_9Test.java | 14 +- .../openmrs1_9/OrderTypeResource1_9.java | 6 +- .../PatientIdentifierResource1_9Test.java | 7 +- .../PatientIdentifierTypeResource1_9Test.java | 8 +- .../openmrs1_9/PatientResource1_9Test.java | 4 +- .../PatientStateResource1_9Test.java | 8 +- .../PersonAddressResource1_9Test.java | 8 +- .../PersonAttributeResource1_9Test.java | 51 +- .../PersonAttributeTypeResource1_9Test.java | 8 +- ...tributeTypeResourceWithConcept1_9Test.java | 49 ++ .../openmrs1_9/PersonNameResource1_9Test.java | 7 +- .../openmrs1_9/PersonResource1_9Test.java | 14 +- .../openmrs1_9/PrivilegeResource1_9Test.java | 4 +- .../openmrs1_9/ProblemResource1_9Test.java | 4 +- .../openmrs1_9/ProgramResource1_9Test.java | 8 +- .../ProgramWorkflowResource1_9Test.java | 8 +- .../ProgramWorkflowStateResource1_9Test.java | 8 +- .../RelationshipResource1_9Test.java | 4 +- .../RelationshipTypeResource1_9Test.java | 10 +- .../openmrs1_9/RoleResource1_9Test.java | 8 +- .../SystemInformationResource1_9Test.java | 4 +- .../TaskDefinitionResource1_9Test.java | 8 +- .../openmrs1_9/UpdateUserResource1_9Test.java | 12 +- .../openmrs1_9/UserResource1_9Test.java | 15 +- .../EncounterSearchHandler1_9Test.java | 5 +- .../openmrs1_9}/FormSearchHandlerTest.java | 8 +- .../openmrs1_9/LocationSearchHandlerTest.java | 94 +++ ...tientByIdentifierSearchHandlerTest1_9.java | 4 +- .../test/resources/EncounterWithObsGroup.xml | 0 ...ntersForDifferentTypesWithObservations.xml | 0 .../PersonControllerTest-otherPersonData.xml | 0 .../test/resources/create_patient (Copy).json | 0 .../src/test/resources/create_patient.json | 58 ++ .../test/resources/customActiveListTest.xml | 0 .../test/resources/customConceptDataset.xml | 0 .../resources/customLocationTagDataset.xml | 0 .../resources/customRelationshipTypes1_8.xml | 0 .../src/test/resources/customTestDataset.xml | 0 .../src/test/resources/formTestDataSet.xml | 0 .../src/test/resources/loctag_data.xml | 0 .../src/test/resources/numericConcept.xml | 0 .../test/resources/obsWithGroupMembers.xml | 0 .../webservices/rest/include/mockModule.omod | Bin .../rest/include/mockModule/mock.omod | 0 .../personAttributeTypeWithConcept.xml | 0 .../test/resources/resourceTestDataset.xml | 0 .../src/test/resources/update_patient.json | 0 .../src/test/resources/update_user.json | 0 omod-2.0/pom.xml | 14 - .../ConceptDatatypeResource2_0.java | 4 +- .../openmrs2_0/ConceptSourceResource2_0.java | 4 +- .../PatientIdentifierTypeResource2_0.java | 4 +- .../openmrs2_0/PersonAddressResource2_0.java | 8 +- .../openmrs2_0/PersonNameResource2_0.java | 4 +- .../resource/openmrs2_0/UserResource2_0.java | 14 +- .../openmrs2_0/EncounterSearchHandler2_0.java | 8 +- .../openmrs2_0/AlertController2_0Test.java | 6 +- .../AlertRecipientController2_0Test.java | 6 +- .../ConceptDatatypeController2_0Test.java | 4 +- .../ConceptProposalController2_0Test.java | 8 +- .../ConceptSourceController2_0Test.java | 4 +- ...nceptStateConversionController2_0Test.java | 10 +- .../EncounterController2_0Test.java | 4 +- .../ProgramWorkflowController2_0Test.java | 10 +- ...ProgramWorkflowStateController2_0Test.java | 14 +- .../openmrs2_0/UserController2_0Test.java | 5 +- .../AlertRecipientResource2_0Test.java | 6 +- .../openmrs2_0/AlertResource2_0Test.java | 4 +- .../ConceptProposalResource2_0Test.java | 4 +- .../openmrs2_0/ConceptResource2_0Test.java | 4 +- ...ConceptStateConversionResource2_0Test.java | 6 +- .../PatientIdentifierTypeResource2_0Test.java | 4 +- .../PersonAddressResource2_0Test.java | 4 +- .../openmrs2_0/UserResource2_0Test.java | 12 +- .../EncounterSearchHandler2_0Test.java | 3 +- omod-2.1/pom.xml | 14 - .../openmrs2_1/CohortResource2_1.java | 4 +- .../PersonNameController2_1Test.java | 4 +- .../openmrs2_1/ObsResource2_1Test.java | 4 +- omod-2.2/pom.xml | 14 - .../openmrs2_2/ConditionResource2_2.java | 4 +- .../openmrs2_2/DiagnosisResource2_2.java | 4 +- .../openmrs2_2/ObsController2_2Test.java | 4 +- .../openmrs2_2/OrderSearchHandler2_2Test.java | 6 +- omod-2.3/pom.xml | 14 - omod-2.4/pom.xml | 14 - .../openmrs2_4/TaskDefinitionResource2_4.java | 4 +- .../TaskActionController2_4Test.java | 6 +- omod-2.5/pom.xml | 14 - omod/pom.xml | 12 - pom.xml | 3 - 277 files changed, 4556 insertions(+), 5492 deletions(-) delete mode 100644 omod-1.8/pom.xml delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/AllergyResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDescriptionResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptMapResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptNameResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ObsResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProblemResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipResource1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/ConceptSearchHandler1_8.java delete mode 100644 omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/EncounterSearchHandler1_8.java delete mode 100644 omod-1.8/src/test/java/org/openmrs/module/webservices/rest/validation/ValidateUtilTest.java delete mode 100644 omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/RestTestConstants1_8.java delete mode 100644 omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8Test.java delete mode 100644 omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResourceWithConcept1_8Test.java delete mode 100644 omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ServerLogResource1_8Test.java rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ChangePasswordController1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ChangePasswordController1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/HL7MessageController1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/HL7MessageController1_9.java (95%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ObsComplexValueController1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ObsComplexValueController1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/converter/openmrs1_8/UserConverter1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/converter/openmrs1_9/UserConverter1_9.java (85%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ActiveListTypeResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ActiveListTypeResource1_9.java (96%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/BaseActiveListItemResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseActiveListItemResource1_9.java (99%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortMemberResource1_9.java (87%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptClassResource1_9.java (96%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDatatypeResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSourceResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugOrderSubclassHandler1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugOrderSubclassHandler1_9.java (94%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterTypeResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldAnswerResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldTypeResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormFieldResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7MessageResource1_9.java (88%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7SourceResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7SourceResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationTagResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/LocationTagResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleActionResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleActionResource1_9.java (99%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierTypeResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientStateResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAddressResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonNameResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonNameResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonResource1_9.java (99%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PrivilegeResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramEnrollmentResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramEnrollmentResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowStateResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationShipTypeResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipTypeResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RoleResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ServerLogResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ServerLogResource1_9.java (97%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/SystemInformationResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemInformationResource1_9.java (93%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskActionResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskActionResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskDefinitionResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskDefinitionResource1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UserResource1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UserResource1_9.java (90%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/FormSearchHandler1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/FormSearchHandler1_9.java (96%) create mode 100644 omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/LocationSearchHandler.java rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/ObservationSearchHandler1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/ObservationSearchHandler1_9.java (93%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/PatientByIdentifierSearchHandler1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/PatientByIdentifierSearchHandler1_9.java (96%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/RelationshipSearchHandler1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/RelationshipSearchHandler1_9.java (98%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/UserSearchHandler1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/UserSearchHandler1_9.java (88%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/CohortMember1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/CohortMember1_9.java (91%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/IncomingHl7Message1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/IncomingHl7Message1_9.java (93%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/UserAndPassword1_8.java => omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/UserAndPassword1_9.java (93%) rename {omod-1.8 => omod-1.9}/src/test/java/org/openmrs/module/webservices/rest/web/DelegatingCrudResourceTest.java (99%) rename {omod-1.8 => omod-1.9}/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrder.java (100%) rename {omod-1.8 => omod-1.9}/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java (99%) rename {omod-1.8 => omod-1.9}/src/test/java/org/openmrs/module/webservices/rest/web/MockModuleFactoryWrapper.java (100%) rename {omod-1.8 => omod-1.9}/src/test/java/org/openmrs/module/webservices/rest/web/MockServerLogActionWrapper.java (100%) rename {omod-1.8 => omod-1.9}/src/test/java/org/openmrs/module/webservices/rest/web/MockTaskServiceWrapper.java (100%) rename {omod-1.8 => omod-1.9}/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/BaseRestControllerTest.java (100%) rename {omod-1.8 => omod-1.9}/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/MainResourceControllerTest.java (100%) rename {omod-1.8 => omod-1.9}/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/RestControllerTestUtils.java (100%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ChangePasswordController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ChangePasswordController1_9Test.java (95%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/CohortController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/CohortController1_9Test.java (98%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/CohortMemberController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/CohortMemberController1_9Test.java (97%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptClassController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptClassController1_9Test.java (97%) rename {omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8 => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9}/ConceptMapController1_8Test.java (92%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptSourceController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptSourceController1_9Test.java (98%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/EncounterTypeController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/EncounterTypeController1_9Test.java (98%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/FieldTypeController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FieldTypeController1_9Test.java (97%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/FormController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FormController1_9Test.java (95%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/HL7MessageController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/HL7MessageController1_9Test.java (97%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/LocationTagController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/LocationTagController1_9Test.java (97%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ModuleActionController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ModuleActionController1_9Test.java (96%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ModuleController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ModuleController1_9Test.java (97%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PatientIdentifierTypeController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierTypeController1_9Test.java (98%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PersonAddressController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAddressController1_9Test.java (94%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PersonAttributeTypeController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAttributeTypeController1_9Test.java (98%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PrivilegeController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PrivilegeController1_9Test.java (97%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/RelationshipTypeController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RelationshipTypeController1_9Test.java (90%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/RoleController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RoleController1_9Test.java (98%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ServerLogController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ServerLogController1_9Test.java (94%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/TaskActionController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/TaskActionController1_9Test.java (95%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/TaskDefinitionController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/TaskDefinitionController1_9Test.java (97%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/UserController1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/UserController1_9Test.java (94%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ActiveListTypeResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ActiveListTypeResource1_9Test.java (95%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortMemberResource1_9Test.java (82%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortResource1_9Test.java (88%) rename {omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8 => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9}/ConceptClassResource1_8Test.java (93%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDatatypeResource1_9Test.java (90%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSourceResource1_9Test.java (90%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugResource1_9Test.java (94%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterTypeResource1_9Test.java (89%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldAnswerResource1_9Test.java (89%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldResource1_9Test.java (89%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldTypeResource1_9Test.java (88%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormFieldResource1_9Test.java (88%) rename {omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8 => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9}/FormResource1_8Test.java (96%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7MessageResource1_9Test.java (83%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7SourceResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7SourceResource1_9Test.java (88%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleResource1_9Test.java (89%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderResource1_9Test.java (90%) rename omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderTypeResource1_8.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderTypeResource1_9.java (95%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierTypeResource1_9Test.java (92%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientStateResource1_9Test.java (90%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAddressResource1_9Test.java (94%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeResource1_9Test.java (86%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResource1_9Test.java (92%) create mode 100644 omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResourceWithConcept1_9Test.java rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonResource1_9Test.java (92%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PrivilegeResource1_9Test.java (93%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramResource1_9Test.java (92%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowResource1_9Test.java (90%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowStateResource1_9Test.java (90%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipTypeResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipTypeResource1_9Test.java (90%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RoleResource1_9Test.java (91%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/SystemInformationResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemInformationResource1_9Test.java (98%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskDefinitionResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskDefinitionResource1_9Test.java (93%) rename omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UpdateUserResource1_8Test.java => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UpdateUserResource1_9Test.java (90%) rename {omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8 => omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9}/FormSearchHandlerTest.java (95%) create mode 100644 omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/LocationSearchHandlerTest.java rename {omod-1.8 => omod-1.9}/src/test/resources/EncounterWithObsGroup.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/EncountersForDifferentTypesWithObservations.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/PersonControllerTest-otherPersonData.xml (100%) rename omod-1.8/src/test/resources/create_patient.json => omod-1.9/src/test/resources/create_patient (Copy).json (100%) create mode 100644 omod-1.9/src/test/resources/create_patient.json rename {omod-1.8 => omod-1.9}/src/test/resources/customActiveListTest.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/customConceptDataset.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/customLocationTagDataset.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/customRelationshipTypes1_8.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/customTestDataset.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/formTestDataSet.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/loctag_data.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/numericConcept.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/obsWithGroupMembers.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/org/openmrs/module/webservices/rest/include/mockModule.omod (100%) create mode 100644 omod-1.9/src/test/resources/org/openmrs/module/webservices/rest/include/mockModule/mock.omod rename {omod-1.8 => omod-1.9}/src/test/resources/personAttributeTypeWithConcept.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/resourceTestDataset.xml (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/update_patient.json (100%) rename {omod-1.8 => omod-1.9}/src/test/resources/update_user.json (100%) diff --git a/omod-1.10/pom.xml b/omod-1.10/pom.xml index 77e5b319f..14cdab0c7 100644 --- a/omod-1.10/pom.xml +++ b/omod-1.10/pom.xml @@ -28,20 +28,6 @@ tests test - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - ${project.parent.groupId} diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/DrugOrderSubclassHandler1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/DrugOrderSubclassHandler1_10.java index a0a188698..31bd1ae91 100644 --- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/DrugOrderSubclassHandler1_10.java +++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/DrugOrderSubclassHandler1_10.java @@ -31,14 +31,14 @@ import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.DrugOrderSubclassHandler1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.DrugOrderSubclassHandler1_9; /** * Exposes the {@link org.openmrs.DrugOrder} subclass as a type in * {@link org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_10.DrugOrderSubclassHandler1_10} */ @SubClassHandler(supportedClass = DrugOrder.class, supportedOpenmrsVersions = { "1.10.* - 1.11.*" }) -public class DrugOrderSubclassHandler1_10 extends DrugOrderSubclassHandler1_8 { +public class DrugOrderSubclassHandler1_10 extends DrugOrderSubclassHandler1_9 { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#newDelegate() diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/DrugResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/DrugResource1_10.java index 820e8298e..74df61821 100644 --- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/DrugResource1_10.java +++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/DrugResource1_10.java @@ -16,7 +16,7 @@ import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.DrugResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.DrugResource1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -27,7 +27,7 @@ * supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/drug", order = 3, supportedClass = Drug.class, supportedOpenmrsVersions = { "1.10.*" }) -public class DrugResource1_10 extends DrugResource1_8 { +public class DrugResource1_10 extends DrugResource1_9 { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getResourceVersion() diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java index 98b8c0f76..4c08179d1 100644 --- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java +++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/OrderResource1_10.java @@ -37,8 +37,8 @@ import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.OrderResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.OrderResource1_9; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PatientResource1_9; import java.util.ArrayList; import java.util.Collections; @@ -51,7 +51,7 @@ * , supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/order", supportedClass = Order.class, supportedOpenmrsVersions = { "1.10.* - 2.1.*" }) -public class OrderResource1_10 extends OrderResource1_8 { +public class OrderResource1_10 extends OrderResource1_9 { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) @@ -220,7 +220,7 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe protected PageableResult doSearch(RequestContext context) throws ResponseException { String patientUuid = context.getRequest().getParameter("patient"); if (patientUuid != null) { - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); if (patient == null) { throw new ObjectNotFoundException(); diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/PersonResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/PersonResource1_10.java index e605ecdf1..d074f2d6a 100644 --- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/PersonResource1_10.java +++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/PersonResource1_10.java @@ -17,14 +17,14 @@ import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PersonResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PersonResource1_9; /** * {@link Resource} for Person, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/person", order = 3, supportedClass = Person.class, supportedOpenmrsVersions = { "1.10.4 - 1.10.*" }) -public class PersonResource1_10 extends PersonResource1_8 { +public class PersonResource1_10 extends PersonResource1_9 { /** * @see DelegatingCrudResource#getRepresentationDescription(Representation) diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramEnrollmentResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramEnrollmentResource1_10.java index 3fad6b60f..1c6c043b3 100644 --- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramEnrollmentResource1_10.java +++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramEnrollmentResource1_10.java @@ -26,7 +26,7 @@ import org.openmrs.module.webservices.rest.web.representation.RefRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ProgramEnrollmentResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ProgramEnrollmentResource1_9; import org.openmrs.util.OpenmrsUtil; import java.util.Collections; @@ -37,7 +37,7 @@ @Resource(name = RestConstants.VERSION_1 + "/programenrollment", supportedClass = PatientProgram.class, supportedOpenmrsVersions = { "1.10.* - 9.*" }) -public class ProgramEnrollmentResource1_10 extends ProgramEnrollmentResource1_8 { +public class ProgramEnrollmentResource1_10 extends ProgramEnrollmentResource1_9 { @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { diff --git a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10.java b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10.java index 123d687bc..1e40c7732 100644 --- a/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10.java +++ b/omod-1.10/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10.java @@ -21,11 +21,11 @@ import org.openmrs.module.webservices.rest.web.representation.RefRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ProgramResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ProgramResource1_9; @Resource(name = RestConstants.VERSION_1 + "/program", supportedClass = Program.class, supportedOpenmrsVersions = { "1.10.* - 9.*" }) -public class ProgramResource1_10 extends ProgramResource1_8 { +public class ProgramResource1_10 extends ProgramResource1_9 { @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { diff --git a/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_10/ProgramEnrollmentController1_10Test.java b/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_10/ProgramEnrollmentController1_10Test.java index ed1429ca5..cb7cf8caf 100644 --- a/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_10/ProgramEnrollmentController1_10Test.java +++ b/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_10/ProgramEnrollmentController1_10Test.java @@ -20,7 +20,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.openmrs.util.OpenmrsUtil; import org.springframework.mock.web.MockHttpServletRequest; @@ -67,17 +67,17 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.PATIENT_PROGRAM_UUID; + return RestTestConstants1_9.PATIENT_PROGRAM_UUID; } @Test @Override public void shouldGetAll() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); - req.setParameter("patient", RestTestConstants1_8.PATIENT_IN_A_PROGRAM_UUID); + req.setParameter("patient", RestTestConstants1_9.PATIENT_IN_A_PROGRAM_UUID); SimpleObject result = deserialize(handle(req)); - Patient patient = patientService.getPatientByUuid(RestTestConstants1_8.PATIENT_IN_A_PROGRAM_UUID); + Patient patient = patientService.getPatientByUuid(RestTestConstants1_9.PATIENT_IN_A_PROGRAM_UUID); List patientPrograms = service.getPatientPrograms(patient, null, null, null, null, null, false); Assert.assertEquals(patientPrograms.size(), Util.getResultsSize(result)); } @@ -85,10 +85,10 @@ public void shouldGetAll() throws Exception { @Test public void shouldExcludeVoided() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); - req.setParameter("patient", RestTestConstants1_8.PATIENT_WITH_VOIDED_PROGRAM_UUID); + req.setParameter("patient", RestTestConstants1_9.PATIENT_WITH_VOIDED_PROGRAM_UUID); SimpleObject result = deserialize(handle(req)); - Patient patient = patientService.getPatientByUuid(RestTestConstants1_8.PATIENT_WITH_VOIDED_PROGRAM_UUID); + Patient patient = patientService.getPatientByUuid(RestTestConstants1_9.PATIENT_WITH_VOIDED_PROGRAM_UUID); List patientPrograms = service.getPatientPrograms(patient, null, null, null, null, null, false); Assert.assertEquals(patientPrograms.size(), Util.getResultsSize(result)); } @@ -97,7 +97,7 @@ public void shouldExcludeVoided() throws Exception { public void shouldTransitPatientState() throws Exception { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); String stateStartDate = "2015-08-04"; - String json = "{ \"states\": [{ \"state\": {\"uuid\" : \"" + RestTestConstants1_8.STATE_UUID + String json = "{ \"states\": [{ \"state\": {\"uuid\" : \"" + RestTestConstants1_9.STATE_UUID + "\"}, \"startDate\": \"" + stateStartDate + "\"}]}"; PatientProgram patientProgram = service.getPatientProgramByUuid(getUuid()); @@ -111,7 +111,7 @@ public void shouldTransitPatientState() throws Exception { List states = new ArrayList(patientProgram.getStates()); Assert.assertEquals(2, states.size()); sortPatientStatesBasedOnStartDate(states); - Assert.assertEquals(RestTestConstants1_8.STATE_UUID, states.get(1).getState().getUuid()); + Assert.assertEquals(RestTestConstants1_9.STATE_UUID, states.get(1).getState().getUuid()); String existingStateEndDate = dateFormat.format(states.get(0).getEndDate()); Assert.assertEquals(stateStartDate, existingStateEndDate); } @@ -149,7 +149,7 @@ public void shouldVoidPatientState() throws Exception { //Transit the existing patient state to new state String stateStartDate = "2015-08-04"; - String json = "{ \"states\": [{ \"state\": {\"uuid\" : \"" + RestTestConstants1_8.STATE_UUID + String json = "{ \"states\": [{ \"state\": {\"uuid\" : \"" + RestTestConstants1_9.STATE_UUID + "\"}, \"startDate\": \"" + stateStartDate + "\"}]}"; MockHttpServletRequest req = newPostRequest(getURI() + "/" + getUuid(), SimpleObject.parseJson(json)); diff --git a/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/PersonResource1_10Test.java b/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/PersonResource1_10Test.java index a6b5c7cb2..e8f4675ae 100644 --- a/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/PersonResource1_10Test.java +++ b/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/PersonResource1_10Test.java @@ -11,7 +11,7 @@ import org.openmrs.Person; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class PersonResource1_10Test extends BaseDelegatingResourceTest { @@ -40,6 +40,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PERSON_UUID; + return RestTestConstants1_9.PERSON_UUID; } } diff --git a/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10Test.java b/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10Test.java index 110a0b288..56e142cfe 100644 --- a/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10Test.java +++ b/omod-1.10/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_10/ProgramResource1_10Test.java @@ -18,7 +18,7 @@ import org.openmrs.api.ProgramWorkflowService; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -41,7 +41,7 @@ public String getURI() { @Override public String getUuid() { - return RestTestConstants1_8.PROGRAM_UUID; + return RestTestConstants1_9.PROGRAM_UUID; } @Override @@ -56,8 +56,8 @@ public void shouldCreateAProgram() throws Exception { SimpleObject program = new SimpleObject(); program.add("name", "Program name"); program.add("description", "Program description"); - program.add("concept", RestTestConstants1_8.CONCEPT_UUID); - program.add("outcomesConcept", RestTestConstants1_8.CONCEPT2_UUID); + program.add("concept", RestTestConstants1_9.CONCEPT3_UUID); + program.add("outcomesConcept", RestTestConstants1_9.CONCEPT2_UUID); String json = new ObjectMapper().writeValueAsString(program); @@ -67,7 +67,7 @@ public void shouldCreateAProgram() throws Exception { SimpleObject newProgram = deserialize(handle(req)); Assert.assertNotNull(PropertyUtils.getProperty(newProgram, "uuid")); - Assert.assertEquals(RestTestConstants1_8.CONCEPT2_UUID, + Assert.assertEquals(RestTestConstants1_9.CONCEPT2_UUID, ((Map) PropertyUtils.getProperty(newProgram, "outcomesConcept")).get("uuid")); Assert.assertEquals(originalCount + 1, getAllCount()); } diff --git a/omod-1.11/pom.xml b/omod-1.11/pom.xml index 38d8c2d6f..3d94c5f97 100644 --- a/omod-1.11/pom.xml +++ b/omod-1.11/pom.xml @@ -28,20 +28,6 @@ tests test - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - ${project.parent.groupId} diff --git a/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_11/ObsController1_11Test.java b/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_11/ObsController1_11Test.java index 8e2dc9cc5..6d22c0eda 100644 --- a/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_11/ObsController1_11Test.java +++ b/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_11/ObsController1_11Test.java @@ -15,7 +15,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; @@ -48,7 +48,7 @@ public String getURI() { @Override public String getUuid() { - return RestTestConstants1_8.OBS_UUID; + return RestTestConstants1_9.OBS2_UUID; } @Override diff --git a/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ConceptResource1_11Test.java b/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ConceptResource1_11Test.java index 1579b90d7..eb3c47b1a 100644 --- a/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ConceptResource1_11Test.java +++ b/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ConceptResource1_11Test.java @@ -11,7 +11,7 @@ import org.openmrs.Concept; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class ConceptResource1_11Test extends BaseDelegatingResourceTest { @@ -36,6 +36,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.CONCEPT_NUMERIC_UUID; + return RestTestConstants1_9.CONCEPT_NUMERIC_UUID; } } diff --git a/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ObsResource1_11Test.java b/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ObsResource1_11Test.java index 3be6db0ea..c073f5d8f 100644 --- a/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ObsResource1_11Test.java +++ b/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/ObsResource1_11Test.java @@ -15,7 +15,7 @@ import org.openmrs.Obs; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; @@ -47,7 +47,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.OBS_UUID; + return RestTestConstants1_9.OBS2_UUID; } @Test diff --git a/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/PersonResource1_11Test.java b/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/PersonResource1_11Test.java index bfe6d999e..9aa980c7c 100644 --- a/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/PersonResource1_11Test.java +++ b/omod-1.11/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_11/PersonResource1_11Test.java @@ -11,7 +11,7 @@ import org.openmrs.Person; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class PersonResource1_11Test extends BaseDelegatingResourceTest { @@ -42,6 +42,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PERSON_UUID; + return RestTestConstants1_9.PERSON_UUID; } } diff --git a/omod-1.12/pom.xml b/omod-1.12/pom.xml index a764d8111..395861a91 100644 --- a/omod-1.12/pom.xml +++ b/omod-1.12/pom.xml @@ -29,20 +29,6 @@ test - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - - ${project.parent.groupId} ${project.parent.artifactId}-omod-1.9 diff --git a/omod-1.8/pom.xml b/omod-1.8/pom.xml deleted file mode 100644 index 0e7d60cae..000000000 --- a/omod-1.8/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - 4.0.0 - - org.openmrs.module - webservices.rest - 2.47.0-SNAPSHOT - - webservices.rest-omod-1.8 - jar - Rest Web Services 1.8 OMOD - OpenMRS module project for Rest Web Services - - - 1.9.10 - - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-common - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-common - ${project.parent.version} - tests - test - - - - org.openmrs.api - openmrs-api - ${openmrs.version.1.8} - - - - org.openmrs.api - openmrs-api - tests - ${openmrs.version.1.8} - - - - org.openmrs.web - openmrs-web - ${openmrs.version.1.8} - - - - org.openmrs.web - openmrs-web - tests - ${openmrs.version.1.8} - - - - org.openmrs.test - openmrs-test - pom - ${openmrs.version.1.8} - - - - - - - org.jacoco - jacoco-maven-plugin - - - com.mycila - license-maven-plugin - -
${project.parent.basedir}/license-header.txt
-
-
-
-
-
diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/AllergyResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/AllergyResource1_8.java deleted file mode 100644 index 9892c90e4..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/AllergyResource1_8.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.ObjectProperty; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; -import org.openmrs.Patient; -import org.openmrs.activelist.Allergy; -import org.openmrs.activelist.AllergySeverity; -import org.openmrs.activelist.AllergyType; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; -import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; - -/** - * {@link Resource} for Allergy, supporting standard CRUD operations - */ -@Resource(name = RestConstants.VERSION_1 + "/allergy", supportedClass = Allergy.class, supportedOpenmrsVersions = { "1.8.*" }) -public class AllergyResource1_8 extends BaseActiveListItemResource1_8 { - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) - */ - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); - description.addProperty("allergyType"); - description.addProperty("reaction", Representation.REF); - description.addProperty("severity"); - description.addProperty("allergen", Representation.REF); - return description; - } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); - description.addProperty("allergyType"); - description.addProperty("reaction", Representation.DEFAULT); - description.addProperty("severity"); - description.addProperty("allergen", Representation.DEFAULT); - return description; - } - return null; - } - - @Override - public Model getGETModel(Representation rep) { - ModelImpl model = ((ModelImpl) super.getGETModel(rep)) - .property("allergyType", new EnumProperty(AllergyType.class)) - .property("reaction", new RefProperty("#/definitions/ConceptGetRef")) - .property("severity", new EnumProperty(AllergySeverity.class)) - .property("allergen", new RefProperty("#/definitions/ConceptGetRef")); - if (rep instanceof FullRepresentation) { - model - .property("reaction", new RefProperty("#/definitions/ConceptGet")) - .property("allergen", new RefProperty("#/definitions/ConceptGet")); - } - return model; - } - - @Override - public Model getCREATEModel(Representation rep) { - return ((ModelImpl) super.getCREATEModel(rep)) - .property("allergyType", new EnumProperty(AllergyType.class)) - .property("reaction", new ObjectProperty() - .property("uuid", new StringProperty())) - .property("severity", new EnumProperty(AllergySeverity.class)) - .property("allergen", new StringProperty()); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() - */ - @Override - public Allergy newDelegate() { - return new Allergy(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = super.getCreatableProperties(); - description.addRequiredProperty("allergyType"); - description.addRequiredProperty("allergen"); - description.addProperty("reaction"); - description.addProperty("severity"); - - return description; - } - - /** - * Display string for allergy - * - * @param allergy - * @return String ConceptName - */ - @PropertyGetter("display") - public String getDisplayString(Allergy allergy) { - if (allergy.getAllergen() == null) - return ""; - - return allergy.getAllergen().getName().toString(); - } - - /** - * Annotated setter for allergen - * - * @param allergen - * @param value - */ - @PropertySetter("allergen") - public static void setAllergen(Allergy allergy, Object value) { - allergy.setAllergen(Context.getConceptService().getConceptByUuid((String) value)); - } - - /** - * Gets allergies for a given patient (paged according to context if necessary) only if a - * patient parameter exists in the request set on the {@link RequestContext} - * - * @param context - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(RequestContext) - */ - @Override - protected PageableResult doSearch(RequestContext context) { - String patientUuid = context.getRequest().getParameter("patient"); - if (patientUuid != null) { - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( - Patient.class)).getByUniqueId(patientUuid); - if (patient == null) - return new EmptySearchResult(); - - return new NeedsPaging(Context.getPatientService().getAllergies(patient), context); - } - - //currently this is not supported since the superclass throws an exception - return super.doSearch(context); - } - -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDescriptionResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDescriptionResource1_8.java deleted file mode 100644 index d5465bd38..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDescriptionResource1_8.java +++ /dev/null @@ -1,215 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import java.util.ArrayList; -import java.util.List; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.StringProperty; -import org.openmrs.Concept; -import org.openmrs.ConceptDescription; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.annotation.SubResource; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.RefRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.response.ResponseException; - -/** - * {@link Resource} for {@link ConceptDescription}, supporting standard CRUD operations - */ -@SubResource(parent = ConceptResource1_8.class, path = "description", supportedClass = ConceptDescription.class, supportedOpenmrsVersions = "1.8.*") -public class ConceptDescriptionResource1_8 extends DelegatingSubResource { - - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof RefRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addSelfLink(); - return description; - } else if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("display"); - description.addProperty("uuid"); - description.addProperty("description"); - description.addProperty("locale"); - description.addSelfLink(); - description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); - return description; - } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("description"); - description.addProperty("locale"); - description.addProperty("auditInfo"); - description.addSelfLink(); - return description; - } - return null; - } - - public Model getGETModel(Representation rep) { - ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); - if (rep instanceof RefRepresentation) { - modelImpl - .property("uuid", new StringProperty()) - .property("display", new StringProperty()); - } else if (rep instanceof DefaultRepresentation) { - modelImpl - .property("uuid", new StringProperty()) - .property("display", new StringProperty()) - .property("description", new StringProperty()) - .property("locale", new StringProperty()); - } else if (rep instanceof FullRepresentation) { - modelImpl - .property("uuid", new StringProperty()) - .property("display", new StringProperty()) - .property("description", new StringProperty()) - .property("locale", new StringProperty()); - } - return modelImpl; - } - - @Override - public Model getCREATEModel(Representation representation) { - return new ModelImpl() - .property("description", new StringProperty()) - .property("locale", new StringProperty().example("fr")) - .required("description").required("locale"); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addRequiredProperty("description"); - description.addRequiredProperty("locale"); - return description; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object) - */ - @Override - public Concept getParent(ConceptDescription instance) { - return instance.getConcept(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#setParent(java.lang.Object, - * java.lang.Object) - */ - @Override - public void setParent(ConceptDescription instance, Concept concept) { - instance.setConcept(concept); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.api.SubResource#doGetAll(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public NeedsPaging doGetAll(Concept parent, RequestContext context) throws ResponseException { - //convert from a collection to a list - List descriptions = new ArrayList(); - if (parent != null) { - for (ConceptDescription description : parent.getDescriptions()) { - descriptions.add(description); - } - } - return new NeedsPaging(descriptions, context); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) - */ - @Override - public ConceptDescription getByUniqueId(String uuid) { - return Context.getConceptService().getConceptDescriptionByUuid(uuid); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#delete(java.lang.Object, - * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void delete(ConceptDescription cd, String reason, RequestContext context) throws ResponseException { - //concept descriptions are neither voidable nor retireable, so delegate to purge - purge(cd, context); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void purge(ConceptDescription cd, RequestContext context) throws ResponseException { - cd.getConcept().removeDescription(cd); - Context.getConceptService().saveConcept(cd.getConcept()); - } - - /** - * @param newDescription - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) - */ - @Override - public ConceptDescription save(ConceptDescription newDescription) { - newDescription.getConcept().addDescription(newDescription); - Context.getConceptService().saveConcept(newDescription.getConcept()); - return newDescription; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() - */ - @Override - public ConceptDescription newDelegate() { - return new ConceptDescription(); - } - - /** - * Gets the display string for a concept description including its locale. - * - * @param conceptDescription the concept description object. - * @return the display string. - */ - @PropertyGetter("display") - public String getDisplayString(ConceptDescription conceptDescription) { - return conceptDescription.getDescription(); - } - - /** - * Returns the locale as a string - * - * @param instance - * @return - */ - @PropertyGetter("locale") - public String getLocaleAsString(ConceptDescription instance) { - if (instance.getLocale() == null) - return ""; - - return instance.getLocale().toString(); - } -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptMapResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptMapResource1_8.java deleted file mode 100644 index 798d54364..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptMapResource1_8.java +++ /dev/null @@ -1,191 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import java.util.ArrayList; -import java.util.List; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.StringProperty; -import org.openmrs.Concept; -import org.openmrs.ConceptMap; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.annotation.SubResource; -import org.openmrs.module.webservices.rest.web.api.RestHelperService; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; -import org.openmrs.module.webservices.rest.web.response.ResponseException; - -/** - * {@link Resource} for ConceptMaps, supporting standard CRUD operations - */ -@SubResource(path = "mapping", parent = ConceptResource1_8.class, supportedClass = ConceptMap.class, supportedOpenmrsVersions = "1.8.*") -public class ConceptMapResource1_8 extends DelegatingSubResource { - - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("display"); - description.addProperty("uuid"); - description.addProperty("source", Representation.REF); - description.addProperty("sourceCode"); - description.addSelfLink(); - description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); - return description; - } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("display"); - description.addProperty("uuid"); - description.addProperty("source", Representation.DEFAULT); - description.addProperty("sourceCode"); - description.addProperty("comment"); - description.addProperty("auditInfo"); - description.addSelfLink(); - return description; - } - return null; - } - - public Model getGETModel(Representation rep) { - ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); - if (rep instanceof DefaultRepresentation) { - modelImpl - .property("display", new StringProperty()) - .property("uuid", new StringProperty()) - .property("source", new StringProperty()) //FIXME - .property("sourceCode", new StringProperty()); - } else if (rep instanceof FullRepresentation) { - modelImpl - .property("display", new StringProperty()) - .property("uuid", new StringProperty()) - .property("source", new StringProperty()) //FIXME - .property("sourceCode", new StringProperty()) - .property("comment", new StringProperty()); - } - return modelImpl; - } - - @Override - public Model getCREATEModel(Representation representation) { - return new ModelImpl() - .property("source", new StringProperty()) - .property("sourceCode", new StringProperty()) - .required("source").required("sourceCode"); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addRequiredProperty("source"); - description.addRequiredProperty("sourceCode"); - return description; - } - - /** - * Gets the display string for a concept map. - * - * @param conceptMap the concept map object. - * @return the display string. - */ - @PropertyGetter("display") - public String getDisplayString(ConceptMap conceptMap) { - if (conceptMap.getSource() == null) { - return ""; - } - return conceptMap.getSource().getName() + ":" + conceptMap.getSourceCode(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#newDelegate() - */ - @Override - public ConceptMap newDelegate() { - return new ConceptMap(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) - */ - @Override - public ConceptMap save(ConceptMap newMap) { - newMap.getConcept().addConceptMapping(newMap); - Context.getConceptService().saveConcept(newMap.getConcept()); - return newMap; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object) - */ - @Override - public Concept getParent(ConceptMap instance) { - return instance.getConcept(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#setParent(java.lang.Object, - * java.lang.Object) - */ - @Override - public void setParent(ConceptMap instance, Concept parent) { - instance.setConcept(parent); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#doGetAll(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public PageableResult doGetAll(Concept parent, RequestContext context) throws ResponseException { - List maps = new ArrayList(parent.getConceptMappings()); - return new NeedsPaging(maps, context); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) - */ - @Override - public ConceptMap getByUniqueId(String uniqueId) { - return Context.getService(RestHelperService.class).getObjectByUuid(ConceptMap.class, uniqueId); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#delete(java.lang.Object, - * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected void delete(ConceptMap delegate, String reason, RequestContext context) throws ResponseException { - throw new ResourceDoesNotSupportOperationException(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void purge(ConceptMap delegate, RequestContext context) throws ResponseException { - delegate.getConcept().removeConceptMapping(delegate); - } - -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptNameResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptNameResource1_8.java deleted file mode 100644 index 8088f9f54..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptNameResource1_8.java +++ /dev/null @@ -1,233 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.BooleanProperty; -import io.swagger.models.properties.StringProperty; -import org.openmrs.Concept; -import org.openmrs.ConceptName; -import org.openmrs.api.ConceptNameType; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.annotation.SubResource; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.response.ResponseException; - -/** - * {@link Resource} for ConceptNames, supporting standard CRUD operations - */ - -@SubResource(parent = ConceptResource1_8.class, path = "name", supportedClass = ConceptName.class, supportedOpenmrsVersions = "1.8.*") -public class ConceptNameResource1_8 extends DelegatingSubResource { - - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("display"); - description.addProperty("uuid"); - description.addProperty("name"); - description.addProperty("locale"); - description.addProperty("localePreferred"); - description.addProperty("conceptNameType"); - description.addSelfLink(); - description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); - return description; - } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("display"); - description.addProperty("uuid"); - description.addProperty("name"); - description.addProperty("locale"); - description.addProperty("localePreferred"); - description.addProperty("conceptNameType"); - description.addProperty("auditInfo"); - description.addSelfLink(); - return description; - } - return null; - } - - public Model getGETModel(Representation rep) { - ModelImpl model = ((ModelImpl) super.getGETModel(rep)) - .property("uuid", new StringProperty()) - .property("display", new StringProperty()); - - if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { - model - .property("name", new StringProperty()) - .property("locale", new StringProperty().example("en")) - .property("localePreferred", new BooleanProperty()) - .property("conceptNameType", new EnumProperty(ConceptNameType.class)); - } - return model; - } - - @Override - public Model getCREATEModel(Representation rep) { - return new ModelImpl() - .property("name", new StringProperty()) - .property("locale", new StringProperty().example("en")) - .property("localePreferred", new BooleanProperty()._default(false)) - .property("conceptNameType", new EnumProperty(ConceptNameType.class)) - .required("name").required("locale"); - } - - @Override - public Model getUPDATEModel(Representation representation) { - return new ModelImpl() - .property("name", new StringProperty()); //FIXME missing props - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addRequiredProperty("name"); - description.addRequiredProperty("locale"); - description.addProperty("localePreferred"); - description.addProperty("conceptNameType"); - return description; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object) - */ - @Override - public Concept getParent(ConceptName instance) { - return instance.getConcept(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#setParent(java.lang.Object, - * java.lang.Object) - */ - @Override - public void setParent(ConceptName instance, Concept concept) { - instance.setConcept(concept); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.api.SubResource#doGetAll(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public NeedsPaging doGetAll(Concept parent, RequestContext context) throws ResponseException { - List names = new ArrayList(); - if (parent != null) { - for (ConceptName name : parent.getNames()) { - if (!name.isVoided()) - names.add(name); - } - } - return new NeedsPaging(names, context); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) - */ - @Override - public ConceptName getByUniqueId(String uuid) { - return Context.getConceptService().getConceptNameByUuid(uuid); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#delete(java.lang.Object, - * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void delete(ConceptName cn, String reason, RequestContext context) throws ResponseException { - cn.setVoided(true); - cn.setVoidedBy(Context.getAuthenticatedUser()); - cn.setVoidReason(reason); - cn.setDateVoided(new Date()); - Context.getConceptService().saveConcept(cn.getConcept()); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void purge(ConceptName cn, RequestContext context) throws ResponseException { - cn.getConcept().removeName(cn); - Context.getConceptService().saveConcept(cn.getConcept()); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) - */ - @Override - public ConceptName save(ConceptName newName) { - // make sure that the name has actually been added to the concept - boolean needToAdd = true; - for (ConceptName cn : newName.getConcept().getNames()) { - if (cn.equals(newName)) { - needToAdd = false; - break; - } - } - if (needToAdd) - newName.getConcept().addName(newName); - Context.getConceptService().saveConcept(newName.getConcept()); - return newName; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() - */ - @Override - public ConceptName newDelegate() { - return new ConceptName(); - } - - /** - * Gets the display string for a concept name. - * - * @param conceptName the concept name object. - * @return the display string. - */ - @PropertyGetter("display") - public String getDisplayString(ConceptName conceptName) { - return conceptName.getName(); - } - - /** - * Gets the locale as a string - * - * @param instance - * @return - */ - @PropertyGetter("locale") - public String getLocaleAsString(ConceptName instance) { - - if (instance.getLocale() == null) - return ""; - - return instance.getLocale().toString(); - } -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptResource1_8.java deleted file mode 100644 index 9c2042dc9..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptResource1_8.java +++ /dev/null @@ -1,716 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.BooleanProperty; -import io.swagger.models.properties.ObjectProperty; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; -import org.apache.commons.lang.StringUtils; -import org.openmrs.Concept; -import org.openmrs.ConceptAnswer; -import org.openmrs.ConceptClass; -import org.openmrs.ConceptDatatype; -import org.openmrs.ConceptDescription; -import org.openmrs.ConceptMap; -import org.openmrs.ConceptName; -import org.openmrs.ConceptNumeric; -import org.openmrs.ConceptSearchResult; -import org.openmrs.Drug; -import org.openmrs.api.ConceptService; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.helper.HibernateCollectionHelper; -import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.ConversionUtil; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; -import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; -import org.openmrs.module.webservices.rest.web.annotation.RepHandler; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.NamedRepresentation; -import org.openmrs.module.webservices.rest.web.representation.RefRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; -import org.openmrs.module.webservices.rest.web.resource.impl.AlreadyPaged; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.response.ConversionException; -import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; -import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.util.LocaleUtility; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Date; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Objects; -import java.util.Set; - -/** - * {@link Resource} for {@link Concept}, supporting standard CRUD operations - */ -@Resource(name = RestConstants.VERSION_1 + "/concept", order = 2, supportedClass = Concept.class, supportedOpenmrsVersions = "1.8.*") -public class ConceptResource1_8 extends DelegatingCrudResource { - - public ConceptResource1_8() { - //RESTWS-439 - //Concept numeric fields - allowedMissingProperties.add("hiNormal"); - allowedMissingProperties.add("hiAbsolute"); - allowedMissingProperties.add("hiCritical"); - allowedMissingProperties.add("lowNormal"); - allowedMissingProperties.add("lowAbsolute"); - allowedMissingProperties.add("lowCritical"); - allowedMissingProperties.add("units"); - allowedMissingProperties.add("precise"); - allowedMissingProperties.add("allowDecimal"); - allowedMissingProperties.add("displayPrecision"); - } - - @RepHandler(RefRepresentation.class) - public SimpleObject asRef(Concept delegate) throws ConversionException { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display", "displayString", Representation.DEFAULT); - if (delegate.isRetired()) { - description.addProperty("retired"); - } - description.addSelfLink(); - return convertDelegateToRepresentation(delegate, description); - } - - @RepHandler(FullRepresentation.class) - public SimpleObject asFull(Concept delegate) throws ConversionException { - DelegatingResourceDescription description = fullRepresentationDescription(delegate); - return convertDelegateToRepresentation(delegate, description); - } - - @RepHandler(value = NamedRepresentation.class, name = "fullchildren") - public SimpleObject asFullChildren(Concept delegate) throws ConversionException { - Set path = new HashSet(); - path.add(delegate.getUuid()); - assertNoCycles(delegate, path); - - return asFullChildrenInternal(delegate); - } - - protected void assertNoCycles(Concept delegate, Set path) throws ConversionException { - for (Concept member : delegate.getSetMembers()) { - if (path.add(member.getUuid())) { - assertNoCycles(member, path); - } else { - throw new ConversionException("Cycles in children are not supported. Concept with uuid " - + delegate.getUuid() + " repeats in a set."); - } - path.remove(member.getUuid()); - } - } - - /** - * It is used internally for the fullchildren representation. Contrary to the fullchildren - * handler it does not check for cycles. - * - * @param delegate - * @return - * @throws ConversionException - */ - @RepHandler(value = NamedRepresentation.class, name = "fullchildreninternal") - public SimpleObject asFullChildrenInternal(Concept delegate) throws ConversionException { - DelegatingResourceDescription description = fullRepresentationDescription(delegate); - description.removeProperty("setMembers"); - description.addProperty("setMembers", new NamedRepresentation("fullchildreninternal")); - description.removeProperty("answers"); - description.addProperty("answers", Representation.FULL); - return convertDelegateToRepresentation(delegate, description); - } - - @Override - public List getAvailableRepresentations() { - List availableRepresentations = super.getAvailableRepresentations(); - availableRepresentations.add(new NamedRepresentation("fullchildren")); - return availableRepresentations; - } - - protected DelegatingResourceDescription fullRepresentationDescription(Concept delegate) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("name", Representation.DEFAULT); - description.addProperty("datatype", Representation.DEFAULT); - description.addProperty("conceptClass", Representation.DEFAULT); - description.addProperty("set"); - description.addProperty("version"); - description.addProperty("retired"); - - description.addProperty("names", Representation.DEFAULT); - description.addProperty("descriptions", Representation.DEFAULT); - - description.addProperty("mappings", Representation.DEFAULT); - - description.addProperty("answers", Representation.DEFAULT); - description.addProperty("setMembers", Representation.DEFAULT); - description.addProperty("auditInfo"); - description.addSelfLink(); - if (delegate.isNumeric()) { - description.addProperty("hiNormal"); - description.addProperty("hiAbsolute"); - description.addProperty("hiCritical"); - description.addProperty("lowNormal"); - description.addProperty("lowAbsolute"); - description.addProperty("lowCritical"); - description.addProperty("units"); - description.addProperty("precise"); - } - return description; - } - - /** - * @see DelegatingCrudResource#getRepresentationDescription(Representation) - */ - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("name", Representation.DEFAULT); - description.addProperty("datatype", Representation.REF); - description.addProperty("conceptClass", Representation.REF); - description.addProperty("set"); - description.addProperty("version"); - description.addProperty("retired"); - - description.addProperty("names", Representation.REF); - description.addProperty("descriptions", Representation.REF); - - description.addProperty("mappings", Representation.REF); - - description.addProperty("answers", Representation.REF); - description.addProperty("setMembers", Representation.REF); - //description.addProperty("conceptMappings", Representation.REF); add as subresource - - description.addSelfLink(); - description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); - return description; - } - return null; - } - - public Model getGETModel(Representation rep) { - ModelImpl modelImpl = ((ModelImpl) super.getGETModel(rep)) - .property("uuid", new StringProperty()) - .property("display", new StringProperty()); - if (rep instanceof DefaultRepresentation) { - modelImpl - .property("name", new RefProperty("#/definitions/ConceptNameGet")) - .property("datatype", new RefProperty("#/definitions/ConceptdatatypeGetRef")) - .property("conceptClass", new RefProperty("#/definitions/ConceptclassGetRef")) - .property("set", new BooleanProperty()) - .property("version", new StringProperty()) - .property("retired", new BooleanProperty()) - .property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameGetRef"))) //FIXME - .property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionGetRef"))) //FIXME - .property("mappings", new ArrayProperty(new RefProperty("#/definitions/ConceptMappingGetRef"))) //FIXME - .property("answers", new ArrayProperty(new ObjectProperty())) //FIXME - .property("setMembers", new ArrayProperty(new ObjectProperty())); //FIXME - } - return modelImpl; - } - - @Override - public Model getCREATEModel(Representation rep) { - ModelImpl model = new ModelImpl() - .property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameCreate"))) - .property("datatype", new StringProperty().example("uuid")) - .property("set", new BooleanProperty()) - .property("version", new StringProperty()) - .property("answers", new ArrayProperty(new StringProperty().example("uuid"))) - .property("setMembers", new ArrayProperty(new StringProperty().example("uuid"))) - - //ConceptNumeric properties - .property("hiNormal", new StringProperty()) - .property("hiAbsolute", new StringProperty()) - .property("hiCritical", new StringProperty()) - .property("lowNormal", new StringProperty()) - .property("lowAbsolute", new StringProperty()) - .property("lowCritical", new StringProperty()) - .property("units", new StringProperty()) - .property("allowDecimal", new StringProperty()) - .property("displayPrecision", new StringProperty()) - - .required("names").required("datatype").required("conceptClass"); - if (rep instanceof DefaultRepresentation) { - model - .property("conceptClass", new StringProperty()) - .property("descriptions", new ArrayProperty(new StringProperty())) - .property("mappings", new ArrayProperty(new StringProperty())); - } - else if (rep instanceof FullRepresentation) { - model - .property("conceptClass", new RefProperty("#/definitions/ConceptclassCreate")) - .property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionCreate"))) - .property("mappings", new ArrayProperty(new RefProperty("#/definitions/ConceptMappingCreate"))); - } - return model; - } - - @Override - public Model getUPDATEModel(Representation representation) { - return new ModelImpl() - .property("name", new RefProperty("#/definitions/ConceptNameCreate")) - .property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameCreate"))) - .property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionCreate"))); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addRequiredProperty("names"); - description.addRequiredProperty("datatype"); - description.addRequiredProperty("conceptClass"); - - description.addProperty("descriptions"); - description.addProperty("set"); - description.addProperty("version"); - description.addProperty("mappings"); - description.addProperty("answers"); - description.addProperty("setMembers"); - - //ConceptNumeric properties - description.addProperty("hiNormal"); - description.addProperty("hiAbsolute"); - description.addProperty("hiCritical"); - description.addProperty("lowNormal"); - description.addProperty("lowAbsolute"); - description.addProperty("lowCritical"); - description.addProperty("units"); - description.addProperty("allowDecimal"); - description.addProperty("displayPrecision"); - return description; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties() - */ - @Override - public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException { - DelegatingResourceDescription description = super.getUpdatableProperties(); - - description.addProperty("name"); - description.addProperty("names"); - description.addProperty("descriptions"); - - return description; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getPropertiesToExposeAsSubResources() - */ - @Override - public List getPropertiesToExposeAsSubResources() { - return Arrays.asList("names", "descriptions", "conceptMappings"); - } - - /** - * Sets the name property to be the fully specified name of the Concept in the current locale - * - * @param instance - * @param name - */ - @PropertySetter("name") - public static void setFullySpecifiedName(Concept instance, String name) { - ConceptName fullySpecifiedName = new ConceptName(name, Context.getLocale()); - instance.setFullySpecifiedName(fullySpecifiedName); - } - - /** - * It's needed, because of ConversionException: Don't know how to handle collection class: - * interface java.util.Collection If request to update Concept updates ConceptName, adequate - * resource takes care of it, so this method just adds new and removes deleted names. - * - * @param instance - * @param names - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalAccessException - */ - @PropertySetter("names") - public static void setNames(Concept instance, List names) throws IllegalAccessException, - InvocationTargetException, NoSuchMethodException { - - new HibernateCollectionHelper( - instance) { - - @Override - public int compare(ConceptName left, ConceptName right) { - if (Objects.equals(left.getUuid(), right.getUuid())) { - return 0; - } - boolean areEqual = (Objects.equals(left.getName(), right.getName()) - && Objects.equals(left.getConceptNameType(), right.getConceptNameType()) && Objects.equals( - left.getLocale(), right.getLocale())); - return areEqual ? 0 : 1; - } - - @Override - public Collection getAll() { - return instance.getNames(); - } - - @Override - public void add(ConceptName item) { - instance.addName(item); - } - - @Override - public void remove(ConceptName item) { - instance.removeName(item); - } - }.set(names); - } - - /** - * It's needed, because of ConversionException: Don't know how to handle collection class: - * interface java.util.Collection - * - * @param instance - * @param descriptions - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws IllegalAccessException - */ - @PropertySetter("descriptions") - public static void setDescriptions(Concept instance, List descriptions) - throws IllegalAccessException, InvocationTargetException, NoSuchMethodException { - - new HibernateCollectionHelper( - instance) { - - @Override - public int compare(ConceptDescription left, ConceptDescription right) { - if (Objects.equals(left.getUuid(), right.getUuid())) { - return 0; - } - boolean areEqual = (Objects.equals(left.getDescription(), right.getDescription()) && Objects.equals( - left.getLocale(), right.getLocale())); - return areEqual ? 0 : 1; - } - - @Override - public Collection getAll() { - return instance.getDescriptions(); - } - - @Override - public void add(ConceptDescription item) { - instance.addDescription(item); - } - - @Override - public void remove(ConceptDescription item) { - instance.removeDescription(item); - } - }.set(descriptions); - } - - /** - * It's needed, because of ConversionException: Don't know how to handle collection class: - * interface java.util.Collection - * - * @param instance - * @param mappings - */ - @PropertySetter("mappings") - public static void setMappings(Concept instance, List mappings) { - instance.getConceptMappings().clear(); - for (ConceptMap map : mappings) { - instance.addConceptMapping(map); - } - } - - @PropertyGetter("mappings") - public static List getMappings(Concept instance) { - return new ArrayList(instance.getConceptMappings()); - } - - /** - * Gets the display name of the Concept delegate - * - * @param instance the delegate instance to get the display name off - */ - @PropertyGetter("display") - public String getDisplayString(Concept instance) { - String localization = getLocalization("Concept", instance.getUuid()); - if (StringUtils.isNotBlank(localization)) { - return localization; - } else { - ConceptName cn = instance.getName(); - if (cn != null) { - return cn.getName(); - } else { - return instance.toString(); - } - } - } - - /** - * {@link #newDelegate(SimpleObject)} is used instead to support ConceptNumeric - * - * @see DelegatingCrudResource#newDelegate() - */ - @Override - public Concept newDelegate() { - throw new ResourceDoesNotSupportOperationException("Should use newDelegate(SimpleObject) instead"); - } - - @Override - public Concept newDelegate(SimpleObject object) { - String datatypeUuid = (String) object.get("datatype"); - if (ConceptDatatype.NUMERIC_UUID.equals(datatypeUuid)) { - return new ConceptNumeric(); - } else { - return new Concept(); - } - } - - /** - * @see DelegatingCrudResource#save(java.lang.Object) - */ - @Override - public Concept save(Concept c) { - return Context.getConceptService().saveConcept(c); - } - - /** - * Fetches a concept by uuid - * - * @see DelegatingCrudResource#getByUniqueId(java.lang.String) - */ - @Override - public Concept getByUniqueId(String uuid) { - return Context.getConceptService().getConceptByUuid(uuid); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void purge(Concept concept, RequestContext context) throws ResponseException { - if (concept == null) - return; - Context.getConceptService().purgeConcept(concept); - } - - /** - * This does not include retired concepts - * - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected NeedsPaging doGetAll(RequestContext context) { - List allConcepts = Context.getConceptService().getAllConcepts(null, true, context.getIncludeAll()); - return new NeedsPaging(allConcepts, context); - } - - /** - * Concept searches support the following additional query parameters: - *
    - *
  • answerTo=(uuid): restricts results to concepts that are answers to the given concept uuid - *
  • - *
  • memberOf=(uuid): restricts to concepts that are set members of the given concept set's - * uuid
  • - *
- * - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(RequestContext) - */ - @Override - protected PageableResult doSearch(RequestContext context) { - ConceptService service = Context.getConceptService(); - Integer startIndex = null; - Integer limit = null; - boolean canPage = true; - - // Collect information for answerTo and memberOf query parameters - String answerToUuid = context.getRequest().getParameter("answerTo"); - String memberOfUuid = context.getRequest().getParameter("memberOf"); - Concept answerTo = null; - List memberOfList = null; - if (StringUtils.isNotBlank(answerToUuid)) { - try { - answerTo = (Concept) ConversionUtil.convert(answerToUuid, Concept.class); - } - catch (ConversionException ex) { - log.error("Unexpected exception while retrieving answerTo Concept with UUID " + answerToUuid, ex); - } - } - - if (StringUtils.isNotBlank(memberOfUuid)) { - Concept memberOf = service.getConceptByUuid(memberOfUuid); - memberOfList = service.getConceptsByConceptSet(memberOf); - canPage = false; // ConceptService does not support memberOf searches, so paging must be deferred. - } - - // Only set startIndex and limit if we can return paged results - if (canPage) { - startIndex = context.getStartIndex(); - limit = context.getLimit(); - } - - List searchResults; - - // get the user's locales...and then convert that from a set to a list - List locales = new ArrayList(LocaleUtility.getLocalesInOrder()); - - searchResults = service.getConcepts(context.getParameter("q"), locales, context.getIncludeAll(), null, null, null, - null, answerTo, startIndex, limit); - - // convert search results into list of concepts - List results = new ArrayList(searchResults.size()); - for (ConceptSearchResult csr : searchResults) { - // apply memberOf filter - if (memberOfList == null || memberOfList.contains(csr.getConcept())) - results.add(csr.getConcept()); - } - - PageableResult result = null; - if (canPage) { - Integer count = service.getCountOfConcepts(context.getParameter("q"), locales, false, - Collections. emptyList(), Collections. emptyList(), - Collections. emptyList(), Collections. emptyList(), answerTo); - boolean hasMore = count > startIndex + limit; - result = new AlreadyPaged(context, results, hasMore, Long.valueOf(count)); - } else { - result = new NeedsPaging(results, context); - } - - return result; - } - - @Override - protected void delete(Concept c, String reason, RequestContext context) throws ResponseException { - if (c.isRetired()) { - // since DELETE should be idempotent, we return success here - return; - } - Context.getConceptService().retireConcept(c, reason); - } - - /** - * @param instance - * @return the list of Concepts or Drugs - */ - @PropertyGetter("answers") - public static Object getAnswers(Concept instance) { - List conceptAnswers = new ArrayList(); - conceptAnswers.addAll(instance.getAnswers(false)); - Collections.sort(conceptAnswers); - - List answers = new ArrayList(); - for (ConceptAnswer conceptAnswer : conceptAnswers) { - if (conceptAnswer.getAnswerDrug() != null) { - answers.add(conceptAnswer.getAnswerDrug()); - } else if (conceptAnswer.getAnswerConcept() != null) { - answers.add(conceptAnswer.getAnswerConcept()); - } - } - - return answers; - } - - /** - * @param instance - * @param answerUuids the list of Concepts or Drugs - * @throws ResourceDoesNotSupportOperationException - */ - @PropertySetter("answers") - public static void setAnswers(Concept instance, List answerUuids /*Concept or Drug uuid*/) - throws ResourceDoesNotSupportOperationException { - - // remove answers that are not in the new list - Iterator iterator = instance.getAnswers(false).iterator(); - while (iterator.hasNext()) { - ConceptAnswer answer = iterator.next(); - String conceptUuid = answer.getConcept().getUuid(); - String drugUuid = (answer.getAnswerDrug() != null) ? answer.getAnswerDrug().getUuid() : null; - if (answerUuids.contains(conceptUuid)) { - answerUuids.remove(conceptUuid); // remove from passed in list - } else if (answerUuids.contains(drugUuid)) { - answerUuids.remove(drugUuid); // remove from passed in list - } else { - instance.removeAnswer(answer); // remove from concept question object - } - } - - List answerObjects = new ArrayList(answerUuids.size()); - for (String uuid : answerUuids) { - Concept c = Context.getConceptService().getConceptByUuid(uuid); - if (c != null) { - answerObjects.add(c); - } else { - // it is a drug - Drug drug = Context.getConceptService().getDrugByUuid(uuid); - if (drug != null) - answerObjects.add(drug); - else - throw new ResourceDoesNotSupportOperationException("There is no concept or drug with given uuid: " - + uuid); - } - } - - // add in new answers - for (Object obj : answerObjects) { - ConceptAnswer answerToAdd = null; - if (obj.getClass().isAssignableFrom(Concept.class)) - answerToAdd = new ConceptAnswer((Concept) obj); - else - answerToAdd = new ConceptAnswer(((Drug) obj).getConcept(), (Drug) obj); - - answerToAdd.setCreator(Context.getAuthenticatedUser()); - answerToAdd.setDateCreated(new Date()); - instance.addAnswer(answerToAdd); - } - } - - /** - * @param instance - * @param setMembers the list of Concepts - */ - @PropertySetter("setMembers") - public static void setSetMembers(Concept instance, List setMembers) { - instance.getConceptSets().clear(); - - if (setMembers == null || setMembers.isEmpty()) { - instance.setSet(false); - } else { - instance.setSet(true); - - for (Concept setMember : setMembers) { - instance.addSetMember(setMember); - } - } - } -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterResource1_8.java deleted file mode 100644 index d28dcce52..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterResource1_8.java +++ /dev/null @@ -1,291 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.BooleanProperty; -import io.swagger.models.properties.DateProperty; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; -import org.openmrs.Encounter; -import org.openmrs.Obs; -import org.openmrs.Order; -import org.openmrs.Patient; -import org.openmrs.api.EncounterService; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; -import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; -import org.openmrs.module.webservices.rest.web.resource.impl.DataDelegatingCrudResource; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.resource.impl.ServiceSearcher; -import org.openmrs.module.webservices.rest.web.response.ResponseException; - -import java.util.Date; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; - -/** - * Resource for Encounters, supporting standard CRUD operations - */ -@Resource(name = RestConstants.VERSION_1 + "/encounter", supportedClass = Encounter.class, supportedOpenmrsVersions = "1.8.*") -public class EncounterResource1_8 extends DataDelegatingCrudResource { - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) - */ - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("encounterDatetime"); - description.addProperty("patient", Representation.REF); - description.addProperty("location", Representation.REF); - description.addProperty("form", Representation.REF); - description.addProperty("encounterType", Representation.REF); - description.addProperty("provider", Representation.REF); - description.addProperty("obs", Representation.REF); - description.addProperty("orders", Representation.REF); - description.addProperty("voided"); - description.addSelfLink(); - description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); - return description; - } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("encounterDatetime"); - description.addProperty("patient", Representation.REF); - description.addProperty("location"); - description.addProperty("form"); - description.addProperty("encounterType"); - description.addProperty("provider"); - description.addProperty("obs"); - description.addProperty("orders"); - description.addProperty("voided"); - description.addProperty("auditInfo"); - description.addSelfLink(); - return description; - } - return null; - } - - public Model getGETModel(Representation rep) { - ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); - if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { - modelImpl - .property("uuid", new StringProperty()) - .property("display", new StringProperty()) - .property("encounterDatetime", new DateProperty()) - .property("provider", new StringProperty()) //FIXME - .property("voided", new BooleanProperty()); - } - if (rep instanceof DefaultRepresentation) { - modelImpl - .property("patient", new RefProperty("#/definitions/PatientGetRef")) //FIXME - .property("location", new RefProperty("#/definitions/LocationGetRef")) //FIXME - .property("form", new RefProperty("#/definitions/FormGetRef")) //FIXME - .property("encounterType", new RefProperty("#/definitions/EncountertypeGetRef")) //FIXME - .property("obs", new ArrayProperty(new RefProperty("#/definitions/ObsGetRef"))) //FIXME - .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderGetRef"))); //FIXME - } else if (rep instanceof FullRepresentation) { - modelImpl - .property("patient", new RefProperty("#/definitions/PatientGet")) //FIXME - .property("location", new RefProperty("#/definitions/LocationGet")) //FIXME - .property("form", new RefProperty("#/definitions/FormGet")) //FIXME - .property("encounterType", new RefProperty("#/definitions/EncountertypeGet")) //FIXME - .property("obs", new ArrayProperty(new RefProperty("#/definitions/ObsGet"))) //FIXME - .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderGet"))); //FIXME - } - return modelImpl; - } - - @Override - public Model getCREATEModel(Representation rep) { - return new ModelImpl() - .property("patient", new RefProperty("#/definitions/PatientCreate")) - .property("encounterType", new RefProperty("#/definitions/EncountertypeCreate")) - .property("encounterDatetime", new DateProperty()) - .property("location", new RefProperty("#/definitions/LocationCreate")) - .property("form", new RefProperty("#/definitions/FormCreate")) - .property("provider", new StringProperty()) - .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderCreate"))) - .property("obs", new ArrayProperty(new RefProperty("#/definitions/ObsCreate"))) - - .required("patient").required("encounterType"); - } - - @Override - public Model getUPDATEModel(Representation rep) { - return getCREATEModel(rep); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - * Should create an encounter type - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - - description.addProperty("encounterDatetime"); // has a default value set, hence not required here - description.addRequiredProperty("patient"); - description.addRequiredProperty("encounterType"); - - description.addProperty("location"); - description.addProperty("form"); - description.addProperty("provider"); - description.addProperty("orders"); - description.addProperty("obs"); - - return description; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#newDelegate() - */ - @Override - public Encounter newDelegate() { - Encounter enc = new Encounter(); - // default to now(), so a web client can create a real-time encounter based on the server time - enc.setEncounterDatetime(new Date()); - // As of 2012-04-27 there is a bug in Encounter.getOrders() where, if null, it returns an empty list without keeping a reference to it - enc.setOrders(new LinkedHashSet()); - return enc; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#save(org.openmrs.Encounter) - */ - @Override - public Encounter save(Encounter enc) { - return Context.getEncounterService().saveEncounter(enc); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getByUniqueId(java.lang.String) - */ - @Override - public Encounter getByUniqueId(String uuid) { - return Context.getEncounterService().getEncounterByUuid(uuid); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#delete(org.openmrs.Encounter, - * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void delete(Encounter enc, String reason, RequestContext context) throws ResponseException { - if (enc.isVoided()) { - // DELETE is idempotent, so we return success here - return; - } - Context.getEncounterService().voidEncounter(enc, reason); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#undelete(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected Encounter undelete(Encounter enc, RequestContext context) throws ResponseException { - if (enc.isVoided()) { - enc = Context.getEncounterService().unvoidEncounter(enc); - } - return enc; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(org.openmrs.Encounter, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void purge(Encounter enc, RequestContext context) throws ResponseException { - if (enc == null) { - // DELETE is idempotent, so we return success here - return; - } - Context.getEncounterService().purgeEncounter(enc); - } - - /** - * @param encounter - * @return encounter type and date - */ - @PropertyGetter("display") - public String getDisplayString(Encounter encounter) { - String ret = encounter.getEncounterType() == null ? "?" : encounter.getEncounterType().getName(); - ret += " "; - ret += encounter.getEncounterDatetime() == null ? "?" : Context.getDateFormat().format( - encounter.getEncounterDatetime()); - return ret; - } - - /** - * @param instance - * @return all non-voided top-level obs from the given encounter - */ - @PropertyGetter("obs") - public static Object getObsAtTopLevel(Encounter instance) { - return instance.getObsAtTopLevel(false); - } - - @PropertySetter("obs") - public static void setObs(Encounter instance, Set obs) { - instance.getAllObs(true).clear(); - for (Obs o : obs) - instance.addObs(o); - } - - @PropertySetter("orders") - public static void setOrders(Encounter instance, Set orders) { - for (Order o : orders) - instance.addOrder(o); - } - - /** - * Gets encounters for the given patient (paged according to context if necessary) only if a - * patient parameter exists in the request set on the {@link RequestContext} otherwise searches - * for encounters that match the specified query - * - * @param context - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected PageableResult doSearch(RequestContext context) { - String patientUuid = context.getRequest().getParameter("patient"); - if (patientUuid != null) { - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( - Patient.class)).getByUniqueId(patientUuid); - if (patient == null) - return new EmptySearchResult(); - List encs = Context.getEncounterService().getEncountersByPatient(patient); - return new NeedsPaging(encs, context); - } - - return new ServiceSearcher(EncounterService.class, "getEncounters", "getCountOfEncounters").search( - context.getParameter("q"), context); - } - -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8.java deleted file mode 100644 index 8f1e9894f..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8.java +++ /dev/null @@ -1,215 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.BooleanProperty; -import io.swagger.models.properties.IntegerProperty; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; -import org.openmrs.EncounterType; -import org.openmrs.Field; -import org.openmrs.Form; -import org.openmrs.FormField; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.response.ResponseException; - -import java.util.Arrays; -import java.util.List; - -/** - * {@link Resource} for {@link Form}, supporting standard CRUD operations - */ -@Resource(name = RestConstants.VERSION_1 + "/form", supportedClass = Form.class, supportedOpenmrsVersions = { "1.8.* - 9.*" }) -public class FormResource1_8 extends MetadataDelegatingCrudResource
{ - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) - */ - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("name"); - description.addProperty("description"); - description.addProperty("encounterType", Representation.REF); - description.addProperty("version"); - description.addProperty("build"); - description.addProperty("published"); - description.addProperty("formFields", Representation.REF); - description.addProperty("retired"); - description.addSelfLink(); - description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); - return description; - } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("name"); - description.addProperty("description"); - description.addProperty("encounterType"); - description.addProperty("version"); - description.addProperty("build"); - description.addProperty("published"); - description.addProperty("formFields"); - description.addProperty("retired"); - description.addProperty("auditInfo"); - description.addSelfLink(); - return description; - } - return null; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = super.getCreatableProperties(); - description.addRequiredProperty("version"); - - description.addProperty("encounterType"); - description.addProperty("build"); - description.addProperty("published"); - description.addProperty("formFields"); - description.addProperty("xslt"); - description.addProperty("template"); - - return description; - } - - @Override - public Model getGETModel(Representation rep) { - ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); - if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { - modelImpl - .property("uuid", new StringProperty()) - .property("display", new StringProperty()) - .property("name", new StringProperty()) - .property("description", new StringProperty()) - .property("version", new StringProperty()) - .property("build", new IntegerProperty()) - .property("published", new BooleanProperty()._default(false)) - .property("retired", new BooleanProperty()); - } - if (rep instanceof DefaultRepresentation) { - modelImpl - .property("encounterType", new RefProperty("#/definitions/EncountertypeGetRef")) - .property("formFields", new ArrayProperty(new RefProperty("#/definitions/FormFormfieldGetRef"))); - } else if (rep instanceof FullRepresentation) { - modelImpl - .property("encounterType", new RefProperty("#/definitions/EncountertypeGet")) - .property("formFields", new ArrayProperty(new RefProperty("#/definitions/FormFormfieldGet"))); - } - return modelImpl; - } - - @Override - public Model getCREATEModel(Representation rep) { - ModelImpl model = ((ModelImpl) super.getCREATEModel(rep)) - .property("version", new StringProperty()) - .property("encounterType", new StringProperty()) - .property("build", new IntegerProperty()) - .property("published", new BooleanProperty()._default(false)) - .property("formFields", new ArrayProperty(new StringProperty())) - .property("xslt", new StringProperty()) - .property("template", new StringProperty()) - - .required("version"); - if (rep instanceof FullRepresentation) { - model - .property("encounterType", new RefProperty("#/definitions/EncountertypeCreate")) - .property("formFields", new ArrayProperty(new RefProperty("#/definitions/FormFormfieldCreate"))); - } - return model; - } - - @Override - public Model getUPDATEModel(Representation rep) { - return getCREATEModel(rep); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) - */ - @Override - public Form getByUniqueId(String uniqueId) { - return Context.getFormService().getFormByUuid(uniqueId); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() - */ - @Override - public Form newDelegate() { - return new Form(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) - */ - @Override - public Form save(Form delegate) { - return Context.getFormService().saveForm(delegate); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void purge(Form delegate, RequestContext context) throws ResponseException { - if (delegate == null) - return; - Context.getFormService().purgeForm(delegate); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected NeedsPaging doGetAll(RequestContext context) throws ResponseException { - return new NeedsPaging(Context.getFormService().getAllForms(context.getIncludeAll()), context); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected NeedsPaging doSearch(RequestContext context) { - String fuzzyName = context.getParameter("q"); - boolean includeRetired = context.getIncludeAll(); - - return new NeedsPaging(Context.getFormService().getForms(fuzzyName, null, null, - includeRetired, null, null, null), context); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getPropertiesToExposeAsSubResources() - */ - @Override - public List getPropertiesToExposeAsSubResources() { - return Arrays.asList("formFields"); - } - -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationResource1_8.java deleted file mode 100644 index 6a9bbb860..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationResource1_8.java +++ /dev/null @@ -1,304 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang3.StringUtils; -import org.openmrs.Location; -import org.openmrs.LocationTag; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.response.ResponseException; - -import static org.openmrs.util.PrivilegeConstants.VIEW_LOCATIONS; - -/** - * {@link Resource} for {@link Location}, supporting standard CRUD operations - */ -@Resource(name = RestConstants.VERSION_1 + "/location", supportedClass = Location.class, supportedOpenmrsVersions = "1.8.*") -public class LocationResource1_8 extends MetadataDelegatingCrudResource { - - /** - * @see DelegatingCrudResource#getRepresentationDescription(Representation) - */ - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("name"); - description.addProperty("description"); - description.addProperty("address1"); - description.addProperty("address2"); - description.addProperty("cityVillage"); - description.addProperty("stateProvince"); - description.addProperty("country"); - description.addProperty("postalCode"); - description.addProperty("latitude"); - description.addProperty("longitude"); - description.addProperty("countyDistrict"); - description.addProperty("address3"); - description.addProperty("address4"); - description.addProperty("address5"); - description.addProperty("address6"); - description.addProperty("tags", Representation.REF); - description.addProperty("parentLocation", Representation.REF); - description.addProperty("childLocations", Representation.REF); - description.addProperty("retired"); - description.addSelfLink(); - description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); - return description; - } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("name"); - description.addProperty("description"); - description.addProperty("address1"); - description.addProperty("address2"); - description.addProperty("cityVillage"); - description.addProperty("stateProvince"); - description.addProperty("country"); - description.addProperty("postalCode"); - description.addProperty("latitude"); - description.addProperty("longitude"); - description.addProperty("countyDistrict"); - description.addProperty("address3"); - description.addProperty("address4"); - description.addProperty("address5"); - description.addProperty("address6"); - description.addProperty("tags", Representation.DEFAULT); - description.addProperty("parentLocation", Representation.DEFAULT); - description.addProperty("childLocations", Representation.DEFAULT); - description.addProperty("retired"); - description.addProperty("auditInfo"); - description.addSelfLink(); - return description; - } - return null; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - - description.addRequiredProperty("name"); - - description.addProperty("description"); - description.addProperty("address1"); - description.addProperty("address2"); - description.addProperty("cityVillage"); - description.addProperty("stateProvince"); - description.addProperty("country"); - description.addProperty("postalCode"); - description.addProperty("latitude"); - description.addProperty("longitude"); - description.addProperty("countyDistrict"); - description.addProperty("address3"); - description.addProperty("address4"); - description.addProperty("address5"); - description.addProperty("address6"); - description.addProperty("tags"); - description.addProperty("parentLocation"); - description.addProperty("childLocations"); - - return description; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties() - */ - @Override - public DelegatingResourceDescription getUpdatableProperties() { - return getCreatableProperties(); - } - - @Override - public Model getGETModel(Representation rep) { - ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); - if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { - modelImpl - .property("address1", new StringProperty()) - .property("address2", new StringProperty()) - .property("cityVillage", new StringProperty()) - .property("stateProvince", new StringProperty()) - .property("country", new StringProperty()) - .property("postalCode", new StringProperty()) - .property("latitude", new StringProperty()) - .property("longitude", new StringProperty()) - .property("countyDistrict", new StringProperty()) - .property("address3", new StringProperty()) - .property("address4", new StringProperty()) - .property("address5", new StringProperty()) - .property("address6", new StringProperty()); - } - if (rep instanceof DefaultRepresentation) { - modelImpl - .property("tags", new ArrayProperty(new RefProperty("#/definitions/LocationtagGetRef"))) - .property("parentLocation", new RefProperty("#/definitions/LocationGetRef")) - .property("childLocations", new ArrayProperty(new RefProperty("#/definitions/LocationGetRef"))); - } else if (rep instanceof FullRepresentation) { - modelImpl - .property("tags", new ArrayProperty(new RefProperty("#/definitions/LocationtagGet"))) - .property("parentLocation", new RefProperty("#/definitions/LocationGet")) - .property("childLocations", new ArrayProperty(new RefProperty("#/definitions/LocationGet"))); - } - return modelImpl; - } - - @Override - public Model getCREATEModel(Representation rep) { - return ((ModelImpl) super.getCREATEModel(rep)) - .property("address1", new StringProperty()) - .property("address2", new StringProperty()) - .property("cityVillage", new StringProperty()) - .property("stateProvince", new StringProperty()) - .property("country", new StringProperty()) - .property("postalCode", new StringProperty()) - .property("latitude", new StringProperty()) - .property("longitude", new StringProperty()) - .property("countyDistrict", new StringProperty()) - .property("address3", new StringProperty()) - .property("address4", new StringProperty()) - .property("address5", new StringProperty()) - .property("address6", new StringProperty()) - .property("tags", new ArrayProperty(new StringProperty())) - .property("parentLocation", new StringProperty()) - .property("childLocations", new ArrayProperty(new StringProperty())); - } - - @Override - public Model getUPDATEModel(Representation rep) { - return getCREATEModel(rep); - } - - /** - * @see DelegatingCrudResource#newDelegate() - */ - @Override - public Location newDelegate() { - return new Location(); - } - - /** - * @see DelegatingCrudResource#save(java.lang.Object) - */ - @Override - public Location save(Location location) { - return Context.getLocationService().saveLocation(location); - } - - /** - * Fetches a location by uuid, if no match is found, it tries to look up one with a matching - * name with the assumption that the passed parameter is a location name - * - * @see DelegatingCrudResource#getByUniqueId(java.lang.String) - */ - @Override - public Location getByUniqueId(String uuid) { - Location location = Context.getLocationService().getLocationByUuid(uuid); - //We assume the caller was fetching by name - if (location == null) - location = Context.getLocationService().getLocation(uuid); - - return location; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void purge(Location location, RequestContext context) throws ResponseException { - if (location == null) - return; - Context.getLocationService().purgeLocation(location); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected NeedsPaging doGetAll(RequestContext context) { - return new NeedsPaging(Context.getLocationService().getAllLocations(context.getIncludeAll()), context); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) - * A query string and/or a tag (referenced by name or uuid) can be passed in; if both are passed in, returns an - * intersection of the results; excludes retired locations - */ - @Override - protected PageableResult doSearch(RequestContext context) { - - String tag = context.getParameter("tag"); - String query = context.getParameter("q"); - - List locationsByTag = null; - List locationsByQuery = null; - - if (StringUtils.isNotBlank(tag)) { - locationsByTag = new ArrayList(); - - try { - Context.addProxyPrivilege(VIEW_LOCATIONS); //Not using PrivilegeConstants.VIEW_LOCATIONS which was removed in platform 1.11+ - Context.addProxyPrivilege("Get Locations"); //1.11+ - - LocationTag locationTag = Context.getLocationService().getLocationTagByUuid(tag); - if (locationTag == null) { - locationTag = Context.getLocationService().getLocationTagByName(tag); - } - - if (locationTag != null) { - locationsByTag = Context.getLocationService().getLocationsHavingAllTags(Arrays.asList(locationTag)); - } - } finally { - Context.removeProxyPrivilege(VIEW_LOCATIONS); //Not using PrivilegeConstants.VIEW_LOCATIONS which was removed in platform 1.11+ - Context.removeProxyPrivilege("Get Locations"); //1.11+ - } - } - - if (StringUtils.isNotBlank(query)) { - locationsByQuery = Context.getLocationService().getLocations(query); - } - - if (locationsByTag == null) { - return new NeedsPaging(locationsByQuery, context); - } else if (locationsByQuery == null) { - return new NeedsPaging(locationsByTag, context); - } else { - return new NeedsPaging( - (List) CollectionUtils.intersection(locationsByQuery, locationsByTag), context); - } - } -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ObsResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ObsResource1_8.java deleted file mode 100644 index 9e4970296..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ObsResource1_8.java +++ /dev/null @@ -1,575 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.DatatypeConverter; - -import org.apache.commons.lang.StringUtils; -import org.openmrs.Concept; -import org.openmrs.ConceptNumeric; -import org.openmrs.Drug; -import org.openmrs.Encounter; -import org.openmrs.Location; -import org.openmrs.Obs; -import org.openmrs.Patient; -import org.openmrs.api.APIException; -import org.openmrs.api.ObsService; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.ConversionUtil; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestUtil; -import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; -import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; -import org.openmrs.module.webservices.rest.web.resource.api.Uploadable; -import org.openmrs.module.webservices.rest.web.resource.impl.DataDelegatingCrudResource; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.response.ConversionException; -import org.openmrs.module.webservices.rest.web.response.IllegalRequestException; -import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; -import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.obs.ComplexData; -import org.springframework.web.multipart.MultipartFile; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.BooleanProperty; -import io.swagger.models.properties.DateProperty; -import io.swagger.models.properties.DateTimeProperty; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; - -/** - * {@link Resource} for Obs, supporting standard CRUD operations - */ -@Resource(name = RestConstants.VERSION_1 + "/obs", order = 2, supportedClass = Obs.class, supportedOpenmrsVersions = { "1.8.*" }) -public class ObsResource1_8 extends DataDelegatingCrudResource implements Uploadable { - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#delete(java.lang.Object, - * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected void delete(Obs delegate, String reason, RequestContext context) throws ResponseException { - if (delegate.isVoided()) { - // DELETE is idempotent, so we return success here - return; - } - Context.getObsService().voidObs(delegate, reason); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#undelete(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected Obs undelete(Obs delegate, RequestContext context) throws ResponseException { - if (delegate.isVoided()) { - delegate = Context.getObsService().unvoidObs(delegate); - } - return delegate; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) - */ - @Override - public Obs getByUniqueId(String uniqueId) { - return Context.getObsService().getObsByUuid(uniqueId); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) - */ - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - // TODO how to handle valueCodedName? - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("concept", Representation.REF); - description.addProperty("person", Representation.REF); - description.addProperty("obsDatetime"); - description.addProperty("accessionNumber"); - description.addProperty("obsGroup", Representation.REF); - description.addProperty("valueCodedName", Representation.REF); - description.addProperty("groupMembers"); - description.addProperty("comment"); - description.addProperty("location", Representation.REF); - description.addProperty("order", Representation.REF); - description.addProperty("encounter", Representation.REF); - description.addProperty("voided"); - description.addProperty("value"); - description.addProperty("valueModifier"); - description.addSelfLink(); - description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); - return description; - } else if (rep instanceof FullRepresentation) { - // TODO how to handle valueCodedName? - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("concept"); - description.addProperty("person", Representation.REF); - description.addProperty("obsDatetime"); - description.addProperty("accessionNumber"); - description.addProperty("obsGroup"); - description.addProperty("valueCodedName"); - description.addProperty("groupMembers", Representation.FULL); - description.addProperty("comment"); - description.addProperty("location"); - description.addProperty("order"); - description.addProperty("encounter"); - description.addProperty("voided"); - description.addProperty("auditInfo"); - description.addProperty("value"); - description.addProperty("valueModifier"); - description.addSelfLink(); - return description; - } - return null; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - - description.addRequiredProperty("person"); - description.addRequiredProperty("obsDatetime"); - description.addRequiredProperty("concept"); - - description.addProperty("location"); - description.addProperty("order"); - description.addProperty("encounter"); - description.addProperty("accessionNumber"); - description.addProperty("groupMembers"); - description.addProperty("valueCodedName"); - description.addProperty("comment"); - description.addProperty("value"); - description.addProperty("valueModifier"); - - return description; - } - - @Override - public Model getGETModel(Representation rep) { - ModelImpl model = (ModelImpl) super.getGETModel(rep); - if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { - model.property("uuid", new StringProperty()).property("display", new StringProperty()) - .property("obsDatetime", new DateProperty()).property("accessionNumber", new StringProperty()) - .property("comment", new StringProperty()).property("voided", new BooleanProperty()) - .property("value", new StringProperty()).property("valueModifier", new StringProperty()); - } - if (rep instanceof DefaultRepresentation) { - model.property("concept", new RefProperty("#/definitions/ConceptGetRef")) - .property("person", new RefProperty("#/definitions/PersonGetRef")) - .property("obsGroup", new RefProperty("#/definitions/ObsGetRef")) - .property("groupMembers", new ArrayProperty(new RefProperty("#/definitions/ObsGetRef"))) - .property("valueCodedName", new RefProperty("#/definitions/ConceptNameGetRef")) - .property("location", new RefProperty("#/definitions/LocationGetRef")) - .property("order", new RefProperty("#/definitions/OrderGetRef")) - .property("encounter", new RefProperty("#/definitions/EncounterGetRef")); - } else if (rep instanceof FullRepresentation) { - model.property("concept", new RefProperty("#/definitions/ConceptGet")) - .property("person", new RefProperty("#/definitions/PersonGet")) - .property("obsGroup", new RefProperty("#/definitions/ObsGet")) - .property("groupMembers", new ArrayProperty(new RefProperty("#/definitions/ObsGet"))) - .property("valueCodedName", new RefProperty("#/definitions/ConceptNameGet")) - .property("location", new RefProperty("#/definitions/LocationGet")) - .property("order", new RefProperty("#/definitions/OrderGet")) - .property("encounter", new RefProperty("#/definitions/EncounterGet")); - } - return model; - } - - @Override - public Model getCREATEModel(Representation rep) { - return new ModelImpl().property("person", new StringProperty().example("uuid")) - .property("obsDatetime", new DateTimeProperty()).property("concept", new StringProperty().example("uuid")) - .property("location", new StringProperty()).property("order", new StringProperty()) - .property("encounter", new StringProperty()).property("accessionNumber", new StringProperty()) - .property("groupMembers", new ArrayProperty(new StringProperty())) - .property("valueCodedName", new StringProperty()).property("comment", new StringProperty()) - .property("voided", new BooleanProperty()).property("value", new StringProperty()) - .property("valueModifier", new StringProperty()) - - .required("person").required("obsDatetime").required("concept"); - } - - @Override - public Model getUPDATEModel(Representation rep) { - return getCREATEModel(rep); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() - */ - @Override - public Obs newDelegate() { - return new Obs(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void purge(Obs delegate, RequestContext context) throws ResponseException { - Context.getObsService().purgeObs(delegate); - - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) - */ - @Override - public Obs save(Obs delegate) { - Obs savedObs = Context.getObsService().saveObs(delegate, "REST web service"); - return Context.getObsService().getObs(savedObs.getId()); - } - - /** - * Display string for Obs - * - * @param obs - * @return String ConceptName = value - */ - @PropertyGetter("display") - public String getDisplayString(Obs obs) { - if (obs.getConcept() == null) - return ""; - - return obs.getConcept().getName() + ": " + obs.getValueAsString(Context.getLocale()); - } - - /** - * Retrives the Obs Value as string - * - * @param obs - * @return - */ - @PropertyGetter("value") - public Object getValue(Obs obs) throws ConversionException { - if (obs.isComplex()) { - //Note that complex obs value is handled by ObsComplexValueController1_8 - SimpleObject so = new SimpleObject(); - so.put("display", "raw file"); - SimpleObject links = new SimpleObject(); - links.put("rel", "self"); - links.put("uri", new ObsResource1_8().getUri(obs) + "/value"); - so.put("links", links); - return so; - } - - if (obs.isObsGrouping()) - return null; - - if (obs.getValueDatetime() != null) { - return ConversionUtil.convert(obs.getValueDatetime(), Date.class); - } - - if (obs.getValueDrug() != null) { - return obs.getValueDrug(); - } - - if (obs.getValueCoded() != null) { - return obs.getValueCoded(); - } - - if (obs.getValueComplex() != null) { - return obs.getValueComplex(); - } - - if (obs.getValueText() != null) { - if ("org.openmrs.Location".equals(obs.getComment())) { // string first to make it null-safe - try { - return Context.getLocationService().getLocation(new Integer(obs.getValueText())); - } - catch (NumberFormatException e) { - // TDOO; we really shouldn't be supporting two ways of storing a location obs, should only use the location id - return Context.getLocationService().getLocationByUuid(obs.getValueText()); - } - } else { - return obs.getValueText(); - } - - } - - if (obs.getValueNumeric() != null) { - return getValueNumeric(obs); - } - - return null; - } - - /** - * @return the valueNumeric from the obs - */ - protected Number getValueNumeric(Obs obs) { - return obs.getValueNumeric(); - } - - /** - * Sets the members of an obs group - * - * @param obsGroup the obs group whose members to set - * @param members the members to set - */ - @PropertySetter("groupMembers") - public static void setGroupMembers(Obs obsGroup, Set members) { - for (Obs member : members) { - member.setObsGroup(obsGroup); - } - obsGroup.setGroupMembers(members); - } - - /** - * Checks if there are more than one obs in GroupMembers and converts into a DEFAULT - * representation - * - * @param obs - * @return Object - * @throws ConversionException - */ - @PropertyGetter("groupMembers") - public static Object getGroupMembers(Obs obs) throws ConversionException { - if (obs.getGroupMembers() != null && !obs.getGroupMembers().isEmpty()) { - return obs.getGroupMembers(); - } - return null; - } - - /** - * Annotated setter for Concept - * - * @param obs - * @param value - */ - @PropertySetter("concept") - public static void setConcept(Obs obs, Object value) { - obs.setConcept(Context.getConceptService().getConceptByUuid((String) value)); - } - - /** - * Annotated setter for ConceptValue - * - * @param obs - * @param value - * @throws ParseException - * @throws ConversionException - * Should return uuid for foncept true - * Should return uuid for concept false - * Should throw exception on unexpected value - * Should return uuid for primitive true - * Should return uuid for primitive false - */ - @PropertySetter("value") - public static void setValue(Obs obs, Object value) throws ParseException, ConversionException, IOException { - if (value != null) { - - // special case for complex obs - if (obs.isComplex()) { - byte[] bytes = DatatypeConverter.parseBase64Binary(value.toString()); - - ComplexData complexData = new ComplexData(obs.getUuid() + ".raw", new ByteArrayInputStream(bytes)); - obs.setComplexData(complexData); - return; - } - - // special case for data type coded (setValueAsString is not implemented for coded obs (in core)) - if (obs.getConcept().getDatatype().isCoded()) { - // We want clients to be able to fetch a coded value in one rest call - // and set the returned payload as the obs value - // (ie support setting based on posting the entire REST rep or just the concept uuid) - if (value instanceof Map) { - Object uuid = ((Map) value).get(RestConstants.PROPERTY_UUID); - if (uuid != null) { - value = uuid.toString(); - } - } - - Concept valueCoded = (Concept) ConversionUtil.convert(value, Concept.class); - if (valueCoded == null) { - //try checking if this this is value drug - Drug valueDrug = (Drug) ConversionUtil.convert(value, Drug.class); - if (valueDrug != null) { - obs.setValueCoded(valueDrug.getConcept()); - obs.setValueDrug(valueDrug); - } else { - throw new ObjectNotFoundException(obs.getConcept().getName().getName() + ":" + value.toString()); - } - - } else { - obs.setValueCoded(valueCoded); - } - return; - } - - // special case for Location - String potentialLocationUuid = null; - - // if this is a representation of an object, get the uuid property as potential location uuid - if (value instanceof Map) { - Object uuid = ((Map) value).get(RestConstants.PROPERTY_UUID); - if (uuid != null) { - potentialLocationUuid = uuid.toString(); - } - } - else { - // otherwise, we will test if the value itself is a location uuid - potentialLocationUuid = value.toString(); - } - - // if there is a potential uuid, see if there is a matching location, and,if so, set the value text as the primary key - if (RestUtil.isValidUuid(potentialLocationUuid)) { - Location location = Context.getLocationService().getLocationByUuid(potentialLocationUuid); - if (location != null) { - obs.setValueText(location.getLocationId().toString()); - obs.setComment("org.openmrs.Location"); - return; - } - } - - // handle all other types using obs.setValueAsString after special conversions for numeric and boolean - if (obs.getConcept().isNumeric()) { - //get the actual persistent object rather than the hibernate proxy - ConceptNumeric concept = Context.getConceptService().getConceptNumeric(obs.getConcept().getId()); - String units = concept.getUnits(); - if (StringUtils.isNotBlank(units)) { - String originalValue = value.toString().trim(); - if (originalValue.endsWith(units)) - value = originalValue.substring(0, originalValue.indexOf(units)).trim(); - else { - //check that this value has no invalid units - try { - Double.parseDouble(originalValue); - } - catch (NumberFormatException e) { - throw new APIException(originalValue + " has invalid units", e); - } - } - } - } else if (obs.getConcept().getDatatype().isBoolean()) { - if (value instanceof Concept) { - value = ((Concept) value).getUuid(); - } - if (value.equals(Context.getConceptService().getTrueConcept().getUuid())) { - value = true; - } else if (value.equals(Context.getConceptService().getFalseConcept().getUuid())) { - value = false; - } else if (!value.getClass().isAssignableFrom(Boolean.class)) { - List trueValues = Arrays.asList("true", "1", "on", "yes"); - List falseValues = Arrays.asList("false", "0", "off", "no"); - - String val = value.toString().trim().toLowerCase(); - if (trueValues.contains(val)) { - value = Boolean.TRUE; - } else if (falseValues.contains(val)) { - value = Boolean.FALSE; - } - - if (!(Boolean.TRUE.equals(value) || Boolean.FALSE.equals(value))) { - throw new ConversionException("Unexpected value: " + value + " set as the value of boolean. " - + trueValues + falseValues + ", ConceptService.getTrueConcept or " - + ", ConceptService.getFalseConcept expected"); - } - } - } - obs.setValueAsString(value.toString()); - - - } else { - throw new APIException("The value for an observation cannot be null"); - } - } - - /** - * Gets obs by patient or encounter (paged according to context if necessary) only if a patient - * or encounter parameter exists respectively in the request set on the {@link RequestContext} - * otherwise searches for obs that match the specified query - * - * @param context - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected PageableResult doSearch(RequestContext context) { - String patientUuid = context.getRequest().getParameter("patient"); - if (patientUuid != null) { - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( - Patient.class)).getByUniqueId(patientUuid); - if (patient == null) - return new EmptySearchResult(); - List obs = Context.getObsService().getObservationsByPerson(patient); - return new NeedsPaging(obs, context); - } - - String encounterUuid = context.getRequest().getParameter("encounter"); - if (encounterUuid != null) { - Encounter enc = ((EncounterResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( - Encounter.class)).getByUniqueId(encounterUuid); - if (enc == null) - return new EmptySearchResult(); - - List obs = new ArrayList(enc.getAllObs(context.getIncludeAll())); - return new NeedsPaging(obs, context); - } - - return new NeedsPaging(Context.getObsService().getObservations(context.getParameter("q")), context); - } - - @Override - public Object upload(MultipartFile file, RequestContext context) throws ResponseException, IOException { - String json = context.getParameter("json"); - if (json == null) { - throw new IllegalRequestException("Obs metadata must be included in a request parameter named 'json'."); - } - - SimpleObject object = SimpleObject.parseJson(json); - Obs obs = convert(object); - - if (!obs.isComplex()) { - throw new IllegalRequestException("Complex concept must be set in order to create a complex obs with data."); - } - - ObsService obsService = Context.getObsService(); - - ComplexData complexData = new ComplexData(file.getOriginalFilename(), new ByteArrayInputStream(file.getBytes())); - obs.setComplexData(complexData); - - obs = obsService.saveObs(obs, null); - - return (SimpleObject) ConversionUtil.convertToRepresentation(obs, Representation.DEFAULT); - } - -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8.java deleted file mode 100644 index 19178907f..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8.java +++ /dev/null @@ -1,370 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.ArrayProperty; -import io.swagger.models.properties.BooleanProperty; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; -import org.openmrs.Patient; -import org.openmrs.PatientIdentifier; -import org.openmrs.Person; -import org.openmrs.api.PatientService; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.ConversionUtil; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; -import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.impl.AlreadyPaged; -import org.openmrs.module.webservices.rest.web.resource.impl.DataDelegatingCrudResource; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.ServiceSearcher; -import org.openmrs.module.webservices.rest.web.response.ConversionException; -import org.openmrs.module.webservices.rest.web.response.IllegalRequestException; -import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; -import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.validation.ValidateUtil; - -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * {@link Resource} for Patients, supporting standard CRUD operations - */ -@Resource(name = RestConstants.VERSION_1 + "/patient", supportedClass = Patient.class, supportedOpenmrsVersions = { "1.8.*" }) -public class PatientResource1_8 extends DataDelegatingCrudResource { - - public PatientResource1_8() { - } - - @PropertyGetter("person") - public static Person getPerson(Patient instance) { - return new Person(instance); //Must be a Person instead of Patient to prevent infinite recursion RESTWS-273 - } - - /** - * It is empty, because we set that already in the create method. - *

- * It takes String instead of Person so that the uuid is not resolved to a person, which leads - * to the Hibernate exception: the object is already associated with the session. - * - * @param instance - * @param personUuid - */ - @PropertySetter("person") - public static void setPerson(Patient instance, String personUuid) { - } - - @PropertyGetter("identifiers") - public static Set getIdentifiers(Patient instance) { - return new LinkedHashSet(instance.getActiveIdentifiers()); - } - - @PropertySetter("identifiers") - public static void setIdentifiers(Patient instance, List identifiers) - throws ResourceDoesNotSupportOperationException { - if (instance.getIdentifiers() != null && instance.getIdentifiers().containsAll(identifiers)) { - return; - } - if (instance.getIdentifiers() != null && !instance.getIdentifiers().isEmpty()) { - throw new ResourceDoesNotSupportOperationException("Identifiers can only be set for newly created objects!"); - } - if (identifiers == null || identifiers.isEmpty()) { - throw new ResourceDoesNotSupportOperationException("At least one identifier required"); - } - - boolean hasPreferred = false; - for (PatientIdentifier identifier : identifiers) { - if (identifier.isPreferred()) { - if (!hasPreferred) { - hasPreferred = true; - } else { - throw new ResourceDoesNotSupportOperationException("Only one preferred identifier allowed"); - } - } - } - - if (!hasPreferred) { - //Mark the first one as preferred if none marked - identifiers.iterator().next().setPreferred(true); - } - - instance.getIdentifiers().clear(); - for (PatientIdentifier identifier : identifiers) { - instance.addIdentifier(identifier); - } - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) - */ - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("identifiers", Representation.REF); - description.addProperty("person", Representation.DEFAULT); - description.addProperty("voided"); - description.addSelfLink(); - description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); - return description; - } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("identifiers", Representation.DEFAULT); - description.addProperty("person", Representation.FULL); - description.addProperty("voided"); - description.addProperty("auditInfo"); - description.addSelfLink(); - return description; - } - return null; - } - - @Override - public Model getGETModel(Representation rep) { - ModelImpl model = (ModelImpl) super.getGETModel(rep); - //FIXME check uuid, display in ref rep - if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { - model - .property("uuid", new StringProperty()) - .property("display", new StringProperty()) - .property("identifiers", new ArrayProperty(new RefProperty("#/definitions/PatientIdentifierGetRef"))) - .property("preferred", new BooleanProperty()._default(false)) - .property("voided", new BooleanProperty()); - } - if (rep instanceof DefaultRepresentation) { - model - .property("person", new RefProperty("#/definitions/PersonGetRef")); - } else if (rep instanceof FullRepresentation) { - model - .property("person", new RefProperty("#/definitions/PersonGet")); - } - return model; - } - - @Override - public Model getCREATEModel(Representation rep) { - ModelImpl model = new ModelImpl() - .property("person", new StringProperty().example("uuid")) - .property("identifiers", new ArrayProperty(new RefProperty("#/definitions/PatientIdentifierCreate"))) - - .required("person").required("identifiers"); - if (rep instanceof FullRepresentation) { - model - .property("person", new RefProperty("#/definitions/PersonCreate")); - } - return model; - } - - @Override - public Model getUPDATEModel(Representation rep) { - return new ModelImpl() - .property("person", new RefProperty("#/definitions/PersonGet")) - - .required("person"); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addRequiredProperty("person"); - description.addRequiredProperty("identifiers"); - return description; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties() - */ - @Override - public DelegatingResourceDescription getUpdatableProperties() { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addRequiredProperty("person"); - return description; - } - - /** - * The method is overwritten, because we need to create a patient from an existing person. In - * the POST body only person and identifiers are provided and other properties must come from - * the existing person. We need to promote the existing person to be a patient by overwriting it - * and at the same time preserving all person properties. - * - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#create(org.openmrs.module.webservices.rest.SimpleObject, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public Object create(SimpleObject propertiesToCreate, RequestContext context) throws ResponseException { - Patient delegate = getPatient(propertiesToCreate); - ValidateUtil.validate(delegate); - delegate = save(delegate); - return ConversionUtil.convertToRepresentation(delegate, Representation.DEFAULT); - } - - public Patient getPatient(SimpleObject propertiesToCreate) { - Object personProperty = propertiesToCreate.get("person"); - Person person = null; - if (personProperty == null) { - throw new ConversionException("The person property is missing"); - } else if (personProperty instanceof String) { - person = Context.getPersonService().getPersonByUuid((String) personProperty); - Context.evictFromSession(person); - } else if (personProperty instanceof Map) { - person = (Person) ConversionUtil.convert(personProperty, Person.class); - propertiesToCreate.put("person", ""); - } - - Patient delegate = new Patient(person); - setConvertedProperties(delegate, propertiesToCreate, getCreatableProperties(), true); - return delegate; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#newDelegate() - */ - @Override - public Patient newDelegate() { - return new Patient(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#save(java.lang.Object) - */ - @Override - public Patient save(Patient patient) { - return Context.getPatientService().savePatient(patient); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getByUniqueId(java.lang.String) - */ - @Override - public Patient getByUniqueId(String uuid) { - return Context.getPatientService().getPatientByUuid(uuid); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#delete(java.lang.Object, - * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void delete(Patient patient, String reason, RequestContext context) throws ResponseException { - if (patient.isVoided()) { - // DELETE is idempotent, so we return success here - return; - } - Context.getPatientService().voidPatient(patient, reason); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#undelete(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected Patient undelete(Patient patient, RequestContext context) throws ResponseException { - if (patient.isVoided()) { - patient = Context.getPatientService().unvoidPatient(patient); - } - return patient; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void purge(Patient patient, RequestContext context) throws ResponseException { - if (patient == null) { - // DELETE is idempotent, so we return success here - return; - } - Context.getPatientService().purgePatient(patient); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected AlreadyPaged doSearch(RequestContext context) { - String attributesParam = context.getParameter("attributesToFindDuplicatesBy"); - if (attributesParam != null) { - List attributes = Arrays.asList((attributesParam.split(","))); - - if (attributes.size() < 2) { - throw new IllegalRequestException("Choose a minimum of two attributes"); - } - - List duplicatedPatientsFound = Context.getPatientService().getDuplicatePatientsByAttributes(attributes); - - return new AlreadyPaged(context, duplicatedPatientsFound, false, (long) duplicatedPatientsFound.size()); - } - - return new ServiceSearcher(PatientService.class, "getPatients", "getCountOfPatients").search( - context.getParameter("q"), context); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getPropertiesToExposeAsSubResources() - */ - @Override - public List getPropertiesToExposeAsSubResources() { - return Arrays.asList("identifiers"); - } - - /** - * @param patient - * @return identifier + name (for concise display purposes) - */ - @PropertyGetter("display") - public String getDisplayString(Patient patient) { - if (patient.getPatientIdentifier() == null) - return ""; - - return patient.getPatientIdentifier().getIdentifier() + " - " + patient.getPersonName().getFullName(); - } - - @Override - public Object update(String uuid, SimpleObject propertiesToUpdate, RequestContext context) throws ResponseException { - if (propertiesToUpdate.get("person") == null) { - return super.update(uuid, propertiesToUpdate, context); - } - Patient patient = getPatientForUpdate(uuid, propertiesToUpdate); - ValidateUtil.validate(patient); - patient = save(patient); - return ConversionUtil.convertToRepresentation(patient, Representation.DEFAULT); - } - - public Patient getPatientForUpdate(String uuid, Map propertiesToUpdate) { - Patient patient = getByUniqueId(uuid); - PersonResource1_8 personResource = (PersonResource1_8) Context.getService(RestService.class) - .getResourceBySupportedClass(Person.class); - personResource.setConvertedProperties(patient, (Map) propertiesToUpdate.get("person"), - personResource.getUpdatableProperties(), false); - return patient; - } - -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProblemResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProblemResource1_8.java deleted file mode 100644 index 19de11f5d..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProblemResource1_8.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.DoubleProperty; -import io.swagger.models.properties.RefProperty; -import org.openmrs.Patient; -import org.openmrs.activelist.Problem; -import org.openmrs.activelist.ProblemModifier; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; -import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; - -/** - * {@link Resource} for Problem, supporting standard CRUD operations - */ -@Resource(name = RestConstants.VERSION_1 + "/problem", supportedClass = Problem.class, supportedOpenmrsVersions = { "1.8.*" }) -public class ProblemResource1_8 extends BaseActiveListItemResource1_8 { - - @Override - public Model getGETModel(Representation rep) { - ModelImpl model = (ModelImpl) super.getGETModel(rep); - if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { - model - .property("modifier", new EnumProperty(ProblemModifier.class)) - .property("sortWeight", new DoubleProperty()); - } - if (rep instanceof DefaultRepresentation) { - model - .property("problem", new RefProperty("#/definitions/ConceptGetRef")); - - } else if (rep instanceof FullRepresentation) { - model - .property("problem", new RefProperty("#/definitions/ConceptGet")); - - } - return model; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) - */ - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); - description.addProperty("modifier"); - description.addProperty("sortWeight"); - description.addProperty("problem", Representation.REF); - return description; - } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); - description.addProperty("modifier"); - description.addProperty("sortWeight"); - description.addProperty("problem", Representation.DEFAULT); - return description; - } - return null; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = super.getCreatableProperties(); - description.addRequiredProperty("problem"); - description.addProperty("modifier"); - description.addProperty("sortWeight"); - - return description; - } - - @Override - public Model getCREATEModel(Representation rep) { - return ((ModelImpl) super.getCREATEModel(rep)) - .property("problem", new RefProperty("#/definitions/ConceptCreate")) - .property("modifier", new EnumProperty(ProblemModifier.class)) - .property("sortWeight", new DoubleProperty()) - - .required("problem"); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() - */ - @Override - public Problem newDelegate() { - return new Problem(); - } - - /** - * Display string for Problem - * - * @param problem - * @return String ConceptName - */ - @PropertyGetter("display") - public String getDisplayString(Problem problem) { - if (problem.getProblem() == null) - return ""; - - return problem.getProblem().getName().toString(); - } - - /** - * Annotated setter for Problem - * - * @param problem - * @param value - */ - - @PropertySetter("problem") - public static void setProblem(Problem problem, Object value) { - problem.setProblem(Context.getConceptService().getConceptByUuid((String) value)); - } - - /** - * Gets problems for a given patient (paged according to context if necessary) only if a patient - * parameter exists in the request set on the {@link RequestContext} - * - * @param context - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected PageableResult doSearch(RequestContext context) { - String patientUuid = context.getRequest().getParameter("patient"); - if (patientUuid != null) { - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( - Patient.class)).getByUniqueId(patientUuid); - if (patient == null) - return new EmptySearchResult(); - return new NeedsPaging(Context.getPatientService().getProblems(patient), context); - } - - //currently this is not supported since the superclass throws an exception - return super.doSearch(context); - } - -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipResource1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipResource1_8.java deleted file mode 100644 index a004176ba..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipResource1_8.java +++ /dev/null @@ -1,211 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import io.swagger.models.Model; -import io.swagger.models.ModelImpl; -import io.swagger.models.properties.BooleanProperty; -import io.swagger.models.properties.DateProperty; -import io.swagger.models.properties.RefProperty; -import io.swagger.models.properties.StringProperty; -import org.openmrs.Person; -import org.openmrs.Relationship; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; -import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; -import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; -import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.impl.DataDelegatingCrudResource; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; -import org.openmrs.module.webservices.rest.web.response.ResponseException; - -/** - * {@link org.openmrs.module.webservices.rest.web.annotation.Resource} for Provider, supporting - * standard CRUD operations - */ -@Resource(name = RestConstants.VERSION_1 + "/relationship", supportedClass = Relationship.class, supportedOpenmrsVersions = { "1.8.*" }) -public class RelationshipResource1_8 extends DataDelegatingCrudResource { - - @Override - public Relationship getByUniqueId(String uuid) { - return Context.getPersonService().getRelationshipByUuid(uuid); - } - - @Override - protected void delete(Relationship delegate, String reason, RequestContext context) throws ResponseException { - if (delegate.isVoided()) { - return; - } - Context.getPersonService().voidRelationship(delegate, reason); - } - - @Override - protected Relationship undelete(Relationship delegate, RequestContext context) throws ResponseException { - if (delegate.isVoided()) { - delegate = Context.getPersonService().unvoidRelationship(delegate); - } - return delegate; - } - - @Override - public Relationship newDelegate() { - return new Relationship(); - } - - @Override - public Relationship save(Relationship delegate) { - return Context.getPersonService().saveRelationship(delegate); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(org.openmrs.Encounter, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public void purge(Relationship relationship, RequestContext context) throws ResponseException { - if (relationship == null) { - return; - } - Context.getPersonService().purgeRelationship(relationship); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) - */ - @Override - public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("personA", Representation.REF, Person.class); - description.addProperty("relationshipType", Representation.REF); - description.addProperty("personB", Representation.REF, Person.class); - description.addProperty("voided"); - description.addSelfLink(); - description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); - return description; - } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addProperty("uuid"); - description.addProperty("display"); - description.addProperty("personA", Representation.DEFAULT, Person.class); - description.addProperty("relationshipType", Representation.DEFAULT); - description.addProperty("personB", Representation.DEFAULT, Person.class); - description.addProperty("voided"); - description.addProperty("auditInfo"); - description.addSelfLink(); - return description; - } - return null; - } - - /** - * @param relationship - * @return relationship type and start date - */ - @PropertyGetter("display") - public String getDisplayString(Relationship relationship) { - String relType = relationship.getRelationshipType() == null ? "NULL" : relationship.getRelationshipType() - .getaIsToB(); - return relationship.getPersonA().getGivenName() + " is the " + relType + " of " - + relationship.getPersonB().getGivenName(); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() - */ - @Override - public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = new DelegatingResourceDescription(); - description.addRequiredProperty("personA"); - description.addRequiredProperty("relationshipType"); - description.addRequiredProperty("personB"); - description.addProperty("startDate"); - description.addProperty("endDate"); - return description; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(java.lang.String, - * org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - protected NeedsPaging doGetAll(RequestContext context) throws ResponseException { - return new NeedsPaging(Context.getPersonService().getAllRelationships(), context); - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties() - */ - @Override - public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException { - DelegatingResourceDescription description = super.getUpdatableProperties(); - //shouldn't be editing the patient - description.removeProperty("personA"); - description.removeProperty("personB"); - description.addProperty("voided"); - return description; - } - - @Override - public Model getGETModel(Representation rep) { - ModelImpl model = (ModelImpl) super.getGETModel(rep); - if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { - model - .property("uuid", new StringProperty()) - .property("display", new StringProperty()) - .property("voided", new BooleanProperty()); - } - if (rep instanceof DefaultRepresentation) { - model - .property("personA", new RefProperty("#/definitions/PersonGetRef")) - .property("relationshipType", new RefProperty("#/definitions/RelationshiptypeGetRef")) - .property("personB", new RefProperty("#/definitions/PersonGetRef")); - } else if (rep instanceof FullRepresentation) { - model - .property("personA", new RefProperty("#/definitions/PersonGet")) - .property("relationshipType", new RefProperty("#/definitions/RelationshiptypeGet")) - .property("personB", new RefProperty("#/definitions/PersonGet")); - } - return model; - } - - @Override - public Model getCREATEModel(Representation rep) { - ModelImpl model = new ModelImpl() - .property("personA", new StringProperty().example("uuid")) - .property("relationshipType", new StringProperty().example("uuid")) - .property("personB", new StringProperty().example("uuid")) - .property("startDate", new DateProperty()) - .property("endDate", new DateProperty()) - - .required("personA").required("relationshipType").required("personB"); - if (rep instanceof FullRepresentation) { - model - .property("personA", new RefProperty("#/definitions/PersonCreate")) - - .property("relationshipType", new RefProperty("#/definitions/RelationshiptypeCreate")) - .property("personB", new RefProperty("#/definitions/PersonCreate")); - } - return model; - } - - @Override - public Model getUPDATEModel(Representation rep) { - return new ModelImpl() - .property("voided", new BooleanProperty()); //FIXME missing properties - } -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/ConceptSearchHandler1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/ConceptSearchHandler1_8.java deleted file mode 100644 index 668c9128b..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/ConceptSearchHandler1_8.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_8; - -import org.apache.commons.lang3.StringUtils; -import org.openmrs.Concept; -import org.openmrs.ConceptClass; -import org.openmrs.ConceptMap; -import org.openmrs.ConceptName; -import org.openmrs.ConceptSearchResult; -import org.openmrs.ConceptSource; -import org.openmrs.api.APIException; -import org.openmrs.api.ConceptService; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestUtil; -import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; -import org.openmrs.module.webservices.rest.web.resource.api.SearchConfig; -import org.openmrs.module.webservices.rest.web.resource.api.SearchHandler; -import org.openmrs.module.webservices.rest.web.resource.api.SearchQuery; -import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.response.InvalidSearchException; -import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.util.LocaleUtility; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; - -/** - * Allows for finding concepts by mapping or by name - */ -@Component -public class ConceptSearchHandler1_8 implements SearchHandler { - - @Autowired - @Qualifier("conceptService") - ConceptService conceptService; - - private final SearchConfig searchConfig = new SearchConfig("default", RestConstants.VERSION_1 + "/concept", - Arrays.asList("1.8.* - 9.*"), - Arrays.asList( - new SearchQuery.Builder("Allows you to find concepts by source and code").withRequiredParameters("source") - .withOptionalParameters("code").build(), new SearchQuery.Builder( - "Allows you to find concepts by name and class").withRequiredParameters("name") - .withOptionalParameters("class", "searchType").build(), new SearchQuery.Builder( - "Allows you to find a list of concepts by passing references") - .withRequiredParameters("references").build())); - - /** - * @see org.openmrs.module.webservices.rest.web.resource.api.SearchHandler#getSearchConfig() - */ - @Override - public SearchConfig getSearchConfig() { - return searchConfig; - } - - /** - * @see org.openmrs.module.webservices.rest.web.resource.api.SearchHandler#search(org.openmrs.module.webservices.rest.web.RequestContext) - */ - @Override - public PageableResult search(RequestContext context) throws ResponseException { - String source = context.getParameter("source"); - String code = context.getParameter("code"); - String name = context.getParameter("name"); - String conceptClass = context.getParameter("class"); - String searchType = context.getParameter("searchType"); - String conceptReferences = context.getParameter("references"); - - List concepts; - - if (StringUtils.isNotBlank(conceptReferences)) { - String[] conceptReferenceStrings = conceptReferences.split(","); - concepts = new ArrayList(conceptReferenceStrings.length); - - for (String conceptReference : conceptReferenceStrings) { - if (StringUtils.isBlank(conceptReference)) { - continue; - } - // handle UUIDs - if (RestUtil.isValidUuid(conceptReference)) { - Concept concept = conceptService.getConceptByUuid(conceptReference); - if (concept != null) { - concepts.add(concept); - continue; - } - } - // handle mappings - int idx = conceptReference.indexOf(':'); - if (idx >= 0 && idx < conceptReference.length() - 1) { - String conceptSource = conceptReference.substring(0, idx); - String conceptCode = conceptReference.substring(idx + 1); - Concept concept = conceptService.getConceptByMapping(conceptCode, conceptSource, false); - if (concept != null) { - concepts.add(concept); - continue; - } - } - } - if (concepts.size() == 0) { - return new EmptySearchResult(); - } - - return new NeedsPaging(concepts, context); - } - - concepts = new ArrayList(); - - // If there's class parameter in query - if ("fuzzy".equals(searchType)) { - List locales = new ArrayList(LocaleUtility.getLocalesInOrder()); - List classes = null; - ConceptClass responseConceptClass = conceptService.getConceptClassByUuid(conceptClass); - - if (responseConceptClass != null) { - classes = Arrays.asList(responseConceptClass); - } - - List searchResults = conceptService.getConcepts(name, locales, context.getIncludeAll(), - classes, null, null, null, null, context.getStartIndex(), context.getLimit()); - List results = new ArrayList(searchResults.size()); - for (ConceptSearchResult csr : searchResults) { - results.add(csr.getConcept()); - } - return new NeedsPaging(results, context); - } else if (searchType == null || "equals".equals(searchType)) { - - if (name != null) { - Concept concept = conceptService.getConceptByName(name); - concepts.add(concept); - if (concept != null) { - boolean isPreferredOrFullySpecified = false; - for (ConceptName conceptname : concept.getNames()) { - if (conceptname.getName().equalsIgnoreCase(name) - && (conceptname.isPreferred() || conceptname.isFullySpecifiedName())) { - isPreferredOrFullySpecified = true; - break; - } - } - if (!isPreferredOrFullySpecified) { - throw new APIException( - "The concept name should be either a fully specified or locale preferred name"); - } - - return new NeedsPaging(concepts, context); - } else { - return new EmptySearchResult(); - } - } - } else { - throw new InvalidSearchException("Invalid searchType: " + searchType - + ". Allowed values: \"equals\" and \"fuzzy\""); - } - - ConceptSource conceptSource = conceptService.getConceptSourceByUuid(source); - if (conceptSource == null) { - conceptSource = conceptService.getConceptSourceByName(source); - } - if (conceptSource == null) { - return new EmptySearchResult(); - } - - if (code == null) { - List conceptMaps = conceptService.getConceptMappingsToSource(conceptSource); - for (ConceptMap conceptMap : conceptMaps) { - if (!conceptMap.getConcept().isRetired() || context.getIncludeAll()) { - concepts.add(conceptMap.getConcept()); - } - } - return new NeedsPaging(concepts, context); - } else { - List conceptsByMapping = conceptService.getConceptsByMapping(code, source, false); - - return new NeedsPaging(conceptsByMapping, context); - } - } -} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/EncounterSearchHandler1_8.java b/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/EncounterSearchHandler1_8.java deleted file mode 100644 index 0785924d3..000000000 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/EncounterSearchHandler1_8.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_8; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import org.openmrs.Encounter; -import org.openmrs.EncounterType; -import org.openmrs.Patient; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.ConversionUtil; -import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; -import org.openmrs.module.webservices.rest.web.resource.api.SearchConfig; -import org.openmrs.module.webservices.rest.web.resource.api.SearchHandler; -import org.openmrs.module.webservices.rest.web.resource.api.SearchQuery; -import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; -import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.EncounterTypeResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; -import org.springframework.stereotype.Component; - -@Component -public class EncounterSearchHandler1_8 implements SearchHandler { - - private static final String DATE_FROM = "fromdate"; - - private static final String DATE_TO = "todate"; - - private final SearchConfig searchConfig = new SearchConfig("default", RestConstants.VERSION_1 + "/encounter", - Collections.singletonList("1.8.* - 1.12.*"), - Collections.singletonList(new SearchQuery.Builder( - "Allows you to find Encounter by patient and encounterType (and optionally by from and to date range)") - .withRequiredParameters("patient").withOptionalParameters("encounterType", DATE_FROM, DATE_TO, "order") - .build())); - - @Override - public SearchConfig getSearchConfig() { - return this.searchConfig; - } - - @Override - public PageableResult search(RequestContext context) throws ResponseException { - String patientUuid = context.getRequest().getParameter("patient"); - String encounterTypeUuid = context.getRequest().getParameter("encounterType"); - - String dateFrom = context.getRequest().getParameter(DATE_FROM); - String dateTo = context.getRequest().getParameter(DATE_TO); - - Date fromDate = dateFrom != null ? (Date) ConversionUtil.convert(dateFrom, Date.class) : null; - Date toDate = dateTo != null ? (Date) ConversionUtil.convert(dateTo, Date.class) : null; - - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( - Patient.class)).getByUniqueId(patientUuid); - EncounterType encounterType = ((EncounterTypeResource1_8) Context.getService(RestService.class) - .getResourceBySupportedClass(EncounterType.class)).getByUniqueId(encounterTypeUuid); - if (patient != null) { - List encounters = Context.getEncounterService().getEncounters(patient, null, fromDate, toDate, null, - encounterType != null ? Arrays.asList(encounterType) : null, null, context.getIncludeAll()); - String order = context.getRequest().getParameter("order"); - if ("desc".equals(order)) { - Collections.reverse(encounters); - } - return new NeedsPaging(encounters, context); - } - return new EmptySearchResult(); - } - -} diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/validation/ValidateUtilTest.java b/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/validation/ValidateUtilTest.java deleted file mode 100644 index 31e605ae0..000000000 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/validation/ValidateUtilTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.validation; - -import org.junit.Test; -import org.openmrs.Location; -import org.openmrs.module.webservices.validation.ValidateUtil; -import org.openmrs.test.Verifies; -import org.openmrs.web.test.BaseModuleWebContextSensitiveTest; - -public class ValidateUtilTest extends BaseModuleWebContextSensitiveTest { - - // we are not supporting this validation against 1.8, so when running against 1.8 no exception should be thrown - - /** - * @see {@link org.openmrs.validator.ValidateUtil#validate(Object)} - */ - @Test - @Verifies(value = "should not throw exception", method = "validate(Object)") - public void validate_shouldNotThrowValidationExceptionButShouldNotFail() throws Exception { - - // we are not supporting this validation against 1.8, so when running against 1.8 when passing in an - // invalid object, no exception should be thrown - - Location loc = new Location(); - loc.setName("name"); - ValidateUtil.validate(loc); - } - -} diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/RestTestConstants1_8.java b/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/RestTestConstants1_8.java deleted file mode 100644 index ef9335a0c..000000000 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/RestTestConstants1_8.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web; - -public class RestTestConstants1_8 { - - public static final String RESOURCE_TEST_DATASET = "resourceTestDataset.xml"; - - public static final String CONCEPT_UUID = "b055abd8-a420-4a11-8b98-02ee170a7b54"; - - public static final String CONCEPT2_UUID = "7d104a6f-8337-4afa-b936-41083a5d9d88"; - - public static final String CONCEPT_NUMERIC_UUID = "a09ab2c5-878e-4905-b25d-5784167d0216"; - - public static final String CONCEPT_NAME_UUID = "ef7ac747-7980-443c-b11f-4617aa587703"; - - public static final String CONCEPT_DESCRIPTION_UUID = "7ae2d5db-2aab-49b9-a256-7c258eaab067"; - - public static final String CONCEPT_DATATYPE_UUID = "8d4a4c94-c2cc-11de-8d13-0010c6dffd0f"; - - public static final String CONCEPT_CLASS_UUID = "ecdee8a7-d741-4fe7-8e01-f79cacbe97bc"; - - public static final String DRUG_UUID = "05ec820a-d297-44e3-be6e-698531d9dd3f"; - - public static final String PERSON_UUID = "da7f524f-27ce-4bb2-86d6-6d1d05312bd5"; - - public static final String PERSON_NAME_UUID = "399e3a7b-6482-487d-94ce-c07bb3ca3cc7"; - - public static final String PERSON_ADDRESS_UUID = "3350d0b5-821c-4e5e-ad1d-a9bce331e118"; - - public static final String PERSON_ATTRIBUTE_TYPE_UUID = "b3b6d540-a32e-44c7-91b3-292d97667518"; - - public static final String PERSON_ATTRIBUTE_UUID = "15d694af-43d6-443a-971c-ec210e3ec5c5"; - - public static final String PATIENT_UUID = "da7f524f-27ce-4bb2-86d6-6d1d05312bd5"; - - public static final String PATIENT_IDENTIFIER_UUID = "8a9aac6e-3f9f-4ed2-8fb5-25215f8bb614"; - - public static final String PATIENT_IDENTIFIER_TYPE_UUID = "1a339fe9-38bc-4ab3-b180-320988c0b968"; - - public static final String OBS_UUID = "39fb7f47-e80a-4056-9285-bd798be13c63"; - - public static final String ORDER_UUID = "921de0a3-05c4-444a-be03-e01b4c4b9142"; - - public static final String LOCATION_UUID = "167ce20c-4785-4285-9119-d197268f7f4a"; - - public static final String LOCATION_TAG_UUID = "001e503a-47ed-11df-bc8b-001e378eb67e"; - - public static final String ENCOUNTER_TYPE_UUID = "61ae96f4-6afe-4351-b6f8-cd4fc383cce1"; - - public static final String ENCOUNTER_UUID = "6519d653-393b-4118-9c83-a3715b82d4ac"; - - public static final String COHORT_UUID = "05e08b3b-5690-41e1-b651-5391fd946c1a"; - - public static final String HL7_SOURCE_NAME = "TEST"; - - public static final String USER_UUID = "c98a1558-e131-11de-babe-001e378eb67e"; - - public static final String ROLE_UUID = "3480cb6d-c291-46c8-8d3a-96dc33d199fb"; - - public static final String FORM_UUID = "d9218f76-6c39-45f4-8efa-4c5c6c199f50"; - - public static final String FORM_FIELD_UUID = "1c822b7b-7840-463d-ba70-e0c8338a4c2d"; - - public static final String FIELD_TYPE_UUID = "abf16b7d-39a5-4911-89da-0eefbfef7cb4"; - - public static final String FIELD_UUID = "db016b7d-39a5-4911-89da-0eefbfef7cb2"; - - public static final String ALLERGY_UUID = "40fb7f47-e80a-7890-9285-bd798be13c61"; - - public static final String PROBLEM_UUID = "50fb7f47-e80a-7890-9285-bd798be13c61"; - - public static final String CONCEPT_SOURCE_UUID = "75f5b378-5065-11de-80cb-001e378eb67e"; - - public static final String PRIVILEGE_UUID = "d979d066-15e6-467c-9d4b-cb575ef97f0f"; - - public static final String RELATIONSHIP_UUID = "c18717dd-5d78-4a0e-84fc-ee62c5f0676a"; - - public static final String RELATIONSHIP_TYPE_UUID = "6d9002ea-a96b-4889-af78-82d48c57a110"; - - public static final String PROGRAM_UUID = "f386c3d2-dd75-441f-a582-2237824edfb0"; - - public static final String WORKFLOW_UUID = "84f0effa-dd73-46cb-b931-7cd6be6c5f81"; - - public static final String PATIENT_PROGRAM_UUID = "b75462a0-4c92-451e-b8bc-e98b38b76534"; - - public static final String PATIENT_IN_A_PROGRAM_UUID = "da7f524f-27ce-4bb2-86d6-6d1d05312bd5"; - - public static final String PATIENT_WITH_VOIDED_PROGRAM_UUID = "8adf539e-4b5a-47aa-80c0-ba1025c957fa"; - - public static final String STATE_UUID = "92584cdc-6a20-4c84-a659-e035e45d36b0"; - - public static final String PATIENT_STATE_UUID = "ea89deaa-23cc-4840-92fe-63d199c37e4c"; - - public static final String TASK_DEFINITION_UUID = "266a2ff1-f0b1-45f4-ad04-2ce952a27920"; -} diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8Test.java b/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8Test.java deleted file mode 100644 index 9a8f6a71d..000000000 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientResource1_8Test.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import org.openmrs.Patient; -import org.openmrs.api.PatientService; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; -import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; - -public class PatientResource1_8Test extends BaseDelegatingResourceTest { - - @Override - public Patient newObject() { - return Context.getService(PatientService.class).getPatientByUuid(getUuidProperty()); - } - - @Override - public void validateDefaultRepresentation() throws Exception { - super.validateDefaultRepresentation(); - assertPropPresent("uuid"); - assertPropEquals("gender", getObject().getGender()); - assertPropEquals("age", getObject().getAge()); - assertPropEquals("birthdate", getObject().getBirthdate()); - assertPropEquals("birthdateEstimated", getObject().getBirthdateEstimated()); - assertPropEquals("dead", getObject().getDead()); - assertPropEquals("deathDate", getObject().getDeathDate()); - assertPropPresent("causeOfDeath"); - assertPropPresent("preferredName"); - assertPropPresent("preferredAddress"); - assertPropPresent("attributes"); - assertPropPresent("display"); - assertPropEquals("voided", getObject().getVoided()); - } - - @Override - public void validateFullRepresentation() throws Exception { - super.validateFullRepresentation(); - assertPropPresent("uuid"); - assertPropEquals("gender", getObject().getGender()); - assertPropEquals("age", getObject().getAge()); - assertPropEquals("birthdate", getObject().getBirthdate()); - assertPropEquals("birthdateEstimated", getObject().getBirthdateEstimated()); - assertPropEquals("dead", getObject().getDead()); - assertPropEquals("deathDate", getObject().getDeathDate()); - assertPropPresent("causeOfDeath"); - assertPropPresent("preferredName"); - assertPropPresent("preferredAddress"); - assertPropPresent("attributes"); - assertPropPresent("display"); - assertPropEquals("voided", getObject().getVoided()); - assertPropPresent("auditInfo"); - } - - @Override - public String getDisplayProperty() { - return "Mr. Horatio Test Hornblower Esq."; - } - - @Override - public String getUuidProperty() { - return RestTestConstants1_8.PATIENT_UUID; - } - -} diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResourceWithConcept1_8Test.java b/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResourceWithConcept1_8Test.java deleted file mode 100644 index 0454c8a8b..000000000 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResourceWithConcept1_8Test.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import static org.junit.Assert.assertEquals; - -import org.junit.Before; -import org.openmrs.Concept; -import org.openmrs.PersonAttributeType; -import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; - -public class PersonAttributeTypeResourceWithConcept1_8Test extends BaseDelegatingResourceTest { - - private static final String ACTIVE_LIST_INITIAL_XML = "personAttributeTypeWithConcept.xml"; - - @Before - public void init() throws Exception { - executeDataSet(ACTIVE_LIST_INITIAL_XML); - } - - @Override - public PersonAttributeType newObject() { - return Context.getPersonService().getPersonAttributeTypeByUuid(getUuidProperty()); - } - - @Override - public void validateFullRepresentation() throws Exception { - Concept concept = (Concept) getRepresentation().get("concept"); - assertEquals("d102c80f-1yz9-4da3-bb88-8122ce8868dd", concept.getUuid()); - } - - @Override - public String getDisplayProperty() { - return "Caste"; - } - - @Override - public String getUuidProperty() { - return "55e6ce9e-25bf-11e3-a013-3c0754156a5d"; - } -} diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ServerLogResource1_8Test.java b/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ServerLogResource1_8Test.java deleted file mode 100644 index af83c6d2f..000000000 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ServerLogResource1_8Test.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under - * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. - * - * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS - * graphic logo is a trademark of OpenMRS Inc. - */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; - -import org.apache.struts.mock.MockHttpServletResponse; -import org.junit.Assert; -import org.junit.Test; -import org.openmrs.module.webservices.helper.ServerLogActionWrapper; -import org.openmrs.module.webservices.helper.ServerLogActionWrapper1_8; -import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.MockServerLogActionWrapper; -import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController; -import org.openmrs.web.test.BaseModuleWebContextSensitiveTest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.mock.web.MockHttpServletRequest; - -import java.util.ArrayList; - -/** - * Integration tests for the ServerLogResource class - */ -public class ServerLogResource1_8Test extends BaseModuleWebContextSensitiveTest { - - @Autowired - RestService restService; - - @Autowired - private MainResourceController mainResourceController; - - private final MockServerLogActionWrapper mockServerLogActionWrapper = new MockServerLogActionWrapper( - new ServerLogActionWrapper1_8()); - - public String getURI() { - return "serverlog"; - } - - @Test - public void testGetAll() { - ServerLogResource1_8 serverLogResource = (ServerLogResource1_8) restService - .getResourceBySupportedClass(ServerLogActionWrapper.class); - serverLogResource.setServerLogActionWrapper(mockServerLogActionWrapper); - - MockHttpServletRequest request = new MockHttpServletRequest(); - request.setMethod("GET"); - MockHttpServletResponse response = new MockHttpServletResponse(); - SimpleObject result = mainResourceController.get(getURI(), request, response); - - ArrayList serverLog = result.get("serverLog"); - Assert.assertEquals(0, serverLog.size()); - - String mockLogLine1 = "INFO - Simple.appender(115) |2018-03-03 15:44:54,834| Info Message"; - // Add some mock log lines to mockMemoryAppenderBuffer - mockServerLogActionWrapper.mockMemoryAppenderBuffer.add(mockLogLine1); - result = mainResourceController.get(getURI(), request, response); - serverLog = result.get("serverLog"); - Assert.assertNotEquals(serverLog.size(), 0); - - String[] logLine1 = serverLog.get(0); - Assert.assertNotEquals(logLine1[0], null); - Assert.assertNotEquals(logLine1[1], null); - Assert.assertNotEquals(logLine1[2], null); - Assert.assertNotEquals(logLine1[3], null); - } - - @Test(expected = Exception.class) - public void shouldThrowExceptionWhenRequestGetDefaultByUuid() { - MockHttpServletRequest request = new MockHttpServletRequest(); - request.setMethod("GET"); - MockHttpServletResponse response = new MockHttpServletResponse(); - SimpleObject result = mainResourceController.get(getURI() + "/" + getUuid(), request, response); - - ArrayList serverLog = result.get("serverLog"); - } - - public String getUuid() { - return "log1"; - } -} diff --git a/omod-1.9/pom.xml b/omod-1.9/pom.xml index a5c3d1ecf..84dd6008a 100644 --- a/omod-1.9/pom.xml +++ b/omod-1.9/pom.xml @@ -29,20 +29,6 @@ test - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - - org.openmrs.api openmrs-api diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ChangePasswordController1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ChangePasswordController1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ChangePasswordController1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ChangePasswordController1_9.java index abac32aea..c34f992ec 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ChangePasswordController1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ChangePasswordController1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -37,7 +37,7 @@ @Controller @RequestMapping(value = "/rest/" + RestConstants.VERSION_1 + "/password") -public class ChangePasswordController1_8 extends BaseRestController { +public class ChangePasswordController1_9 extends BaseRestController { @Qualifier("userService") @Autowired diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/HL7MessageController1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/HL7MessageController1_9.java similarity index 95% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/HL7MessageController1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/HL7MessageController1_9.java index 4b3344453..6e635c819 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/HL7MessageController1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/HL7MessageController1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import java.io.IOException; @@ -27,7 +27,7 @@ import org.openmrs.module.webservices.rest.web.response.ResponseException; import org.openmrs.module.webservices.rest.web.v1_0.controller.BaseRestController; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceController; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.HL7MessageResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.HL7MessageResource1_9; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Controller; @@ -43,13 +43,13 @@ import ca.uhn.hl7v2.util.Terser; /** - * Controller for {@link HL7MessageResource1_8}. + * Controller for {@link HL7MessageResource1_9}. *

* It is provided, because we want to support posting plain HL7 messages in addition to those in * json. */ @Controller -public class HL7MessageController1_8 extends BaseRestController { +public class HL7MessageController1_9 extends BaseRestController { @Autowired @Qualifier("mainResourceController") @@ -92,7 +92,7 @@ public Object create(@RequestBody String hl7, HttpServletRequest request, HttpSe throw new ConversionException(e.getMessage(), e); } - Object created = ((HL7MessageResource1_8) Context.getService(RestService.class).getResourceByName( + Object created = ((HL7MessageResource1_9) Context.getService(RestService.class).getResourceByName( RestConstants.VERSION_1 + "/hl7")).create(post, context); return RestUtil.created(response, created); } diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ObsComplexValueController1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ObsComplexValueController1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ObsComplexValueController1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ObsComplexValueController1_9.java index ef6ddc4e3..976ea24d3 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ObsComplexValueController1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ObsComplexValueController1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.io.IOUtils; @@ -34,7 +34,7 @@ @Controller @RequestMapping(value = "/rest/" + RestConstants.VERSION_1 + "/obs") -public class ObsComplexValueController1_8 extends BaseRestController { +public class ObsComplexValueController1_9 extends BaseRestController { @Autowired ObsService obsService; diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/converter/openmrs1_8/UserConverter1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/converter/openmrs1_9/UserConverter1_9.java similarity index 85% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/converter/openmrs1_8/UserConverter1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/converter/openmrs1_9/UserConverter1_9.java index adcffe92a..bfda5df9e 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/converter/openmrs1_8/UserConverter1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/converter/openmrs1_9/UserConverter1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.converter.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.converter.openmrs1_9; import org.openmrs.User; import org.openmrs.annotation.Handler; @@ -18,15 +18,15 @@ import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.api.Converter; import org.openmrs.module.webservices.rest.web.response.ConversionException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.UserResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.UserAndPassword1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.UserResource1_9; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.UserAndPassword1_9; /** * An implementation of Converter to be able to create a representation from a User when User is * used in another resource. Currently UserAndPassword doesn't convert User */ @Handler(supports = User.class, order = 0) -public class UserConverter1_8 implements Converter { +public class UserConverter1_9 implements Converter { /** * @see org.openmrs.module.webservices.rest.web.resource.api.Converter#getByUniqueId(java.lang.String) @@ -50,8 +50,8 @@ public User newInstance(String type) { */ @Override public SimpleObject asRepresentation(User instance, Representation rep) throws ConversionException { - UserAndPassword1_8 userPass = new UserAndPassword1_8(instance); - UserResource1_8 userResource = (UserResource1_8) Context.getService(RestService.class).getResourceByName( + UserAndPassword1_9 userPass = new UserAndPassword1_9(instance); + UserResource1_9 userResource = (UserResource1_9) Context.getService(RestService.class).getResourceByName( RestConstants.VERSION_1 + "/user"); return userResource.asRepresentation(userPass, rep); } @@ -62,8 +62,8 @@ public SimpleObject asRepresentation(User instance, Representation rep) throws C */ @Override public Object getProperty(User instance, String propertyName) throws ConversionException { - UserAndPassword1_8 userPass = new UserAndPassword1_8(instance); - UserResource1_8 userResource = (UserResource1_8) Context.getService(RestService.class).getResourceByName( + UserAndPassword1_9 userPass = new UserAndPassword1_9(instance); + UserResource1_9 userResource = (UserResource1_9) Context.getService(RestService.class).getResourceByName( RestConstants.VERSION_1 + "/user"); return userResource.getProperty(userPass, propertyName); } @@ -74,8 +74,8 @@ public Object getProperty(User instance, String propertyName) throws ConversionE */ @Override public void setProperty(Object instance, String propertyName, Object value) throws ConversionException { - UserAndPassword1_8 userPass = new UserAndPassword1_8((User) instance); - UserResource1_8 userResource = (UserResource1_8) Context.getService(RestService.class).getResourceByName( + UserAndPassword1_9 userPass = new UserAndPassword1_9((User) instance); + UserResource1_9 userResource = (UserResource1_9) Context.getService(RestService.class).getResourceByName( RestConstants.VERSION_1 + "/user"); userResource.setProperty(userPass, propertyName, value); } diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ActiveListTypeResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ActiveListTypeResource1_9.java similarity index 96% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ActiveListTypeResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ActiveListTypeResource1_9.java index c12ea2ba3..c4059c702 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ActiveListTypeResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ActiveListTypeResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.activelist.ActiveListType; import org.openmrs.module.webservices.rest.web.RequestContext; @@ -23,8 +23,8 @@ * {@link Resource} for ActiveListType, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/activelisttype", supportedClass = ActiveListType.class, supportedOpenmrsVersions = { - "1.8.* - 1.12.*" }) -public class ActiveListTypeResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 1.12.*" }) +public class ActiveListTypeResource1_9 extends MetadataDelegatingCrudResource { /** * @see DelegatingCrudResource#newDelegate() diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/AllergyResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/AllergyResource1_9.java index 942126455..588aaeac2 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/AllergyResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/AllergyResource1_9.java @@ -9,15 +9,120 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; +import org.openmrs.Patient; import org.openmrs.activelist.Allergy; +import org.openmrs.activelist.AllergySeverity; +import org.openmrs.activelist.AllergyType; +import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty; +import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; +import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.AllergyResource1_8; +import org.openmrs.module.webservices.rest.web.api.RestService; +import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; +import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; +import org.openmrs.module.webservices.rest.web.representation.Representation; +import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; +import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; +import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PatientResource1_9; + +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.ObjectProperty; +import io.swagger.models.properties.RefProperty; +import io.swagger.models.properties.StringProperty; @Resource(name = RestConstants.VERSION_1 + "/allergy", supportedClass = Allergy.class, supportedOpenmrsVersions = { "1.9.*", "1.10.* - 1.12.*" }) -public class AllergyResource1_9 extends AllergyResource1_8 { +public class AllergyResource1_9 extends BaseActiveListItemResource1_9 { + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) + */ + @Override + public DelegatingResourceDescription getRepresentationDescription(Representation rep) { + if (rep instanceof DefaultRepresentation) { + DelegatingResourceDescription description = super.getRepresentationDescription(rep); + description.addProperty("allergyType"); + description.addProperty("reaction", Representation.REF); + description.addProperty("severity"); + description.addProperty("allergen", Representation.REF); + return description; + } else if (rep instanceof FullRepresentation) { + DelegatingResourceDescription description = super.getRepresentationDescription(rep); + description.addProperty("allergyType"); + description.addProperty("reaction", Representation.DEFAULT); + description.addProperty("severity"); + description.addProperty("allergen", Representation.DEFAULT); + return description; + } + return null; + } + + @Override + public Model getGETModel(Representation rep) { + ModelImpl model = ((ModelImpl) super.getGETModel(rep)) + .property("allergyType", new EnumProperty(AllergyType.class)) + .property("reaction", new RefProperty("#/definitions/ConceptGetRef")) + .property("severity", new EnumProperty(AllergySeverity.class)) + .property("allergen", new RefProperty("#/definitions/ConceptGetRef")); + if (rep instanceof FullRepresentation) { + model + .property("reaction", new RefProperty("#/definitions/ConceptGet")) + .property("allergen", new RefProperty("#/definitions/ConceptGet")); + } + return model; + } + + @Override + public Model getCREATEModel(Representation rep) { + return ((ModelImpl) super.getCREATEModel(rep)) + .property("allergyType", new EnumProperty(AllergyType.class)) + .property("reaction", new ObjectProperty() + .property("uuid", new StringProperty())) + .property("severity", new EnumProperty(AllergySeverity.class)) + .property("allergen", new StringProperty()); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() + */ + @Override + public Allergy newDelegate() { + return new Allergy(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = super.getCreatableProperties(); + description.addRequiredProperty("allergyType"); + description.addRequiredProperty("allergen"); + description.addProperty("reaction"); + description.addProperty("severity"); + + return description; + } + + /** + * Display string for allergy + * + * @param allergy + * @return String ConceptName + */ + @PropertyGetter("display") + public String getDisplayString(Allergy allergy) { + if (allergy.getAllergen() == null) + return ""; + + return allergy.getAllergen().getName().toString(); + } /** * Annotated setter for allergen @@ -29,4 +134,27 @@ public class AllergyResource1_9 extends AllergyResource1_8 { public static void setAllergen(Allergy allergy, Object value) { allergy.setAllergen(new ConceptResource1_9().getByUniqueId((String) value)); } + + /** + * Gets allergies for a given patient (paged according to context if necessary) only if a + * patient parameter exists in the request set on the {@link RequestContext} + * + * @param context + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(RequestContext) + */ + @Override + protected PageableResult doSearch(RequestContext context) { + String patientUuid = context.getRequest().getParameter("patient"); + if (patientUuid != null) { + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( + Patient.class)).getByUniqueId(patientUuid); + if (patient == null) + return new EmptySearchResult(); + + return new NeedsPaging(Context.getPatientService().getAllergies(patient), context); + } + + //currently this is not supported since the superclass throws an exception + return super.doSearch(context); + } } diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/BaseActiveListItemResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseActiveListItemResource1_9.java similarity index 99% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/BaseActiveListItemResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseActiveListItemResource1_9.java index 9ef1b74c0..64b1d4df9 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/BaseActiveListItemResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/BaseActiveListItemResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -30,7 +30,7 @@ * Subclass of {@link DataDelegatingCrudResource} with helper methods specific to * {@link ActiveListItem} */ -public abstract class BaseActiveListItemResource1_8 extends DataDelegatingCrudResource { +public abstract class BaseActiveListItemResource1_9 extends DataDelegatingCrudResource { @Override public Model getCREATEModel(Representation rep) { diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortMemberResource1_9.java similarity index 87% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortMemberResource1_9.java index e062d1db3..1983d97b9 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortMemberResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.ArrayList; import java.util.List; @@ -36,33 +36,33 @@ import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.CohortMember1_8; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.CohortMember1_9; /** * Sub-resource for cohort members */ -@SubResource(parent = CohortResource1_8.class, path = "member", supportedClass = CohortMember1_8.class, supportedOpenmrsVersions = { - "1.8.* - 2.0.*" }) -public class CohortMemberResource1_8 extends DelegatingSubResource { +@SubResource(parent = CohortResource1_9.class, path = "member", supportedClass = CohortMember1_9.class, supportedOpenmrsVersions = { + "1.9.* - 2.0.*" }) +public class CohortMemberResource1_9 extends DelegatingSubResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#doGetAll(java.lang.Object, * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override - public NeedsPaging doGetAll(Cohort parent, RequestContext context) throws ResponseException { - List members = new ArrayList(); + public NeedsPaging doGetAll(Cohort parent, RequestContext context) throws ResponseException { + List members = new ArrayList(); for (Patient cohortMember : Context.getService(RestHelperService.class).getPatients(parent.getMemberIds())) { - members.add(new CohortMember1_8(cohortMember, parent)); + members.add(new CohortMember1_9(cohortMember, parent)); } - return new NeedsPaging(members, context); + return new NeedsPaging(members, context); } /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object) */ @Override - public Cohort getParent(CohortMember1_8 instance) { + public Cohort getParent(CohortMember1_9 instance) { return instance.getCohort(); } @@ -71,7 +71,7 @@ public Cohort getParent(CohortMember1_8 instance) { * java.lang.Object) */ @Override - public void setParent(CohortMember1_8 instance, Cohort parent) { + public void setParent(CohortMember1_9 instance, Cohort parent) { instance.setCohort(parent); } @@ -80,7 +80,7 @@ public void setParent(CohortMember1_8 instance, Cohort parent) { * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) */ @Override - protected void delete(CohortMember1_8 delegate, String reason, RequestContext context) throws ResponseException { + protected void delete(CohortMember1_9 delegate, String reason, RequestContext context) throws ResponseException { removeMemberFromCohort(delegate); } @@ -88,8 +88,8 @@ protected void delete(CohortMember1_8 delegate, String reason, RequestContext co * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) */ @Override - public CohortMember1_8 getByUniqueId(String uniqueId) { - return new CohortMember1_8(Context.getPatientService().getPatientByUuid(uniqueId), null); + public CohortMember1_9 getByUniqueId(String uniqueId) { + return new CohortMember1_9(Context.getPatientService().getPatientByUuid(uniqueId), null); } /** @@ -175,8 +175,8 @@ public DelegatingResourceDescription getUpdatableProperties() { * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() */ @Override - public CohortMember1_8 newDelegate() { - return new CohortMember1_8(); + public CohortMember1_9 newDelegate() { + return new CohortMember1_9(); } /** @@ -184,7 +184,7 @@ public CohortMember1_8 newDelegate() { * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override - public void purge(CohortMember1_8 delegate, RequestContext context) throws ResponseException { + public void purge(CohortMember1_9 delegate, RequestContext context) throws ResponseException { throw new ResourceDoesNotSupportOperationException(); } @@ -192,7 +192,7 @@ public void purge(CohortMember1_8 delegate, RequestContext context) throws Respo * Should add patient to cohort */ @Override - public CohortMember1_8 save(CohortMember1_8 delegate) { + public CohortMember1_9 save(CohortMember1_9 delegate) { addMemberToCohort(delegate); return delegate; } @@ -200,7 +200,7 @@ public CohortMember1_8 save(CohortMember1_8 delegate) { /** * @param member the patient to be added to cohort */ - public void addMemberToCohort(CohortMember1_8 member) { + public void addMemberToCohort(CohortMember1_9 member) { getParent(member).addMember(member.getPatient().getId()); Context.getCohortService().saveCohort(getParent(member)); } @@ -208,7 +208,7 @@ public void addMemberToCohort(CohortMember1_8 member) { /** * @param member the patient to be removed from cohort */ - public void removeMemberFromCohort(CohortMember1_8 member) { + public void removeMemberFromCohort(CohortMember1_9 member) { getParent(member).removeMember(member.getPatient().getId()); Context.getCohortService().saveCohort(getParent(member)); } @@ -221,7 +221,7 @@ public void removeMemberFromCohort(CohortMember1_8 member) { @Override public Object create(String parentUniqueId, SimpleObject post, RequestContext context) throws ResponseException { Cohort parent = Context.getCohortService().getCohortByUuid(parentUniqueId); - CohortMember1_8 delegate = newDelegate(); + CohortMember1_9 delegate = newDelegate(); setParent(delegate, parent); delegate.setPatient(Context.getPatientService().getPatientByUuid(post.get("patient").toString())); delegate = save(delegate); @@ -235,7 +235,7 @@ public Object create(String parentUniqueId, SimpleObject post, RequestContext co */ @Override public void delete(String parentUniqueId, String uuid, String reason, RequestContext context) throws ResponseException { - CohortMember1_8 delegate = getByUniqueId(uuid); + CohortMember1_9 delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); Cohort parent = Context.getCohortService().getCohortByUuid(parentUniqueId); @@ -249,7 +249,7 @@ public void delete(String parentUniqueId, String uuid, String reason, RequestCon */ @Override public Object retrieve(String parentUniqueId, String uuid, RequestContext context) throws ResponseException { - CohortMember1_8 delegate = getByUniqueId(uuid); + CohortMember1_9 delegate = getByUniqueId(uuid); if (delegate == null) throw new ObjectNotFoundException(); delegate.setCohort(Context.getCohortService().getCohortByUuid(parentUniqueId)); @@ -262,7 +262,7 @@ public Object retrieve(String parentUniqueId, String uuid, RequestContext contex * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUniqueId(java.lang.Object) */ @Override - protected String getUniqueId(CohortMember1_8 delegate) { + protected String getUniqueId(CohortMember1_9 delegate) { return delegate.getPatient().getUuid(); } @@ -271,7 +271,7 @@ protected String getUniqueId(CohortMember1_8 delegate) { * @return string that contains cohort member's identifier and full name */ @PropertyGetter("display") - public String getDisplayString(CohortMember1_8 member) { + public String getDisplayString(CohortMember1_9 member) { if (member.getPatient().getPatientIdentifier() == null) return ""; diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortResource1_9.java index ff12bc660..0ec72e021 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.List; @@ -33,8 +33,8 @@ /** * {@link Resource} for Cohorts, supporting standard CRUD operations */ -@Resource(name = RestConstants.VERSION_1 + "/cohort", supportedClass = Cohort.class, supportedOpenmrsVersions = { "1.8.* - 2.0.*" }) -public class CohortResource1_8 extends DataDelegatingCrudResource { +@Resource(name = RestConstants.VERSION_1 + "/cohort", supportedClass = Cohort.class, supportedOpenmrsVersions = { "1.9.* - 2.0.*" }) +public class CohortResource1_9 extends DataDelegatingCrudResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#delete(java.lang.Object, diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptClassResource1_9.java similarity index 96% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptClassResource1_9.java index e4a8e25a0..2ec231b56 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptClassResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import org.openmrs.ConceptClass; @@ -25,8 +25,8 @@ * {@link Resource} for {@link ConceptClass}, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/conceptclass", supportedClass = ConceptClass.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class ConceptClassResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 9.*" }) +public class ConceptClassResource1_9 extends MetadataDelegatingCrudResource { /** * @see DelegatingCrudResource#newDelegate() diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDatatypeResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDatatypeResource1_9.java index 0de73cceb..ca6203c27 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDatatypeResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -33,8 +33,8 @@ * {@link Resource} for {@link ConceptDatatype}, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/conceptdatatype", supportedClass = ConceptDatatype.class, supportedOpenmrsVersions = { - "1.8.* - 1.12.*" }) -public class ConceptDatatypeResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 1.12.*" }) +public class ConceptDatatypeResource1_9 extends MetadataDelegatingCrudResource { /** * @see DelegatingCrudResource#getRepresentationDescription(Representation) diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDescriptionResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDescriptionResource1_9.java index e6d3a3d27..1516d6cf2 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDescriptionResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDescriptionResource1_9.java @@ -9,16 +9,209 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; +import java.util.ArrayList; +import java.util.List; + +import org.openmrs.Concept; import org.openmrs.ConceptDescription; +import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.rest.web.RequestContext; +import org.openmrs.module.webservices.rest.web.RestConstants; +import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; import org.openmrs.module.webservices.rest.web.annotation.SubResource; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptDescriptionResource1_8; +import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; +import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; +import org.openmrs.module.webservices.rest.web.representation.RefRepresentation; +import org.openmrs.module.webservices.rest.web.representation.Representation; +import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; +import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.response.ResponseException; +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.StringProperty; /** * Implemented to increase the resource version. */ @SubResource(parent = ConceptResource1_9.class, path = "description", supportedClass = ConceptDescription.class, supportedOpenmrsVersions = { "1.9.* - 9.*" }) -public class ConceptDescriptionResource1_9 extends ConceptDescriptionResource1_8 { +public class ConceptDescriptionResource1_9 extends DelegatingSubResource { + + @Override + public DelegatingResourceDescription getRepresentationDescription(Representation rep) { + if (rep instanceof RefRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addSelfLink(); + return description; + } else if (rep instanceof DefaultRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("display"); + description.addProperty("uuid"); + description.addProperty("description"); + description.addProperty("locale"); + description.addSelfLink(); + description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); + return description; + } else if (rep instanceof FullRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("description"); + description.addProperty("locale"); + description.addProperty("auditInfo"); + description.addSelfLink(); + return description; + } + return null; + } + + public Model getGETModel(Representation rep) { + ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); + if (rep instanceof RefRepresentation) { + modelImpl + .property("uuid", new StringProperty()) + .property("display", new StringProperty()); + } else if (rep instanceof DefaultRepresentation) { + modelImpl + .property("uuid", new StringProperty()) + .property("display", new StringProperty()) + .property("description", new StringProperty()) + .property("locale", new StringProperty()); + } else if (rep instanceof FullRepresentation) { + modelImpl + .property("uuid", new StringProperty()) + .property("display", new StringProperty()) + .property("description", new StringProperty()) + .property("locale", new StringProperty()); + } + return modelImpl; + } + + @Override + public Model getCREATEModel(Representation representation) { + return new ModelImpl() + .property("description", new StringProperty()) + .property("locale", new StringProperty().example("fr")) + .required("description").required("locale"); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addRequiredProperty("description"); + description.addRequiredProperty("locale"); + return description; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object) + */ + @Override + public Concept getParent(ConceptDescription instance) { + return instance.getConcept(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#setParent(java.lang.Object, + * java.lang.Object) + */ + @Override + public void setParent(ConceptDescription instance, Concept concept) { + instance.setConcept(concept); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.api.SubResource#doGetAll(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public NeedsPaging doGetAll(Concept parent, RequestContext context) throws ResponseException { + //convert from a collection to a list + List descriptions = new ArrayList(); + if (parent != null) { + for (ConceptDescription description : parent.getDescriptions()) { + descriptions.add(description); + } + } + return new NeedsPaging(descriptions, context); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) + */ + @Override + public ConceptDescription getByUniqueId(String uuid) { + return Context.getConceptService().getConceptDescriptionByUuid(uuid); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#delete(java.lang.Object, + * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void delete(ConceptDescription cd, String reason, RequestContext context) throws ResponseException { + //concept descriptions are neither voidable nor retireable, so delegate to purge + purge(cd, context); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void purge(ConceptDescription cd, RequestContext context) throws ResponseException { + cd.getConcept().removeDescription(cd); + Context.getConceptService().saveConcept(cd.getConcept()); + } + + /** + * @param newDescription + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) + */ + @Override + public ConceptDescription save(ConceptDescription newDescription) { + newDescription.getConcept().addDescription(newDescription); + Context.getConceptService().saveConcept(newDescription.getConcept()); + return newDescription; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() + */ + @Override + public ConceptDescription newDelegate() { + return new ConceptDescription(); + } + + /** + * Gets the display string for a concept description including its locale. + * + * @param conceptDescription the concept description object. + * @return the display string. + */ + @PropertyGetter("display") + public String getDisplayString(ConceptDescription conceptDescription) { + return conceptDescription.getDescription(); + } + + /** + * Returns the locale as a string + * + * @param instance + * @return + */ + @PropertyGetter("locale") + public String getLocaleAsString(ConceptDescription instance) { + if (instance.getLocale() == null) + return ""; + + return instance.getLocale().toString(); + } /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getResourceVersion() diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapResource1_9.java index 420153e67..e204b1826 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptMapResource1_9.java @@ -12,25 +12,36 @@ import io.swagger.models.Model; import io.swagger.models.ModelImpl; import io.swagger.models.properties.RefProperty; + +import java.util.ArrayList; +import java.util.List; + import org.apache.commons.lang.StringUtils; +import org.openmrs.Concept; import org.openmrs.ConceptMap; +import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; import org.openmrs.module.webservices.rest.web.annotation.Resource; import org.openmrs.module.webservices.rest.web.annotation.SubResource; +import org.openmrs.module.webservices.rest.web.api.RestHelperService; import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; +import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptMapResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptResource1_8; +import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; +import org.openmrs.module.webservices.rest.web.response.ResponseException; /** * {@link Resource} for {@link ConceptMap}, supporting standard CRUD operations */ -@SubResource(path = "mapping", parent = ConceptResource1_8.class, supportedClass = ConceptMap.class, supportedOpenmrsVersions = { +@SubResource(path = "mapping", parent = ConceptResource1_9.class, supportedClass = ConceptMap.class, supportedOpenmrsVersions = { "1.9.* - 9.*" }) -public class ConceptMapResource1_9 extends ConceptMapResource1_8 { +public class ConceptMapResource1_9 extends DelegatingSubResource { @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { @@ -108,7 +119,6 @@ public String getResourceVersion() { * @param conceptMap the concept map object. * @return the display string. */ - @Override @PropertyGetter("display") public String getDisplayString(ConceptMap conceptMap) { if (conceptMap.getConceptReferenceTerm() == null || conceptMap.getConceptReferenceTerm().getConceptSource() == null) { @@ -122,4 +132,75 @@ public String getDisplayString(ConceptMap conceptMap) { } return display; } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#newDelegate() + */ + @Override + public ConceptMap newDelegate() { + return new ConceptMap(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) + */ + @Override + public ConceptMap save(ConceptMap newMap) { + newMap.getConcept().addConceptMapping(newMap); + Context.getConceptService().saveConcept(newMap.getConcept()); + return newMap; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object) + */ + @Override + public Concept getParent(ConceptMap instance) { + return instance.getConcept(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#setParent(java.lang.Object, + * java.lang.Object) + */ + @Override + public void setParent(ConceptMap instance, Concept parent) { + instance.setConcept(parent); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#doGetAll(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public PageableResult doGetAll(Concept parent, RequestContext context) throws ResponseException { + List maps = new ArrayList(parent.getConceptMappings()); + return new NeedsPaging(maps, context); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) + */ + @Override + public ConceptMap getByUniqueId(String uniqueId) { + return Context.getService(RestHelperService.class).getObjectByUuid(ConceptMap.class, uniqueId); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#delete(java.lang.Object, + * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected void delete(ConceptMap delegate, String reason, RequestContext context) throws ResponseException { + throw new ResourceDoesNotSupportOperationException(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void purge(ConceptMap delegate, RequestContext context) throws ResponseException { + delegate.getConcept().removeConceptMapping(delegate); + } } diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNameResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNameResource1_9.java index f096b5e4d..ab27cb374 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNameResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNameResource1_9.java @@ -9,16 +9,226 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.openmrs.Concept; import org.openmrs.ConceptName; +import org.openmrs.api.ConceptNameType; +import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty; +import org.openmrs.module.webservices.rest.web.RequestContext; +import org.openmrs.module.webservices.rest.web.RestConstants; +import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; import org.openmrs.module.webservices.rest.web.annotation.SubResource; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptNameResource1_8; +import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; +import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; +import org.openmrs.module.webservices.rest.web.representation.Representation; +import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; +import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.response.ResponseException; +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.StringProperty; /** * Implemented to increase the resource version. */ @SubResource(parent = ConceptResource1_9.class, path = "name", supportedClass = ConceptName.class, supportedOpenmrsVersions = { "1.9.* - 9.*" }) -public class ConceptNameResource1_9 extends ConceptNameResource1_8 { +public class ConceptNameResource1_9 extends DelegatingSubResource { + + @Override + public DelegatingResourceDescription getRepresentationDescription(Representation rep) { + if (rep instanceof DefaultRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("display"); + description.addProperty("uuid"); + description.addProperty("name"); + description.addProperty("locale"); + description.addProperty("localePreferred"); + description.addProperty("conceptNameType"); + description.addSelfLink(); + description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); + return description; + } else if (rep instanceof FullRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("display"); + description.addProperty("uuid"); + description.addProperty("name"); + description.addProperty("locale"); + description.addProperty("localePreferred"); + description.addProperty("conceptNameType"); + description.addProperty("auditInfo"); + description.addSelfLink(); + return description; + } + return null; + } + + public Model getGETModel(Representation rep) { + ModelImpl model = ((ModelImpl) super.getGETModel(rep)) + .property("uuid", new StringProperty()) + .property("display", new StringProperty()); + + if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { + model + .property("name", new StringProperty()) + .property("locale", new StringProperty().example("en")) + .property("localePreferred", new BooleanProperty()) + .property("conceptNameType", new EnumProperty(ConceptNameType.class)); + } + return model; + } + + @Override + public Model getCREATEModel(Representation rep) { + return new ModelImpl() + .property("name", new StringProperty()) + .property("locale", new StringProperty().example("en")) + .property("localePreferred", new BooleanProperty()._default(false)) + .property("conceptNameType", new EnumProperty(ConceptNameType.class)) + .required("name").required("locale"); + } + + @Override + public Model getUPDATEModel(Representation representation) { + return new ModelImpl() + .property("name", new StringProperty()); //FIXME missing props + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addRequiredProperty("name"); + description.addRequiredProperty("locale"); + description.addProperty("localePreferred"); + description.addProperty("conceptNameType"); + return description; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#getParent(java.lang.Object) + */ + @Override + public Concept getParent(ConceptName instance) { + return instance.getConcept(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#setParent(java.lang.Object, + * java.lang.Object) + */ + @Override + public void setParent(ConceptName instance, Concept concept) { + instance.setConcept(concept); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.api.SubResource#doGetAll(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public NeedsPaging doGetAll(Concept parent, RequestContext context) throws ResponseException { + List names = new ArrayList(); + if (parent != null) { + for (ConceptName name : parent.getNames()) { + if (!name.isVoided()) + names.add(name); + } + } + return new NeedsPaging(names, context); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) + */ + @Override + public ConceptName getByUniqueId(String uuid) { + return Context.getConceptService().getConceptNameByUuid(uuid); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#delete(java.lang.Object, + * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void delete(ConceptName cn, String reason, RequestContext context) throws ResponseException { + cn.setVoided(true); + cn.setVoidedBy(Context.getAuthenticatedUser()); + cn.setVoidReason(reason); + cn.setDateVoided(new Date()); + Context.getConceptService().saveConcept(cn.getConcept()); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void purge(ConceptName cn, RequestContext context) throws ResponseException { + cn.getConcept().removeName(cn); + Context.getConceptService().saveConcept(cn.getConcept()); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) + */ + @Override + public ConceptName save(ConceptName newName) { + // make sure that the name has actually been added to the concept + boolean needToAdd = true; + for (ConceptName cn : newName.getConcept().getNames()) { + if (cn.equals(newName)) { + needToAdd = false; + break; + } + } + if (needToAdd) + newName.getConcept().addName(newName); + Context.getConceptService().saveConcept(newName.getConcept()); + return newName; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() + */ + @Override + public ConceptName newDelegate() { + return new ConceptName(); + } + + /** + * Gets the display string for a concept name. + * + * @param conceptName the concept name object. + * @return the display string. + */ + @PropertyGetter("display") + public String getDisplayString(ConceptName conceptName) { + return conceptName.getName(); + } + + /** + * Gets the locale as a string + * + * @param instance + * @return + */ + @PropertyGetter("locale") + public String getLocaleAsString(ConceptName instance) { + + if (instance.getLocale() == null) + return ""; + + return instance.getLocale().toString(); + } /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getResourceVersion() diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptResource1_9.java index e612e9aee..984e592b4 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptResource1_9.java @@ -9,18 +9,504 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Locale; +import java.util.Set; + +import org.apache.commons.lang.StringUtils; import org.openmrs.Concept; +import org.openmrs.ConceptAnswer; +import org.openmrs.ConceptClass; +import org.openmrs.ConceptDatatype; +import org.openmrs.ConceptDescription; +import org.openmrs.ConceptMap; +import org.openmrs.ConceptName; +import org.openmrs.ConceptNumeric; +import org.openmrs.ConceptSearchResult; +import org.openmrs.Drug; +import org.openmrs.OpenmrsObject; +import org.openmrs.api.ConceptService; import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.helper.HibernateCollectionHelper; +import org.openmrs.module.webservices.rest.SimpleObject; +import org.openmrs.module.webservices.rest.web.ConversionUtil; +import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; +import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; +import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; +import org.openmrs.module.webservices.rest.web.annotation.RepHandler; import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptResource1_8; +import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; +import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; +import org.openmrs.module.webservices.rest.web.representation.NamedRepresentation; +import org.openmrs.module.webservices.rest.web.representation.RefRepresentation; +import org.openmrs.module.webservices.rest.web.representation.Representation; +import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; +import org.openmrs.module.webservices.rest.web.resource.impl.AlreadyPaged; +import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource; +import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.response.ConversionException; +import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; +import org.openmrs.module.webservices.rest.web.response.ResponseException; +import org.openmrs.util.LocaleUtility; + +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.ObjectProperty; +import io.swagger.models.properties.RefProperty; +import io.swagger.models.properties.StringProperty; +import org.openmrs.util.OpenmrsUtil; /** * Implemented to increase the resource version since the mapping subresource changed. */ @Resource(name = RestConstants.VERSION_1 + "/concept", order = 1, supportedClass = Concept.class, supportedOpenmrsVersions = { "1.9.* - 1.10.*" }) -public class ConceptResource1_9 extends ConceptResource1_8 { +public class ConceptResource1_9 extends DelegatingCrudResource { + + public ConceptResource1_9() { + //RESTWS-439 + //Concept numeric fields + allowedMissingProperties.add("hiNormal"); + allowedMissingProperties.add("hiAbsolute"); + allowedMissingProperties.add("hiCritical"); + allowedMissingProperties.add("lowNormal"); + allowedMissingProperties.add("lowAbsolute"); + allowedMissingProperties.add("lowCritical"); + allowedMissingProperties.add("units"); + allowedMissingProperties.add("precise"); + allowedMissingProperties.add("allowDecimal"); + allowedMissingProperties.add("displayPrecision"); + } + + @RepHandler(RefRepresentation.class) + public SimpleObject asRef(Concept delegate) throws ConversionException { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display", "displayString", Representation.DEFAULT); + if (delegate.isRetired()) { + description.addProperty("retired"); + } + description.addSelfLink(); + return convertDelegateToRepresentation(delegate, description); + } + + @RepHandler(FullRepresentation.class) + public SimpleObject asFull(Concept delegate) throws ConversionException { + DelegatingResourceDescription description = fullRepresentationDescription(delegate); + return convertDelegateToRepresentation(delegate, description); + } + + @RepHandler(value = NamedRepresentation.class, name = "fullchildren") + public SimpleObject asFullChildren(Concept delegate) throws ConversionException { + Set path = new HashSet(); + path.add(delegate.getUuid()); + assertNoCycles(delegate, path); + + return asFullChildrenInternal(delegate); + } + + protected void assertNoCycles(Concept delegate, Set path) throws ConversionException { + for (Concept member : delegate.getSetMembers()) { + if (path.add(member.getUuid())) { + assertNoCycles(member, path); + } else { + throw new ConversionException("Cycles in children are not supported. Concept with uuid " + + delegate.getUuid() + " repeats in a set."); + } + path.remove(member.getUuid()); + } + } + + /** + * It is used internally for the fullchildren representation. Contrary to the fullchildren + * handler it does not check for cycles. + * + * @param delegate + * @return + * @throws ConversionException + */ + @RepHandler(value = NamedRepresentation.class, name = "fullchildreninternal") + public SimpleObject asFullChildrenInternal(Concept delegate) throws ConversionException { + DelegatingResourceDescription description = fullRepresentationDescription(delegate); + description.removeProperty("setMembers"); + description.addProperty("setMembers", new NamedRepresentation("fullchildreninternal")); + description.removeProperty("answers"); + description.addProperty("answers", Representation.FULL); + return convertDelegateToRepresentation(delegate, description); + } + + @Override + public List getAvailableRepresentations() { + List availableRepresentations = super.getAvailableRepresentations(); + availableRepresentations.add(new NamedRepresentation("fullchildren")); + return availableRepresentations; + } + + protected DelegatingResourceDescription fullRepresentationDescription(Concept delegate) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("name", Representation.DEFAULT); + description.addProperty("datatype", Representation.DEFAULT); + description.addProperty("conceptClass", Representation.DEFAULT); + description.addProperty("set"); + description.addProperty("version"); + description.addProperty("retired"); + + description.addProperty("names", Representation.DEFAULT); + description.addProperty("descriptions", Representation.DEFAULT); + + description.addProperty("mappings", Representation.DEFAULT); + + description.addProperty("answers", Representation.DEFAULT); + description.addProperty("setMembers", Representation.DEFAULT); + description.addProperty("auditInfo"); + description.addSelfLink(); + + if (delegate.isNumeric()) { + description.addProperty("hiNormal"); + description.addProperty("hiAbsolute"); + description.addProperty("hiCritical"); + description.addProperty("lowNormal"); + description.addProperty("lowAbsolute"); + description.addProperty("lowCritical"); + description.addProperty("units"); + description.addProperty("precise"); + } + return description; + } + + /** + * @see DelegatingCrudResource#getRepresentationDescription(Representation) + */ + @Override + public DelegatingResourceDescription getRepresentationDescription(Representation rep) { + if (rep instanceof DefaultRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("name", Representation.DEFAULT); + description.addProperty("datatype", Representation.REF); + description.addProperty("conceptClass", Representation.REF); + description.addProperty("set"); + description.addProperty("version"); + description.addProperty("retired"); + + description.addProperty("names", Representation.REF); + description.addProperty("descriptions", Representation.REF); + + description.addProperty("mappings", Representation.REF); + + description.addProperty("answers", Representation.REF); + description.addProperty("setMembers", Representation.REF); + //description.addProperty("conceptMappings", Representation.REF); add as subresource + + description.addSelfLink(); + description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); + return description; + } + return null; + } + + public Model getGETModel(Representation rep) { + ModelImpl modelImpl = ((ModelImpl) super.getGETModel(rep)) + .property("uuid", new StringProperty()) + .property("display", new StringProperty()); + if (rep instanceof DefaultRepresentation) { + modelImpl + .property("name", new RefProperty("#/definitions/ConceptNameGet")) + .property("datatype", new RefProperty("#/definitions/ConceptdatatypeGetRef")) + .property("conceptClass", new RefProperty("#/definitions/ConceptclassGetRef")) + .property("set", new BooleanProperty()) + .property("version", new StringProperty()) + .property("retired", new BooleanProperty()) + .property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameGetRef"))) //FIXME + .property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionGetRef"))) //FIXME + .property("mappings", new ArrayProperty(new RefProperty("#/definitions/ConceptMappingGetRef"))) //FIXME + .property("answers", new ArrayProperty(new ObjectProperty())) //FIXME + .property("setMembers", new ArrayProperty(new ObjectProperty())); //FIXME + } + return modelImpl; + } + + @Override + public Model getCREATEModel(Representation rep) { + ModelImpl model = new ModelImpl() + .property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameCreate"))) + .property("datatype", new StringProperty().example("uuid")) + .property("set", new BooleanProperty()) + .property("version", new StringProperty()) + .property("answers", new ArrayProperty(new StringProperty().example("uuid"))) + .property("setMembers", new ArrayProperty(new StringProperty().example("uuid"))) + + //ConceptNumeric properties + .property("hiNormal", new StringProperty()) + .property("hiAbsolute", new StringProperty()) + .property("hiCritical", new StringProperty()) + .property("lowNormal", new StringProperty()) + .property("lowAbsolute", new StringProperty()) + .property("lowCritical", new StringProperty()) + .property("units", new StringProperty()) + .property("allowDecimal", new StringProperty()) + .property("displayPrecision", new StringProperty()) + + .required("names").required("datatype").required("conceptClass"); + if (rep instanceof DefaultRepresentation) { + model + .property("conceptClass", new StringProperty()) + .property("descriptions", new ArrayProperty(new StringProperty())) + .property("mappings", new ArrayProperty(new StringProperty())); + } + else if (rep instanceof FullRepresentation) { + model + .property("conceptClass", new RefProperty("#/definitions/ConceptclassCreate")) + .property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionCreate"))) + .property("mappings", new ArrayProperty(new RefProperty("#/definitions/ConceptMappingCreate"))); + } + return model; + } + + @Override + public Model getUPDATEModel(Representation representation) { + return new ModelImpl() + .property("name", new RefProperty("#/definitions/ConceptNameCreate")) + .property("names", new ArrayProperty(new RefProperty("#/definitions/ConceptNameCreate"))) + .property("descriptions", new ArrayProperty(new RefProperty("#/definitions/ConceptDescriptionCreate"))); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addRequiredProperty("names"); + description.addRequiredProperty("datatype"); + description.addRequiredProperty("conceptClass"); + + description.addProperty("descriptions"); + description.addProperty("set"); + description.addProperty("version"); + description.addProperty("mappings"); + description.addProperty("answers"); + description.addProperty("setMembers"); + + //ConceptNumeric properties + description.addProperty("hiNormal"); + description.addProperty("hiAbsolute"); + description.addProperty("hiCritical"); + description.addProperty("lowNormal"); + description.addProperty("lowAbsolute"); + description.addProperty("lowCritical"); + description.addProperty("units"); + description.addProperty("allowDecimal"); + description.addProperty("displayPrecision"); + return description; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties() + */ + @Override + public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException { + DelegatingResourceDescription description = super.getUpdatableProperties(); + + description.addProperty("name"); + description.addProperty("names"); + description.addProperty("descriptions"); + + return description; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getPropertiesToExposeAsSubResources() + */ + @Override + public List getPropertiesToExposeAsSubResources() { + return Arrays.asList("names", "descriptions", "conceptMappings"); + } + + /** + * Sets the name property to be the fully specified name of the Concept in the current locale + * + * @param instance + * @param name + */ + @PropertySetter("name") + public static void setFullySpecifiedName(Concept instance, String name) { + ConceptName fullySpecifiedName = new ConceptName(name, Context.getLocale()); + instance.setFullySpecifiedName(fullySpecifiedName); + } + + /** + * It's needed, because of ConversionException: Don't know how to handle collection class: + * interface java.util.Collection If request to update Concept updates ConceptName, adequate + * resource takes care of it, so this method just adds new and removes deleted names. + * + * @param instance + * @param names + */ + @PropertySetter("names") + public static void setNames(Concept instance, List names) { + + new HibernateCollectionHelper(instance) { + + @Override + public int compare(ConceptName left, ConceptName right) { + if (OpenmrsUtil.nullSafeEquals(left.getUuid(), right.getUuid())) { + return 0; + } + + int result = OpenmrsUtil.compareWithNullAsLowest(left.getName(), right.getName()); + + if (result == 0) { + result = OpenmrsUtil.compareWithNullAsLowest(left.getConceptNameType(), right.getConceptNameType()); + } + + if (result == 0) { + result = OpenmrsUtil.compareWithNullAsLowest(left.getLocale().toString(), right.getLocale().toString()); + } + + return result; + } + + @Override + public Collection getAll() { + return instance.getNames(); + } + + @Override + public void add(ConceptName item) { + instance.addName(item); + } + + @Override + public void remove(ConceptName item) { + instance.removeName(item); + } + }.set(names); + } + + /** + * It's needed, because of ConversionException: Don't know how to handle collection class: + * interface java.util.Collection + * + * @param instance + * @param descriptions + */ + @PropertySetter("descriptions") + public static void setDescriptions(Concept instance, List descriptions) { + new HibernateCollectionHelper(instance) { + @Override + public int compare(ConceptDescription left, ConceptDescription right) { + int result = OpenmrsUtil.compareWithNullAsLowest(left.getUuid(), right.getUuid()); + + if (result == 0) { + result = OpenmrsUtil.compareWithNullAsLowest(left.getDescription(), right.getDescription()); + } + + if (result == 0) { + result = OpenmrsUtil.compareWithNullAsLowest(left.getLocale().toString(), right.getLocale().toString()); + } + + return result; + } + + @Override + public Collection getAll() { + return instance.getDescriptions(); + } + + @Override + public void add(ConceptDescription item) { + instance.addDescription(item); + } + + @Override + public void remove(ConceptDescription item) { + instance.removeDescription(item); + } + }.set(descriptions); + } + + /** + * It's needed, because of ConversionException: Don't know how to handle collection class: + * interface java.util.Collection + * + * @param instance + * @param mappings + */ + @PropertySetter("mappings") + public static void setMappings(Concept instance, List mappings) { + instance.getConceptMappings().clear(); + for (ConceptMap map : mappings) { + instance.addConceptMapping(map); + } + } + + @PropertyGetter("mappings") + public static List getMappings(Concept instance) { + return new ArrayList(instance.getConceptMappings()); + } + + /** + * Gets the display name of the Concept delegate + * + * @param instance the delegate instance to get the display name off + */ + @PropertyGetter("display") + public String getDisplayName(Concept instance) { + String locationalization = getLocalization(Concept.class.getSimpleName(), instance.getUuid()); + + if (StringUtils.isNotBlank(locationalization)) { + return locationalization; + } + + ConceptName cn = instance.getName(); + if (cn != null) { + return cn.getName(); + } else { + return instance.toString(); + } + } + + /** + * {@link #newDelegate(SimpleObject)} is used instead to support ConceptNumeric + * + * @see DelegatingCrudResource#newDelegate() + */ + @Override + public Concept newDelegate() { + throw new ResourceDoesNotSupportOperationException("Should use newDelegate(SimpleObject) instead"); + } + + @Override + public Concept newDelegate(SimpleObject object) { + String datatypeUuid = object.get("datatype"); + if (ConceptDatatype.NUMERIC_UUID.equals(datatypeUuid)) { + return new ConceptNumeric(); + } else { + return new Concept(); + } + } + + /** + * @see DelegatingCrudResource#save(java.lang.Object) + */ + @Override + public Concept save(Concept c) { + return Context.getConceptService().saveConcept(c); + } /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getResourceVersion() @@ -46,4 +532,208 @@ public Concept getByUniqueId(String identifier) { return concept; } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void purge(Concept concept, RequestContext context) throws ResponseException { + if (concept == null) { + return; + } + + Context.getConceptService().purgeConcept(concept); + } + + /** + * This does not include retired concepts + * + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected NeedsPaging doGetAll(RequestContext context) { + List allConcepts = Context.getConceptService().getAllConcepts(null, true, context.getIncludeAll()); + return new NeedsPaging(allConcepts, context); + } + + /** + * Concept searches support the following additional query parameters: + *

    + *
  • answerTo=(uuid): restricts results to concepts that are answers to the given concept uuid + *
  • + *
  • memberOf=(uuid): restricts to concepts that are set members of the given concept set's + * uuid
  • + *
+ * + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(RequestContext) + */ + @Override + protected PageableResult doSearch(RequestContext context) { + ConceptService service = Context.getConceptService(); + Integer startIndex = null; + Integer limit = null; + boolean canPage = true; + + // Collect information for answerTo and memberOf query parameters + String answerToUuid = context.getRequest().getParameter("answerTo"); + String memberOfUuid = context.getRequest().getParameter("memberOf"); + Concept answerTo = null; + List memberOfList = null; + if (StringUtils.isNotBlank(answerToUuid)) { + try { + answerTo = (Concept) ConversionUtil.convert(answerToUuid, Concept.class); + } + catch (ConversionException ex) { + log.error("Unexpected exception while retrieving answerTo Concept with UUID " + answerToUuid, ex); + } + } + + if (StringUtils.isNotBlank(memberOfUuid)) { + Concept memberOf = service.getConceptByUuid(memberOfUuid); + memberOfList = service.getConceptsByConceptSet(memberOf); + canPage = false; // ConceptService does not support memberOf searches, so paging must be deferred. + } + + // Only set startIndex and limit if we can return paged results + if (canPage) { + startIndex = context.getStartIndex(); + limit = context.getLimit(); + } + + List searchResults; + + // get the user's locales...and then convert that from a set to a list + List locales = new ArrayList(LocaleUtility.getLocalesInOrder()); + + searchResults = service.getConcepts(context.getParameter("q"), locales, context.getIncludeAll(), null, null, null, + null, answerTo, startIndex, limit); + + // convert search results into list of concepts + List results = new ArrayList(searchResults.size()); + for (ConceptSearchResult csr : searchResults) { + // apply memberOf filter + if (memberOfList == null || memberOfList.contains(csr.getConcept())) + results.add(csr.getConcept()); + } + + PageableResult result = null; + if (canPage) { + Integer count = service.getCountOfConcepts(context.getParameter("q"), locales, false, + Collections. emptyList(), Collections. emptyList(), + Collections. emptyList(), Collections. emptyList(), answerTo); + boolean hasMore = count > startIndex + limit; + result = new AlreadyPaged(context, results, hasMore, Long.valueOf(count)); + } else { + result = new NeedsPaging(results, context); + } + + return result; + } + + @Override + protected void delete(Concept c, String reason, RequestContext context) throws ResponseException { + if (c.isRetired()) { + // since DELETE should be idempotent, we return success here + return; + } + Context.getConceptService().retireConcept(c, reason); + } + + /** + * @param instance + * @return the list of Concepts or Drugs + */ + @PropertyGetter("answers") + public static Object getAnswers(Concept instance) { + List conceptAnswers = new ArrayList(instance.getAnswers(false)); + Collections.sort(conceptAnswers); + + List answers = new ArrayList(); + for (ConceptAnswer conceptAnswer : conceptAnswers) { + if (conceptAnswer.getAnswerDrug() != null) { + answers.add(conceptAnswer.getAnswerDrug()); + } else if (conceptAnswer.getAnswerConcept() != null) { + answers.add(conceptAnswer.getAnswerConcept()); + } + } + + return answers; + } + + /** + * @param instance + * @param answerUuids the list of Concepts or Drugs + * @throws ResourceDoesNotSupportOperationException + */ + @PropertySetter("answers") + public static void setAnswers(Concept instance, List answerUuids /*Concept or Drug uuid*/) + throws ResourceDoesNotSupportOperationException { + + // remove answers that are not in the new list + for (ConceptAnswer answer : instance.getAnswers(false)) { + String conceptUuid = answer.getConcept().getUuid(); + String drugUuid = (answer.getAnswerDrug() != null) ? answer.getAnswerDrug().getUuid() : null; + + if (answerUuids.contains(conceptUuid)) { + answerUuids.remove(conceptUuid); // remove from passed in list + } else if (answerUuids.contains(drugUuid)) { + answerUuids.remove(drugUuid); // remove from passed in list + } else { + instance.removeAnswer(answer); // remove from concept question object + } + } + + List answerObjects = new ArrayList(answerUuids.size()); + for (String uuid : answerUuids) { + Concept c = Context.getConceptService().getConceptByUuid(uuid); + if (c != null) { + answerObjects.add(c); + } else { + // it is a drug + Drug drug = Context.getConceptService().getDrugByUuid(uuid); + if (drug != null) { + answerObjects.add(drug); + } else { + throw new ResourceDoesNotSupportOperationException("There is no concept or drug with given uuid: " + + uuid); + } + } + } + + // add in new answers + for (OpenmrsObject obj : answerObjects) { + ConceptAnswer answerToAdd; + if (obj.getClass().isAssignableFrom(Concept.class)) { + answerToAdd = new ConceptAnswer((Concept) obj); + } else if (obj.getClass().isAssignableFrom(Drug.class)) { + answerToAdd = new ConceptAnswer(((Drug) obj).getConcept(), (Drug) obj); + } else { + continue; + } + + answerToAdd.setCreator(Context.getAuthenticatedUser()); + answerToAdd.setDateCreated(new Date()); + instance.addAnswer(answerToAdd); + } + } + + /** + * @param instance + * @param setMembers the list of Concepts + */ + @PropertySetter("setMembers") + public static void setSetMembers(Concept instance, List setMembers) { + instance.getConceptSets().clear(); + + if (setMembers == null || setMembers.isEmpty()) { + instance.setSet(false); + } else { + instance.setSet(true); + + for (Concept setMember : setMembers) { + instance.addSetMember(setMember); + } + } + } } diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSourceResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSourceResource1_9.java index 58bf17ce0..95072c2cb 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSourceResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -36,8 +36,8 @@ * {@link Resource} for {@link ConceptSource}, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/conceptsource", supportedClass = ConceptSource.class, supportedOpenmrsVersions = { - "1.8.* - 1.12.*" }) -public class ConceptSourceResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 1.12.*" }) +public class ConceptSourceResource1_9 extends MetadataDelegatingCrudResource { /** * @see DelegatingCrudResource#getRepresentationDescription(Representation) diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugOrderSubclassHandler1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugOrderSubclassHandler1_9.java similarity index 94% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugOrderSubclassHandler1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugOrderSubclassHandler1_9.java index f1d82939d..926881bbb 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugOrderSubclassHandler1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugOrderSubclassHandler1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.List; @@ -38,12 +38,12 @@ import org.openmrs.util.OpenmrsConstants; /** - * Exposes the {@link DrugOrder} subclass as a type in {@link OrderResource1_8} + * Exposes the {@link DrugOrder} subclass as a type in {@link OrderResource1_9} */ -@SubClassHandler(supportedClass = DrugOrder.class, supportedOpenmrsVersions = { "1.8.* - 1.9.*" }) -public class DrugOrderSubclassHandler1_8 extends BaseDelegatingSubclassHandler implements DelegatingSubclassHandler { +@SubClassHandler(supportedClass = DrugOrder.class, supportedOpenmrsVersions = { "1.9.* - 1.9.*" }) +public class DrugOrderSubclassHandler1_9 extends BaseDelegatingSubclassHandler implements DelegatingSubclassHandler { - public DrugOrderSubclassHandler1_8() { + public DrugOrderSubclassHandler1_9() { //RESTWS-439 //Order subclass fields allowedMissingProperties.add("dose"); @@ -88,7 +88,7 @@ public PageableResult getAllByType(RequestContext context) throws ResourceDoesNo @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { if (rep instanceof DefaultRepresentation) { - OrderResource1_8 orderResource = (OrderResource1_8) Context.getService(RestService.class) + OrderResource1_9 orderResource = (OrderResource1_9) Context.getService(RestService.class) .getResourceBySupportedClass(Order.class); DelegatingResourceDescription d = orderResource.getRepresentationDescription(rep); d.addProperty("dose"); @@ -100,7 +100,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation d.addProperty("drug", Representation.REF); return d; } else if (rep instanceof FullRepresentation) { - OrderResource1_8 orderResource = (OrderResource1_8) Context.getService(RestService.class) + OrderResource1_9 orderResource = (OrderResource1_9) Context.getService(RestService.class) .getResourceBySupportedClass(Order.class); DelegatingResourceDescription d = orderResource.getRepresentationDescription(rep); d.addProperty("dose"); @@ -120,7 +120,7 @@ public DelegatingResourceDescription getRepresentationDescription(Representation */ @Override public DelegatingResourceDescription getCreatableProperties() { - OrderResource1_8 orderResource = (OrderResource1_8) Context.getService(RestService.class) + OrderResource1_9 orderResource = (OrderResource1_9) Context.getService(RestService.class) .getResourceBySupportedClass(Order.class); DelegatingResourceDescription d = orderResource.getCreatableProperties(); d.addProperty("dose"); @@ -138,7 +138,7 @@ public DelegatingResourceDescription getCreatableProperties() { @Override public Model getGETModel(Representation rep) { - OrderResource1_8 orderResource = (OrderResource1_8) Context.getService(RestService.class) + OrderResource1_9 orderResource = (OrderResource1_9) Context.getService(RestService.class) .getResourceBySupportedClass(Order.class); ModelImpl orderModel = (ModelImpl) orderResource.getGETModel(rep); orderModel @@ -161,7 +161,7 @@ public Model getGETModel(Representation rep) { @Override public Model getCREATEModel(Representation rep) { - OrderResource1_8 orderResource = (OrderResource1_8) Context.getService(RestService.class) + OrderResource1_9 orderResource = (OrderResource1_9) Context.getService(RestService.class) .getResourceBySupportedClass(Order.class); ModelImpl orderModel = (ModelImpl) orderResource.getCREATEModel(rep); orderModel diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugResource1_9.java index f34e6df7f..804998345 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -35,8 +35,8 @@ /** * {@link Resource} for {@link Drug}, supporting standard CRUD operations */ -@Resource(name = RestConstants.VERSION_1 + "/drug", supportedClass = Drug.class, supportedOpenmrsVersions = { "1.8.* - 1.9.*" }) -public class DrugResource1_8 extends MetadataDelegatingCrudResource { +@Resource(name = RestConstants.VERSION_1 + "/drug", supportedClass = Drug.class, supportedOpenmrsVersions = { "1.9.*" }) +public class DrugResource1_9 extends MetadataDelegatingCrudResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterResource1_9.java index 92e413727..fd01eae80 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterResource1_9.java @@ -11,18 +11,37 @@ import org.openmrs.Encounter; import org.openmrs.EncounterProvider; +import org.openmrs.Obs; +import org.openmrs.Order; +import org.openmrs.Patient; +import org.openmrs.api.EncounterService; import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; import org.openmrs.module.webservices.rest.web.annotation.Resource; +import org.openmrs.module.webservices.rest.web.api.RestService; import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; -import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource; +import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; +import org.openmrs.module.webservices.rest.web.resource.impl.DataDelegatingCrudResource; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; +import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.resource.impl.ServiceSearcher; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; +import org.openmrs.module.webservices.rest.web.response.ResponseException; +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.DateProperty; +import io.swagger.models.properties.RefProperty; +import io.swagger.models.properties.StringProperty; +import java.util.Date; import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -32,29 +51,105 @@ */ @Resource(name = RestConstants.VERSION_1 + "/encounter", supportedClass = Encounter.class, supportedOpenmrsVersions = { "1.9.* - 2.1.*" }) -public class EncounterResource1_9 extends org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.EncounterResource1_8 { +public class EncounterResource1_9 extends DataDelegatingCrudResource { /** - * @see DelegatingCrudResource#getRepresentationDescription(Representation) + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) */ @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("encounterDatetime"); + description.addProperty("patient", Representation.REF); + description.addProperty("location", Representation.REF); + description.addProperty("form", Representation.REF); + description.addProperty("encounterType", Representation.REF); + description.addProperty("provider", Representation.REF); + description.addProperty("obs", Representation.REF); + description.addProperty("orders", Representation.REF); + description.addProperty("voided"); description.addProperty("visit", Representation.REF); description.removeProperty("provider"); - description.addProperty("encounterProviders", Representation.REF); + description.addProperty("encounterProviders", Representation.DEFAULT); + description.addSelfLink(); + description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); return description; } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("encounterDatetime"); + description.addProperty("patient", Representation.REF); + description.addProperty("location"); + description.addProperty("form"); + description.addProperty("encounterType"); + description.addProperty("provider"); + description.addProperty("obs"); + description.addProperty("orders"); + description.addProperty("voided"); + description.addProperty("auditInfo"); description.addProperty("visit", Representation.DEFAULT); description.removeProperty("provider"); description.addProperty("encounterProviders", Representation.DEFAULT); + description.addSelfLink(); return description; } return null; } + public Model getGETModel(Representation rep) { + ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); + if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { + modelImpl + .property("uuid", new StringProperty()) + .property("display", new StringProperty()) + .property("encounterDatetime", new DateProperty()) + .property("provider", new StringProperty()) //FIXME + .property("voided", new BooleanProperty()); + } + if (rep instanceof DefaultRepresentation) { + modelImpl + .property("patient", new RefProperty("#/definitions/PatientGetRef")) //FIXME + .property("location", new RefProperty("#/definitions/LocationGetRef")) //FIXME + .property("form", new RefProperty("#/definitions/FormGetRef")) //FIXME + .property("encounterType", new RefProperty("#/definitions/EncountertypeGetRef")) //FIXME + .property("obs", new ArrayProperty(new RefProperty("#/definitions/ObsGetRef"))) //FIXME + .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderGetRef"))); //FIXME + } else if (rep instanceof FullRepresentation) { + modelImpl + .property("patient", new RefProperty("#/definitions/PatientGet")) //FIXME + .property("location", new RefProperty("#/definitions/LocationGet")) //FIXME + .property("form", new RefProperty("#/definitions/FormGet")) //FIXME + .property("encounterType", new RefProperty("#/definitions/EncountertypeGet")) //FIXME + .property("obs", new ArrayProperty(new RefProperty("#/definitions/ObsGet"))) //FIXME + .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderGet"))); //FIXME + } + return modelImpl; + } + + @Override + public Model getCREATEModel(Representation rep) { + return new ModelImpl() + .property("patient", new RefProperty("#/definitions/PatientCreate")) + .property("encounterType", new RefProperty("#/definitions/EncountertypeCreate")) + .property("encounterDatetime", new DateProperty()) + .property("location", new RefProperty("#/definitions/LocationCreate")) + .property("form", new RefProperty("#/definitions/FormCreate")) + .property("provider", new StringProperty()) + .property("orders", new ArrayProperty(new RefProperty("#/definitions/OrderCreate"))) + .property("obs", new ArrayProperty(new RefProperty("#/definitions/ObsCreate"))) + + .required("patient").required("encounterType"); + } + + @Override + public Model getUPDATEModel(Representation rep) { + return getCREATEModel(rep); + } + @Override public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException { DelegatingResourceDescription description = super.getUpdatableProperties(); @@ -64,15 +159,43 @@ public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoe /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() + * Should create an encounter type */ @Override public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = super.getCreatableProperties(); - description.addProperty("visit"); + DelegatingResourceDescription description = new DelegatingResourceDescription(); + + description.addProperty("encounterDatetime"); // has a default value set, hence not required here + description.addRequiredProperty("patient"); + description.addRequiredProperty("encounterType"); + + description.addProperty("location"); + description.addProperty("form"); + description.addProperty("provider"); + description.addProperty("orders"); + description.addProperty("obs"); description.addProperty("encounterProviders"); + description.addProperty("visit"); + return description; } + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#newDelegate() + */ + @Override + public Encounter newDelegate() { + Encounter enc = new Encounter(); + // default to now(), so a web client can create a real-time encounter based on the server time + enc.setEncounterDatetime(new Date()); + // As of 2012-04-27 there is a bug in Encounter.getOrders() where, if null, it returns an empty list without keeping a reference to it + enc.setOrders(new LinkedHashSet()); + return enc; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#save(org.openmrs.Encounter) + */ @Override public Encounter save(Encounter delegate) { //This is a hack to save encounterProviders correctly. Without this they are created without encounter_id in @@ -84,6 +207,111 @@ public Encounter save(Encounter delegate) { return delegate; } + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getByUniqueId(java.lang.String) + */ + @Override + public Encounter getByUniqueId(String uuid) { + return Context.getEncounterService().getEncounterByUuid(uuid); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#delete(org.openmrs.Encounter, + * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void delete(Encounter enc, String reason, RequestContext context) throws ResponseException { + if (enc.isVoided()) { + // DELETE is idempotent, so we return success here + return; + } + Context.getEncounterService().voidEncounter(enc, reason); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#undelete(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected Encounter undelete(Encounter enc, RequestContext context) throws ResponseException { + if (enc.isVoided()) { + enc = Context.getEncounterService().unvoidEncounter(enc); + } + return enc; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(org.openmrs.Encounter, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void purge(Encounter enc, RequestContext context) throws ResponseException { + if (enc == null) { + // DELETE is idempotent, so we return success here + return; + } + Context.getEncounterService().purgeEncounter(enc); + } + + /** + * @param encounter + * @return encounter type and date + */ + @PropertyGetter("display") + public String getDisplayString(Encounter encounter) { + String ret = encounter.getEncounterType() == null ? "?" : encounter.getEncounterType().getName(); + ret += " "; + ret += encounter.getEncounterDatetime() == null ? "?" : Context.getDateFormat().format( + encounter.getEncounterDatetime()); + return ret; + } + + /** + * @param instance + * @return all non-voided top-level obs from the given encounter + */ + @PropertyGetter("obs") + public static Object getObsAtTopLevel(Encounter instance) { + return instance.getObsAtTopLevel(false); + } + + @PropertySetter("obs") + public static void setObs(Encounter instance, Set obs) { + instance.getAllObs(true).clear(); + for (Obs o : obs) + instance.addObs(o); + } + + @PropertySetter("orders") + public static void setOrders(Encounter instance, Set orders) { + for (Order o : orders) + instance.addOrder(o); + } + + /** + * Gets encounters for the given patient (paged according to context if necessary) only if a + * patient parameter exists in the request set on the {@link RequestContext} otherwise searches + * for encounters that match the specified query + * + * @param context + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected PageableResult doSearch(RequestContext context) { + String patientUuid = context.getRequest().getParameter("patient"); + if (patientUuid != null) { + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( + Patient.class)).getByUniqueId(patientUuid); + if (patient == null) + return new EmptySearchResult(); + List encs = Context.getEncounterService().getEncountersByPatient(patient); + return new NeedsPaging(encs, context); + } + + return new ServiceSearcher(EncounterService.class, "getEncounters", "getCountOfEncounters").search( + context.getParameter("q"), context); + } + @PropertyGetter("encounterProviders") public static Set getActiveEncounterProviders(Encounter instance) { Set encounterProviders = instance.getEncounterProviders(); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterTypeResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterTypeResource1_9.java index 952889804..5cc8a2efd 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterTypeResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -27,8 +27,8 @@ * {@link Resource} for {@link EncounterType}, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/encountertype", supportedClass = EncounterType.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class EncounterTypeResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 9.*" }) +public class EncounterTypeResource1_9 extends MetadataDelegatingCrudResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldAnswerResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldAnswerResource1_9.java index 61e70b452..78f8e5b3d 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldAnswerResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.ArrayList; import java.util.List; @@ -39,9 +39,9 @@ /** * {@link Resource} for {@link FieldAnswer}, supporting standard CRUD operations */ -@SubResource(parent = FieldResource1_8.class, path = "answer", supportedClass = FieldAnswer.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class FieldAnswerResource1_8 extends DelegatingSubResource { +@SubResource(parent = FieldResource1_9.class, path = "answer", supportedClass = FieldAnswer.class, supportedOpenmrsVersions = { + "1.9.* - 9.*" }) +public class FieldAnswerResource1_9 extends DelegatingSubResource { @Override @RepHandler(RefRepresentation.class) diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldResource1_9.java index 7eb26f5c2..ffc838173 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -33,8 +33,8 @@ /** * {@link Resource} for {@link Field}, supporting standard CRUD operations */ -@Resource(name = RestConstants.VERSION_1 + "/field", supportedClass = Field.class, supportedOpenmrsVersions = { "1.8.* - 9.*" }) -public class FieldResource1_8 extends MetadataDelegatingCrudResource { +@Resource(name = RestConstants.VERSION_1 + "/field", supportedClass = Field.class, supportedOpenmrsVersions = { "1.9.* - 9.*" }) +public class FieldResource1_9 extends MetadataDelegatingCrudResource { public Model getGETModel(Representation rep) { ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldTypeResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldTypeResource1_9.java index ba62a0174..fddddb4de 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldTypeResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -29,8 +29,8 @@ * {@link Resource} for {@link FieldType}, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/fieldtype", supportedClass = FieldType.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class FieldTypeResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 9.*" }) +public class FieldTypeResource1_9 extends MetadataDelegatingCrudResource { public Model getGETModel(Representation rep) { ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormFieldResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormFieldResource1_9.java index 4b7ddfece..ab1abb97b 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormFieldResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.ArrayList; import java.util.List; @@ -38,9 +38,9 @@ /** * {@link Resource} for {@link FormField}, supporting standard CRUD operations */ -@SubResource(parent = FormResource1_8.class, path = "formfield", supportedClass = FormField.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class FormFieldResource1_8 extends DelegatingSubResource { +@SubResource(parent = FormResource1_9.class, path = "formfield", supportedClass = FormField.class, supportedOpenmrsVersions = { + "1.9.* - 9.*" }) +public class FormFieldResource1_9 extends DelegatingSubResource { public Model getGETModel(Representation rep) { ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResource1_9.java index 81c1e2de7..d3e24d73d 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResource1_9.java @@ -13,6 +13,7 @@ import org.openmrs.FormResource; import org.openmrs.api.FormService; import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; @@ -21,33 +22,199 @@ import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.FormResource1_8; +import org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.response.ResponseException; +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.IntegerProperty; +import io.swagger.models.properties.RefProperty; +import io.swagger.models.properties.StringProperty; +import java.util.Arrays; import java.util.List; @Resource(name = RestConstants.VERSION_1 + "/form", supportedClass = Form.class, order = 10, supportedOpenmrsVersions = { "1.9.* - 9.*" }) -public class FormResource1_9 extends FormResource1_8 { - - // TODO: Find out why autowiring is failing, in the mean time use Context.getService - // @Autowired - // private FormService formService; +public class FormResource1_9 extends MetadataDelegatingCrudResource { + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) + */ @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); if (rep instanceof DefaultRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("name"); + description.addProperty("description"); + description.addProperty("encounterType", Representation.REF); + description.addProperty("version"); + description.addProperty("build"); + description.addProperty("published"); + description.addProperty("formFields", Representation.REF); + description.addProperty("retired"); description.addProperty("resources", Representation.REF); + description.addSelfLink(); + description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); return description; } else if (rep instanceof FullRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("name"); + description.addProperty("description"); + description.addProperty("encounterType"); + description.addProperty("version"); + description.addProperty("build"); + description.addProperty("published"); + description.addProperty("formFields"); + description.addProperty("retired"); + description.addProperty("auditInfo"); description.removeProperty("xslt"); description.removeProperty("template"); description.addProperty("resources"); + description.addSelfLink(); return description; } return null; } + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = super.getCreatableProperties(); + description.addRequiredProperty("version"); + + description.addProperty("encounterType"); + description.addProperty("build"); + description.addProperty("published"); + description.addProperty("formFields"); + description.addProperty("xslt"); + description.addProperty("template"); + + return description; + } + + @Override + public Model getGETModel(Representation rep) { + ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); + if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { + modelImpl + .property("uuid", new StringProperty()) + .property("display", new StringProperty()) + .property("name", new StringProperty()) + .property("description", new StringProperty()) + .property("version", new StringProperty()) + .property("build", new IntegerProperty()) + .property("published", new BooleanProperty()._default(false)) + .property("retired", new BooleanProperty()); + } + if (rep instanceof DefaultRepresentation) { + modelImpl + .property("encounterType", new RefProperty("#/definitions/EncountertypeGetRef")) + .property("formFields", new ArrayProperty(new RefProperty("#/definitions/FormFormfieldGetRef"))); + } else if (rep instanceof FullRepresentation) { + modelImpl + .property("encounterType", new RefProperty("#/definitions/EncountertypeGet")) + .property("formFields", new ArrayProperty(new RefProperty("#/definitions/FormFormfieldGet"))); + } + return modelImpl; + } + + @Override + public Model getCREATEModel(Representation rep) { + ModelImpl model = ((ModelImpl) super.getCREATEModel(rep)) + .property("version", new StringProperty()) + .property("encounterType", new StringProperty()) + .property("build", new IntegerProperty()) + .property("published", new BooleanProperty()._default(false)) + .property("formFields", new ArrayProperty(new StringProperty())) + .property("xslt", new StringProperty()) + .property("template", new StringProperty()) + + .required("version"); + if (rep instanceof FullRepresentation) { + model + .property("encounterType", new RefProperty("#/definitions/EncountertypeCreate")) + .property("formFields", new ArrayProperty(new RefProperty("#/definitions/FormFormfieldCreate"))); + } + return model; + } + + @Override + public Model getUPDATEModel(Representation rep) { + return getCREATEModel(rep); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) + */ + @Override + public Form getByUniqueId(String uniqueId) { + return Context.getFormService().getFormByUuid(uniqueId); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() + */ + @Override + public Form newDelegate() { + return new Form(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) + */ + @Override + public Form save(Form delegate) { + return Context.getFormService().saveForm(delegate); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void purge(Form delegate, RequestContext context) throws ResponseException { + if (delegate == null) + return; + Context.getFormService().purgeForm(delegate); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected NeedsPaging doGetAll(RequestContext context) throws ResponseException { + return new NeedsPaging(Context.getFormService().getAllForms(context.getIncludeAll()), context); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected NeedsPaging doSearch(RequestContext context) { + String fuzzyName = context.getParameter("q"); + boolean includeRetired = context.getIncludeAll(); + + return new NeedsPaging(Context.getFormService().getForms(fuzzyName, null, null, + includeRetired, null, null, null), context); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getPropertiesToExposeAsSubResources() + */ + @Override + public List getPropertiesToExposeAsSubResources() { + return Arrays.asList("formFields"); + } + @PropertyGetter("resources") public List getFormResources(Form form) { FormService formService = Context.getFormService(); diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResourceResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResourceResource1_9.java index 83f6978eb..d8a03bfaf 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResourceResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResourceResource1_9.java @@ -35,14 +35,12 @@ import org.openmrs.module.webservices.rest.web.response.ConversionException; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.FormResource1_8; - import java.util.List; @SuppressWarnings("SpringJavaAutowiredMembersInspection") -@SubResource(parent = FormResource1_8.class, path = "resource", supportedClass = FormResource.class, supportedOpenmrsVersions = { +@SubResource(parent = FormResource1_9.class, path = "resource", supportedClass = FormResource.class, supportedOpenmrsVersions = { "1.9.* - 9.*" }) -public class FormResourceResource1_9 extends DelegatingSubResource { +public class FormResourceResource1_9 extends DelegatingSubResource { @RepHandler(RefRepresentation.class) public SimpleObject convertToRef(FormResource delegate) throws ConversionException { diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7MessageResource1_9.java similarity index 88% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7MessageResource1_9.java index 999810ac9..e9526af84 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7MessageResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -27,24 +27,23 @@ import org.openmrs.module.webservices.rest.web.response.ConversionException; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.HL7MessageController1_8; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.IncomingHl7Message1_8; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.IncomingHl7Message1_9; import java.util.Map; /** - * {@link Resource} for {@link IncomingHl7Message1_8}, supporting standard CRUD operations + * {@link Resource} for {@link IncomingHl7Message1_9}, supporting standard CRUD operations */ -@Resource(name = RestConstants.VERSION_1 + "/hl7", supportedClass = IncomingHl7Message1_8.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class HL7MessageResource1_8 extends DataDelegatingCrudResource { +@Resource(name = RestConstants.VERSION_1 + "/hl7", supportedClass = IncomingHl7Message1_9.class, supportedOpenmrsVersions = { + "1.9.* - 9.*" }) +public class HL7MessageResource1_9 extends DataDelegatingCrudResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#delete(java.lang.Object, * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) */ @Override - protected void delete(IncomingHl7Message1_8 delegate, String reason, RequestContext context) throws ResponseException { + protected void delete(IncomingHl7Message1_9 delegate, String reason, RequestContext context) throws ResponseException { throw new ResourceDoesNotSupportOperationException(); } @@ -52,7 +51,7 @@ protected void delete(IncomingHl7Message1_8 delegate, String reason, RequestCont * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) */ @Override - public IncomingHl7Message1_8 getByUniqueId(String uniqueId) { + public IncomingHl7Message1_9 getByUniqueId(String uniqueId) { // Currently it's not supported because we don't have methods within HL7 service, which are returning hl7 message // by its uuid. It will be fixed when such methods will be implemented throw new ResourceDoesNotSupportOperationException(); @@ -134,7 +133,7 @@ public Model getCREATEModel(Representation rep) { * boolean) */ @Override - public void setConvertedProperties(IncomingHl7Message1_8 delegate, Map propertyMap, + public void setConvertedProperties(IncomingHl7Message1_9 delegate, Map propertyMap, DelegatingResourceDescription description, boolean mustIncludeRequiredProperties) throws ConversionException { for (Map.Entry prop : propertyMap.entrySet()) { setProperty(delegate, prop.getKey(), prop.getValue()); @@ -145,8 +144,8 @@ public void setConvertedProperties(IncomingHl7Message1_8 delegate, Map { + "1.9.* - 9.*" }) +public class HL7SourceResource1_9 extends MetadataDelegatingCrudResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/LocationResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/LocationResource1_9.java index 5d3464ad7..b56094624 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/LocationResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/LocationResource1_9.java @@ -9,16 +9,31 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; +import org.apache.commons.collections.CollectionUtils; import org.openmrs.Location; import org.openmrs.LocationAttribute; +import org.openmrs.LocationTag; +import org.openmrs.api.LocationService; +import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; import org.openmrs.module.webservices.rest.web.annotation.Resource; import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; +import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; +import org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.response.ResponseException; + +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.RefProperty; +import io.swagger.models.properties.StringProperty; import java.util.Arrays; import java.util.List; @@ -28,20 +43,7 @@ */ @Resource(name = RestConstants.VERSION_1 + "/location", supportedClass = Location.class, supportedOpenmrsVersions = { "1.9.* - 1.12.*" }) -public class LocationResource1_9 extends org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.LocationResource1_8 { - - /** - * Sets attributes on the given Location. - * - * @param instance - * @param attrs - */ - @PropertySetter("attributes") - public static void setAttributes(Location instance, List attrs) { - for (LocationAttribute attr : attrs) { - instance.addAttribute(attr); - } - } +public class LocationResource1_9 extends MetadataDelegatingCrudResource { /** * @see DelegatingCrudResource#getRepresentationDescription(Representation) @@ -49,12 +51,58 @@ public static void setAttributes(Location instance, List attr @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { if (rep instanceof DefaultRepresentation) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("name"); + description.addProperty("description"); + description.addProperty("address1"); + description.addProperty("address2"); + description.addProperty("cityVillage"); + description.addProperty("stateProvince"); + description.addProperty("country"); + description.addProperty("postalCode"); + description.addProperty("latitude"); + description.addProperty("longitude"); + description.addProperty("countyDistrict"); + description.addProperty("address3"); + description.addProperty("address4"); + description.addProperty("address5"); + description.addProperty("address6"); + description.addProperty("tags", Representation.REF); + description.addProperty("parentLocation", Representation.REF); + description.addProperty("childLocations", Representation.REF); + description.addProperty("retired"); description.addProperty("attributes", Representation.REF); + description.addSelfLink(); + description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); return description; } else if (rep instanceof FullRepresentation) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("name"); + description.addProperty("description"); + description.addProperty("address1"); + description.addProperty("address2"); + description.addProperty("cityVillage"); + description.addProperty("stateProvince"); + description.addProperty("country"); + description.addProperty("postalCode"); + description.addProperty("latitude"); + description.addProperty("longitude"); + description.addProperty("countyDistrict"); + description.addProperty("address3"); + description.addProperty("address4"); + description.addProperty("address5"); + description.addProperty("address6"); + description.addProperty("tags", Representation.DEFAULT); + description.addProperty("parentLocation", Representation.DEFAULT); + description.addProperty("childLocations", Representation.DEFAULT); + description.addProperty("retired"); + description.addProperty("auditInfo"); description.addProperty("attributes", Representation.DEFAULT); + description.addSelfLink(); return description; } return null; @@ -65,11 +113,185 @@ public DelegatingResourceDescription getRepresentationDescription(Representation */ @Override public DelegatingResourceDescription getCreatableProperties() { - DelegatingResourceDescription description = super.getCreatableProperties(); + DelegatingResourceDescription description = new DelegatingResourceDescription(); + + description.addRequiredProperty("name"); + + description.addProperty("description"); + description.addProperty("address1"); + description.addProperty("address2"); + description.addProperty("cityVillage"); + description.addProperty("stateProvince"); + description.addProperty("country"); + description.addProperty("postalCode"); + description.addProperty("latitude"); + description.addProperty("longitude"); + description.addProperty("countyDistrict"); + description.addProperty("address3"); + description.addProperty("address4"); + description.addProperty("address5"); + description.addProperty("address6"); + description.addProperty("tags"); + description.addProperty("parentLocation"); + description.addProperty("childLocations"); description.addProperty("attributes"); + return description; } + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties() + */ + @Override + public DelegatingResourceDescription getUpdatableProperties() { + return getCreatableProperties(); + } + + @Override + public Model getGETModel(Representation rep) { + ModelImpl modelImpl = (ModelImpl) super.getGETModel(rep); + if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { + modelImpl + .property("address1", new StringProperty()) + .property("address2", new StringProperty()) + .property("cityVillage", new StringProperty()) + .property("stateProvince", new StringProperty()) + .property("country", new StringProperty()) + .property("postalCode", new StringProperty()) + .property("latitude", new StringProperty()) + .property("longitude", new StringProperty()) + .property("countyDistrict", new StringProperty()) + .property("address3", new StringProperty()) + .property("address4", new StringProperty()) + .property("address5", new StringProperty()) + .property("address6", new StringProperty()); + } + if (rep instanceof DefaultRepresentation) { + modelImpl + .property("tags", new ArrayProperty(new RefProperty("#/definitions/LocationtagGetRef"))) + .property("parentLocation", new RefProperty("#/definitions/LocationGetRef")) + .property("childLocations", new ArrayProperty(new RefProperty("#/definitions/LocationGetRef"))); + } else if (rep instanceof FullRepresentation) { + modelImpl + .property("tags", new ArrayProperty(new RefProperty("#/definitions/LocationtagGet"))) + .property("parentLocation", new RefProperty("#/definitions/LocationGet")) + .property("childLocations", new ArrayProperty(new RefProperty("#/definitions/LocationGet"))); + } + return modelImpl; + } + + @Override + public Model getCREATEModel(Representation rep) { + return ((ModelImpl) super.getCREATEModel(rep)) + .property("address1", new StringProperty()) + .property("address2", new StringProperty()) + .property("cityVillage", new StringProperty()) + .property("stateProvince", new StringProperty()) + .property("country", new StringProperty()) + .property("postalCode", new StringProperty()) + .property("latitude", new StringProperty()) + .property("longitude", new StringProperty()) + .property("countyDistrict", new StringProperty()) + .property("address3", new StringProperty()) + .property("address4", new StringProperty()) + .property("address5", new StringProperty()) + .property("address6", new StringProperty()) + .property("tags", new ArrayProperty(new StringProperty())) + .property("parentLocation", new StringProperty()) + .property("childLocations", new ArrayProperty(new StringProperty())); + } + + @Override + public Model getUPDATEModel(Representation rep) { + return getCREATEModel(rep); + } + + /** + * @see DelegatingCrudResource#newDelegate() + */ + @Override + public Location newDelegate() { + return new Location(); + } + + /** + * @see DelegatingCrudResource#save(java.lang.Object) + */ + @Override + public Location save(Location location) { + return Context.getLocationService().saveLocation(location); + } + + /** + * Fetches a location by uuid, if no match is found, it tries to look up one with a matching + * name with the assumption that the passed parameter is a location name + * + * @see DelegatingCrudResource#getByUniqueId(java.lang.String) + */ + @Override + public Location getByUniqueId(String uuid) { + Location location = Context.getLocationService().getLocationByUuid(uuid); + //We assume the caller was fetching by name + if (location == null) + location = Context.getLocationService().getLocation(uuid); + + return location; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void purge(Location location, RequestContext context) throws ResponseException { + if (location == null) + return; + Context.getLocationService().purgeLocation(location); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected NeedsPaging doGetAll(RequestContext context) { + return new NeedsPaging(Context.getLocationService().getAllLocations(context.getIncludeAll()), context); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) + * A query string and/or a tag uuid can be passed in; if both are passed in, returns an + * intersection of the results; excludes retired locations + */ + @Override + protected PageableResult doSearch(RequestContext context) { + + LocationService locationService = Context.getLocationService(); + + String tagUuid = context.getParameter("tag"); + String query = context.getParameter("q"); + + List locationsByTag = null; + List locationsByQuery = null; + + if (tagUuid != null) { + LocationTag locationTag = locationService.getLocationTagByUuid(tagUuid); + locationsByTag = locationService.getLocationsHavingAllTags(Arrays.asList(locationTag)); + } + + if (query != null) { + locationsByQuery = locationService.getLocations(query); + } + + if (locationsByTag == null) { + return new NeedsPaging(locationsByQuery, context); + } else if (locationsByQuery == null) { + return new NeedsPaging(locationsByTag, context); + } else { + return new NeedsPaging( + (List) CollectionUtils.intersection(locationsByQuery, locationsByTag), context); + } + } + /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getPropertiesToExposeAsSubResources() */ diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationTagResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/LocationTagResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationTagResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/LocationTagResource1_9.java index 9199ba24c..b1d80496f 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/LocationTagResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/LocationTagResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -29,8 +29,8 @@ * Allows standard CRUD for the {@link LocationTag} domain object */ @Resource(name = RestConstants.VERSION_1 + "/locationtag", supportedClass = LocationTag.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class LocationTagResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 9.*" }) +public class LocationTagResource1_9 extends MetadataDelegatingCrudResource { private LocationService service() { return Context.getLocationService(); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleActionResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleActionResource1_9.java similarity index 99% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleActionResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleActionResource1_9.java index d67ab5ff4..6159dbf5c 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleActionResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleActionResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -50,8 +50,8 @@ import java.util.List; @Resource(name = RestConstants.VERSION_1 + "/moduleaction", supportedClass = ModuleAction.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class ModuleActionResource1_8 extends BaseDelegatingResource implements Creatable { + "1.9.* - 9.*" }) +public class ModuleActionResource1_9 extends BaseDelegatingResource implements Creatable { /** * ModuleFactoryWrapper is used for testing purposes. diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleResource1_9.java index e4d5ecc25..c309f6dd6 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -41,12 +41,12 @@ import java.util.Collection; import java.util.List; -@Resource(name = RestConstants.VERSION_1 + "/module", supportedClass = Module.class, supportedOpenmrsVersions = { "1.8.* - 9.*" }) -public class ModuleResource1_8 extends BaseDelegatingReadableResource implements Uploadable { +@Resource(name = RestConstants.VERSION_1 + "/module", supportedClass = Module.class, supportedOpenmrsVersions = { "1.9.* - 9.*" }) +public class ModuleResource1_9 extends BaseDelegatingReadableResource implements Uploadable { private ModuleFactoryWrapper moduleFactoryWrapper = new ModuleFactoryWrapper(); - private final String moduleActionLink = ModuleActionResource1_8.class.getAnnotation(Resource.class).name(); + private final String moduleActionLink = ModuleActionResource1_9.class.getAnnotation(Resource.class).name(); public void setModuleFactoryWrapper(ModuleFactoryWrapper moduleFactoryWrapper) { this.moduleFactoryWrapper = moduleFactoryWrapper; diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsResource1_9.java index 369d28a15..5cb136b06 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsResource1_9.java @@ -9,18 +9,63 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; +import org.apache.commons.lang.StringUtils; import org.openmrs.Concept; +import org.openmrs.ConceptNumeric; +import org.openmrs.Drug; +import org.openmrs.Encounter; +import org.openmrs.Location; import org.openmrs.Obs; +import org.openmrs.Patient; +import org.openmrs.api.APIException; +import org.openmrs.api.ObsService; +import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.ConversionUtil; +import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; +import org.openmrs.module.webservices.rest.web.RestUtil; +import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; import org.openmrs.module.webservices.rest.web.annotation.Resource; +import org.openmrs.module.webservices.rest.web.api.RestService; +import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; +import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; +import org.openmrs.module.webservices.rest.web.representation.Representation; +import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; +import org.openmrs.module.webservices.rest.web.resource.api.Uploadable; +import org.openmrs.module.webservices.rest.web.resource.impl.DataDelegatingCrudResource; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; +import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; import org.openmrs.module.webservices.rest.web.response.ConversionException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ObsResource1_8; +import org.openmrs.module.webservices.rest.web.response.IllegalRequestException; +import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; +import org.openmrs.module.webservices.rest.web.response.ResponseException; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PatientResource1_9; +import org.openmrs.obs.ComplexData; +import org.springframework.web.multipart.MultipartFile; +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.DateProperty; +import io.swagger.models.properties.DateTimeProperty; +import io.swagger.models.properties.RefProperty; +import io.swagger.models.properties.StringProperty; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; import java.util.Map; +import java.util.Set; + +import javax.xml.bind.DatatypeConverter; /** * {@link org.openmrs.module.webservices.rest.web.annotation.Resource} for Obs, supporting standard @@ -28,8 +73,306 @@ */ @Resource(name = RestConstants.VERSION_1 + "/obs", order = 2, supportedClass = Obs.class, supportedOpenmrsVersions = { "1.9.* - 1.10.*" }) -public class ObsResource1_9 extends ObsResource1_8 { +public class ObsResource1_9 extends DataDelegatingCrudResource implements Uploadable { + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#delete(java.lang.Object, + * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected void delete(Obs delegate, String reason, RequestContext context) throws ResponseException { + if (delegate.isVoided()) { + // DELETE is idempotent, so we return success here + return; + } + Context.getObsService().voidObs(delegate, reason); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#undelete(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected Obs undelete(Obs delegate, RequestContext context) throws ResponseException { + if (delegate.isVoided()) { + delegate = Context.getObsService().unvoidObs(delegate); + } + return delegate; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) + */ + @Override + public Obs getByUniqueId(String uniqueId) { + return Context.getObsService().getObsByUuid(uniqueId); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) + */ + @Override + public DelegatingResourceDescription getRepresentationDescription(Representation rep) { + if (rep instanceof DefaultRepresentation) { + // TODO how to handle valueCodedName? + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("concept", Representation.REF); + description.addProperty("person", Representation.REF); + description.addProperty("obsDatetime"); + description.addProperty("accessionNumber"); + description.addProperty("obsGroup", Representation.REF); + description.addProperty("valueCodedName", Representation.REF); + description.addProperty("groupMembers"); + description.addProperty("comment"); + description.addProperty("location", Representation.REF); + description.addProperty("order", Representation.REF); + description.addProperty("encounter", Representation.REF); + description.addProperty("voided"); + description.addProperty("value"); + description.addProperty("valueModifier"); + description.addSelfLink(); + description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); + return description; + } else if (rep instanceof FullRepresentation) { + // TODO how to handle valueCodedName? + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("concept"); + description.addProperty("person", Representation.REF); + description.addProperty("obsDatetime"); + description.addProperty("accessionNumber"); + description.addProperty("obsGroup"); + description.addProperty("valueCodedName"); + description.addProperty("groupMembers", Representation.FULL); + description.addProperty("comment"); + description.addProperty("location"); + description.addProperty("order"); + description.addProperty("encounter"); + description.addProperty("voided"); + description.addProperty("auditInfo"); + description.addProperty("value"); + description.addProperty("valueModifier"); + description.addSelfLink(); + return description; + } + return null; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + + description.addRequiredProperty("person"); + description.addRequiredProperty("obsDatetime"); + description.addRequiredProperty("concept"); + + description.addProperty("location"); + description.addProperty("order"); + description.addProperty("encounter"); + description.addProperty("accessionNumber"); + description.addProperty("groupMembers"); + description.addProperty("valueCodedName"); + description.addProperty("comment"); + description.addProperty("value"); + description.addProperty("valueModifier"); + + return description; + } + + @Override + public Model getGETModel(Representation rep) { + ModelImpl model = (ModelImpl) super.getGETModel(rep); + if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { + model.property("uuid", new StringProperty()).property("display", new StringProperty()) + .property("obsDatetime", new DateProperty()).property("accessionNumber", new StringProperty()) + .property("comment", new StringProperty()).property("voided", new BooleanProperty()) + .property("value", new StringProperty()).property("valueModifier", new StringProperty()); + } + if (rep instanceof DefaultRepresentation) { + model.property("concept", new RefProperty("#/definitions/ConceptGetRef")) + .property("person", new RefProperty("#/definitions/PersonGetRef")) + .property("obsGroup", new RefProperty("#/definitions/ObsGetRef")) + .property("groupMembers", new ArrayProperty(new RefProperty("#/definitions/ObsGetRef"))) + .property("valueCodedName", new RefProperty("#/definitions/ConceptNameGetRef")) + .property("location", new RefProperty("#/definitions/LocationGetRef")) + .property("order", new RefProperty("#/definitions/OrderGetRef")) + .property("encounter", new RefProperty("#/definitions/EncounterGetRef")); + } else if (rep instanceof FullRepresentation) { + model.property("concept", new RefProperty("#/definitions/ConceptGet")) + .property("person", new RefProperty("#/definitions/PersonGet")) + .property("obsGroup", new RefProperty("#/definitions/ObsGet")) + .property("groupMembers", new ArrayProperty(new RefProperty("#/definitions/ObsGet"))) + .property("valueCodedName", new RefProperty("#/definitions/ConceptNameGet")) + .property("location", new RefProperty("#/definitions/LocationGet")) + .property("order", new RefProperty("#/definitions/OrderGet")) + .property("encounter", new RefProperty("#/definitions/EncounterGet")); + } + return model; + } + + @Override + public Model getCREATEModel(Representation rep) { + return new ModelImpl().property("person", new StringProperty().example("uuid")) + .property("obsDatetime", new DateTimeProperty()).property("concept", new StringProperty().example("uuid")) + .property("location", new StringProperty()).property("order", new StringProperty()) + .property("encounter", new StringProperty()).property("accessionNumber", new StringProperty()) + .property("groupMembers", new ArrayProperty(new StringProperty())) + .property("valueCodedName", new StringProperty()).property("comment", new StringProperty()) + .property("voided", new BooleanProperty()).property("value", new StringProperty()) + .property("valueModifier", new StringProperty()) + + .required("person").required("obsDatetime").required("concept"); + } + + @Override + public Model getUPDATEModel(Representation rep) { + return new ModelImpl(); //FIXME missing props + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() + */ + @Override + public Obs newDelegate() { + return new Obs(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#purge(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void purge(Obs delegate, RequestContext context) throws ResponseException { + Context.getObsService().purgeObs(delegate); + + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceHandler#save(java.lang.Object) + */ + @Override + public Obs save(Obs delegate) { + Obs savedObs = Context.getObsService().saveObs(delegate, "REST web service"); + return Context.getObsService().getObs(savedObs.getId()); + } + + /** + * Display string for Obs + * + * @param obs + * @return String ConceptName = value + */ + @PropertyGetter("display") + public String getDisplayString(Obs obs) { + if (obs.getConcept() == null) + return ""; + + return obs.getConcept().getName() + ": " + obs.getValueAsString(Context.getLocale()); + } + + /** + * Retrives the Obs Value as string + * + * @param obs + * @return + */ + @PropertyGetter("value") + public Object getValue(Obs obs) throws ConversionException { + if (obs.isComplex()) { + //Note that complex obs value is handled by ObsComplexValueController1_8 + SimpleObject so = new SimpleObject(); + so.put("display", "raw file"); + SimpleObject links = new SimpleObject(); + links.put("rel", "self"); + links.put("uri", new ObsResource1_9().getUri(obs) + "/value"); + so.put("links", links); + return so; + } + + if (obs.isObsGrouping()) + return null; + + if (obs.getValueDatetime() != null) { + return ConversionUtil.convert(obs.getValueDatetime(), Date.class); + } + + if (obs.getValueDrug() != null) { + return obs.getValueDrug(); + } + + if (obs.getValueCoded() != null) { + return obs.getValueCoded(); + } + + if (obs.getValueComplex() != null) { + return obs.getValueComplex(); + } + + if (obs.getValueText() != null) { + if ("org.openmrs.Location".equals(obs.getComment())) { // string first to make it null-safe + try { + return Context.getLocationService().getLocation(new Integer(obs.getValueText())); + } + catch (NumberFormatException e) { + // TDOO; we really shouldn't be supporting two ways of storing a location obs, should only use the location id + return Context.getLocationService().getLocationByUuid(obs.getValueText()); + } + } else { + return obs.getValueText(); + } + + } + + if (obs.getValueNumeric() != null) { + return getValueNumeric(obs); + } + + return null; + } + + /** + * @return the valueNumeric from the obs + */ + protected Number getValueNumeric(Obs obs) { + return obs.getValueNumeric(); + } + + /** + * Sets the members of an obs group + * + * @param obsGroup the obs group whose members to set + * @param members the members to set + */ + @PropertySetter("groupMembers") + public static void setGroupMembers(Obs obsGroup, Set members) { + for (Obs member : members) { + member.setObsGroup(obsGroup); + } + obsGroup.setGroupMembers(members); + } + + /** + * Checks if there are more than one obs in GroupMembers and converts into a DEFAULT + * representation + * + * @param obs + * @return Object + * @throws ConversionException + */ + @PropertyGetter("groupMembers") + public static Object getGroupMembers(Obs obs) throws ConversionException { + if (obs.getGroupMembers() != null && !obs.getGroupMembers().isEmpty()) { + return obs.getGroupMembers(); + } + return null; + } + /** * Annotated setter for Concept * @@ -53,8 +396,7 @@ public static void setConcept(Obs obs, Object value) { obs.setConcept(ConversionUtil.getConverter(Concept.class).getByUniqueId((String) identifier)); } - - @Override + @Override protected SimpleObject convertDelegateToRepresentation(Obs delegate, DelegatingResourceDescription rep) { try { return super.convertDelegateToRepresentation(delegate, rep); @@ -73,4 +415,195 @@ protected SimpleObject convertDelegateToRepresentation(Obs delegate, DelegatingR } } + /** + * Annotated setter for ConceptValue + * + * @param obs + * @param value + * @throws ParseException + * @throws ConversionException + * Should return uuid for foncept true + * Should return uuid for concept false + * Should throw exception on unexpected value + * Should return uuid for primitive true + * Should return uuid for primitive false + */ + @PropertySetter("value") + public static void setValue(Obs obs, Object value) throws ParseException, ConversionException, IOException { + if (value != null) { + + // special case for complex obs + if (obs.isComplex()) { + byte[] bytes = DatatypeConverter.parseBase64Binary(value.toString()); + + ComplexData complexData = new ComplexData(obs.getUuid() + ".raw", new ByteArrayInputStream(bytes)); + obs.setComplexData(complexData); + return; + } + + // special case for data type coded (setValueAsString is not implemented for coded obs (in core)) + if (obs.getConcept().getDatatype().isCoded()) { + // We want clients to be able to fetch a coded value in one rest call + // and set the returned payload as the obs value + // (ie support setting based on posting the entire REST rep or just the concept uuid) + if (value instanceof Map) { + Object uuid = ((Map) value).get(RestConstants.PROPERTY_UUID); + if (uuid != null) { + value = uuid.toString(); + } + } + + Concept valueCoded = (Concept) ConversionUtil.convert(value, Concept.class); + if (valueCoded == null) { + //try checking if this this is value drug + Drug valueDrug = (Drug) ConversionUtil.convert(value, Drug.class); + if (valueDrug != null) { + obs.setValueCoded(valueDrug.getConcept()); + obs.setValueDrug(valueDrug); + } else { + throw new ObjectNotFoundException(obs.getConcept().getName().getName() + ":" + value.toString()); + } + + } else { + obs.setValueCoded(valueCoded); + } + return; + } + + // special case for Location + String potentialLocationUuid = null; + + // if this is a representation of an object, get the uuid property as potential location uuid + if (value instanceof Map) { + Object uuid = ((Map) value).get(RestConstants.PROPERTY_UUID); + if (uuid != null) { + potentialLocationUuid = uuid.toString(); + } + } + else { + // otherwise, we will test if the value itself is a location uuid + potentialLocationUuid = value.toString(); + } + + // if there is a potential uuid, see if there is a matching location, and,if so, set the value text as the primary key + if (RestUtil.isValidUuid(potentialLocationUuid)) { + Location location = Context.getLocationService().getLocationByUuid(potentialLocationUuid); + if (location != null) { + obs.setValueText(location.getLocationId().toString()); + obs.setComment("org.openmrs.Location"); + return; + } + } + + // handle all other types using obs.setValueAsString after special conversions for numeric and boolean + if (obs.getConcept().isNumeric()) { + //get the actual persistent object rather than the hibernate proxy + ConceptNumeric concept = Context.getConceptService().getConceptNumeric(obs.getConcept().getId()); + String units = concept.getUnits(); + if (StringUtils.isNotBlank(units)) { + String originalValue = value.toString().trim(); + if (originalValue.endsWith(units)) + value = originalValue.substring(0, originalValue.indexOf(units)).trim(); + else { + //check that this value has no invalid units + try { + Double.parseDouble(originalValue); + } + catch (NumberFormatException e) { + throw new APIException(originalValue + " has invalid units", e); + } + } + } + } else if (obs.getConcept().getDatatype().isBoolean()) { + if (value instanceof Concept) { + value = ((Concept) value).getUuid(); + } + if (value.equals(Context.getConceptService().getTrueConcept().getUuid())) { + value = true; + } else if (value.equals(Context.getConceptService().getFalseConcept().getUuid())) { + value = false; + } else if (!value.getClass().isAssignableFrom(Boolean.class)) { + List trueValues = Arrays.asList("true", "1", "on", "yes"); + List falseValues = Arrays.asList("false", "0", "off", "no"); + + String val = value.toString().trim().toLowerCase(); + if (trueValues.contains(val)) { + value = Boolean.TRUE; + } else if (falseValues.contains(val)) { + value = Boolean.FALSE; + } + + if (!(Boolean.TRUE.equals(value) || Boolean.FALSE.equals(value))) { + throw new ConversionException("Unexpected value: " + value + " set as the value of boolean. " + + trueValues + falseValues + ", ConceptService.getTrueConcept or " + + ", ConceptService.getFalseConcept expected"); + } + } + } + obs.setValueAsString(value.toString()); + + + } else { + throw new APIException("The value for an observation cannot be null"); + } + } + + /** + * Gets obs by patient or encounter (paged according to context if necessary) only if a patient + * or encounter parameter exists respectively in the request set on the {@link RequestContext} + * otherwise searches for obs that match the specified query + * + * @param context + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected PageableResult doSearch(RequestContext context) { + String patientUuid = context.getRequest().getParameter("patient"); + if (patientUuid != null) { + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( + Patient.class)).getByUniqueId(patientUuid); + if (patient == null) + return new EmptySearchResult(); + List obs = Context.getObsService().getObservationsByPerson(patient); + return new NeedsPaging(obs, context); + } + + String encounterUuid = context.getRequest().getParameter("encounter"); + if (encounterUuid != null) { + Encounter enc = ((EncounterResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( + Encounter.class)).getByUniqueId(encounterUuid); + if (enc == null) + return new EmptySearchResult(); + + List obs = new ArrayList(enc.getAllObs(context.getIncludeAll())); + return new NeedsPaging(obs, context); + } + + return new NeedsPaging(Context.getObsService().getObservations(context.getParameter("q")), context); + } + + @Override + public Object upload(MultipartFile file, RequestContext context) throws ResponseException, IOException { + String json = context.getParameter("json"); + if (json == null) { + throw new IllegalRequestException("Obs metadata must be included in a request parameter named 'json'."); + } + + SimpleObject object = SimpleObject.parseJson(json); + Obs obs = convert(object); + + if (!obs.isComplex()) { + throw new IllegalRequestException("Complex concept must be set in order to create a complex obs with data."); + } + + ObsService obsService = Context.getObsService(); + + ComplexData complexData = new ComplexData(file.getOriginalFilename(), new ByteArrayInputStream(file.getBytes())); + obs.setComplexData(complexData); + + obs = obsService.saveObs(obs, null); + + return (SimpleObject) ConversionUtil.convertToRepresentation(obs, Representation.DEFAULT); + } + } diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsTreeResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsTreeResource1_9.java index 58ed70263..bdc289239 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsTreeResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsTreeResource1_9.java @@ -40,7 +40,6 @@ import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; @Resource(name = RestConstants.VERSION_1 + "/obstree", supportedClass = SimpleObject.class, supportedOpenmrsVersions = { "1.9.* - 9.*" }) @@ -86,7 +85,7 @@ public SimpleObject search(RequestContext context) throws ResponseException { Date fromDate = fromDateString != null ? (Date) ConversionUtil.convert(fromDateString, Date.class) : null; Date toDate = toDateString != null ? (Date) ConversionUtil.convert(toDateString, Date.class) : null; - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); if (patient == null) { throw new ObjectNotFoundException("No patient found with uuid " + patientUuid); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderResource1_9.java index e087cb560..cbd8b7472 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.List; @@ -39,8 +39,8 @@ /** * Resource for {@link Order} and all of its subclasses */ -@Resource(name = RestConstants.VERSION_1 + "/order", supportedClass = Order.class, supportedOpenmrsVersions = { "1.8.* - 1.9.*" }, order = 1) -public class OrderResource1_8 extends DataDelegatingCrudResource { +@Resource(name = RestConstants.VERSION_1 + "/order", supportedClass = Order.class, supportedOpenmrsVersions = { "1.9.*" }, order = 1) +public class OrderResource1_9 extends DataDelegatingCrudResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#hasTypesDefined() @@ -295,7 +295,7 @@ public Model getUPDATEModel(Representation rep) { protected PageableResult doSearch(RequestContext context) { String patientUuid = context.getRequest().getParameter("patient"); if (patientUuid != null) { - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); if (patient == null) return new EmptySearchResult(); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierResource1_9.java index 34f24c837..e6edae06e 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.ArrayList; import java.util.List; @@ -41,9 +41,9 @@ /** * Sub-resource for patient identifiers */ -@SubResource(parent = PatientResource1_8.class, path = "identifier", supportedClass = PatientIdentifier.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class PatientIdentifierResource1_8 extends DelegatingSubResource { +@SubResource(parent = PatientResource1_9.class, path = "identifier", supportedClass = PatientIdentifier.class, supportedOpenmrsVersions = { + "1.9.* - 9.*" }) +public class PatientIdentifierResource1_9 extends DelegatingSubResource { @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierTypeResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierTypeResource1_9.java index 209f47396..c8e261077 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierTypeResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -32,10 +32,10 @@ * Allows standard CRUD for the {@link PatientIdentifierType} domain object */ @Resource(name = RestConstants.VERSION_1 + "/patientidentifiertype", supportedClass = PatientIdentifierType.class, supportedOpenmrsVersions = { - "1.8.* - 1.12.*" }) -public class PatientIdentifierTypeResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 1.12.*" }) +public class PatientIdentifierTypeResource1_9 extends MetadataDelegatingCrudResource { - public PatientIdentifierTypeResource1_8() { + public PatientIdentifierTypeResource1_9() { allowedMissingProperties.add("locationBehavior"); allowedMissingProperties.add("uniquenessBehavior"); } diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientResource1_9.java index 50b548595..9df2c36f9 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientResource1_9.java @@ -9,35 +9,368 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; +import java.util.Arrays; +import java.util.LinkedHashSet; import java.util.List; +import java.util.Map; +import java.util.Set; import org.openmrs.Patient; +import org.openmrs.PatientIdentifier; +import org.openmrs.Person; import org.openmrs.Visit; +import org.openmrs.api.PatientService; import org.openmrs.api.VisitService; import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.rest.SimpleObject; +import org.openmrs.module.webservices.rest.web.ConversionUtil; import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; +import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; +import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; import org.openmrs.module.webservices.rest.web.annotation.Resource; +import org.openmrs.module.webservices.rest.web.api.RestService; +import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; +import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; +import org.openmrs.module.webservices.rest.web.representation.Representation; +import org.openmrs.module.webservices.rest.web.resource.impl.AlreadyPaged; +import org.openmrs.module.webservices.rest.web.resource.impl.DataDelegatingCrudResource; +import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; +import org.openmrs.module.webservices.rest.web.resource.impl.ServiceSearcher; +import org.openmrs.module.webservices.rest.web.response.ConversionException; +import org.openmrs.module.webservices.rest.web.response.IllegalRequestException; +import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; +import org.openmrs.module.webservices.validation.ValidateUtil; + +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.ArrayProperty; +import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.RefProperty; +import io.swagger.models.properties.StringProperty; @Resource(name = RestConstants.VERSION_1 + "/patient", supportedClass = Patient.class, supportedOpenmrsVersions = { "1.9.* - 9.*" }) -public class PatientResource1_9 extends PatientResource1_8 { +public class PatientResource1_9 extends DataDelegatingCrudResource { + + public PatientResource1_9() { + } + + @PropertyGetter("person") + public static Person getPerson(Patient instance) { + return new Person(instance); //Must be a Person instead of Patient to prevent infinite recursion RESTWS-273 + } + + /** + * It is empty, because we set that already in the create method. + *

+ * It takes String instead of Person so that the uuid is not resolved to a person, which leads + * to the Hibernate exception: the object is already associated with the session. + * + * @param instance + * @param personUuid + */ + @PropertySetter("person") + public static void setPerson(Patient instance, String personUuid) { + } + + @PropertyGetter("identifiers") + public static Set getIdentifiers(Patient instance) { + return new LinkedHashSet(instance.getActiveIdentifiers()); + } + + @PropertySetter("identifiers") + public static void setIdentifiers(Patient instance, List identifiers) + throws ResourceDoesNotSupportOperationException { + if (instance.getIdentifiers() != null && instance.getIdentifiers().containsAll(identifiers)) { + return; + } + if (instance.getIdentifiers() != null && !instance.getIdentifiers().isEmpty()) { + throw new ResourceDoesNotSupportOperationException("Identifiers can only be set for newly created objects!"); + } + if (identifiers == null || identifiers.isEmpty()) { + throw new ResourceDoesNotSupportOperationException("At least one identifier required"); + } + + boolean hasPreferred = false; + for (PatientIdentifier identifier : identifiers) { + if (identifier.isPreferred()) { + if (!hasPreferred) { + hasPreferred = true; + } else { + throw new ResourceDoesNotSupportOperationException("Only one preferred identifier allowed"); + } + } + } + + if (!hasPreferred) { + //Mark the first one as preferred if none marked + identifiers.iterator().next().setPreferred(true); + } + + instance.getIdentifiers().clear(); + for (PatientIdentifier identifier : identifiers) { + instance.addIdentifier(identifier); + } + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) + */ + @Override + public DelegatingResourceDescription getRepresentationDescription(Representation rep) { + if (rep instanceof DefaultRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("identifiers", Representation.REF); + description.addProperty("person", Representation.DEFAULT); + description.addProperty("voided"); + description.addSelfLink(); + description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); + return description; + } else if (rep instanceof FullRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("identifiers", Representation.DEFAULT); + description.addProperty("person", Representation.FULL); + description.addProperty("voided"); + description.addProperty("auditInfo"); + description.addSelfLink(); + return description; + } + return null; + } + + @Override + public Model getGETModel(Representation rep) { + ModelImpl model = (ModelImpl) super.getGETModel(rep); + //FIXME check uuid, display in ref rep + if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { + model + .property("uuid", new StringProperty()) + .property("display", new StringProperty()) + .property("identifiers", new ArrayProperty(new RefProperty("#/definitions/PatientIdentifierGetRef"))) + .property("preferred", new BooleanProperty()._default(false)) + .property("voided", new BooleanProperty()); + } + if (rep instanceof DefaultRepresentation) { + model + .property("person", new RefProperty("#/definitions/PersonGetRef")); + } else if (rep instanceof FullRepresentation) { + model + .property("person", new RefProperty("#/definitions/PersonGet")); + } + return model; + } + + @Override + public Model getCREATEModel(Representation rep) { + ModelImpl model = new ModelImpl() + .property("person", new StringProperty().example("uuid")) + .property("identifiers", new ArrayProperty(new RefProperty("#/definitions/PatientIdentifierCreate"))) + + .required("person").required("identifiers"); + if (rep instanceof FullRepresentation) { + model + .property("person", new RefProperty("#/definitions/PersonCreate")); + } + return model; + } + @Override + public Model getUPDATEModel(Representation rep) { + return new ModelImpl() + .property("person", new RefProperty("#/definitions/PersonGet")) + + .required("person"); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addRequiredProperty("person"); + description.addRequiredProperty("identifiers"); + return description; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties() + */ + @Override + public DelegatingResourceDescription getUpdatableProperties() { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addRequiredProperty("person"); + return description; + } + + /** + * The method is overwritten, because we need to create a patient from an existing person. In + * the POST body only person and identifiers are provided and other properties must come from + * the existing person. We need to promote the existing person to be a patient by overwriting it + * and at the same time preserving all person properties. + * + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#create(org.openmrs.module.webservices.rest.SimpleObject, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public Object create(SimpleObject propertiesToCreate, RequestContext context) throws ResponseException { + Patient delegate = getPatient(propertiesToCreate); + ValidateUtil.validate(delegate); + delegate = save(delegate); + return ConversionUtil.convertToRepresentation(delegate, Representation.DEFAULT); + } + + public Patient getPatient(SimpleObject propertiesToCreate) { + Object personProperty = propertiesToCreate.get("person"); + Person person = null; + if (personProperty == null) { + throw new ConversionException("The person property is missing"); + } else if (personProperty instanceof String) { + person = Context.getPersonService().getPersonByUuid((String) personProperty); + Context.evictFromSession(person); + } else if (personProperty instanceof Map) { + person = (Person) ConversionUtil.convert(personProperty, Person.class); + propertiesToCreate.put("person", ""); + } + + Patient delegate = new Patient(person); + setConvertedProperties(delegate, propertiesToCreate, getCreatableProperties(), true); + return delegate; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#newDelegate() + */ + @Override + public Patient newDelegate() { + return new Patient(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#save(java.lang.Object) + */ + @Override + public Patient save(Patient patient) { + return Context.getPatientService().savePatient(patient); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getByUniqueId(java.lang.String) + */ + @Override + public Patient getByUniqueId(String uuid) { + return Context.getPatientService().getPatientByUuid(uuid); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#delete(java.lang.Object, + * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) + */ @Override public void delete(Patient patient, String reason, RequestContext context) throws ResponseException { if (patient.isVoided()) { // DELETE is idempotent, so we return success here return; } - + VisitService visitService = Context.getVisitService(); List visits = Context.getVisitService().getVisitsByPatient(patient); for (Visit visit : visits) { visitService.voidVisit(visit, "Patient deleted"); } + Context.getPatientService().voidPatient(patient, reason); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#undelete(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected Patient undelete(Patient patient, RequestContext context) throws ResponseException { + if (patient.isVoided()) { + patient = Context.getPatientService().unvoidPatient(patient); + } + return patient; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(java.lang.Object, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void purge(Patient patient, RequestContext context) throws ResponseException { + if (patient == null) { + // DELETE is idempotent, so we return success here + return; + } + Context.getPatientService().purgePatient(patient); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected AlreadyPaged doSearch(RequestContext context) { + String attributesParam = context.getParameter("attributesToFindDuplicatesBy"); + if (attributesParam != null) { + List attributes = Arrays.asList((attributesParam.split(","))); + + if (attributes.size() < 2) { + throw new IllegalRequestException("Choose a minimum of two attributes"); + } + + List duplicatedPatientsFound = Context.getPatientService().getDuplicatePatientsByAttributes(attributes); + + return new AlreadyPaged(context, duplicatedPatientsFound, false, (long) duplicatedPatientsFound.size()); + } + + return new ServiceSearcher(PatientService.class, "getPatients", "getCountOfPatients").search( + context.getParameter("q"), context); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getPropertiesToExposeAsSubResources() + */ + @Override + public List getPropertiesToExposeAsSubResources() { + return Arrays.asList("identifiers"); + } + + /** + * @param patient + * @return identifier + name (for concise display purposes) + */ + @PropertyGetter("display") + public String getDisplayString(Patient patient) { + if (patient.getPatientIdentifier() == null) + return ""; - super.delete(patient, reason, context); + return patient.getPatientIdentifier().getIdentifier() + " - " + patient.getPersonName().getFullName(); + } + + @Override + public Object update(String uuid, SimpleObject propertiesToUpdate, RequestContext context) throws ResponseException { + if (propertiesToUpdate.get("person") == null) { + return super.update(uuid, propertiesToUpdate, context); + } + Patient patient = getPatientForUpdate(uuid, propertiesToUpdate); + ValidateUtil.validate(patient); + patient = save(patient); + return ConversionUtil.convertToRepresentation(patient, Representation.DEFAULT); + } + + public Patient getPatientForUpdate(String uuid, Map propertiesToUpdate) { + Patient patient = getByUniqueId(uuid); + PersonResource1_9 personResource = (PersonResource1_9) Context.getService(RestService.class) + .getResourceBySupportedClass(Person.class); + personResource.setConvertedProperties(patient, (Map) propertiesToUpdate.get("person"), + personResource.getUpdatableProperties(), false); + return patient; } } diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientStateResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientStateResource1_9.java index b865ce818..9a98b4d25 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientStateResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -43,9 +43,9 @@ /** * {@link Resource} for PatientState, supporting standard CRUD operations */ -@SubResource(parent = ProgramEnrollmentResource1_8.class, path = "state", supportedClass = PatientState.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class PatientStateResource1_8 extends DelegatingSubResource { +@SubResource(parent = ProgramEnrollmentResource1_9.class, path = "state", supportedClass = PatientState.class, supportedOpenmrsVersions = { + "1.9.* - 9.*" }) +public class PatientStateResource1_9 extends DelegatingSubResource { @Override public PatientProgram getParent(PatientState instance) { diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAddressResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAddressResource1_9.java index b47bc1f90..cc2d92a60 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAddressResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -31,17 +31,18 @@ import org.openmrs.module.webservices.rest.web.response.ResponseException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Date; import java.util.List; /** * {@link Resource} for PersonAddress, supporting standard CRUD operations */ -@SubResource(parent = PersonResource1_8.class, path = "address", supportedClass = PersonAddress.class, supportedOpenmrsVersions = { - "1.8.* - 1.12.*" }) -public class PersonAddressResource1_8 extends DelegatingSubResource { +@SubResource(parent = PersonResource1_9.class, path = "address", supportedClass = PersonAddress.class, supportedOpenmrsVersions = { + "1.9.* - 1.12.*" }) +public class PersonAddressResource1_9 extends DelegatingSubResource { - public PersonAddressResource1_8() { + public PersonAddressResource1_9() { allowedMissingProperties.add("startDate"); allowedMissingProperties.add("endDate"); } @@ -277,7 +278,7 @@ public PersonAddress newDelegate() { public Person getParent(PersonAddress instance) { return instance.getPerson(); } - + /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingSubResource#setParent(java.lang.Object, * java.lang.Object) diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeResource1_9.java index 45a7ed6ed..6a62e19dd 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -42,9 +42,9 @@ /** * {@link Resource} for PersonAttributes, supporting standard CRUD operations */ -@SubResource(parent = PersonResource1_8.class, path = "attribute", supportedClass = PersonAttribute.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class PersonAttributeResource1_8 extends DelegatingSubResource { +@SubResource(parent = PersonResource1_9.class, path = "attribute", supportedClass = PersonAttribute.class, supportedOpenmrsVersions = { + "1.9.* - 9.*" }) +public class PersonAttributeResource1_9 extends DelegatingSubResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResource1_9.java index b630f9aa0..b49508a8f 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -38,10 +38,10 @@ * Allows standard CRUD for the {@link PersonAttributeType} domain object */ @Resource(name = RestConstants.VERSION_1 + "/personattributetype", supportedClass = PersonAttributeType.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class PersonAttributeTypeResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 9.*" }) +public class PersonAttributeTypeResource1_9 extends MetadataDelegatingCrudResource { - public PersonAttributeTypeResource1_8() { + public PersonAttributeTypeResource1_9() { } diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonNameResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonNameResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonNameResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonNameResource1_9.java index 171c10cd7..61a7f6f43 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonNameResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonNameResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -39,9 +39,9 @@ /** * {@link Resource} for PersonNames, supporting standard CRUD operations */ -@SubResource(parent = PersonResource1_8.class, path = "name", supportedClass = PersonName.class, supportedOpenmrsVersions = { - "1.8.* - 1.12.*" }) -public class PersonNameResource1_8 extends DelegatingSubResource { +@SubResource(parent = PersonResource1_9.class, path = "name", supportedClass = PersonName.class, supportedOpenmrsVersions = { + "1.9.* - 1.12.*" }) +public class PersonNameResource1_9 extends DelegatingSubResource { @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonResource1_9.java similarity index 99% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonResource1_9.java index 15de940cc..76cba01d4 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.Arrays; import java.util.Date; @@ -50,9 +50,9 @@ * {@link Resource} for Person, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/person", order = 2, supportedClass = Person.class, supportedOpenmrsVersions = { - "1.8.* - 1.10.3" }) + "1.9.* - 1.10.3" }) //order must be greater than that for PatientResource(order=0) RESTWS-273 -public class PersonResource1_8 extends DataDelegatingCrudResource { +public class PersonResource1_9 extends DataDelegatingCrudResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PrivilegeResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PrivilegeResource1_9.java index 5ca45144b..ed3a3cbc4 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PrivilegeResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -30,8 +30,8 @@ * {@link Resource} for Privilege, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/privilege", supportedClass = Privilege.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class PrivilegeResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 9.*" }) +public class PrivilegeResource1_9 extends MetadataDelegatingCrudResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProblemResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProblemResource1_9.java index f4faecf4c..76b80ee02 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProblemResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProblemResource1_9.java @@ -9,18 +9,121 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; +import org.openmrs.Patient; import org.openmrs.activelist.Problem; +import org.openmrs.activelist.ProblemModifier; +import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.docs.swagger.core.property.EnumProperty; +import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; +import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; import org.openmrs.module.webservices.rest.web.annotation.PropertySetter; import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ProblemResource1_8; +import org.openmrs.module.webservices.rest.web.api.RestService; +import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; +import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; +import org.openmrs.module.webservices.rest.web.representation.Representation; +import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; +import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; +import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.DoubleProperty; +import io.swagger.models.properties.RefProperty; /** * {@link org.openmrs.module.webservices.rest.web.annotation.Resource} for Problem, supporting * standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/problem", supportedClass = Problem.class, supportedOpenmrsVersions = { "1.9.* - 1.12.*" }) -public class ProblemResource1_9 extends ProblemResource1_8 { +public class ProblemResource1_9 extends BaseActiveListItemResource1_9 { + + @Override + public Model getGETModel(Representation rep) { + ModelImpl model = (ModelImpl) super.getGETModel(rep); + if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { + model + .property("modifier", new EnumProperty(ProblemModifier.class)) + .property("sortWeight", new DoubleProperty()); + } + if (rep instanceof DefaultRepresentation) { + model + .property("problem", new RefProperty("#/definitions/ConceptGetRef")); + + } else if (rep instanceof FullRepresentation) { + model + .property("problem", new RefProperty("#/definitions/ConceptGet")); + + } + return model; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) + */ + @Override + public DelegatingResourceDescription getRepresentationDescription(Representation rep) { + if (rep instanceof DefaultRepresentation) { + DelegatingResourceDescription description = super.getRepresentationDescription(rep); + description.addProperty("modifier"); + description.addProperty("sortWeight"); + description.addProperty("problem", Representation.REF); + return description; + } else if (rep instanceof FullRepresentation) { + DelegatingResourceDescription description = super.getRepresentationDescription(rep); + description.addProperty("modifier"); + description.addProperty("sortWeight"); + description.addProperty("problem", Representation.DEFAULT); + return description; + } + return null; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = super.getCreatableProperties(); + description.addRequiredProperty("problem"); + description.addProperty("modifier"); + description.addProperty("sortWeight"); + + return description; + } + + @Override + public Model getCREATEModel(Representation rep) { + return ((ModelImpl) super.getCREATEModel(rep)) + .property("problem", new RefProperty("#/definitions/ConceptCreate")) + .property("modifier", new EnumProperty(ProblemModifier.class)) + .property("sortWeight", new DoubleProperty()) + + .required("problem"); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#newDelegate() + */ + @Override + public Problem newDelegate() { + return new Problem(); + } + + /** + * Display string for Problem + * + * @param problem + * @return String ConceptName + */ + @PropertyGetter("display") + public String getDisplayString(Problem problem) { + if (problem.getProblem() == null) + return ""; + + return problem.getProblem().getName().toString(); + } /** * Annotated setter for Problem @@ -33,5 +136,27 @@ public class ProblemResource1_9 extends ProblemResource1_8 { public static void setProblem(Problem problem, Object value) { problem.setProblem(new ConceptResource1_9().getByUniqueId((String) value)); } + + /** + * Gets problems for a given patient (paged according to context if necessary) only if a patient + * parameter exists in the request set on the {@link RequestContext} + * + * @param context + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected PageableResult doSearch(RequestContext context) { + String patientUuid = context.getRequest().getParameter("patient"); + if (patientUuid != null) { + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( + Patient.class)).getByUniqueId(patientUuid); + if (patient == null) + return new EmptySearchResult(); + return new NeedsPaging(Context.getPatientService().getProblems(patient), context); + } + + //currently this is not supported since the superclass throws an exception + return super.doSearch(context); + } } diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramEnrollmentResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramEnrollmentResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramEnrollmentResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramEnrollmentResource1_9.java index 67dcb2dc7..9f86e660c 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramEnrollmentResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramEnrollmentResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -35,8 +35,8 @@ import java.util.List; -@Resource(name = RestConstants.VERSION_1 + "/programenrollment", supportedClass = PatientProgram.class, supportedOpenmrsVersions = { "1.8.* - 1.9.*" }, order = 1) -public class ProgramEnrollmentResource1_8 extends DataDelegatingCrudResource { +@Resource(name = RestConstants.VERSION_1 + "/programenrollment", supportedClass = PatientProgram.class, supportedOpenmrsVersions = { "1.9.*" }, order = 1) +public class ProgramEnrollmentResource1_9 extends DataDelegatingCrudResource { @Override public PatientProgram getByUniqueId(String uniqueId) { diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramResource1_9.java index 144760495..50f4aac0e 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -33,8 +33,8 @@ import java.util.List; -@Resource(name = RestConstants.VERSION_1 + "/program", supportedClass = Program.class, supportedOpenmrsVersions = { "1.8.* - 1.9.*" }, order = 1) -public class ProgramResource1_8 extends MetadataDelegatingCrudResource { +@Resource(name = RestConstants.VERSION_1 + "/program", supportedClass = Program.class, supportedOpenmrsVersions = { "1.9.*" }, order = 1) +public class ProgramResource1_9 extends MetadataDelegatingCrudResource { @Override public Program getByUniqueId(String uniqueId) { diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowResource1_9.java index 9bc4b8834..3d8c0ffd2 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -33,8 +33,8 @@ import java.util.Set; @Resource(name = RestConstants.VERSION_1 + "/workflow", supportedClass = ProgramWorkflow.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }, order = 1) -public class ProgramWorkflowResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 9.*" }, order = 1) +public class ProgramWorkflowResource1_9 extends MetadataDelegatingCrudResource { @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowStateResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowStateResource1_9.java index ce4ec8840..40bede12e 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowStateResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -35,9 +35,9 @@ import java.util.ArrayList; import java.util.List; -@SubResource(parent = ProgramWorkflowResource1_8.class, path = "state", supportedClass = ProgramWorkflowState.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class ProgramWorkflowStateResource1_8 extends DelegatingSubResource { +@SubResource(parent = ProgramWorkflowResource1_9.class, path = "state", supportedClass = ProgramWorkflowState.class, supportedOpenmrsVersions = { + "1.9.* - 9.*" }) +public class ProgramWorkflowStateResource1_9 extends DelegatingSubResource { @Override public ProgramWorkflow getParent(ProgramWorkflowState instance) { diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipResource1_9.java index 726394070..722563169 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipResource1_9.java @@ -1,3 +1,4 @@ + /** * This Source Code Form is subject to the terms of the Mozilla Public License, * v. 2.0. If a copy of the MPL was not distributed with this file, You can @@ -9,37 +10,210 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; +import io.swagger.models.Model; +import io.swagger.models.ModelImpl; +import io.swagger.models.properties.BooleanProperty; +import io.swagger.models.properties.DateProperty; +import io.swagger.models.properties.RefProperty; +import io.swagger.models.properties.StringProperty; +import org.openmrs.Person; import org.openmrs.Relationship; +import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; +import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; import org.openmrs.module.webservices.rest.web.annotation.Resource; import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; +import org.openmrs.module.webservices.rest.web.resource.impl.DataDelegatingCrudResource; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.RelationshipResource1_8; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; +import org.openmrs.module.webservices.rest.web.response.ResponseException; /** * {@link org.openmrs.module.webservices.rest.web.annotation.Resource} for Provider, supporting * standard CRUD operations */ -@Resource(name = RestConstants.VERSION_1 + "/relationship", supportedClass = Relationship.class, supportedOpenmrsVersions = { - "1.9.* - 9.*" }) -public class RelationshipResource1_9 extends RelationshipResource1_8 { +@Resource(name = RestConstants.VERSION_1 + "/relationship", supportedClass = Relationship.class, supportedOpenmrsVersions = { "1.9.* - 9.*" }) +public class RelationshipResource1_9 extends DataDelegatingCrudResource { + + @Override + public Relationship getByUniqueId(String uuid) { + return Context.getPersonService().getRelationshipByUuid(uuid); + } + + @Override + protected void delete(Relationship delegate, String reason, RequestContext context) throws ResponseException { + if (delegate.isVoided()) { + return; + } + Context.getPersonService().voidRelationship(delegate, reason); + } + + @Override + protected Relationship undelete(Relationship delegate, RequestContext context) throws ResponseException { + if (delegate.isVoided()) { + delegate = Context.getPersonService().unvoidRelationship(delegate); + } + return delegate; + } + + @Override + public Relationship newDelegate() { + return new Relationship(); + } + + @Override + public Relationship save(Relationship delegate) { + return Context.getPersonService().saveRelationship(delegate); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#purge(org.openmrs.Encounter, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public void purge(Relationship relationship, RequestContext context) throws ResponseException { + if (relationship == null) { + return; + } + Context.getPersonService().purgeRelationship(relationship); + } /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) */ @Override public DelegatingResourceDescription getRepresentationDescription(Representation rep) { - DelegatingResourceDescription description = super.getRepresentationDescription(rep); - if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { + if (rep instanceof DefaultRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("personA", Representation.REF, Person.class); + description.addProperty("relationshipType", Representation.REF); + description.addProperty("personB", Representation.REF, Person.class); + description.addProperty("voided"); description.addProperty("startDate"); description.addProperty("endDate"); + description.addSelfLink(); + description.addLink("full", ".?v=" + RestConstants.REPRESENTATION_FULL); + return description; + } else if (rep instanceof FullRepresentation) { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("uuid"); + description.addProperty("display"); + description.addProperty("personA", Representation.DEFAULT, Person.class); + description.addProperty("relationshipType", Representation.DEFAULT); + description.addProperty("personB", Representation.DEFAULT, Person.class); + description.addProperty("voided"); + description.addProperty("auditInfo"); + description.addProperty("startDate"); + description.addProperty("endDate"); + description.addSelfLink(); return description; } return null; } + /** + * @param relationship + * @return relationship type and start date + */ + @PropertyGetter("display") + public String getDisplayString(Relationship relationship) { + String relType = relationship.getRelationshipType() == null ? "NULL" : relationship.getRelationshipType() + .getaIsToB(); + return relationship.getPersonA().getGivenName() + " is the " + relType + " of " + + relationship.getPersonB().getGivenName(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getCreatableProperties() + */ + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addRequiredProperty("personA"); + description.addRequiredProperty("relationshipType"); + description.addRequiredProperty("personB"); + description.addProperty("startDate"); + description.addProperty("endDate"); + return description; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(java.lang.String, + * org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + protected NeedsPaging doGetAll(RequestContext context) throws ResponseException { + return new NeedsPaging(Context.getPersonService().getAllRelationships(), context); + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUpdatableProperties() + */ + @Override + public DelegatingResourceDescription getUpdatableProperties() throws ResourceDoesNotSupportOperationException { + DelegatingResourceDescription description = super.getUpdatableProperties(); + //shouldn't be editing the patient + description.removeProperty("personA"); + description.removeProperty("personB"); + description.addProperty("voided"); + return description; + } + + @Override + public Model getGETModel(Representation rep) { + ModelImpl model = (ModelImpl) super.getGETModel(rep); + if (rep instanceof DefaultRepresentation || rep instanceof FullRepresentation) { + model + .property("uuid", new StringProperty()) + .property("display", new StringProperty()) + .property("voided", new BooleanProperty()); + } + if (rep instanceof DefaultRepresentation) { + model + .property("personA", new RefProperty("#/definitions/PersonGetRef")) + .property("relationshipType", new RefProperty("#/definitions/RelationshiptypeGetRef")) + .property("personB", new RefProperty("#/definitions/PersonGetRef")); + } else if (rep instanceof FullRepresentation) { + model + .property("personA", new RefProperty("#/definitions/PersonGet")) + .property("relationshipType", new RefProperty("#/definitions/RelationshiptypeGet")) + .property("personB", new RefProperty("#/definitions/PersonGet")); + } + return model; + } + + @Override + public Model getCREATEModel(Representation rep) { + ModelImpl model = new ModelImpl() + .property("personA", new StringProperty().example("uuid")) + .property("relationshipType", new StringProperty().example("uuid")) + .property("personB", new StringProperty().example("uuid")) + .property("startDate", new DateProperty()) + .property("endDate", new DateProperty()) + + .required("personA").required("relationshipType").required("personB"); + if (rep instanceof FullRepresentation) { + model + .property("personA", new RefProperty("#/definitions/PersonCreate")) + + .property("relationshipType", new RefProperty("#/definitions/RelationshiptypeCreate")) + .property("personB", new RefProperty("#/definitions/PersonCreate")); + } + return model; + } + + @Override + public Model getUPDATEModel(Representation rep) { + return new ModelImpl() + .property("voided", new BooleanProperty()); //FIXME missing properties + } + @Override public String getResourceVersion() { return RestConstants1_9.RESOURCE_VERSION; diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationShipTypeResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipTypeResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationShipTypeResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipTypeResource1_9.java index 8180de756..58e7a7698 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationShipTypeResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipTypeResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.apache.commons.lang.StringUtils; import io.swagger.models.Model; @@ -32,10 +32,10 @@ import java.util.List; @Resource(name = RestConstants.VERSION_1 + "/relationshiptype", supportedClass = RelationshipType.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class RelationShipTypeResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 9.*" }) +public class RelationshipTypeResource1_9 extends MetadataDelegatingCrudResource { - public RelationShipTypeResource1_8() { + public RelationshipTypeResource1_9() { super(); this.propertiesIgnoredWhenUpdating.add("displayAIsToB"); this.propertiesIgnoredWhenUpdating.add("displayBIsToA"); @@ -201,7 +201,7 @@ public String getDisplayString(RelationshipType delegate) { } @PropertyGetter("displayAIsToB") - public String getDisplayAIsToBe(RelationshipType delegate) { + public String getDisplayAIsToB(RelationshipType delegate) { String localization = getLocalization(delegate.getUuid(), "aIsToB"); if (localization != null) { return localization; @@ -211,7 +211,7 @@ public String getDisplayAIsToBe(RelationshipType delegate) { } @PropertyGetter("displayBIsToA") - public String getDisplayBIsToAe(RelationshipType delegate) { + public String getDisplayBIsToA(RelationshipType delegate) { String localization = getLocalization(delegate.getUuid(), "bIsToA"); if (localization != null) { return localization; @@ -235,7 +235,7 @@ protected String getLocalization(String uuid, String type) { */ @Override public String getResourceVersion() { - return "1.8"; + return "1.9"; } } diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RoleResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RoleResource1_9.java index bacd9c032..40a6d8b07 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RoleResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -37,8 +37,8 @@ /** * {@link Resource} for Role, supporting standard CRUD operations */ -@Resource(name = RestConstants.VERSION_1 + "/role", supportedClass = Role.class, supportedOpenmrsVersions = { "1.8.* - 9.*" }) -public class RoleResource1_8 extends MetadataDelegatingCrudResource { +@Resource(name = RestConstants.VERSION_1 + "/role", supportedClass = Role.class, supportedOpenmrsVersions = { "1.9.* - 9.*" }) +public class RoleResource1_9 extends MetadataDelegatingCrudResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ServerLogResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ServerLogResource1_9.java similarity index 97% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ServerLogResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ServerLogResource1_9.java index 0cf9916db..8424d6dec 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ServerLogResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ServerLogResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -28,8 +28,8 @@ * {@link Resource} for ServerLogController, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/serverlog", supportedClass = ServerLogActionWrapper.class, supportedOpenmrsVersions = { - "1.8.* - 2.3.*" }) -public class ServerLogResource1_8 extends BaseDelegatingResource implements Listable { + "1.9.* - 2.3.*" }) +public class ServerLogResource1_9 extends BaseDelegatingResource implements Listable { private ServerLogActionWrapper serverLogActionWrapper = new ServerLogActionWrapper1_8(); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/SystemInformationResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemInformationResource1_9.java similarity index 93% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/SystemInformationResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemInformationResource1_9.java index f9d876c1b..6d3a36738 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/SystemInformationResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemInformationResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.api.impl.AdministrationServiceImpl; import org.openmrs.api.context.Context; @@ -19,8 +19,8 @@ import org.openmrs.module.webservices.rest.web.response.ResponseException; @Resource(name = RestConstants.VERSION_1 + "/systeminformation", supportedClass = AdministrationServiceImpl.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class SystemInformationResource1_8 implements Listable { + "1.9.* - 9.*" }) +public class SystemInformationResource1_9 implements Listable { @Override public SimpleObject getAll(RequestContext context) throws ResponseException { diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskActionResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskActionResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskActionResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskActionResource1_9.java index c1f750a4b..badf084f6 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskActionResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskActionResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -38,8 +38,8 @@ import java.util.Collection; @Resource(name = RestConstants.VERSION_1 + "/taskaction", supportedClass = TaskAction.class, supportedOpenmrsVersions = { - "1.8.* - 9.*" }) -public class TaskActionResource1_8 extends BaseDelegatingResource implements Creatable { + "1.9.* - 9.*" }) +public class TaskActionResource1_9 extends BaseDelegatingResource implements Creatable { private TaskServiceWrapper taskServiceWrapper = new TaskServiceWrapper(); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskDefinitionResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskDefinitionResource1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskDefinitionResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskDefinitionResource1_9.java index 596ff1b1b..a78128d7a 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskDefinitionResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskDefinitionResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.module.webservices.helper.TaskServiceWrapper; import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; @@ -31,8 +31,8 @@ * Resource for Task Definitions, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/taskdefinition", supportedClass = TaskDefinition.class, supportedOpenmrsVersions = { - "1.8.* - 2.3.*" }) -public class TaskDefinitionResource1_8 extends MetadataDelegatingCrudResource { + "1.9.* - 2.3.*" }) +public class TaskDefinitionResource1_9 extends MetadataDelegatingCrudResource { private TaskServiceWrapper taskServiceWrapper = new TaskServiceWrapper(); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UserResource1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UserResource1_9.java similarity index 90% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UserResource1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UserResource1_9.java index 9cf656933..c3cf5417d 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UserResource1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UserResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.lang.reflect.Method; import java.util.ArrayList; @@ -38,7 +38,7 @@ import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; import org.openmrs.module.webservices.rest.web.response.ConversionException; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.UserAndPassword1_8; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.UserAndPassword1_9; import io.swagger.models.Model; import io.swagger.models.ModelImpl; @@ -51,21 +51,21 @@ /** * {@link Resource} for User, supporting standard CRUD operations */ -@Resource(name = RestConstants.VERSION_1 + "/user", supportedClass = UserAndPassword1_8.class, supportedOpenmrsVersions = { - "1.8.* - 1.12.*" }) -public class UserResource1_8 extends MetadataDelegatingCrudResource { +@Resource(name = RestConstants.VERSION_1 + "/user", supportedClass = UserAndPassword1_9.class, supportedOpenmrsVersions = { + "1.9.* - 1.12.*" }) +public class UserResource1_9 extends MetadataDelegatingCrudResource { /** * The name of the parameter that can be used to restrict a search to roles. */ public static final String PARAMETER_ROLES = "roles"; - public UserResource1_8() { + public UserResource1_9() { } @RepHandler(RefRepresentation.class) - public SimpleObject asRef(UserAndPassword1_8 delegate) throws ConversionException { + public SimpleObject asRef(UserAndPassword1_9 delegate) throws ConversionException { DelegatingResourceDescription description = new DelegatingResourceDescription(); description.addProperty("uuid"); description.addProperty("display"); @@ -181,22 +181,22 @@ public Model getCREATEModel(Representation rep) { * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#newDelegate() */ @Override - public UserAndPassword1_8 newDelegate() { - return new UserAndPassword1_8(); + public UserAndPassword1_9 newDelegate() { + return new UserAndPassword1_9(); } /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#save(java.lang.Object) */ @Override - public UserAndPassword1_8 save(UserAndPassword1_8 user) { + public UserAndPassword1_9 save(UserAndPassword1_9 user) { String password = user.getPassword(); User openmrsUser = Context.getUserService().saveUser(user.getUser(), password); Context.refreshAuthenticatedUser(); if (openmrsUser.getId() != null && StringUtils.isNotBlank(password)) { Context.getUserService().changePassword(openmrsUser, password); } - return new UserAndPassword1_8(openmrsUser); + return new UserAndPassword1_9(openmrsUser); } @@ -204,8 +204,8 @@ public UserAndPassword1_8 save(UserAndPassword1_8 user) { * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getByUniqueId(java.lang.String) */ @Override - public UserAndPassword1_8 getByUniqueId(String uuid) { - return new UserAndPassword1_8(Context.getUserService().getUserByUuid(uuid)); + public UserAndPassword1_9 getByUniqueId(String uuid) { + return new UserAndPassword1_9(Context.getUserService().getUserByUuid(uuid)); } /** @@ -213,7 +213,7 @@ public UserAndPassword1_8 getByUniqueId(String uuid) { * java.lang.String, org.openmrs.module.webservices.rest.web.RequestContext) */ @Override - public void delete(UserAndPassword1_8 user, String reason, RequestContext context) throws ResponseException { + public void delete(UserAndPassword1_9 user, String reason, RequestContext context) throws ResponseException { if (user.isRetired()) { // DELETE is idempotent, so we return success here return; @@ -226,7 +226,7 @@ public void delete(UserAndPassword1_8 user, String reason, RequestContext contex * org.openmrs.module.webservices.rest.web.RequestContext) */ @Override - public void purge(UserAndPassword1_8 user, RequestContext context) throws ResponseException { + public void purge(UserAndPassword1_9 user, RequestContext context) throws ResponseException { if (user == null) { // DELETE is idempotent, so we return success here return; @@ -246,7 +246,7 @@ public void purge(UserAndPassword1_8 user, RequestContext context) throws Respon * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override - protected NeedsPaging doSearch(RequestContext context) { + protected NeedsPaging doSearch(RequestContext context) { // determine roles List foundRoles = null; final String requestedRolesParameter = context.getParameter(PARAMETER_ROLES); @@ -265,12 +265,12 @@ protected NeedsPaging doSearch(RequestContext context) { } // convert to UserAndPassword class - final List usersResult = new ArrayList(); + final List usersResult = new ArrayList(); for (User user : users) { - usersResult.add(new UserAndPassword1_8(user)); + usersResult.add(new UserAndPassword1_9(user)); } - return new NeedsPaging(usersResult, context); + return new NeedsPaging(usersResult, context); } private boolean isNoRequestedRoleFound(List roles) { @@ -314,7 +314,7 @@ private List getRequestedRoles(final String rolesParameter) { * @throws ConversionException */ @Override - public Object getProperty(UserAndPassword1_8 instance, String propertyName) throws ConversionException { + public Object getProperty(UserAndPassword1_9 instance, String propertyName) throws ConversionException { try { if (propertyName.equals("password")) { return instance.getPassword(); @@ -346,7 +346,7 @@ public Object getProperty(UserAndPassword1_8 instance, String propertyName) thro @Override public void setProperty(Object instance, String propertyName, Object value) throws ConversionException { try { - UserAndPassword1_8 userAndPassword = (UserAndPassword1_8) instance; + UserAndPassword1_9 userAndPassword = (UserAndPassword1_9) instance; if (propertyName.equals("password")) { userAndPassword.setPassword(value != null ? value.toString() : null); } else { @@ -364,7 +364,7 @@ public void setProperty(Object instance, String propertyName, Object value) thro * @return roles for user * @see User#getRoles() */ - public Set getRoles(UserAndPassword1_8 user) { + public Set getRoles(UserAndPassword1_9 user) { if (user.getUser().getRoles() == null) return null; return RestUtil.removeRetiredData(user.getUser().getRoles()); @@ -375,7 +375,7 @@ public Set getRoles(UserAndPassword1_8 user) { * @return all roles for user * @see User#getAllRoles() */ - public Set getAllRoles(UserAndPassword1_8 user) { + public Set getAllRoles(UserAndPassword1_9 user) { if (user.getUser().getRoles() == null) return null; return RestUtil.removeRetiredData(user.getUser().getAllRoles()); //Get all active roles, including inherited roles @@ -387,7 +387,7 @@ public Set getAllRoles(UserAndPassword1_8 user) { */ @Override @PropertyGetter("display") - public String getDisplayString(UserAndPassword1_8 user) { + public String getDisplayString(UserAndPassword1_9 user) { StringBuilder ret = new StringBuilder(); User u = user.getUser(); ret.append(StringUtils.isNotEmpty(u.getUsername()) ? u.getUsername() : u.getSystemId()); @@ -400,7 +400,7 @@ public String getDisplayString(UserAndPassword1_8 user) { * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getUniqueId(java.lang.Object) */ @Override - protected String getUniqueId(UserAndPassword1_8 delegate) { + protected String getUniqueId(UserAndPassword1_9 delegate) { return delegate.getUser().getUuid(); } @@ -410,7 +410,7 @@ protected String getUniqueId(UserAndPassword1_8 delegate) { * @see org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource#getAuditInfo(java.lang.Object) */ @PropertyGetter("auditInfo") - public SimpleObject getAuditInfo(UserAndPassword1_8 delegate) throws Exception { + public SimpleObject getAuditInfo(UserAndPassword1_9 delegate) throws Exception { return super.getAuditInfo(delegate.getUser()); } @@ -418,11 +418,11 @@ public SimpleObject getAuditInfo(UserAndPassword1_8 delegate) throws Exception { * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override - protected NeedsPaging doGetAll(RequestContext context) { - List users = new ArrayList(); + protected NeedsPaging doGetAll(RequestContext context) { + List users = new ArrayList(); for (User user : Context.getUserService().getAllUsers()) { - users.add(new UserAndPassword1_8(user)); + users.add(new UserAndPassword1_9(user)); } - return new NeedsPaging(users, context); + return new NeedsPaging(users, context); } } diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitResource1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitResource1_9.java index de53a35c2..b9b00cdb5 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitResource1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/VisitResource1_9.java @@ -42,9 +42,6 @@ import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.LocationResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; - import io.swagger.models.Model; import io.swagger.models.ModelImpl; import io.swagger.models.properties.ArrayProperty; @@ -377,7 +374,7 @@ protected NeedsPaging doGetAll(RequestContext context) { } private Patient getPatient(String patientUniqueId) { - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceByName( + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceByName( RestConstants.VERSION_1 + "/patient")).getByUniqueId(patientUniqueId); if (patient == null) throw new ObjectNotFoundException(); @@ -385,7 +382,7 @@ private Patient getPatient(String patientUniqueId) { } private Location getLocation(String locationUniqueId) { - Location location = ((LocationResource1_8) Context.getService(RestService.class).getResourceByName( + Location location = ((LocationResource1_9) Context.getService(RestService.class).getResourceByName( RestConstants.VERSION_1 + "/location")).getByUniqueId(locationUniqueId); if (location == null) throw new ObjectNotFoundException(); diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/ConceptSearchHandler1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/ConceptSearchHandler1_9.java index cc5d13e20..2f67c0b70 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/ConceptSearchHandler1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/ConceptSearchHandler1_9.java @@ -1,3 +1,4 @@ + /** * This Source Code Form is subject to the terms of the Mozilla Public License, * v. 2.0. If a copy of the MPL was not distributed with this file, You can @@ -9,12 +10,19 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9; +import org.apache.commons.lang3.StringUtils; import org.openmrs.Concept; +import org.openmrs.ConceptClass; import org.openmrs.ConceptMap; +import org.openmrs.ConceptName; import org.openmrs.ConceptReferenceTerm; +import org.openmrs.ConceptSearchResult; +import org.openmrs.ConceptSource; +import org.openmrs.api.APIException; import org.openmrs.api.ConceptService; import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; +import org.openmrs.module.webservices.rest.web.RestUtil; import org.openmrs.module.webservices.rest.web.api.RestHelperService; import org.openmrs.module.webservices.rest.web.api.RestHelperService.Field; import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; @@ -23,14 +31,17 @@ import org.openmrs.module.webservices.rest.web.resource.api.SearchQuery; import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.response.InvalidSearchException; import org.openmrs.module.webservices.rest.web.response.ResponseException; +import org.openmrs.util.LocaleUtility; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; import java.util.ArrayList; -import java.util.Collections; +import java.util.Arrays; import java.util.List; +import java.util.Locale; /** * Returns concepts which map to term (uuid) @@ -41,16 +52,22 @@ public class ConceptSearchHandler1_9 implements SearchHandler { @Autowired @Qualifier("conceptService") ConceptService conceptService; - + @Autowired @Qualifier("restHelperService") RestHelperService restHelperService; private final SearchConfig searchConfig = new SearchConfig("byTerm", RestConstants.VERSION_1 + "/concept", - Collections.singletonList("1.9.* - 9.*"), - new SearchQuery.Builder( - "Allows you to find concepts which map to term, uuid of term given as input").withRequiredParameters( - "term").build()); + Arrays.asList("1.9.* - 9.*"), + Arrays.asList( + new SearchQuery.Builder("Allows you to find concepts by source and code").withRequiredParameters("source") + .withOptionalParameters("code").build(), new SearchQuery.Builder( + "Allows you to find concepts by name and class").withRequiredParameters("name") + .withOptionalParameters("class", "searchType").build(), new SearchQuery.Builder( + "Allows you to find a list of concepts by passing references") + .withRequiredParameters("references").build(), new SearchQuery.Builder( + "Allows you to find concepts which map to term, uuid of term given as input").withRequiredParameters( + "term").build())); /** * @see org.openmrs.module.webservices.rest.web.resource.api.SearchHandler#getSearchConfig() @@ -65,26 +82,143 @@ public SearchConfig getSearchConfig() { */ @Override public PageableResult search(RequestContext context) throws ResponseException { + String source = context.getParameter("source"); + String code = context.getParameter("code"); + String name = context.getParameter("name"); + String conceptClass = context.getParameter("class"); + String searchType = context.getParameter("searchType"); + String conceptReferences = context.getParameter("references"); String uuid = context.getParameter("term"); - ConceptReferenceTerm conceptReferenceTerm = conceptService.getConceptReferenceTermByUuid(uuid); - if (conceptReferenceTerm == null) { - return new EmptySearchResult(); + List concepts; + + if (StringUtils.isNotBlank(conceptReferences)) { + String[] conceptReferenceStrings = conceptReferences.split(","); + concepts = new ArrayList(conceptReferenceStrings.length); + + for (String conceptReference : conceptReferenceStrings) { + if (StringUtils.isBlank(conceptReference)) { + continue; + } + // handle UUIDs + if (RestUtil.isValidUuid(conceptReference)) { + Concept concept = conceptService.getConceptByUuid(conceptReference); + if (concept != null) { + concepts.add(concept); + continue; + } + } + // handle mappings + int idx = conceptReference.indexOf(':'); + if (idx >= 0 && idx < conceptReference.length() - 1) { + String conceptSource = conceptReference.substring(0, idx); + String conceptCode = conceptReference.substring(idx + 1); + Concept concept = conceptService.getConceptByMapping(conceptCode, conceptSource, false); + if (concept != null) { + concepts.add(concept); + continue; + } + } + } + if (concepts.size() == 0) { + return new EmptySearchResult(); + } + + return new NeedsPaging(concepts, context); + } + + concepts = new ArrayList(); + + // If there's class parameter in query + if ("fuzzy".equals(searchType)) { + List locales = new ArrayList(LocaleUtility.getLocalesInOrder()); + List classes = null; + ConceptClass responseConceptClass = conceptService.getConceptClassByUuid(conceptClass); + + if (responseConceptClass != null) { + classes = Arrays.asList(responseConceptClass); + } + + List searchResults = conceptService.getConcepts(name, locales, context.getIncludeAll(), + classes, null, null, null, null, context.getStartIndex(), context.getLimit()); + List results = new ArrayList(searchResults.size()); + for (ConceptSearchResult csr : searchResults) { + results.add(csr.getConcept()); + } + return new NeedsPaging(results, context); + } else if (searchType == null || "equals".equals(searchType)) { + + if (name != null) { + Concept concept = conceptService.getConceptByName(name); + concepts.add(concept); + if (concept != null) { + boolean isPreferredOrFullySpecified = false; + for (ConceptName conceptname : concept.getNames()) { + if (conceptname.getName().equalsIgnoreCase(name) + && (conceptname.isPreferred() || conceptname.isFullySpecifiedName())) { + isPreferredOrFullySpecified = true; + break; + } + } + if (!isPreferredOrFullySpecified) { + throw new APIException( + "The concept name should be either a fully specified or locale preferred name"); + } + + return new NeedsPaging(concepts, context); + } else { + return new EmptySearchResult(); + } + } + } else { + throw new InvalidSearchException("Invalid searchType: " + searchType + + ". Allowed values: \"equals\" and \"fuzzy\""); } - else { + ConceptSource conceptSource = conceptService.getConceptSourceByUuid(source); + if (conceptSource == null) { + conceptSource = conceptService.getConceptSourceByName(source); + } + + if (conceptSource == null && uuid == null) { + return new EmptySearchResult(); // No source or UUID found + } + + concepts = new ArrayList(); + + // Handle the case where a code is provided + if (code != null) { + List conceptsByMapping = conceptService.getConceptsByMapping(code, source, false); + return new NeedsPaging(conceptsByMapping, context); + } + // Handle the case where no code is provided + if (conceptSource != null) { + List conceptMaps = conceptService.getConceptMappingsToSource(conceptSource); + for (ConceptMap conceptMap : conceptMaps) { + if (!conceptMap.getConcept().isRetired() || context.getIncludeAll()) { + concepts.add(conceptMap.getConcept()); + } + } + } + + // Handle concept reference term case (uuid is provided) + if (uuid != null) { + ConceptReferenceTerm conceptReferenceTerm = conceptService.getConceptReferenceTermByUuid(uuid); + if (conceptReferenceTerm == null) { + return new EmptySearchResult(); + } + List conceptMaps = new ArrayList(); - conceptMaps.addAll(restHelperService.getObjectsByFields(ConceptMap.class, new Field("conceptReferenceTerm", - conceptReferenceTerm))); - List concepts = new ArrayList(); + conceptMaps.addAll(restHelperService.getObjectsByFields(ConceptMap.class, + new Field("conceptReferenceTerm", conceptReferenceTerm))); for (ConceptMap conceptMap : conceptMaps) { if (!conceptMap.getConcept().isRetired() || context.getIncludeAll()) { concepts.add(conceptMap.getConcept()); - } } - return new NeedsPaging(concepts, context); } + + // Return the final paging result + return new NeedsPaging(concepts, context); } - } diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/EncounterSearchHandler1_9.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/EncounterSearchHandler1_9.java index aac2a55ed..1b93ed3b6 100644 --- a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/EncounterSearchHandler1_9.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/EncounterSearchHandler1_9.java @@ -23,8 +23,8 @@ import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ConceptResource1_9; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PatientResource1_9; import org.openmrs.util.OpenmrsUtil; import org.springframework.stereotype.Component; @@ -78,12 +78,12 @@ public PageableResult search(RequestContext context) throws ResponseException { String values = context.getRequest().getParameter(REQUEST_PARAM_VALUES); if (StringUtils.isNotBlank(patientUuid) && StringUtils.isNotBlank(conceptUuid)) { - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); // get all encounters matching patient and concept if (patient != null) { - Concept concept = ((ConceptResource1_8) Context.getService(RestService.class) + Concept concept = ((ConceptResource1_9) Context.getService(RestService.class) .getResourceBySupportedClass(Concept.class)).getByUniqueId(conceptUuid); if (concept != null) { List obs = Context.getObsService().getObservationsByPersonAndConcept(patient, concept); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/FormSearchHandler1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/FormSearchHandler1_9.java similarity index 96% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/FormSearchHandler1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/FormSearchHandler1_9.java index 05790f89b..e68972dbb 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/FormSearchHandler1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/FormSearchHandler1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9; import java.util.Collections; import java.util.List; @@ -26,9 +26,9 @@ import org.springframework.stereotype.Component; @Component -public class FormSearchHandler1_8 implements SearchHandler { +public class FormSearchHandler1_9 implements SearchHandler { - private final SearchConfig searchConfig = new SearchConfig("default", RestConstants.VERSION_1 + "/form", Collections.singletonList("1.8 - 9.*"), + private final SearchConfig searchConfig = new SearchConfig("default", RestConstants.VERSION_1 + "/form", Collections.singletonList("1.9 - 9.*"), new SearchQuery.Builder( "Allows you to filter forms by published status") diff --git a/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/LocationSearchHandler.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/LocationSearchHandler.java new file mode 100644 index 000000000..d4e6c429a --- /dev/null +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/LocationSearchHandler.java @@ -0,0 +1,78 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.openmrs.Location; +import org.openmrs.LocationTag; +import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.rest.web.RequestContext; +import org.openmrs.module.webservices.rest.web.RestConstants; +import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; +import org.openmrs.module.webservices.rest.web.resource.api.SearchConfig; +import org.openmrs.module.webservices.rest.web.resource.api.SearchHandler; +import org.openmrs.module.webservices.rest.web.resource.api.SearchQuery; +import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; +import org.openmrs.module.webservices.rest.web.response.ResponseException; +import org.springframework.stereotype.Component; + +@Component +public class LocationSearchHandler implements SearchHandler { + + private static final String VIEW_LOCATIONS = "View Locations"; + + private final SearchConfig searchConfig = new SearchConfig("default", RestConstants.VERSION_1 + "/location", + Collections.singletonList("1.9.* - 9.*"), + new SearchQuery.Builder( + "Allows you to find locations by tag uuid or tag name").withRequiredParameters("tag").build()); + + /** + * @see org.openmrs.module.webservices.rest.web.resource.api.SearchHandler#getSearchConfig() + * Should return location by tag uuid + * Should return location by tag name + */ + @Override + public SearchConfig getSearchConfig() { + return searchConfig; + } + + /** + * @see org.openmrs.module.webservices.rest.web.resource.api.SearchHandler#search(org.openmrs.module.webservices.rest.web.RequestContext) + */ + @Override + public PageableResult search(RequestContext context) throws ResponseException { + String tag = context.getRequest().getParameter("tag"); + + List locations = new ArrayList(); + try { + Context.addProxyPrivilege(VIEW_LOCATIONS); //Not using PrivilegeConstants.VIEW_LOCATIONS which was removed in platform 1.11+ + Context.addProxyPrivilege("Get Locations"); //1.11+ + + LocationTag locationTag = Context.getLocationService().getLocationTagByUuid(tag); + if (locationTag == null) { + locationTag = Context.getLocationService().getLocationTagByName(tag); + } + + if (locationTag != null) { + locations = Context.getLocationService().getLocationsHavingAllTags(Arrays.asList(locationTag)); + } + } + finally { + Context.removeProxyPrivilege(VIEW_LOCATIONS); //Not using PrivilegeConstants.VIEW_LOCATIONS which was removed in platform 1.11+ + Context.removeProxyPrivilege("Get Locations"); //1.11+ + } + + return new NeedsPaging(locations, context); + } +} diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/ObservationSearchHandler1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/ObservationSearchHandler1_9.java similarity index 93% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/ObservationSearchHandler1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/ObservationSearchHandler1_9.java index 7011625c7..e10b852de 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/ObservationSearchHandler1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/ObservationSearchHandler1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9; import org.openmrs.Concept; import org.openmrs.Obs; @@ -24,8 +24,8 @@ import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ConceptResource1_9; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PatientResource1_9; import org.springframework.stereotype.Component; import java.util.ArrayList; @@ -43,10 +43,10 @@ * All Rights Reserved. */ @Component -public class ObservationSearchHandler1_8 implements SearchHandler { +public class ObservationSearchHandler1_9 implements SearchHandler { private final SearchConfig searchConfig = new SearchConfig("default", RestConstants.VERSION_1 + "/obs", Arrays.asList( - "1.8.* - 2.*"), Arrays.asList(new SearchQuery.Builder( + "1.9.* - 2.*"), Arrays.asList(new SearchQuery.Builder( "Allows you to find Observations by patient and concept").withRequiredParameters("patient") .withOptionalParameters("concept", "concepts", "answers", "groupingConcepts").build())); @@ -80,7 +80,7 @@ else if (context.getRequest().getParameter("concepts") != null) { if (patientUuid != null) { - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); List questionConcepts = new ArrayList(); @@ -90,14 +90,14 @@ else if (context.getRequest().getParameter("concepts") != null) { if (!questionConceptUuids.isEmpty()) { for (String conceptUuid : questionConceptUuids) { - questionConcepts.add(((ConceptResource1_8) Context.getService(RestService.class) + questionConcepts.add(((ConceptResource1_9) Context.getService(RestService.class) .getResourceBySupportedClass(Concept.class)).getByUniqueId(conceptUuid)); } } if (!answerConceptUuids.isEmpty()) { for (String conceptUuid : answerConceptUuids) { - answerConcepts.add(((ConceptResource1_8) Context.getService(RestService.class) + answerConcepts.add(((ConceptResource1_9) Context.getService(RestService.class) .getResourceBySupportedClass(Concept.class)).getByUniqueId(conceptUuid)); } } diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/PatientByIdentifierSearchHandler1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/PatientByIdentifierSearchHandler1_9.java similarity index 96% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/PatientByIdentifierSearchHandler1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/PatientByIdentifierSearchHandler1_9.java index 5fa0ae1d5..3752635a7 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/PatientByIdentifierSearchHandler1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/PatientByIdentifierSearchHandler1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9; import org.apache.commons.lang.StringUtils; import org.openmrs.Patient; @@ -29,13 +29,13 @@ import java.util.List; @Component -public class PatientByIdentifierSearchHandler1_8 implements SearchHandler { +public class PatientByIdentifierSearchHandler1_9 implements SearchHandler { @Autowired RestHelperService restHelperService; private final SearchConfig searchConfig = new SearchConfig("patientByIdentifier", RestConstants.VERSION_1 + "/patient", - Collections.singletonList("1.8.* - 9.*"), + Collections.singletonList("1.9.* - 9.*"), Collections.singletonList(new SearchQuery.Builder("Allows you to find Patients by identifier") .withRequiredParameters("identifier").withOptionalParameters("searchType").build())); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/RelationshipSearchHandler1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/RelationshipSearchHandler1_9.java similarity index 98% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/RelationshipSearchHandler1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/RelationshipSearchHandler1_9.java index 9597de489..1e2a2eb9e 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/RelationshipSearchHandler1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/RelationshipSearchHandler1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9; import org.openmrs.Person; import org.openmrs.Relationship; @@ -33,10 +33,10 @@ * Allows search for relationships by mappings */ @Component -public class RelationshipSearchHandler1_8 implements SearchHandler { +public class RelationshipSearchHandler1_9 implements SearchHandler { private final SearchConfig searchConfig = new SearchConfig("default", RestConstants.VERSION_1 + "/relationship", - Collections.singletonList("1.8.* - 9.*"), + Collections.singletonList("1.9.* - 9.*"), Arrays.asList( new SearchQuery.Builder("Allows you to find relationship by person uuid").withRequiredParameters("person") .build(), new SearchQuery.Builder( diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/UserSearchHandler1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/UserSearchHandler1_9.java similarity index 88% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/UserSearchHandler1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/UserSearchHandler1_9.java index f5453013c..997f2e399 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/UserSearchHandler1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/UserSearchHandler1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9; import org.openmrs.User; import org.openmrs.api.UserService; @@ -20,7 +20,7 @@ import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.UserAndPassword1_8; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.UserAndPassword1_9; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @@ -33,14 +33,14 @@ * Allows for finding users by username */ @Component -public class UserSearchHandler1_8 implements SearchHandler { +public class UserSearchHandler1_9 implements SearchHandler { @Autowired @Qualifier("userService") UserService userService; private final SearchConfig searchConfig = new SearchConfig("default", RestConstants.VERSION_1 + "/user", - Collections.singletonList("1.8.* - 9.*"), + Collections.singletonList("1.9.* - 9.*"), new SearchQuery.Builder( "Allows you to find users by username").withRequiredParameters("username").build()); @@ -64,9 +64,9 @@ public PageableResult search(RequestContext context) throws ResponseException { return new EmptySearchResult(); } - List users = new ArrayList(); - users.add(new UserAndPassword1_8(user)); - return new NeedsPaging(users, context); + List users = new ArrayList(); + users.add(new UserAndPassword1_9(user)); + return new NeedsPaging(users, context); } } diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/CohortMember1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/CohortMember1_9.java similarity index 91% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/CohortMember1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/CohortMember1_9.java index 5bb0ea376..9529c100c 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/CohortMember1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/CohortMember1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9; import java.io.Serializable; @@ -20,11 +20,11 @@ * This class is a wrapper for {@link org.openmrs.Cohort} and {@link org.openmrs.Patient} that needs * to be sent for adding/removing members from a cohort. */ -public class CohortMember1_8 implements Serializable { +public class CohortMember1_9 implements Serializable { public static final long serialVersionUID = 1L; - private static final Log log = LogFactory.getLog(UserAndPassword1_8.class); + private static final Log log = LogFactory.getLog(UserAndPassword1_9.class); /** Patient, who exists in cohort */ private Patient patient; @@ -35,7 +35,7 @@ public class CohortMember1_8 implements Serializable { /** * Default constructor */ - public CohortMember1_8() { + public CohortMember1_9() { this.patient = new Patient(); this.cohort = new Cohort(); } @@ -46,7 +46,7 @@ public CohortMember1_8() { * @param patient * @param cohort */ - public CohortMember1_8(Patient patient, Cohort cohort) { + public CohortMember1_9(Patient patient, Cohort cohort) { super(); this.patient = patient; this.cohort = cohort; diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/IncomingHl7Message1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/IncomingHl7Message1_9.java similarity index 93% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/IncomingHl7Message1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/IncomingHl7Message1_9.java index 53e97de6c..62d2416aa 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/IncomingHl7Message1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/IncomingHl7Message1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9; import java.io.Serializable; @@ -20,7 +20,7 @@ /** * This class represents generic HL7 message (e.g. InQueue/Archive/Error) */ -public class IncomingHl7Message1_8 extends BaseOpenmrsData implements Serializable { +public class IncomingHl7Message1_9 extends BaseOpenmrsData implements Serializable { private static final long serialVersionUID = 1L; @@ -36,7 +36,7 @@ public class IncomingHl7Message1_8 extends BaseOpenmrsData implements Serializab /** * Empty constructor */ - public IncomingHl7Message1_8() { + public IncomingHl7Message1_9() { super(); } @@ -48,7 +48,7 @@ public IncomingHl7Message1_8() { * @param data hl7 message pay-load * @param messageState (optional) state of hl7 message */ - public IncomingHl7Message1_8(HL7Source hl7Source, String hl7SourceKey, String hl7Data, Integer messageState) { + public IncomingHl7Message1_9(HL7Source hl7Source, String hl7SourceKey, String hl7Data, Integer messageState) { super(); this.source = hl7Source; this.sourceKey = hl7SourceKey; @@ -59,7 +59,7 @@ public IncomingHl7Message1_8(HL7Source hl7Source, String hl7SourceKey, String hl /** * Creates new {@link HL7InQueue} instance from hl7 in queue message */ - public IncomingHl7Message1_8(HL7InQueue message) { + public IncomingHl7Message1_9(HL7InQueue message) { setSource(message.getHL7Source()); setSourceKey(message.getHL7SourceKey()); setData(message.getHL7Data()); diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/UserAndPassword1_8.java b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/UserAndPassword1_9.java similarity index 93% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/UserAndPassword1_8.java rename to omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/UserAndPassword1_9.java index b8341200e..a3748bf8c 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_8/UserAndPassword1_8.java +++ b/omod-1.9/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/wrapper/openmrs1_9/UserAndPassword1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9; import java.io.Serializable; @@ -21,7 +21,7 @@ * * @see org.openmrs.module.webservices.rest.web.resource.impl.MetadataDelegatingCrudResource */ -public class UserAndPassword1_8 extends BaseOpenmrsMetadata implements Serializable { +public class UserAndPassword1_9 extends BaseOpenmrsMetadata implements Serializable { public static final long serialVersionUID = 1L; @@ -32,14 +32,14 @@ public class UserAndPassword1_8 extends BaseOpenmrsMetadata implements Serializa //Constructors /** default constructor */ - public UserAndPassword1_8() { + public UserAndPassword1_9() { user = new User(); } /** * @param user */ - public UserAndPassword1_8(User user) { + public UserAndPassword1_9(User user) { this.user = user; } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/ClassHierarchyResourceTest.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/ClassHierarchyResourceTest.java index 14c0746b2..a10f7a5b0 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/ClassHierarchyResourceTest.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/ClassHierarchyResourceTest.java @@ -18,7 +18,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.OrderResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.OrderResource1_9; import org.openmrs.web.test.BaseModuleWebContextSensitiveTest; import org.springframework.mock.web.MockHttpServletRequest; @@ -43,13 +43,13 @@ public class ClassHierarchyResourceTest extends BaseModuleWebContextSensitiveTes RequestContext context; - OrderResource1_8 resource; + OrderResource1_9 resource; @Before public void beforeEachTests() throws Exception { executeDataSet(DATASET_FILENAME); context = new RequestContext(); - resource = (OrderResource1_8) Context.getService(RestService.class).getResourceBySupportedClass(Order.class); + resource = (OrderResource1_9) Context.getService(RestService.class).getResourceBySupportedClass(Order.class); } private SimpleObject buildSuperclass() { diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/ConversionUtil1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/ConversionUtil1_9Test.java index 2f3eac5fe..310a827bc 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/ConversionUtil1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/ConversionUtil1_9Test.java @@ -17,7 +17,7 @@ import org.openmrs.Obs; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.representation.CustomRepresentation; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.EncounterResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.EncounterResource1_9; import org.openmrs.web.test.BaseModuleWebContextSensitiveTest; import java.util.List; @@ -58,7 +58,7 @@ public void convertToRepresentation_shouldConvertObsDrugValueAsNull() { // the custom rep is expecting a representation where all the values are concepts // our hack fix (see https://issues.openmrs.org/browse/RESTWS-816) is to simply to return null as the value for value drug - SimpleObject result = (SimpleObject) ConversionUtil.convertToRepresentation(encounter, new CustomRepresentation("uuid,obs:(uuid,value:(names))"), new EncounterResource1_8()); + SimpleObject result = (SimpleObject) ConversionUtil.convertToRepresentation(encounter, new CustomRepresentation("uuid,obs:(uuid,value:(names))"), new EncounterResource1_9()); List resultObsList = (List) result.get("obs"); assertThat(resultObsList.size(), is(2)); SimpleObject resultObs1 = resultObsList.get(0); diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/DelegatingCrudResourceTest.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/DelegatingCrudResourceTest.java similarity index 99% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/DelegatingCrudResourceTest.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/DelegatingCrudResourceTest.java index 566e9b2e0..8b65147b2 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/DelegatingCrudResourceTest.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/DelegatingCrudResourceTest.java @@ -30,8 +30,8 @@ import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.LocationResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.UserResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.LocationResource1_9; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.UserResource1_9; import org.openmrs.util.Reflect; import org.openmrs.web.test.BaseModuleWebContextSensitiveTest; import org.springframework.beans.factory.config.BeanDefinition; @@ -69,7 +69,7 @@ public void testAllReprsentationDescriptions() throws Exception { Class openmrsClass = (Class) parameterizedType.getActualTypeArguments()[0]; //User Resource is special in that the Actual parameterized Type isn't a standard domain object, so we also //need to look up fields and methods from the org.openmrs.User class - boolean isUserResource = resourceClass.equals(UserResource1_8.class); + boolean isUserResource = resourceClass.equals(UserResource1_9.class); List refDescriptions = new ArrayList(); if (method.getName().equals("getRepresentationDescription") @@ -168,7 +168,7 @@ public void convert_shouldConvertASimpleObjectThatIncludesAUuid() { so.add("uuid", uuid); so.add("name", "Location name"); so.add("description", "Location description"); - DelegatingCrudResource resource = new LocationResource1_8(); + DelegatingCrudResource resource = new LocationResource1_9(); Location location = resource.convert(so); Assert.assertEquals(uuid, location.getUuid()); } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrder.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrder.java similarity index 100% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrder.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrder.java diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java similarity index 99% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java index 0a555964c..05d77dd28 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/HivDrugOrderSubclassHandler.java @@ -32,7 +32,7 @@ /** * This is a contrived example for testing purposes */ -@SubClassHandler(supportedClass = HivDrugOrder.class, supportedOpenmrsVersions = { "1.8.*" }) +@SubClassHandler(supportedClass = HivDrugOrder.class, supportedOpenmrsVersions = { "1.9.*" }) public class HivDrugOrderSubclassHandler extends BaseDelegatingSubclassHandler implements DelegatingSubclassHandler { /** diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/MockModuleFactoryWrapper.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/MockModuleFactoryWrapper.java similarity index 100% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/MockModuleFactoryWrapper.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/MockModuleFactoryWrapper.java diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/MockServerLogActionWrapper.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/MockServerLogActionWrapper.java similarity index 100% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/MockServerLogActionWrapper.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/MockServerLogActionWrapper.java diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/MockTaskServiceWrapper.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/MockTaskServiceWrapper.java similarity index 100% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/MockTaskServiceWrapper.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/MockTaskServiceWrapper.java diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/RestTestConstants1_9.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/RestTestConstants1_9.java index d63c19f74..f5b8932e8 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/RestTestConstants1_9.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/RestTestConstants1_9.java @@ -11,6 +11,96 @@ public class RestTestConstants1_9 { + public static final String RESOURCE_TEST_DATASET = "resourceTestDataset.xml"; + + public static final String CONCEPT3_UUID = "b055abd8-a420-4a11-8b98-02ee170a7b54"; + + public static final String CONCEPT2_UUID = "7d104a6f-8337-4afa-b936-41083a5d9d88"; + + public static final String CONCEPT_NUMERIC_UUID = "a09ab2c5-878e-4905-b25d-5784167d0216"; + + public static final String CONCEPT_NAME_UUID = "ef7ac747-7980-443c-b11f-4617aa587703"; + + public static final String CONCEPT_DESCRIPTION_UUID = "7ae2d5db-2aab-49b9-a256-7c258eaab067"; + + public static final String CONCEPT_DATATYPE_UUID = "8d4a4c94-c2cc-11de-8d13-0010c6dffd0f"; + + public static final String CONCEPT_CLASS_UUID = "ecdee8a7-d741-4fe7-8e01-f79cacbe97bc"; + + public static final String DRUG_UUID = "05ec820a-d297-44e3-be6e-698531d9dd3f"; + + public static final String PERSON_UUID = "da7f524f-27ce-4bb2-86d6-6d1d05312bd5"; + + public static final String PERSON_NAME_UUID = "399e3a7b-6482-487d-94ce-c07bb3ca3cc7"; + + public static final String PERSON_ADDRESS_UUID = "3350d0b5-821c-4e5e-ad1d-a9bce331e118"; + + public static final String PERSON_ATTRIBUTE_TYPE_UUID = "b3b6d540-a32e-44c7-91b3-292d97667518"; + + public static final String PERSON_ATTRIBUTE_UUID = "15d694af-43d6-443a-971c-ec210e3ec5c5"; + + public static final String PATIENT_UUID = "da7f524f-27ce-4bb2-86d6-6d1d05312bd5"; + + public static final String PATIENT_IDENTIFIER_UUID = "8a9aac6e-3f9f-4ed2-8fb5-25215f8bb614"; + + public static final String PATIENT_IDENTIFIER_TYPE_UUID = "1a339fe9-38bc-4ab3-b180-320988c0b968"; + + public static final String OBS2_UUID = "39fb7f47-e80a-4056-9285-bd798be13c63"; + + public static final String ORDER_UUID = "921de0a3-05c4-444a-be03-e01b4c4b9142"; + + public static final String LOCATION2_UUID = "167ce20c-4785-4285-9119-d197268f7f4a"; + + public static final String LOCATION_TAG_UUID = "001e503a-47ed-11df-bc8b-001e378eb67e"; + + public static final String ENCOUNTER_TYPE_UUID = "61ae96f4-6afe-4351-b6f8-cd4fc383cce1"; + + public static final String ENCOUNTER2_UUID = "6519d653-393b-4118-9c83-a3715b82d4ac"; + + public static final String COHORT_UUID = "05e08b3b-5690-41e1-b651-5391fd946c1a"; + + public static final String HL7_SOURCE_NAME = "TEST"; + + public static final String USER_UUID = "c98a1558-e131-11de-babe-001e378eb67e"; + + public static final String ROLE_UUID = "3480cb6d-c291-46c8-8d3a-96dc33d199fb"; + + public static final String FORM2_UUID = "d9218f76-6c39-45f4-8efa-4c5c6c199f50"; + + public static final String FORM_FIELD_UUID = "1c822b7b-7840-463d-ba70-e0c8338a4c2d"; + + public static final String FIELD_TYPE_UUID = "abf16b7d-39a5-4911-89da-0eefbfef7cb4"; + + public static final String FIELD_UUID = "db016b7d-39a5-4911-89da-0eefbfef7cb2"; + + public static final String ALLERGY_UUID = "40fb7f47-e80a-7890-9285-bd798be13c61"; + + public static final String PROBLEM_UUID = "50fb7f47-e80a-7890-9285-bd798be13c61"; + + public static final String CONCEPT_SOURCE_UUID = "75f5b378-5065-11de-80cb-001e378eb67e"; + + public static final String PRIVILEGE_UUID = "d979d066-15e6-467c-9d4b-cb575ef97f0f"; + + public static final String RELATIONSHIP_UUID = "c18717dd-5d78-4a0e-84fc-ee62c5f0676a"; + + public static final String RELATIONSHIP_TYPE_UUID = "6d9002ea-a96b-4889-af78-82d48c57a110"; + + public static final String PROGRAM_UUID = "f386c3d2-dd75-441f-a582-2237824edfb0"; + + public static final String WORKFLOW_UUID = "84f0effa-dd73-46cb-b931-7cd6be6c5f81"; + + public static final String PATIENT_PROGRAM_UUID = "b75462a0-4c92-451e-b8bc-e98b38b76534"; + + public static final String PATIENT_IN_A_PROGRAM_UUID = "da7f524f-27ce-4bb2-86d6-6d1d05312bd5"; + + public static final String PATIENT_WITH_VOIDED_PROGRAM_UUID = "8adf539e-4b5a-47aa-80c0-ba1025c957fa"; + + public static final String STATE_UUID = "92584cdc-6a20-4c84-a659-e035e45d36b0"; + + public static final String PATIENT_STATE_UUID = "ea89deaa-23cc-4840-92fe-63d199c37e4c"; + + public static final String TASK_DEFINITION_UUID = "266a2ff1-f0b1-45f4-ad04-2ce952a27920"; + public final static String LOCATION_UUID = "f08ba64b-ea57-4a41-nfdr-9dfc59b0c60a"; public final static String LOCATION_ATTRIBUTE_UUID = "3a2bdb18-6faa-11e0-8414-001e378eb67e"; @@ -83,4 +173,6 @@ public class RestTestConstants1_9 { public static final String PATIENT_WITH_ENCOUNTER_UUID = "da7f524f-27ce-4bb2-86d6-6d1d05312bd5"; + public static final String OBS_UUID = null; + } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/BaseRestControllerTest.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/BaseRestControllerTest.java similarity index 100% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/BaseRestControllerTest.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/BaseRestControllerTest.java diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/MainResourceControllerTest.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/MainResourceControllerTest.java similarity index 100% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/MainResourceControllerTest.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/MainResourceControllerTest.java diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/RestControllerTestUtils.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/RestControllerTestUtils.java similarity index 100% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/RestControllerTestUtils.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/RestControllerTestUtils.java diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/AllergyController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/AllergyController1_9Test.java index 12bc15687..50b7c2ef9 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/AllergyController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/AllergyController1_9Test.java @@ -23,10 +23,9 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.AllergyResource1_8; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.context.request.WebRequest; @@ -45,10 +44,10 @@ public void init() throws Exception { */ @Test public void getAllergy_shouldGetADefaultRepresentationOfAnAllergy() throws Exception { - SimpleObject result = deserialize(handle(newGetRequest(getURI() + "/" + RestTestConstants1_8.ALLERGY_UUID))); + SimpleObject result = deserialize(handle(newGetRequest(getURI() + "/" + RestTestConstants1_9.ALLERGY_UUID))); Assert.assertNotNull(result); Util.log("Allergy fetched (default)", result); - Assert.assertEquals(RestTestConstants1_8.ALLERGY_UUID, PropertyUtils.getProperty(result, "uuid")); + Assert.assertEquals(RestTestConstants1_9.ALLERGY_UUID, PropertyUtils.getProperty(result, "uuid")); Assert.assertNotNull(PropertyUtils.getProperty(result, "links")); Assert.assertNotNull(PropertyUtils.getProperty(result, "person")); Assert.assertNotNull(PropertyUtils.getProperty(result, "allergen")); @@ -61,12 +60,12 @@ public void getAllergy_shouldGetADefaultRepresentationOfAnAllergy() throws Excep */ @Test public void getAllergy_shouldGetAFullRepresentationOfAnAllergy() throws Exception { - MockHttpServletRequest req = newGetRequest(getURI() + "/" + RestTestConstants1_8.ALLERGY_UUID, new Parameter( + MockHttpServletRequest req = newGetRequest(getURI() + "/" + RestTestConstants1_9.ALLERGY_UUID, new Parameter( RestConstants.REQUEST_PROPERTY_FOR_REPRESENTATION, RestConstants.REPRESENTATION_FULL)); SimpleObject result = deserialize(handle(req)); Assert.assertNotNull(result); Util.log("Allergy fetched (default)", result); - Assert.assertEquals(RestTestConstants1_8.ALLERGY_UUID, PropertyUtils.getProperty(result, "uuid")); + Assert.assertEquals(RestTestConstants1_9.ALLERGY_UUID, PropertyUtils.getProperty(result, "uuid")); Assert.assertNotNull(PropertyUtils.getProperty(result, "links")); Assert.assertNotNull(PropertyUtils.getProperty(result, "person")); Assert.assertNotNull(PropertyUtils.getProperty(result, "allergen")); @@ -82,14 +81,14 @@ public void voidAllergy_shouldVoidAnAllergy() throws Exception { Allergy allergy = Context.getPatientService().getAllergy(1); Assert.assertFalse(allergy.isVoided()); - handle(newDeleteRequest(getURI() + "/" + RestTestConstants1_8.ALLERGY_UUID, new Parameter("reason", "unit test"))); + handle(newDeleteRequest(getURI() + "/" + RestTestConstants1_9.ALLERGY_UUID, new Parameter("reason", "unit test"))); allergy = Context.getPatientService().getAllergy(1); Assert.assertTrue(allergy.isVoided()); Assert.assertEquals("unit test", allergy.getVoidReason()); } /** - * @see AllergyResource1_8#getAllergyByPatient(String, + * @see AllergyResource1_9#getAllergyByPatient(String, * org.openmrs.module.webservices.rest.web.RequestContext) * @throws Exception */ @@ -100,7 +99,7 @@ public void searchByPatient_shouldGetAllergyForAPatient() throws Exception { SimpleObject result = deserialize(handle(req)); List results = Util.getResultsList(result); Assert.assertEquals(1, results.size()); - Assert.assertEquals(RestTestConstants1_8.ALLERGY_UUID, PropertyUtils.getProperty(results.get(0), "uuid")); + Assert.assertEquals(RestTestConstants1_9.ALLERGY_UUID, PropertyUtils.getProperty(results.get(0), "uuid")); } /** @@ -116,7 +115,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.ALLERGY_UUID; + return RestTestConstants1_9.ALLERGY_UUID; } /** @@ -138,7 +137,7 @@ public void shouldGetAll() throws Exception { @Test public void getAllergen_shouldGetAllergenByConceptMappings() throws Exception { - String json = "{\"person\":\"" + RestTestConstants1_8.PERSON_UUID + String json = "{\"person\":\"" + RestTestConstants1_9.PERSON_UUID + "\", \"allergen\":\"SNOMED CT:2332523\", \"startDate\":\"2013-12-09\", \"allergyType\":\"" + AllergyType.DRUG + "\"}"; Object newObs = deserialize(handle(newPostRequest(getURI(), json))); diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ChangePasswordController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ChangePasswordController1_9Test.java similarity index 95% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ChangePasswordController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ChangePasswordController1_9Test.java index 3697d1209..983fe073e 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ChangePasswordController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ChangePasswordController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -22,7 +22,7 @@ import org.openmrs.api.UserService; import org.openmrs.api.context.Context; import org.openmrs.api.context.ContextAuthenticationException; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.RestControllerTestUtils; import org.openmrs.module.webservices.validation.ValidationException; import org.openmrs.util.PrivilegeConstants; @@ -30,7 +30,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.mock.web.MockHttpServletResponse; -public class ChangePasswordController1_8Test extends RestControllerTestUtils { +public class ChangePasswordController1_9Test extends RestControllerTestUtils { private static final String PASSWORD_URI = "password"; @@ -43,7 +43,7 @@ public class ChangePasswordController1_8Test extends RestControllerTestUtils { @Test public void updateUser_shouldUpdateTheUserPassword() throws Exception { - User user = service.getUserByUuid(RestTestConstants1_8.USER_UUID); + User user = service.getUserByUuid(RestTestConstants1_9.USER_UUID); assertNotNull(user); assertNotEquals(user, Context.getAuthenticatedUser()); final String username = user.getUsername(); @@ -116,7 +116,7 @@ public void testUserChangeOtherUsersPassword() throws Exception { String newPassword = "newPassword9"; - MockHttpServletResponse response = handle(newPostRequest(PASSWORD_URI + "/" + RestTestConstants1_8.USER_UUID, + MockHttpServletResponse response = handle(newPostRequest(PASSWORD_URI + "/" + RestTestConstants1_9.USER_UUID, "{\"password\":\"" + newPassword + "\"}")); assertEquals(200, response.getStatus()); @@ -131,7 +131,7 @@ public void testUserChangeOtherUsersPasswordWithOutPrivilege() throws Exception expectedException.expect(APIAuthenticationException.class); expectedException.expectMessage("Privileges required: [Edit User Passwords]"); - handle(newPostRequest(PASSWORD_URI + "/" + RestTestConstants1_8.USER_UUID, "{\"newPassword\":\"" + newPassword + handle(newPostRequest(PASSWORD_URI + "/" + RestTestConstants1_9.USER_UUID, "{\"newPassword\":\"" + newPassword + "\"}")); } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/CohortController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/CohortController1_9Test.java similarity index 98% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/CohortController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/CohortController1_9Test.java index 2ac74da61..f52c498a1 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/CohortController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/CohortController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import java.util.List; @@ -20,7 +20,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ConversionException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; @@ -30,7 +30,7 @@ /** * Tests functionality of {@link CohortController}. */ -public class CohortController1_8Test extends MainResourceControllerTest { +public class CohortController1_9Test extends MainResourceControllerTest { private static final String DATASET_FILENAME = "customTestDataset.xml"; @@ -63,7 +63,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.COHORT_UUID; + return RestTestConstants1_9.COHORT_UUID; } @Test diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/CohortMemberController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/CohortMemberController1_9Test.java similarity index 97% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/CohortMemberController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/CohortMemberController1_9Test.java index 9a1f2f280..37b6d5662 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/CohortMemberController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/CohortMemberController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; @@ -21,7 +21,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -29,7 +29,7 @@ /** * Tests functionality of {@link CohortMemberController}. */ -public class CohortMemberController1_8Test extends MainResourceControllerTest { +public class CohortMemberController1_9Test extends MainResourceControllerTest { private static final String PATIENT_UUID = "a7e04421-525f-442f-8138-05b619d16def"; @@ -67,7 +67,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.COHORT_UUID; + return RestTestConstants1_9.COHORT_UUID; } @Test diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptClassController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptClassController1_9Test.java similarity index 97% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptClassController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptClassController1_9Test.java index 9a32c5fb3..bb809a5d6 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptClassController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptClassController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import java.util.List; @@ -21,7 +21,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -29,7 +29,7 @@ /** * Tests functionality of {@link ConceptClassController}. */ -public class ConceptClassController1_8Test extends MainResourceControllerTest { +public class ConceptClassController1_9Test extends MainResourceControllerTest { private ConceptService service; @@ -152,7 +152,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.CONCEPT_CLASS_UUID; + return RestTestConstants1_9.CONCEPT_CLASS_UUID; } /** diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptController1_8Test.java index cb9f1d443..72d150a7d 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptController1_8Test.java @@ -33,7 +33,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.api.SearchQuery; import org.openmrs.module.webservices.rest.web.response.ConversionException; import org.openmrs.module.webservices.rest.web.response.InvalidSearchException; @@ -386,7 +386,7 @@ public void doSearch_shouldReturnAnswersToConcept() throws Exception { } /** - * {@link ConceptResource1_8#getByUniqueId(String)} + * {@link ConceptResource1_9#getByUniqueId(String)} * * @throws Exception */ @@ -404,7 +404,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.CONCEPT_UUID; + return RestTestConstants1_9.CONCEPT3_UUID; } /** diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptDatatypeController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptDatatypeController1_9Test.java index 226a11589..5cd415a97 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptDatatypeController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptDatatypeController1_9Test.java @@ -20,7 +20,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; @@ -59,7 +59,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.CONCEPT_DATATYPE_UUID; + return RestTestConstants1_9.CONCEPT_DATATYPE_UUID; } @Test diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptDescriptionController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptDescriptionController1_9Test.java index 561eb33a3..b4bfde425 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptDescriptionController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptDescriptionController1_9Test.java @@ -24,7 +24,6 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptDescriptionResource1_8; public class ConceptDescriptionController1_9Test extends MainResourceControllerTest { @@ -64,7 +63,7 @@ public void before() throws Exception { } /** - * @See {@link ConceptDescriptionResource1_8#create(String, SimpleObject, org.openmrs.module.webservices.rest.web.RequestContext)} + * @See {@link ConceptDescriptionResource1_9#create(String, SimpleObject, org.openmrs.module.webservices.rest.web.RequestContext)} * @throws Exception */ @Test @@ -79,7 +78,7 @@ public void shouldAddADescriptionToConcept() throws Exception { } /** - * @See {@link ConceptDescriptionResource1_8#doGetAll(Concept, org.openmrs.module.webservices.rest.web.RequestContext)} + * @See {@link ConceptDescriptionResource1_9#doGetAll(Concept, org.openmrs.module.webservices.rest.web.RequestContext)} * @throws Exception */ @Test @@ -104,7 +103,7 @@ public void shouldListDescriptionsForAConcept() throws Exception { } /** - * @See {@link ConceptDescriptionResource1_8#update(String, String, SimpleObject, org.openmrs.module.webservices.rest.web.RequestContext)} + * @See {@link ConceptDescriptionResource1_9#update(String, String, SimpleObject, org.openmrs.module.webservices.rest.web.RequestContext)} * @throws Exception */ @Test @@ -121,10 +120,10 @@ public void shouldEditAConceptDescription() throws Exception { /** * This tests that delete always delegates to - * {@link ConceptDescriptionResource1_8#purge(ConceptDescription, org.openmrs.module.webservices.rest.web.RequestContext)} + * {@link ConceptDescriptionResource1_9#purge(ConceptDescription, org.openmrs.module.webservices.rest.web.RequestContext)} * since descriptions are not retirable/voidable * - * @see {@link ConceptDescriptionResource1_8#delete(ConceptDescription, String, org.openmrs.module.webservices.rest.web.RequestContext)} + * @see {@link ConceptDescriptionResource1_9#delete(ConceptDescription, String, org.openmrs.module.webservices.rest.web.RequestContext)} * @throws Exception */ @Test @@ -138,7 +137,7 @@ public void shouldDeleteAConceptDescription() throws Exception { } /** - * @See {@link ConceptDescriptionResource1_8#purge(ConceptDescription, org.openmrs.module.webservices.rest.web.RequestContext)} + * @See {@link ConceptDescriptionResource1_9#purge(ConceptDescription, org.openmrs.module.webservices.rest.web.RequestContext)} * @throws Exception */ @Test diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptMapController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptMapController1_8Test.java similarity index 92% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptMapController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptMapController1_8Test.java index 281f7ce8b..6ac88ab21 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptMapController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptMapController1_8Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertNull; @@ -24,7 +24,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.OpenmrsProfileRule; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.api.RestHelperService; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; @@ -45,7 +45,7 @@ public class ConceptMapController1_8Test extends MainResourceControllerTest { @Override public String getURI() { - return "concept/" + RestTestConstants1_8.CONCEPT2_UUID + "/mapping"; + return "concept/" + RestTestConstants1_9.CONCEPT2_UUID + "/mapping"; } @Override @@ -55,7 +55,7 @@ public String getUuid() { @Override public long getAllCount() { - return service.getConceptByUuid(RestTestConstants1_8.CONCEPT2_UUID).getConceptMappings().size(); + return service.getConceptByUuid(RestTestConstants1_9.CONCEPT2_UUID).getConceptMappings().size(); } @Before @@ -63,7 +63,7 @@ public void before() { service = Context.getConceptService(); restHelperService = Context.getService(RestHelperService.class); - Concept concept = service.getConceptByUuid(RestTestConstants1_8.CONCEPT2_UUID); + Concept concept = service.getConceptByUuid(RestTestConstants1_9.CONCEPT2_UUID); ConceptMap next = concept.getConceptMappings().iterator().next(); //The UUID property is not set in standardTestDataset.xml. next.setUuid(UUID.randomUUID().toString()); @@ -73,15 +73,15 @@ public void before() { @Test public void shouldCreateConceptMap() throws Exception { - String json = "{\"source\": \"" + RestTestConstants1_8.CONCEPT_SOURCE_UUID + "\", \"sourceCode\": \"test\"}"; + String json = "{\"source\": \"" + RestTestConstants1_9.CONCEPT_SOURCE_UUID + "\", \"sourceCode\": \"test\"}"; SimpleObject newConceptMap = deserialize(handle(newPostRequest(getURI(), json))); String uuid = (String) newConceptMap.get("uuid"); ConceptMap conceptMap = restHelperService.getObjectByUuid(ConceptMap.class, uuid); - assertThat(conceptMap.getConcept().getUuid(), is(RestTestConstants1_8.CONCEPT2_UUID)); - assertThat(conceptMap.getSource().getUuid(), is(RestTestConstants1_8.CONCEPT_SOURCE_UUID)); + assertThat(conceptMap.getConcept().getUuid(), is(RestTestConstants1_9.CONCEPT2_UUID)); + assertThat(conceptMap.getSource().getUuid(), is(RestTestConstants1_9.CONCEPT_SOURCE_UUID)); assertThat(conceptMap.getSourceCode(), is("test")); } @@ -105,4 +105,4 @@ public void shouldPurgeConceptMap() throws Exception { handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("purge", ""))); assertNull(restHelperService.getObjectByUuid(ConceptMap.class, getUuid())); } -} +} \ No newline at end of file diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptSourceController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptSourceController1_9Test.java similarity index 98% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptSourceController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptSourceController1_9Test.java index 1adb1ce90..e836a275b 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ConceptSourceController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ConceptSourceController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import org.apache.commons.beanutils.PropertyUtils; import org.codehaus.jackson.map.ObjectMapper; @@ -20,7 +20,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -28,7 +28,7 @@ /** * Tests functionality of {@link ConceptSourceController}. */ -public class ConceptSourceController1_8Test extends MainResourceControllerTest { +public class ConceptSourceController1_9Test extends MainResourceControllerTest { private ConceptService service; @@ -58,7 +58,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.CONCEPT_SOURCE_UUID; + return RestTestConstants1_9.CONCEPT_SOURCE_UUID; } @Test diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/DrugController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/DrugController1_9Test.java index 9423ef156..b2b91831b 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/DrugController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/DrugController1_9Test.java @@ -20,7 +20,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -58,7 +58,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.DRUG_UUID; + return RestTestConstants1_9.DRUG_UUID; } @Test diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/EncounterController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/EncounterController1_9Test.java index 507f3134c..37991dcbb 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/EncounterController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/EncounterController1_9Test.java @@ -518,7 +518,7 @@ public void shouldFetchAllPatientEncounterIncludingVoidedPatientEncountersIfIncl SimpleObject result = deserialize(handle(req)); List encounters = result.get("results"); - Assert.assertEquals(2, encounters.size()); + Assert.assertEquals(1, encounters.size()); } @Test diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/EncounterTypeController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/EncounterTypeController1_9Test.java similarity index 98% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/EncounterTypeController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/EncounterTypeController1_9Test.java index 8eeac176c..22378d887 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/EncounterTypeController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/EncounterTypeController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -25,7 +25,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -33,7 +33,7 @@ /** * Tests functionality of {@link EncounterTypeController}. */ -public class EncounterTypeController1_8Test extends MainResourceControllerTest { +public class EncounterTypeController1_9Test extends MainResourceControllerTest { private EncounterService service; @@ -44,7 +44,7 @@ public String getURI() { @Override public String getUuid() { - return RestTestConstants1_8.ENCOUNTER_TYPE_UUID; + return RestTestConstants1_9.ENCOUNTER_TYPE_UUID; } @Override diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FieldController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FieldController1_9Test.java index 6150ffe72..4fe2cbcc8 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FieldController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FieldController1_9Test.java @@ -19,7 +19,7 @@ import org.openmrs.api.context.Context; import org.openmrs.api.FormService; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.apache.commons.beanutils.PropertyUtils; @@ -43,7 +43,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.FIELD_UUID; + return RestTestConstants1_9.FIELD_UUID; } /** diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/FieldTypeController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FieldTypeController1_9Test.java similarity index 97% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/FieldTypeController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FieldTypeController1_9Test.java index a4addbf7f..fd99ae204 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/FieldTypeController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FieldTypeController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -22,14 +22,14 @@ import org.openmrs.api.context.Context; import org.openmrs.api.FormService; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.apache.commons.beanutils.PropertyUtils; /** * Tests functionality of {@link FieldTypeController}. */ -public class FieldTypeController1_8Test extends MainResourceControllerTest { +public class FieldTypeController1_9Test extends MainResourceControllerTest { private FormService service; @@ -46,7 +46,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.FIELD_TYPE_UUID; + return RestTestConstants1_9.FIELD_TYPE_UUID; } /** diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/FormController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FormController1_9Test.java similarity index 95% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/FormController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FormController1_9Test.java index 1dabd15d1..ffbbe5061 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/FormController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FormController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -19,14 +19,14 @@ import org.openmrs.api.context.Context; import org.openmrs.api.FormService; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.apache.commons.beanutils.PropertyUtils; /** * Tests functionality of {@link FormController}. */ -public class FormController1_8Test extends MainResourceControllerTest { +public class FormController1_9Test extends MainResourceControllerTest { private FormService service; @@ -43,7 +43,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.FORM_UUID; + return RestTestConstants1_9.FORM2_UUID; } /** diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FormFieldController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FormFieldController1_9Test.java index 6e280c894..339387a25 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FormFieldController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/FormFieldController1_9Test.java @@ -9,7 +9,7 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; /** @@ -22,7 +22,7 @@ public class FormFieldController1_9Test extends MainResourceControllerTest { */ @Override public String getURI() { - return "form/" + RestTestConstants1_8.FORM_UUID + "/formfield"; + return "form/" + RestTestConstants1_9.FORM2_UUID + "/formfield"; } /** @@ -30,7 +30,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.FORM_FIELD_UUID; + return RestTestConstants1_9.FORM_FIELD_UUID; } /** diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/HL7MessageController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/HL7MessageController1_9Test.java similarity index 97% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/HL7MessageController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/HL7MessageController1_9Test.java index 2bb6cf430..18608fb6f 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/HL7MessageController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/HL7MessageController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import org.junit.Assert; import org.junit.Before; @@ -23,9 +23,9 @@ import org.springframework.mock.web.MockHttpServletRequest; /** - * Tests functionality of {@link HL7MessageController1_8}. + * Tests functionality of {@link HL7MessageController1_9}. */ -public class HL7MessageController1_8Test extends MainResourceControllerTest { +public class HL7MessageController1_9Test extends MainResourceControllerTest { private static final String HL7_DATA = "MSH|^~\\&|NES|AMRS.ELD|TESTSYSTEM|TESTFACILITY|20010101000000||ADT^A04|REl7wt78q9Pzlqe9ecJB|P|2.5"; diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/LocationController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/LocationController1_9Test.java index d317749ef..847923e1c 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/LocationController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/LocationController1_9Test.java @@ -22,7 +22,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -65,7 +65,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.LOCATION_UUID; + return RestTestConstants1_9.LOCATION2_UUID; } @Test diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/LocationTagController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/LocationTagController1_9Test.java similarity index 97% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/LocationTagController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/LocationTagController1_9Test.java index b0e4a058e..8b664857c 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/LocationTagController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/LocationTagController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import org.apache.commons.beanutils.PropertyUtils; import org.codehaus.jackson.map.ObjectMapper; @@ -19,7 +19,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -27,7 +27,7 @@ /** * Tests functionality of {@link LocationTagController}. */ -public class LocationTagController1_8Test extends MainResourceControllerTest { +public class LocationTagController1_9Test extends MainResourceControllerTest { private LocationService service; @@ -60,7 +60,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.LOCATION_TAG_UUID; + return RestTestConstants1_9.LOCATION_TAG_UUID; } @Test diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ModuleActionController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ModuleActionController1_9Test.java similarity index 96% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ModuleActionController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ModuleActionController1_9Test.java index 215620ec6..283f47b6c 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ModuleActionController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ModuleActionController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import org.junit.Before; import org.junit.Test; @@ -18,8 +18,8 @@ import org.openmrs.module.webservices.rest.web.api.RestService; import org.openmrs.module.webservices.rest.web.response.IllegalRequestException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ModuleActionResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ModuleResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ModuleActionResource1_9; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ModuleResource1_9; import org.springframework.beans.factory.annotation.Autowired; import java.util.Arrays; @@ -32,7 +32,7 @@ import static org.hamcrest.collection.IsEmptyCollection.emptyCollectionOf; import static org.hamcrest.core.IsNot.not; -public class ModuleActionController1_8Test extends MainResourceControllerTest { +public class ModuleActionController1_9Test extends MainResourceControllerTest { @Autowired RestService restService; @@ -53,11 +53,11 @@ public class ModuleActionController1_8Test extends MainResourceControllerTest { public void setUp() throws Exception { mockModuleFactory.loadedModules.addAll(Arrays.asList(atlasModule, conceptLabModule, webservicesRestModule)); - ModuleActionResource1_8 moduleActionResource = (ModuleActionResource1_8) restService + ModuleActionResource1_9 moduleActionResource = (ModuleActionResource1_9) restService .getResourceBySupportedClass(ModuleAction.class); moduleActionResource.setModuleFactoryWrapper(mockModuleFactory); - ModuleResource1_8 moduleResource = (ModuleResource1_8) restService.getResourceBySupportedClass(Module.class); + ModuleResource1_9 moduleResource = (ModuleResource1_9) restService.getResourceBySupportedClass(Module.class); moduleResource.setModuleFactoryWrapper(mockModuleFactory); } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ModuleController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ModuleController1_9Test.java similarity index 97% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ModuleController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ModuleController1_9Test.java index ba899c539..ef58efd0d 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ModuleController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ModuleController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; @@ -26,7 +26,7 @@ import org.openmrs.module.webservices.rest.web.MockModuleFactoryWrapper; import org.openmrs.module.webservices.rest.web.api.RestService; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ModuleResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ModuleResource1_9; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; @@ -37,7 +37,7 @@ /** * */ -public class ModuleController1_8Test extends MainResourceControllerTest { +public class ModuleController1_9Test extends MainResourceControllerTest { @Autowired RestService restService; @@ -56,7 +56,7 @@ public void setUp() throws Exception { mockModuleFactory.loadedModules.add(atlasModule); mockModuleFactory.loadedModules.add(conceptLabModule); - ModuleResource1_8 resource = (ModuleResource1_8) restService.getResourceBySupportedClass(Module.class); + ModuleResource1_9 resource = (ModuleResource1_9) restService.getResourceBySupportedClass(Module.class); resource.setModuleFactoryWrapper(mockModuleFactory); } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ObsController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ObsController1_9Test.java index 03ccfaee9..2288c7b77 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ObsController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ObsController1_9Test.java @@ -28,7 +28,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.openmrs.util.OpenmrsConstants; @@ -62,7 +62,7 @@ public class ObsController1_9Test extends MainResourceControllerTest { @Test public void getObs_shouldGetObsConceptByConceptMappings() throws Exception { - String json = "{ \"value\":\"" + 10.0 + "\", \"person\":\"" + RestTestConstants1_8.PERSON_UUID + String json = "{ \"value\":\"" + 10.0 + "\", \"person\":\"" + RestTestConstants1_9.PERSON_UUID + "\", \"concept\":\"SNOMED CT:2332523\", \"obsDatetime\":\"2013-12-09T00:00:00.000+0100\"}"; Object newObs = deserialize(handle(newPostRequest(getURI(), json))); @@ -120,7 +120,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.OBS_UUID; + return RestTestConstants1_9.OBS2_UUID; } /** diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/OrderController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/OrderController1_9Test.java index 1d5cd0deb..9a0056e96 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/OrderController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/OrderController1_9Test.java @@ -24,7 +24,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; @@ -74,7 +74,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.ORDER_UUID; + return RestTestConstants1_9.ORDER_UUID; } @Test diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientController1_9Test.java index 72bb4c798..e0c7efd01 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientController1_9Test.java @@ -25,7 +25,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ConversionException; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; @@ -46,7 +46,7 @@ public String getURI() { @Override public String getUuid() { - return RestTestConstants1_8.PATIENT_UUID; + return RestTestConstants1_9.PATIENT_UUID; } @Override diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierController1_9Test.java index cabdf9d8a..7151c45d3 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierController1_9Test.java @@ -28,7 +28,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -42,17 +42,17 @@ public class PatientIdentifierController1_9Test extends MainResourceControllerTe @Override public String getURI() { - return "patient/" + RestTestConstants1_8.PATIENT_UUID + "/identifier"; + return "patient/" + RestTestConstants1_9.PATIENT_UUID + "/identifier"; } @Override public String getUuid() { - return RestTestConstants1_8.PATIENT_IDENTIFIER_UUID; + return RestTestConstants1_9.PATIENT_IDENTIFIER_UUID; } @Override public long getAllCount() { - return service.getPatientByUuid(RestTestConstants1_8.PATIENT_UUID).getActiveIdentifiers().size(); + return service.getPatientByUuid(RestTestConstants1_9.PATIENT_UUID).getActiveIdentifiers().size(); } @Before @@ -87,7 +87,7 @@ public void shouldAddANewIdentifierToAPatient() throws Exception { SimpleObject patientIdentifier = new SimpleObject(); patientIdentifier.add("identifier", "abc123ez"); patientIdentifier.add("identifierType", "2f470aa8-1d73-43b7-81b5-01f0c0dfa53c"); - patientIdentifier.add("location", RestTestConstants1_8.LOCATION_UUID); + patientIdentifier.add("location", RestTestConstants1_9.LOCATION2_UUID); String json = new ObjectMapper().writeValueAsString(patientIdentifier); @@ -102,7 +102,7 @@ public void shouldAddANewIdentifierToAPatient() throws Exception { @Test public void shouldEditAPatientIdentifier() throws Exception { - final String newLocationUuid = RestTestConstants1_8.LOCATION_UUID; + final String newLocationUuid = RestTestConstants1_9.LOCATION2_UUID; PatientIdentifier patientIdentifierType = service.getPatientIdentifierByUuid(getUuid()); assertFalse(newLocationUuid.equals(patientIdentifierType.getLocation().getUuid())); SimpleObject patientIdentifier = new SimpleObject(); @@ -124,7 +124,7 @@ public void shouldUnsetOtherPreferredIdentifiers() throws Exception { SimpleObject patientIdentifier = new SimpleObject(); patientIdentifier.add("identifier", "abc123ez"); patientIdentifier.add("identifierType", "2f470aa8-1d73-43b7-81b5-01f0c0dfa53c"); - patientIdentifier.add("location", RestTestConstants1_8.LOCATION_UUID); + patientIdentifier.add("location", RestTestConstants1_9.LOCATION2_UUID); patientIdentifier.add("preferred", true); String json = new ObjectMapper().writeValueAsString(patientIdentifier); @@ -197,7 +197,7 @@ public void shouldNotAddIdentifierInUseByAnotherPatient() throws Exception { SimpleObject patientIdentifier = new SimpleObject(); patientIdentifier.add("identifier", "123456789qwerty"); patientIdentifier.add("identifierType", "2f470aa8-1d73-43b7-81b5-01f0c0dfa53c"); - patientIdentifier.add("location", RestTestConstants1_8.LOCATION_UUID); + patientIdentifier.add("location", RestTestConstants1_9.LOCATION2_UUID); String json = new ObjectMapper().writeValueAsString(patientIdentifier); diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PatientIdentifierTypeController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierTypeController1_9Test.java similarity index 98% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PatientIdentifierTypeController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierTypeController1_9Test.java index 664122971..d2070e1ae 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PatientIdentifierTypeController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PatientIdentifierTypeController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -25,7 +25,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -33,7 +33,7 @@ /** * Tests CRUD operations for {@link PatientIdentifierType}s via web service calls */ -public class PatientIdentifierTypeController1_8Test extends MainResourceControllerTest { +public class PatientIdentifierTypeController1_9Test extends MainResourceControllerTest { private PatientService service; @@ -44,7 +44,7 @@ public String getURI() { @Override public String getUuid() { - return RestTestConstants1_8.PATIENT_IDENTIFIER_TYPE_UUID; + return RestTestConstants1_9.PATIENT_IDENTIFIER_TYPE_UUID; } @Override diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PersonAddressController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAddressController1_9Test.java similarity index 94% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PersonAddressController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAddressController1_9Test.java index 822ec3bef..38e1f8d82 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PersonAddressController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAddressController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.hamcrest.beans.HasPropertyWithValue.hasProperty; import static org.hamcrest.core.AllOf.allOf; @@ -27,7 +27,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -35,7 +35,7 @@ /** * Tests functionality of {@link PersonAddressController}. */ -public class PersonAddressController1_8Test extends MainResourceControllerTest { +public class PersonAddressController1_9Test extends MainResourceControllerTest { private static final String ADDRESS_TEST_UUID = "address-test-uuid"; @@ -52,7 +52,7 @@ public void before() throws Exception { */ @Override public String getURI() { - return "person" + "/" + RestTestConstants1_8.PERSON_UUID + "/address"; + return "person" + "/" + RestTestConstants1_9.PERSON_UUID + "/address"; } /** @@ -62,7 +62,7 @@ public String getURI() { public long getAllCount() { int count = 0; - Person person = service.getPersonByUuid(RestTestConstants1_8.PERSON_UUID); + Person person = service.getPersonByUuid(RestTestConstants1_9.PERSON_UUID); for (PersonAddress addr : person.getAddresses()) { if (!addr.isVoided()) { @@ -78,7 +78,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.PERSON_ADDRESS_UUID; + return RestTestConstants1_9.PERSON_ADDRESS_UUID; } @Test @@ -119,7 +119,7 @@ public void shouldGetAllNonVoidedAddressesOfAPerson() throws Exception { @Test public void shouldExcludeVoidedAddressesForAPerson() throws Exception { // For test purposes, we need to void all addresses - Person person = service.getPersonByUuid(RestTestConstants1_8.PERSON_UUID); + Person person = service.getPersonByUuid(RestTestConstants1_9.PERSON_UUID); for (PersonAddress addr : person.getAddresses()) { addr.setVoided(true); } @@ -133,7 +133,7 @@ public void shouldExcludeVoidedAddressesForAPerson() throws Exception { @Test public void shouldAddAnAddressToAPerson() throws Exception { - int before = service.getPersonByUuid(RestTestConstants1_8.PERSON_UUID).getAddresses().size(); + int before = service.getPersonByUuid(RestTestConstants1_9.PERSON_UUID).getAddresses().size(); SimpleObject address = new SimpleObject(); address.add("address1", "test address"); @@ -143,7 +143,7 @@ public void shouldAddAnAddressToAPerson() throws Exception { MockHttpServletRequest req = newPostRequest(getURI(), address); handle(req); - int after = service.getPersonByUuid(RestTestConstants1_8.PERSON_UUID).getAddresses().size(); + int after = service.getPersonByUuid(RestTestConstants1_9.PERSON_UUID).getAddresses().size(); Assert.assertEquals(before + 1, after); } @@ -158,7 +158,7 @@ public void shouldAddAnAddressWithSpecificUuidToAPerson() throws Exception { MockHttpServletRequest req = newPostRequest(getURI(), address); handle(req); - PersonAddress personAddress = service.getPersonByUuid(RestTestConstants1_8.PERSON_UUID).getPersonAddress(); + PersonAddress personAddress = service.getPersonByUuid(RestTestConstants1_9.PERSON_UUID).getPersonAddress(); Assert.assertNotNull(personAddress); Assert.assertEquals(ADDRESS_TEST_UUID, personAddress.getUuid()); } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAttributeController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAttributeController1_9Test.java index 6e71df580..48c315087 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAttributeController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAttributeController1_9Test.java @@ -23,7 +23,7 @@ import org.openmrs.api.PersonService; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import java.util.Iterator; @@ -37,7 +37,7 @@ */ public class PersonAttributeController1_9Test extends MainResourceControllerTest { - String personUuid = RestTestConstants1_8.PERSON_UUID; + String personUuid = RestTestConstants1_9.PERSON_UUID; private PersonService service; @@ -169,7 +169,7 @@ public void shouldSupportLocationPersonAttributeBySettingUuidAsValue() throws Ex */ @Override public String getURI() { - return "person/" + RestTestConstants1_8.PERSON_UUID + "/attribute"; + return "person/" + RestTestConstants1_9.PERSON_UUID + "/attribute"; } /** @@ -177,7 +177,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.PERSON_ATTRIBUTE_UUID; + return RestTestConstants1_9.PERSON_ATTRIBUTE_UUID; } /** @@ -185,6 +185,6 @@ public String getUuid() { */ @Override public long getAllCount() { - return service.getPersonByUuid(RestTestConstants1_8.PERSON_UUID).getAttributes().size(); + return service.getPersonByUuid(RestTestConstants1_9.PERSON_UUID).getAttributes().size(); } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PersonAttributeTypeController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAttributeTypeController1_9Test.java similarity index 98% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PersonAttributeTypeController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAttributeTypeController1_9Test.java index e469e2dbc..759d52806 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PersonAttributeTypeController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonAttributeTypeController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import java.util.List; import org.apache.commons.beanutils.PropertyUtils; @@ -21,13 +21,13 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.context.request.WebRequest; -public class PersonAttributeTypeController1_8Test extends MainResourceControllerTest { +public class PersonAttributeTypeController1_9Test extends MainResourceControllerTest { private PersonService service; @@ -234,7 +234,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.PERSON_ATTRIBUTE_TYPE_UUID; + return RestTestConstants1_9.PERSON_ATTRIBUTE_TYPE_UUID; } /** diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonController1_9Test.java index 174aef713..5086ebc1e 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PersonController1_9Test.java @@ -27,7 +27,7 @@ import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.ConversionUtil; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.response.ConversionException; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; @@ -55,7 +55,7 @@ public String getURI() { @Override public String getUuid() { - return RestTestConstants1_8.PERSON_UUID; + return RestTestConstants1_9.PERSON_UUID; } @Override diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PrivilegeController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PrivilegeController1_9Test.java similarity index 97% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PrivilegeController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PrivilegeController1_9Test.java index eeb27bf6f..1b430c169 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/PrivilegeController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/PrivilegeController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -23,12 +23,12 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; -public class PrivilegeController1_8Test extends MainResourceControllerTest { +public class PrivilegeController1_9Test extends MainResourceControllerTest { private static final String XML_FILENAME = "org/openmrs/api/include/UserServiceTest.xml"; @@ -41,7 +41,7 @@ public String getURI() { @Override public String getUuid() { - return RestTestConstants1_8.PRIVILEGE_UUID; + return RestTestConstants1_9.PRIVILEGE_UUID; } @Override diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProblemController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProblemController1_9Test.java index 07f77e851..4e444a4a4 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProblemController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProblemController1_9Test.java @@ -26,7 +26,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; @@ -51,7 +51,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.PROBLEM_UUID; + return RestTestConstants1_9.PROBLEM_UUID; } /** @@ -63,7 +63,7 @@ public long getAllCount() { } private String getPatientUuid() { - return RestTestConstants1_8.PATIENT_UUID; + return RestTestConstants1_9.PATIENT_UUID; } /** @@ -114,7 +114,7 @@ public void shouldAddANewProblemToAPatient() throws Exception { long originalCount = getAllCount(); SimpleObject problem = new SimpleObject(); - problem.add("problem", RestTestConstants1_8.CONCEPT_UUID); + problem.add("problem", RestTestConstants1_9.CONCEPT3_UUID); problem.add("person", getPatientUuid()); problem.add("startDate", "2013-01-01"); String json = new ObjectMapper().writeValueAsString(problem); @@ -173,7 +173,7 @@ public void searchByPatient_shouldGetProblemsForAPatient() throws Exception { @Test public void getProblem_shouldGetProblemByConceptMappings() throws Exception { - String json = "{\"person\":\"" + RestTestConstants1_8.PERSON_UUID + String json = "{\"person\":\"" + RestTestConstants1_9.PERSON_UUID + "\", \"problem\":\"SNOMED CT:2332523\", \"startDate\":\"2013-12-09\"}"; Object newObs = deserialize(handle(newPostRequest(getURI(), json))); Assert.assertNotNull(PropertyUtils.getProperty(newObs, "problem")); diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProgramController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProgramController1_9Test.java index 537cde651..463c0600c 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProgramController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProgramController1_9Test.java @@ -19,7 +19,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -60,7 +60,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.PROGRAM_UUID; + return RestTestConstants1_9.PROGRAM_UUID; } public String getName() { @@ -108,7 +108,7 @@ public void shouldCreateAProgram() throws Exception { SimpleObject program = new SimpleObject(); program.add("name", "Program name"); program.add("description", "Program description"); - program.add("concept", RestTestConstants1_8.CONCEPT_UUID); + program.add("concept", RestTestConstants1_9.CONCEPT3_UUID); String json = new ObjectMapper().writeValueAsString(program); @@ -118,7 +118,7 @@ public void shouldCreateAProgram() throws Exception { SimpleObject newProgram = deserialize(handle(req)); Assert.assertNotNull(PropertyUtils.getProperty(newProgram, "uuid")); - Assert.assertEquals(RestTestConstants1_8.CONCEPT_UUID, + Assert.assertEquals(RestTestConstants1_9.CONCEPT3_UUID, ((Map) PropertyUtils.getProperty(newProgram, "concept")).get("uuid")); Assert.assertEquals(originalCount + 1, getAllCount()); } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProgramEnrollmentController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProgramEnrollmentController1_9Test.java index b73b3eb07..95de8499f 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProgramEnrollmentController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ProgramEnrollmentController1_9Test.java @@ -21,7 +21,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; @@ -69,17 +69,17 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.PATIENT_PROGRAM_UUID; + return RestTestConstants1_9.PATIENT_PROGRAM_UUID; } @Test @Override public void shouldGetAll() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); - req.setParameter("patient", RestTestConstants1_8.PATIENT_IN_A_PROGRAM_UUID); + req.setParameter("patient", RestTestConstants1_9.PATIENT_IN_A_PROGRAM_UUID); SimpleObject result = deserialize(handle(req)); - Patient patient = patientService.getPatientByUuid(RestTestConstants1_8.PATIENT_IN_A_PROGRAM_UUID); + Patient patient = patientService.getPatientByUuid(RestTestConstants1_9.PATIENT_IN_A_PROGRAM_UUID); List patientPrograms = service.getPatientPrograms(patient, null, null, null, null, null, true); Assert.assertEquals(patientPrograms.size(), Util.getResultsSize(result)); } @@ -87,10 +87,10 @@ public void shouldGetAll() throws Exception { @Test public void shouldExcludeVoided() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); - req.setParameter("patient", RestTestConstants1_8.PATIENT_WITH_VOIDED_PROGRAM_UUID); + req.setParameter("patient", RestTestConstants1_9.PATIENT_WITH_VOIDED_PROGRAM_UUID); SimpleObject result = deserialize(handle(req)); - Patient patient = patientService.getPatientByUuid(RestTestConstants1_8.PATIENT_WITH_VOIDED_PROGRAM_UUID); + Patient patient = patientService.getPatientByUuid(RestTestConstants1_9.PATIENT_WITH_VOIDED_PROGRAM_UUID); List patientPrograms = service.getPatientPrograms(patient, null, null, null, null, null, false); Assert.assertEquals(patientPrograms.size(), Util.getResultsSize(result)); } @@ -135,14 +135,14 @@ public void shouldGetAPatientProgramByUuid() throws Exception { public void shouldEnrollAPatientToAProgram() throws Exception { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); SimpleObject params = new SimpleObject(); - params.add("patient", RestTestConstants1_8.PATIENT_UUID); - params.add("program", RestTestConstants1_8.PROGRAM_UUID); + params.add("patient", RestTestConstants1_9.PATIENT_UUID); + params.add("program", RestTestConstants1_9.PROGRAM_UUID); params.add("dateEnrolled", dateFormat.format(new Date())); MockHttpServletRequest req = newPostRequest(getURI(), params); SimpleObject result = deserialize(handle(req)); - Patient patient = patientService.getPatientByUuid(RestTestConstants1_8.PATIENT_IN_A_PROGRAM_UUID); + Patient patient = patientService.getPatientByUuid(RestTestConstants1_9.PATIENT_IN_A_PROGRAM_UUID); List patientPrograms = service.getPatientPrograms(patient, null, null, null, null, null, true); PatientProgram newEnrollment = patientPrograms.get(patientPrograms.size() - 1); Assert.assertEquals(newEnrollment.getProgram().getUuid(), ((Map) result.get("program")).get("uuid")); diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RelationshipController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RelationshipController1_9Test.java index 11a6283d5..06a5919b1 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RelationshipController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RelationshipController1_9Test.java @@ -18,7 +18,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import java.text.DateFormat; @@ -49,7 +49,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.RELATIONSHIP_UUID; + return RestTestConstants1_9.RELATIONSHIP_UUID; } /** @@ -70,7 +70,7 @@ public void before() throws Exception { public void shouldCreateARelationship() throws Exception { int originalCount = service.getAllRelationships().size(); String json = "{ \"personA\":\"da7f524f-27ce-4bb2-86d6-6d1d05312bd5\", \"relationshipType\":\"" - + RestTestConstants1_8.RELATIONSHIP_TYPE_UUID + "\", \"personB\":" + + RestTestConstants1_9.RELATIONSHIP_TYPE_UUID + "\", \"personB\":" + "\"5946f880-b197-400b-9caa-a3c661d23041\"" + "}"; Object newRelationship = deserialize(handle(newPostRequest(getURI(), json))); @@ -81,34 +81,34 @@ public void shouldCreateARelationship() throws Exception { @Test public void shouldEditARelationship() throws Exception { final String newRelationshipTypeUuid = "d47f056e-f147-49a3-88e1-0c91d199510d"; - Relationship relationship = service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID); + Relationship relationship = service.getRelationshipByUuid(RestTestConstants1_9.RELATIONSHIP_UUID); Assert.assertNotNull(relationship); //sanity checks Assert.assertFalse(newRelationshipTypeUuid.equalsIgnoreCase(relationship.getRelationshipType().getUuid())); String json = "{\"relationshipType\":\"" + newRelationshipTypeUuid + "\"" + "}"; handle(newPostRequest(getURI() + "/" + getUuid(), json)); - Relationship updated = service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID); + Relationship updated = service.getRelationshipByUuid(RestTestConstants1_9.RELATIONSHIP_UUID); Assert.assertNotNull(updated); Assert.assertEquals(newRelationshipTypeUuid, updated.getRelationshipType().getUuid()); } @Test public void shouldVoidARelationship() throws Exception { - Relationship relationship = service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID); + Relationship relationship = service.getRelationshipByUuid(RestTestConstants1_9.RELATIONSHIP_UUID); Assert.assertFalse(relationship.isVoided()); handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("reason", "test reason"))); - relationship = service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID); + relationship = service.getRelationshipByUuid(RestTestConstants1_9.RELATIONSHIP_UUID); Assert.assertTrue(relationship.isVoided()); Assert.assertEquals("test reason", relationship.getVoidReason()); } @Test public void shouldUnVoidARelationship() throws Exception { - Relationship relationship = service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID); + Relationship relationship = service.getRelationshipByUuid(RestTestConstants1_9.RELATIONSHIP_UUID); service.voidRelationship(relationship, "some random reason"); - relationship = service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID); + relationship = service.getRelationshipByUuid(RestTestConstants1_9.RELATIONSHIP_UUID); Assert.assertTrue(relationship.isVoided()); String json = "{\"deleted\": \"false\"}"; @@ -122,12 +122,12 @@ public void shouldUnVoidARelationship() throws Exception { @Test public void shouldPurgeARelatonship() throws Exception { - Assert.assertNotNull(service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID)); + Assert.assertNotNull(service.getRelationshipByUuid(RestTestConstants1_9.RELATIONSHIP_UUID)); int originalCount = service.getAllRelationships().size(); handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("purge", "true"))); - Assert.assertNull(service.getRelationshipByUuid(RestTestConstants1_8.RELATIONSHIP_UUID)); + Assert.assertNull(service.getRelationshipByUuid(RestTestConstants1_9.RELATIONSHIP_UUID)); Assert.assertEquals(originalCount - 1, service.getAllRelationships().size()); } @@ -156,20 +156,20 @@ public void shouldSearchRelationshipsByPersonUuidAndRelatedPersonUuid() throws E public void shouldSearchRelationshipsByPersonUuidAndRelationshipType() throws Exception { SimpleObject result = deserialize(handle(newGetRequest(getURI(), new Parameter("person", "341b4e41-790c-484f-b6ed-71dc8da222de"), new Parameter("relation", - RestTestConstants1_8.RELATIONSHIP_TYPE_UUID)))); + RestTestConstants1_9.RELATIONSHIP_TYPE_UUID)))); List hits = Util.getResultsList(result); Assert.assertEquals(2, hits.size()); - Assert.assertEquals(RestTestConstants1_8.RELATIONSHIP_UUID, PropertyUtils.getProperty(hits.get(0), "uuid")); + Assert.assertEquals(RestTestConstants1_9.RELATIONSHIP_UUID, PropertyUtils.getProperty(hits.get(0), "uuid")); } @Test public void shouldSearchRelationshipsByPersonAUuidAndPersonBUuidAndRelationshipType() throws Exception { SimpleObject result = deserialize(handle(newGetRequest(getURI(), new Parameter("personA", "341b4e41-790c-484f-b6ed-71dc8da222de"), new Parameter("personB", "da7f524f-27ce-4bb2-86d6-6d1d05312bd5"), - new Parameter("relation", RestTestConstants1_8.RELATIONSHIP_TYPE_UUID)))); + new Parameter("relation", RestTestConstants1_9.RELATIONSHIP_TYPE_UUID)))); List hits = Util.getResultsList(result); Assert.assertEquals(1, hits.size()); - Assert.assertEquals(RestTestConstants1_8.RELATIONSHIP_UUID, PropertyUtils.getProperty(hits.get(0), "uuid")); + Assert.assertEquals(RestTestConstants1_9.RELATIONSHIP_UUID, PropertyUtils.getProperty(hits.get(0), "uuid")); } @Test @@ -178,14 +178,14 @@ public void shouldSearchRelationshipsByPersonAUuidAndPersonBUuid() throws Except "341b4e41-790c-484f-b6ed-71dc8da222de"), new Parameter("personB", "da7f524f-27ce-4bb2-86d6-6d1d05312bd5")))); List hits = Util.getResultsList(result); Assert.assertEquals(1, hits.size()); - Assert.assertEquals(RestTestConstants1_8.RELATIONSHIP_UUID, PropertyUtils.getProperty(hits.get(0), "uuid")); + Assert.assertEquals(RestTestConstants1_9.RELATIONSHIP_UUID, PropertyUtils.getProperty(hits.get(0), "uuid")); } @Test public void shouldSearchRelationshipsByPersonAUuidAndRelationshipType() throws Exception { SimpleObject result = deserialize(handle(newGetRequest(getURI(), new Parameter("personA", "86526ed6-3c11-11de-a0ba-001e378eb67e"), new Parameter("relation", - RestTestConstants1_8.RELATIONSHIP_TYPE_UUID)))); + RestTestConstants1_9.RELATIONSHIP_TYPE_UUID)))); List hits = Util.getResultsList(result); Assert.assertEquals(2, hits.size()); Assert.assertEquals("4ce634c8-d744-40b3-9d5f-577a5f025b01", PropertyUtils.getProperty(hits.get(0), "uuid")); diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/RelationshipTypeController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RelationshipTypeController1_9Test.java similarity index 90% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/RelationshipTypeController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RelationshipTypeController1_9Test.java index b240a22ab..ef4cd1595 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/RelationshipTypeController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RelationshipTypeController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import org.apache.commons.beanutils.PropertyUtils; import org.junit.Assert; @@ -18,7 +18,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import java.util.List; @@ -26,7 +26,7 @@ /** * Contains tests for {@link RelationshipTypeController} CRUD operations */ -public class RelationshipTypeController1_8Test extends MainResourceControllerTest { +public class RelationshipTypeController1_9Test extends MainResourceControllerTest { private PersonService service; @@ -43,7 +43,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.RELATIONSHIP_TYPE_UUID; + return RestTestConstants1_9.RELATIONSHIP_TYPE_UUID; } /** @@ -69,7 +69,7 @@ public void before() { public void shouldGetARelationshipTypeByName() throws Exception { Object result = deserialize(handle(newGetRequest(getURI() + "/Doctor"))); Assert.assertNotNull(result); - Assert.assertEquals(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID, PropertyUtils.getProperty(result, "uuid")); + Assert.assertEquals(RestTestConstants1_9.RELATIONSHIP_TYPE_UUID, PropertyUtils.getProperty(result, "uuid")); Assert.assertEquals("Relationship from a primary care provider to the patient", PropertyUtils.getProperty(result, "description")); } @@ -87,34 +87,34 @@ public void shouldCreateARelationshipType() throws Exception { public void shouldEditARelationshipType() throws Exception { String json = "{ \"aIsToB\":\"Teacher\",\"bIsToA\":\"Student\",\"weight\":\"0\",\"description\":\"new description\"}"; handle(newPostRequest(getURI() + "/" + getUuid(), json)); - RelationshipType updated = service.getRelationshipTypeByUuid(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID); + RelationshipType updated = service.getRelationshipTypeByUuid(RestTestConstants1_9.RELATIONSHIP_TYPE_UUID); Assert.assertNotNull(updated); Assert.assertEquals("new description", updated.getDescription()); } @Test public void shouldRetireARelationshipType() throws Exception { - RelationshipType relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID); + RelationshipType relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_9.RELATIONSHIP_TYPE_UUID); Assert.assertFalse(relationshipType.isRetired()); handle(newDeleteRequest(getURI() + "/" + getUuid(), new Parameter("reason", "test reason"))); - relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID); + relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_9.RELATIONSHIP_TYPE_UUID); Assert.assertTrue(relationshipType.isRetired()); Assert.assertEquals("test reason", relationshipType.getRetireReason()); } @Test public void shouldUnRetireARelationshipType() throws Exception { - RelationshipType relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID); + RelationshipType relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_9.RELATIONSHIP_TYPE_UUID); relationshipType.setRetired(true); relationshipType.setRetireReason("random reason"); service.saveRelationshipType(relationshipType); - relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID); + relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_9.RELATIONSHIP_TYPE_UUID); Assert.assertTrue(relationshipType.isRetired()); String json = "{\"deleted\": \"false\"}"; SimpleObject response = deserialize(handle(newPostRequest(getURI() + "/" + getUuid(), json))); - relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID); + relationshipType = service.getRelationshipTypeByUuid(RestTestConstants1_9.RELATIONSHIP_TYPE_UUID); Assert.assertFalse(relationshipType.isRetired()); Assert.assertEquals("false", PropertyUtils.getProperty(response, "retired").toString()); @@ -135,7 +135,7 @@ public void shouldSearchAndReturnAListOfRelationshipTypesMatchingTheQueryString( SimpleObject result = deserialize(handle(newGetRequest(getURI(), new Parameter("q", "Doc")))); List hits = Util.getResultsList(result); Assert.assertEquals(1, hits.size()); - Assert.assertEquals(RestTestConstants1_8.RELATIONSHIP_TYPE_UUID, PropertyUtils.getProperty(hits.get(0), "uuid")); + Assert.assertEquals(RestTestConstants1_9.RELATIONSHIP_TYPE_UUID, PropertyUtils.getProperty(hits.get(0), "uuid")); } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/RoleController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RoleController1_9Test.java similarity index 98% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/RoleController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RoleController1_9Test.java index e8625ea95..3e1699f8f 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/RoleController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/RoleController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import java.util.List; @@ -25,12 +25,12 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; -public class RoleController1_8Test extends MainResourceControllerTest { +public class RoleController1_9Test extends MainResourceControllerTest { private UserService service; @@ -60,7 +60,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.ROLE_UUID; + return RestTestConstants1_9.ROLE_UUID; } /** diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ServerLogController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ServerLogController1_9Test.java similarity index 94% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ServerLogController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ServerLogController1_9Test.java index 3320c8090..ec9f755eb 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/ServerLogController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/ServerLogController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import org.junit.Assert; import org.junit.Before; @@ -20,7 +20,7 @@ import org.openmrs.module.webservices.rest.web.MockServerLogActionWrapper; import org.openmrs.module.webservices.rest.web.api.RestService; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ServerLogResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ServerLogResource1_9; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -29,7 +29,7 @@ import java.util.Arrays; import java.util.List; -public class ServerLogController1_8Test extends MainResourceControllerTest { +public class ServerLogController1_9Test extends MainResourceControllerTest { @Autowired private RestService restService; @@ -46,9 +46,9 @@ public class ServerLogController1_8Test extends MainResourceControllerTest { @Before public void setUp() { - ServerLogResource1_8 serverLogResource1_8 = (ServerLogResource1_8) restService + ServerLogResource1_9 serverLogResource1_9 = (ServerLogResource1_9) restService .getResourceBySupportedClass(ServerLogActionWrapper.class); - serverLogResource1_8.setServerLogActionWrapper(mockServerLogActionWrapper); + serverLogResource1_9.setServerLogActionWrapper(mockServerLogActionWrapper); } @Test(expected = Exception.class) diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/SessionController1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/SessionController1_9Test.java index 17d420fe2..5ff929b84 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/SessionController1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/SessionController1_9Test.java @@ -23,8 +23,10 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpSession; import org.springframework.mock.web.MockServletContext; +import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.context.request.WebRequest; + import javax.servlet.http.HttpServletRequest; -import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.List; import java.util.Locale; @@ -83,22 +85,6 @@ public void get_shouldReturnTheUserIfTheUserIsAuthenticated() throws Exception { Assert.assertEquals(Context.getAuthenticatedUser().getPerson().getUuid(), PropertyUtils.getProperty(personProp, "uuid")); } - - @Test - public void get_shouldReturnLocaleInfoIfTheUserIsNotAuthenticated() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { - Assert.assertTrue(Context.isAuthenticated()); - - // log out the current authenticated user - controller.delete(hsr); - Assert.assertFalse(Context.isAuthenticated()); - Assert.assertNull(hsr.getSession(false)); - - // check if the unauthenticated user response has locale and allowedLocales - Object ret = controller.get(); - Assert.assertEquals(Context.getLocale(), PropertyUtils.getProperty(ret, "locale")); - Assert.assertArrayEquals(Context.getAdministrationService().getAllowedLocales().toArray(), - ((List) PropertyUtils.getProperty(ret, "allowedLocales")).toArray()); - } @Test public void get_shouldReturnLocaleInfoIfTheUserIsAuthenticated() throws Exception { diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/TaskActionController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/TaskActionController1_9Test.java similarity index 95% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/TaskActionController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/TaskActionController1_9Test.java index 8f65d06a8..40b2755ff 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/TaskActionController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/TaskActionController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.MatcherAssert.assertThat; @@ -22,13 +22,13 @@ import org.openmrs.module.webservices.rest.web.MockTaskServiceWrapper; import org.openmrs.module.webservices.rest.web.api.RestService; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.TaskActionResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.TaskDefinitionResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.TaskActionResource1_9; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.TaskDefinitionResource1_9; import org.openmrs.scheduler.Task; import org.openmrs.scheduler.TaskDefinition; import org.springframework.beans.factory.annotation.Autowired; -public class TaskActionController1_8Test extends MainResourceControllerTest { +public class TaskActionController1_9Test extends MainResourceControllerTest { @Autowired RestService restService; @@ -50,11 +50,11 @@ public class TaskActionController1_8Test extends MainResourceControllerTest { public void setUp() throws Exception { mockTaskServiceWrapper.registeredTasks.addAll(Arrays.asList(testTask, tempTask, testDummyTask)); - TaskActionResource1_8 taskActionResource = (TaskActionResource1_8) restService + TaskActionResource1_9 taskActionResource = (TaskActionResource1_9) restService .getResourceBySupportedClass(TaskAction.class); taskActionResource.setTaskServiceWrapper(mockTaskServiceWrapper); - TaskDefinitionResource1_8 taskResource = (TaskDefinitionResource1_8) restService + TaskDefinitionResource1_9 taskResource = (TaskDefinitionResource1_9) restService .getResourceBySupportedClass(TaskDefinition.class); taskResource.setTaskServiceWrapper(mockTaskServiceWrapper); } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/TaskDefinitionController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/TaskDefinitionController1_9Test.java similarity index 97% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/TaskDefinitionController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/TaskDefinitionController1_9Test.java index a2ce58687..8a2bb0692 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/TaskDefinitionController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/TaskDefinitionController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import org.apache.commons.beanutils.PropertyUtils; import org.codehaus.jackson.map.ObjectMapper; @@ -19,14 +19,14 @@ import org.openmrs.module.webservices.rest.web.MockTaskServiceWrapper; import org.openmrs.module.webservices.rest.web.api.RestService; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.TaskDefinitionResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.TaskDefinitionResource1_9; import org.openmrs.scheduler.TaskDefinition; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; import java.util.List; -public class TaskDefinitionController1_8Test extends MainResourceControllerTest { +public class TaskDefinitionController1_9Test extends MainResourceControllerTest { @Autowired RestService restService; @@ -44,7 +44,7 @@ public void setUp() throws Exception { mockTaskServiceWrapper.registeredTasks.add(testTask); - TaskDefinitionResource1_8 taskResource = (TaskDefinitionResource1_8) restService + TaskDefinitionResource1_9 taskResource = (TaskDefinitionResource1_9) restService .getResourceBySupportedClass(TaskDefinition.class); taskResource.setTaskServiceWrapper(mockTaskServiceWrapper); } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/UserController1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/UserController1_9Test.java similarity index 94% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/UserController1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/UserController1_9Test.java index 625766f4f..06987093f 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_8/UserController1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs1_9/UserController1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; @@ -33,7 +33,7 @@ import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.api.PageableResult; import org.openmrs.module.webservices.rest.web.resource.api.SearchConfig; import org.openmrs.module.webservices.rest.web.resource.api.SearchHandler; @@ -42,7 +42,7 @@ import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; import org.openmrs.module.webservices.rest.web.response.ResponseException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.UserAndPassword1_8; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.UserAndPassword1_9; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.mock.web.MockHttpServletRequest; @@ -50,7 +50,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.context.request.WebRequest; -public class UserController1_8Test extends MainResourceControllerTest { +public class UserController1_9Test extends MainResourceControllerTest { public static final String MOCKED_USER_NAME_FOR_FIRST_COMPONENT = "FirstComponent"; @@ -75,7 +75,7 @@ public static class UserSearchHandlerWithRequiredUsernameAndOptionalLocalesParam @Override public SearchConfig getSearchConfig() { return new SearchConfig("config-for-first-test", RestConstants.VERSION_1 + "/user", - Collections.singletonList("1.8.* - 9.*"), + Collections.singletonList("1.9.* - 9.*"), new SearchQuery.Builder( "Allows you to find users by username") .withRequiredParameters(new SearchParameter("username", "admin")) @@ -86,9 +86,9 @@ public SearchConfig getSearchConfig() { public PageableResult search(RequestContext context) throws ResponseException { User user = new User(); user.setUsername(MOCKED_USER_NAME_FOR_FIRST_COMPONENT); - List users = new ArrayList(); - users.add(new UserAndPassword1_8(user)); - return new NeedsPaging(users, context); + List users = new ArrayList(); + users.add(new UserAndPassword1_9(user)); + return new NeedsPaging(users, context); } } @@ -102,7 +102,7 @@ public static class UserSearchHandlerWithRequiredIdAndOptionalUsernameParams imp @Override public SearchConfig getSearchConfig() { return new SearchConfig("config-for-second-test", RestConstants.VERSION_1 + "/user", - Collections.singletonList("1.8.* - 9.*"), + Collections.singletonList("1.9.* - 9.*"), new SearchQuery.Builder( "Allows you to find users by username").withRequiredParameters(new SearchParameter("systemId")) .withOptionalParameters(new SearchParameter("username", "bruno")).build()); @@ -112,9 +112,9 @@ public SearchConfig getSearchConfig() { public PageableResult search(RequestContext context) throws ResponseException { User user = new User(); user.setUsername(MOCKED_USER_NAME_FOR_SECOND_COMPONENT); - List users = new ArrayList(); - users.add(new UserAndPassword1_8(user)); - return new NeedsPaging(users, context); + List users = new ArrayList(); + users.add(new UserAndPassword1_9(user)); + return new NeedsPaging(users, context); } } @@ -128,7 +128,7 @@ public static class UserSearchHandlerWithOptionalParam implements SearchHandler @Override public SearchConfig getSearchConfig() { return new SearchConfig("config-for-third-test", RestConstants.VERSION_1 + "/user", - Collections.singletonList("1.8.* - 9.*"), + Collections.singletonList("1.9.*- 9.*"), new SearchQuery.Builder( "Allows you to find users by username").withOptionalParameters( new SearchParameter("username", "bruno")) @@ -139,9 +139,9 @@ public SearchConfig getSearchConfig() { public PageableResult search(RequestContext context) throws ResponseException { User user = new User(); user.setUsername(MOCKED_USER_NAME_FOR_THRID_COMPONENT); - List users = new ArrayList(); - users.add(new UserAndPassword1_8(user)); - return new NeedsPaging(users, context); + List users = new ArrayList(); + users.add(new UserAndPassword1_9(user)); + return new NeedsPaging(users, context); } } @@ -205,7 +205,7 @@ public void createUser_shouldCreateANewUserWithRoles() throws Exception { } /** - * @see UserController#getUser(UserAndPassword1_8,WebRequest) + * @see UserController#getUser(UserAndPassword1_9,WebRequest) * @throws Exception * @verifies get a default representation of a UserAndPassword */ @@ -249,7 +249,7 @@ public void getUser_shouldGetAFullRepresentationOfAPatient() throws Exception { } /** - * @see UserController#updateUser(UserAndPassword1_8,SimpleObject,WebRequest) + * @see UserController#updateUser(UserAndPassword1_9,SimpleObject,WebRequest) * @throws Exception * @verifies change a property on a patient */ @@ -475,7 +475,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.USER_UUID; + return RestTestConstants1_9.USER_UUID; } /** diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ActiveListTypeResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ActiveListTypeResource1_9Test.java similarity index 95% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ActiveListTypeResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ActiveListTypeResource1_9Test.java index 5b9d00ab8..2cadfe9b7 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ActiveListTypeResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ActiveListTypeResource1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.junit.Test; import org.mockito.Mock; @@ -20,7 +20,7 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; -public class ActiveListTypeResource1_8Test extends BaseModuleWebContextSensitiveTest { +public class ActiveListTypeResource1_9Test extends BaseModuleWebContextSensitiveTest { @Autowired private MainResourceController mainResourceController; diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/AllergyResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/AllergyResource1_9Test.java index a78b7ae07..e674d83c9 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/AllergyResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/AllergyResource1_9Test.java @@ -16,7 +16,7 @@ import org.openmrs.activelist.Allergy; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; @@ -78,7 +78,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.ALLERGY_UUID; + return RestTestConstants1_9.ALLERGY_UUID; } @Test diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortMemberResource1_9Test.java similarity index 82% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortMemberResource1_9Test.java index 6f5d09ad2..bbfc79f1f 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortMemberResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortMemberResource1_9Test.java @@ -7,22 +7,22 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.Cohort; import org.openmrs.Patient; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.CohortMember1_8; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.CohortMember1_9; -public class CohortMemberResource1_8Test extends BaseDelegatingResourceTest { +public class CohortMemberResource1_9Test extends BaseDelegatingResourceTest { @Override - public CohortMember1_8 newObject() { - Cohort cohort = Context.getCohortService().getCohortByUuid(RestTestConstants1_8.COHORT_UUID); - Patient patient = Context.getPatientService().getPatientByUuid(RestTestConstants1_8.PATIENT_UUID); - return new CohortMember1_8(patient, cohort); + public CohortMember1_9 newObject() { + Cohort cohort = Context.getCohortService().getCohortByUuid(RestTestConstants1_9.COHORT_UUID); + Patient patient = Context.getPatientService().getPatientByUuid(RestTestConstants1_9.PATIENT_UUID); + return new CohortMember1_9(patient, cohort); } @Override diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortResource1_9Test.java similarity index 88% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortResource1_9Test.java index 4af81768f..05b7a4929 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/CohortResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CohortResource1_9Test.java @@ -7,19 +7,19 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.junit.Before; import org.openmrs.Cohort; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class CohortResource1_8Test extends BaseDelegatingResourceTest { +public class CohortResource1_9Test extends BaseDelegatingResourceTest { @Before public void before() throws Exception { - executeDataSet(RestTestConstants1_8.RESOURCE_TEST_DATASET); + executeDataSet(RestTestConstants1_9.RESOURCE_TEST_DATASET); } @Override @@ -53,7 +53,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.COHORT_UUID; + return RestTestConstants1_9.COHORT_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptClassResource1_8Test.java similarity index 93% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptClassResource1_8Test.java index 3855fb294..4b7354500 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptClassResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptClassResource1_8Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.ConceptClass; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class ConceptClassResource1_8Test extends BaseDelegatingResourceTest { +public class ConceptClassResource1_8Test extends BaseDelegatingResourceTest { @Override public ConceptClass newObject() { @@ -45,7 +45,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.CONCEPT_CLASS_UUID; + return RestTestConstants1_9.CONCEPT_CLASS_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDatatypeResource1_9Test.java similarity index 90% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDatatypeResource1_9Test.java index 4e1c36828..861276be5 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptDatatypeResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDatatypeResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.ConceptDatatype; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class ConceptDatatypeResource1_8Test extends BaseDelegatingResourceTest { +public class ConceptDatatypeResource1_9Test extends BaseDelegatingResourceTest { @Override public ConceptDatatype newObject() { @@ -47,7 +47,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.CONCEPT_DATATYPE_UUID; + return RestTestConstants1_9.CONCEPT_DATATYPE_UUID; } } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDescriptionResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDescriptionResource1_9Test.java index 5f1694868..ef6d9a47e 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDescriptionResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptDescriptionResource1_9Test.java @@ -11,7 +11,7 @@ import org.openmrs.ConceptDescription; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class ConceptDescriptionResource1_9Test extends BaseDelegatingResourceTest { @@ -43,7 +43,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.CONCEPT_DESCRIPTION_UUID; + return RestTestConstants1_9.CONCEPT_DESCRIPTION_UUID; } } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNameResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNameResource1_9Test.java index cd08f1433..e24af0481 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNameResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNameResource1_9Test.java @@ -11,7 +11,7 @@ import org.openmrs.ConceptName; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class ConceptNameResource1_9Test extends BaseDelegatingResourceTest { @@ -47,7 +47,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.CONCEPT_NAME_UUID; + return RestTestConstants1_9.CONCEPT_NAME_UUID; } } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNumericResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNumericResource1_9Test.java index ada98e290..d474465f7 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNumericResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptNumericResource1_9Test.java @@ -11,7 +11,7 @@ import org.openmrs.Concept; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class ConceptNumericResource1_9Test extends BaseDelegatingResourceTest { @@ -69,7 +69,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.CONCEPT_NUMERIC_UUID; + return RestTestConstants1_9.CONCEPT_NUMERIC_UUID; } } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptResource1_9Test.java index d43aff45b..c69c97bca 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptResource1_9Test.java @@ -28,11 +28,10 @@ import org.openmrs.api.context.ServiceContext; import org.openmrs.messagesource.MessageSourceService; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.representation.NamedRepresentation; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; import org.openmrs.module.webservices.rest.web.response.ConversionException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptResource1_8; public class ConceptResource1_9Test extends BaseDelegatingResourceTest { @@ -81,7 +80,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.CONCEPT_UUID; + return RestTestConstants1_9.CONCEPT3_UUID; } @Test @@ -95,21 +94,21 @@ public void testSetNames() throws Exception { otherName.setUuid("newUuid"); otherNames.add(otherName); - ConceptResource1_8.setNames(instance, otherNames); + ConceptResource1_9.setNames(instance, otherNames); assertEquals(1, instance.getNames().size()); assertTrue(instance.getNames().contains(otherName)); - ConceptResource1_8.setNames(instance, getMockNamesList()); + ConceptResource1_9.setNames(instance, getMockNamesList()); assertEquals(2, instance.getNames().size()); assertFalse(instance.getNames().contains(otherName)); otherNames.addAll(getMockNamesList()); - ConceptResource1_8.setNames(instance, otherNames); + ConceptResource1_9.setNames(instance, otherNames); assertEquals(3, instance.getNames().size()); assertTrue(instance.getNames().contains(otherName)); - ConceptResource1_8.setNames(instance, getMockNamesList()); + ConceptResource1_9.setNames(instance, getMockNamesList()); assertEquals(2, instance.getNames().size()); assertFalse(instance.getNames().contains(otherName)); } @@ -156,7 +155,7 @@ public void testGetDisplayName() throws Exception { concept.addName(fullySpecifiedName); ConceptResource1_9 resource = new ConceptResource1_9(); - String result = resource.getDisplayString(concept); + String result = resource.getDisplayName(concept); Assert.assertEquals("some name", result); } @@ -165,7 +164,7 @@ public void testGetDisplayName() throws Exception { public void testGetDisplayNameForConceptWithNoName() throws Exception { Concept concept = new Concept(1); ConceptResource1_9 resource = new ConceptResource1_9(); - String result = resource.getDisplayString(concept); + String result = resource.getDisplayName(concept); Assert.assertEquals("1", result); // this will need to updated to "Concept #1" when we start building against more recent versions of OpenMRS Core } @@ -187,7 +186,7 @@ public void testGetDisplayNameWithLocalizationOverride() throws Exception { concept.addName(fullySpecifiedName); ConceptResource1_9 resource = new ConceptResource1_9(); - String result = resource.getDisplayString(concept); + String result = resource.getDisplayName(concept); Assert.assertEquals("Overridden by message source", result); } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSearchResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSearchResource1_9Test.java index 8928d8d65..c0e0fc2a2 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSearchResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSearchResource1_9Test.java @@ -12,7 +12,7 @@ import org.openmrs.Concept; import org.openmrs.ConceptSearchResult; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class ConceptSearchResource1_9Test extends BaseDelegatingResourceTest { @@ -68,7 +68,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.CONCEPT_UUID; + return RestTestConstants1_9.CONCEPT3_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSourceResource1_9Test.java similarity index 90% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSourceResource1_9Test.java index 7c40e999f..a58bc6127 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ConceptSourceResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ConceptSourceResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.ConceptSource; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class ConceptSourceResource1_8Test extends BaseDelegatingResourceTest { +public class ConceptSourceResource1_9Test extends BaseDelegatingResourceTest { @Override public ConceptSource newObject() { @@ -47,7 +47,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.CONCEPT_SOURCE_UUID; + return RestTestConstants1_9.CONCEPT_SOURCE_UUID; } } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CreatePatientIdentifierResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CreatePatientIdentifierResource1_9Test.java index 7f305d476..ea1fb06c6 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CreatePatientIdentifierResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/CreatePatientIdentifierResource1_9Test.java @@ -20,16 +20,15 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientIdentifierResource1_8; import org.openmrs.web.test.BaseModuleWebContextSensitiveTest; public class CreatePatientIdentifierResource1_9Test extends BaseModuleWebContextSensitiveTest { - private PatientIdentifierResource1_8 resource; + private PatientIdentifierResource1_9 resource; @Before public void beforeEachTests() throws Exception { - resource = (PatientIdentifierResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( + resource = (PatientIdentifierResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( PatientIdentifier.class); } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugResource1_9Test.java similarity index 94% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugResource1_9Test.java index 451bf78c6..645134ac6 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/DrugResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/DrugResource1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.HashMap; import java.util.Map; @@ -16,13 +16,13 @@ import org.openmrs.Concept; import org.openmrs.Drug; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; import org.springframework.util.Assert; -public class DrugResource1_8Test extends BaseDelegatingResourceTest { +public class DrugResource1_9Test extends BaseDelegatingResourceTest { @Override public Drug newObject() { @@ -69,7 +69,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.DRUG_UUID; + return RestTestConstants1_9.DRUG_UUID; } /** @@ -78,7 +78,7 @@ public String getUuidProperty() { */ @Test public void setConvertedProperties_shouldAllowSettingANullValue() { - DrugResource1_8 resource = new DrugResource1_8(); + DrugResource1_9 resource = new DrugResource1_9(); Drug drug = new Drug(); drug.setRoute(new Concept()); Map propertyMap = new HashMap(); diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterTypeResource1_9Test.java similarity index 89% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterTypeResource1_9Test.java index 8d95f9340..553d78660 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/EncounterTypeResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/EncounterTypeResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.EncounterType; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class EncounterTypeResource1_8Test extends BaseDelegatingResourceTest { +public class EncounterTypeResource1_9Test extends BaseDelegatingResourceTest { @Override public EncounterType newObject() { @@ -45,7 +45,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.ENCOUNTER_TYPE_UUID; + return RestTestConstants1_9.ENCOUNTER_TYPE_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldAnswerResource1_9Test.java similarity index 89% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldAnswerResource1_9Test.java index 4949351dc..ddefd1d9e 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldAnswerResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldAnswerResource1_9Test.java @@ -7,15 +7,15 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.Field; import org.openmrs.FieldAnswer; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class FieldAnswerResource1_8Test extends BaseDelegatingResourceTest { +public class FieldAnswerResource1_9Test extends BaseDelegatingResourceTest { private String fieldAnswerUUID; @@ -24,9 +24,9 @@ public class FieldAnswerResource1_8Test extends BaseDelegatingResourceTest { +public class FieldResource1_9Test extends BaseDelegatingResourceTest { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#newObject() @@ -37,7 +37,7 @@ public String getDisplayProperty() { */ @Override public String getUuidProperty() { - return RestTestConstants1_8.FIELD_UUID; + return RestTestConstants1_9.FIELD_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldTypeResource1_9Test.java similarity index 88% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldTypeResource1_9Test.java index a6772f166..1d9fb9151 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FieldTypeResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FieldTypeResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.FieldType; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class FieldTypeResource1_8Test extends BaseDelegatingResourceTest { +public class FieldTypeResource1_9Test extends BaseDelegatingResourceTest { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#newObject() @@ -37,7 +37,7 @@ public String getDisplayProperty() { */ @Override public String getUuidProperty() { - return RestTestConstants1_8.FIELD_TYPE_UUID; + return RestTestConstants1_9.FIELD_TYPE_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormFieldResource1_9Test.java similarity index 88% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormFieldResource1_9Test.java index 3ab2f348b..0079b2da4 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormFieldResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormFieldResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.FormField; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class FormFieldResource1_8Test extends BaseDelegatingResourceTest { +public class FormFieldResource1_9Test extends BaseDelegatingResourceTest { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#newObject() @@ -37,7 +37,7 @@ public String getDisplayProperty() { */ @Override public String getUuidProperty() { - return RestTestConstants1_8.FORM_FIELD_UUID; + return RestTestConstants1_9.FORM_FIELD_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResource1_8Test.java similarity index 96% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResource1_8Test.java index 622ea5631..5271624eb 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/FormResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/FormResource1_8Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.Form; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class FormResource1_8Test extends BaseDelegatingResourceTest { +public class FormResource1_8Test extends BaseDelegatingResourceTest { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest#newObject() @@ -37,7 +37,7 @@ public String getDisplayProperty() { */ @Override public String getUuidProperty() { - return RestTestConstants1_8.FORM_UUID; + return RestTestConstants1_9.FORM2_UUID; } @Override diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7MessageResource1_9Test.java similarity index 83% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7MessageResource1_9Test.java index b3d947c9a..e6b8697cd 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7MessageResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7MessageResource1_9Test.java @@ -7,30 +7,30 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.junit.Before; import org.openmrs.api.context.Context; import org.openmrs.hl7.HL7InQueue; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.IncomingHl7Message1_8; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.IncomingHl7Message1_9; -public class HL7MessageResource1_8Test extends BaseDelegatingResourceTest { +public class HL7MessageResource1_9Test extends BaseDelegatingResourceTest { @Before public void before() throws Exception { - executeDataSet(RestTestConstants1_8.RESOURCE_TEST_DATASET); + executeDataSet(RestTestConstants1_9.RESOURCE_TEST_DATASET); } @Override - public IncomingHl7Message1_8 newObject() { + public IncomingHl7Message1_9 newObject() { HL7InQueue msg = new HL7InQueue(); msg.setHL7Data("hl7Data"); msg.setHL7SourceKey("sourceKey"); - msg.setHL7Source(Context.getHL7Service().getHL7SourceByName(RestTestConstants1_8.HL7_SOURCE_NAME)); + msg.setHL7Source(Context.getHL7Service().getHL7SourceByName(RestTestConstants1_9.HL7_SOURCE_NAME)); Context.getHL7Service().saveHL7InQueue(msg); - return new IncomingHl7Message1_8(msg); + return new IncomingHl7Message1_9(msg); } @Override diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7SourceResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7SourceResource1_9Test.java similarity index 88% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7SourceResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7SourceResource1_9Test.java index b8b312d50..cdf714690 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/HL7SourceResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/HL7SourceResource1_9Test.java @@ -7,24 +7,24 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.junit.Before; import org.openmrs.api.context.Context; import org.openmrs.hl7.HL7Source; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class HL7SourceResource1_8Test extends BaseDelegatingResourceTest { +public class HL7SourceResource1_9Test extends BaseDelegatingResourceTest { @Before public void before() throws Exception { - executeDataSet(RestTestConstants1_8.RESOURCE_TEST_DATASET); + executeDataSet(RestTestConstants1_9.RESOURCE_TEST_DATASET); } @Override public HL7Source newObject() { - return Context.getHL7Service().getHL7SourceByName(RestTestConstants1_8.HL7_SOURCE_NAME); + return Context.getHL7Service().getHL7SourceByName(RestTestConstants1_9.HL7_SOURCE_NAME); } @Override diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleResource1_9Test.java similarity index 89% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleResource1_9Test.java index 408916f72..5693c024a 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ModuleResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ModuleResource1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.module.Module; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; @@ -15,7 +15,7 @@ /** * */ -public class ModuleResource1_8Test extends BaseDelegatingResourceTest { +public class ModuleResource1_9Test extends BaseDelegatingResourceTest { @Override public Module newObject() { @@ -31,4 +31,4 @@ public String getDisplayProperty() { public String getUuidProperty() { return "atlas"; } -} +} \ No newline at end of file diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsResource1_9Test.java index 91b15d7f6..cd8400716 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ObsResource1_9Test.java @@ -20,11 +20,10 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.ConversionUtil; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; import org.openmrs.module.webservices.rest.web.response.ConversionException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ObsResource1_8; import org.openmrs.util.OpenmrsConstants; import java.util.Date; @@ -111,7 +110,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.OBS_UUID; + return RestTestConstants1_9.OBS2_UUID; } @Test @@ -187,14 +186,14 @@ public void asRepresentation_shouldReturnProperlyEncodedValues() throws Exceptio @Test public void setGroupMembers_shouldSetGroupMembers() throws Exception { executeDataSet("obsWithGroupMembers.xml"); - ObsResource1_8 resource = getResource(); + ObsResource1_9 resource = getResource(); Obs groupMemberParent = resource.getByUniqueId("47f18998-96cc-11e0-8d6b-9b9415a91423"); Set groupMembersBefore = groupMemberParent.getGroupMembers(); - Set groupMembersAfter = (Set) ObsResource1_8.getGroupMembers(resource + Set groupMembersAfter = (Set) ObsResource1_9.getGroupMembers(resource .getByUniqueId("5117f5d4-96cc-11e0-8d6b-9b9415a91433")); - ObsResource1_8.setGroupMembers(groupMemberParent, groupMembersAfter); + ObsResource1_9.setGroupMembers(groupMemberParent, groupMembersAfter); assertNotEquals(groupMembersBefore, groupMemberParent.getGroupMembers()); assertEquals(groupMembersAfter, groupMemberParent.getGroupMembers()); } @@ -203,13 +202,13 @@ public void setGroupMembers_shouldSetGroupMembers() throws Exception { public void getGroupMembers_shouldReturnAllGroupMembers() throws Exception { executeDataSet("obsWithGroupMembers.xml"); - ObsResource1_8 resource = getResource(); + ObsResource1_9 resource = getResource(); - Set groupMembers1 = (Set) ObsResource1_8.getGroupMembers(resource + Set groupMembers1 = (Set) ObsResource1_9.getGroupMembers(resource .getByUniqueId("47f18998-96cc-11e0-8d6b-9b9415a91423")); assertEquals(1, groupMembers1.size()); - Set groupMembers2 = (Set) ObsResource1_8.getGroupMembers(resource + Set groupMembers2 = (Set) ObsResource1_9.getGroupMembers(resource .getByUniqueId("5117f5d4-96cc-11e0-8d6b-9b9415a91433")); assertEquals(2, groupMembers2.size()); @@ -219,8 +218,8 @@ public void getGroupMembers_shouldReturnAllGroupMembers() throws Exception { public void setValue_shouldReturnUuidForConceptTrue() throws Exception { Obs obs = new Obs(); obs.setConcept(Context.getConceptService().getConceptByUuid(BOOLEAN_CONCEPT_UUID)); - ObsResource1_8.setValue(obs, trueConcept); - assertEquals(trueConcept, new ObsResource1_8().getValue(obs)); + ObsResource1_9.setValue(obs, trueConcept); + assertEquals(trueConcept, new ObsResource1_9().getValue(obs)); } @Test @@ -231,8 +230,8 @@ public void setValue_shouldReturnDrug() throws Exception { // drug String drugUuid = "3cfcf118-931c-46f7-8ff6-7b876f0d4202"; Drug drug = Context.getConceptService().getDrugByUuid(drugUuid); - ObsResource1_8.setValue(obs, drugUuid); - assertEquals(drug, new ObsResource1_8().getValue(obs)); + ObsResource1_9.setValue(obs, drugUuid); + assertEquals(drug, new ObsResource1_9().getValue(obs)); } @Test @@ -240,8 +239,8 @@ public void setValue_shouldSupportPassingInFullConceptRep() throws Exception { Obs obs = new Obs(); obs.setConcept(Context.getConceptService().getConceptByUuid("89ca642a-dab6-4f20-b712-e12ca4fc6d36")); Concept valueCoded = Context.getConceptService().getConceptByUuid("32d3611a-6699-4d52-823f-b4b788bac3e3"); - ObsResource1_8.setValue(obs, ConversionUtil.convertToRepresentation(valueCoded, Representation.FULL)); - assertEquals(valueCoded, new ObsResource1_8().getValue(obs)); + ObsResource1_9.setValue(obs, ConversionUtil.convertToRepresentation(valueCoded, Representation.FULL)); + assertEquals(valueCoded, new ObsResource1_9().getValue(obs)); } @Test @@ -251,8 +250,8 @@ public void setValue_shouldReturnLocation() throws Exception { obs.setConcept(concept); String locationUuid = "8d6c993e-c2cc-11de-8d13-0010c6dffd0f"; Location location = Context.getLocationService().getLocationByUuid(locationUuid); - ObsResource1_8.setValue(obs, locationUuid); - assertEquals(location, new ObsResource1_8().getValue(obs)); + ObsResource1_9.setValue(obs, locationUuid); + assertEquals(location, new ObsResource1_9().getValue(obs)); } @Test @@ -261,8 +260,8 @@ public void setValue_shouldSupportPassingInFullLocationRep() throws Exception { obs.setConcept(Context.getConceptService().getConceptByUuid("96408258-000b-424e-af1a-403919332938")); String locationUuid = "8d6c993e-c2cc-11de-8d13-0010c6dffd0f"; Location location = Context.getLocationService().getLocationByUuid(locationUuid); - ObsResource1_8.setValue(obs, ConversionUtil.convertToRepresentation(location, Representation.FULL)); - assertEquals(location, new ObsResource1_8().getValue(obs)); + ObsResource1_9.setValue(obs, ConversionUtil.convertToRepresentation(location, Representation.FULL)); + assertEquals(location, new ObsResource1_9().getValue(obs)); } @Test @@ -270,39 +269,39 @@ public void setValue_shouldReturnValueText() throws Exception { Obs obs = new Obs(); Concept concept = Context.getConceptService().getConceptByUuid("96408258-000b-424e-af1a-403919332938"); obs.setConcept(concept); - ObsResource1_8.setValue(obs, "cheesecake"); - assertEquals("cheesecake", new ObsResource1_8().getValue(obs)); + ObsResource1_9.setValue(obs, "cheesecake"); + assertEquals("cheesecake", new ObsResource1_9().getValue(obs)); } @Test public void setValue_shouldReturnUuidForConceptFalse() throws Exception { Obs obs = new Obs(); obs.setConcept(Context.getConceptService().getConceptByUuid(BOOLEAN_CONCEPT_UUID)); - ObsResource1_8.setValue(obs, falseConcept); - assertEquals(falseConcept, new ObsResource1_8().getValue(obs)); + ObsResource1_9.setValue(obs, falseConcept); + assertEquals(falseConcept, new ObsResource1_9().getValue(obs)); } @Test(expected = ConversionException.class) public void setValue_shouldThrowExceptionOnUnexpectedValue() throws Exception { Obs obs = new Obs(); obs.setConcept(Context.getConceptService().getConceptByUuid(BOOLEAN_CONCEPT_UUID)); - ObsResource1_8.setValue(obs, "unexpected"); + ObsResource1_9.setValue(obs, "unexpected"); } @Test public void setValue_shouldReturnUuidForPrimitiveTrue() throws Exception { Obs obs = new Obs(); obs.setConcept(Context.getConceptService().getConceptByUuid(BOOLEAN_CONCEPT_UUID)); - ObsResource1_8.setValue(obs, true); - assertEquals(trueConcept, new ObsResource1_8().getValue(obs)); + ObsResource1_9.setValue(obs, true); + assertEquals(trueConcept, new ObsResource1_9().getValue(obs)); } @Test public void setValue_shouldReturnUuidForPrimitiveFalse() throws Exception { Obs obs = new Obs(); obs.setConcept(Context.getConceptService().getConceptByUuid(BOOLEAN_CONCEPT_UUID)); - ObsResource1_8.setValue(obs, false); - assertEquals(falseConcept, new ObsResource1_8().getValue(obs)); + ObsResource1_9.setValue(obs, false); + assertEquals(falseConcept, new ObsResource1_9().getValue(obs)); } private void clearAndSetValue(Obs obs, ObsType type, Object value) { @@ -316,16 +315,16 @@ private void clearAndSetValue(Obs obs, ObsType type, Object value) { @Test public void setConvertedProperties_shouldAllowAnyPropertyOrder() throws Exception { - ObsResource1_8 resource = getResource(); + ObsResource1_9 resource = getResource(); Obs obs = getObject(); Map propertyMap = new HashMap(); propertyMap.put("value", 10.0); - propertyMap.put("person", RestTestConstants1_8.PERSON_UUID); + propertyMap.put("person", RestTestConstants1_9.PERSON_UUID); propertyMap.put("concept", "c607c80f-1ea9-4da3-bb88-6276ce8868dd"); propertyMap.put("obsDatetime", "2013-12-09T00:00:00.000+0100"); resource.setConvertedProperties(obs, propertyMap, resource.getUpdatableProperties(), false); - org.springframework.util.Assert.isTrue(((Double) new ObsResource1_8().getValue(obs)) == 10.0); + org.springframework.util.Assert.isTrue(((Double) new ObsResource1_9().getValue(obs)) == 10.0); } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderResource1_9Test.java similarity index 90% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderResource1_9Test.java index 4a9e4f60f..969e8d501 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderResource1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.List; @@ -16,10 +16,10 @@ import org.openmrs.Order; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class OrderResource1_8Test extends BaseDelegatingResourceTest { +public class OrderResource1_9Test extends BaseDelegatingResourceTest { @Override public Order newObject() { @@ -33,7 +33,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.ORDER_UUID; + return RestTestConstants1_9.ORDER_UUID; } /** @@ -43,7 +43,7 @@ public String getUuidProperty() { @SuppressWarnings({ "unchecked", "rawtypes" }) @Test public void doGetAll_shouldReturnAllOrdersIncludingRetiredIfContextincludeAllIsSet() throws Exception { - OrderResource1_8 or = getResource(); + OrderResource1_9 or = getResource(); RequestContext ctx = new RequestContext(); @@ -63,9 +63,9 @@ public void doGetAll_shouldReturnAllOrdersIncludingRetiredIfContextincludeAllIsS } private void voidOneOrder() { - Order order = Context.getOrderService().getOrderByUuid(RestTestConstants1_8.ORDER_UUID); + Order order = Context.getOrderService().getOrderByUuid(RestTestConstants1_9.ORDER_UUID); order.setVoided(true); Context.getOrderService().saveOrder(order); } -} +} \ No newline at end of file diff --git a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderTypeResource1_8.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderTypeResource1_9.java similarity index 95% rename from omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderTypeResource1_8.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderTypeResource1_9.java index 1e18a54f1..6418a8310 100644 --- a/omod-1.8/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/OrderTypeResource1_8.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/OrderTypeResource1_9.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.OrderType; import org.openmrs.api.context.Context; @@ -22,8 +22,8 @@ * */ @Resource(name = RestConstants.VERSION_1 + "/ordertype", supportedClass = OrderType.class, supportedOpenmrsVersions = { - "1.8.* - 1.9.*" }) -public class OrderTypeResource1_8 extends MetadataDelegatingCrudResource { + "1.9.*" }) +public class OrderTypeResource1_9 extends MetadataDelegatingCrudResource { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getByUniqueId(java.lang.String) diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierResource1_9Test.java index f9d0e67a5..c40914a7a 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierResource1_9Test.java @@ -9,14 +9,13 @@ */ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientIdentifierResource1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.PatientIdentifier; import org.openmrs.api.PatientService; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class PatientIdentifierResource1_9Test extends BaseDelegatingResourceTest { +public class PatientIdentifierResource1_9Test extends BaseDelegatingResourceTest { @Override public PatientIdentifier newObject() { @@ -51,7 +50,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PATIENT_IDENTIFIER_UUID; + return RestTestConstants1_9.PATIENT_IDENTIFIER_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierTypeResource1_9Test.java similarity index 92% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierTypeResource1_9Test.java index 8c0c3afdf..64b4014c3 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientIdentifierTypeResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientIdentifierTypeResource1_9Test.java @@ -7,15 +7,15 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.PatientIdentifierType; import org.openmrs.api.PatientService; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class PatientIdentifierTypeResource1_8Test extends BaseDelegatingResourceTest { +public class PatientIdentifierTypeResource1_9Test extends BaseDelegatingResourceTest { @Override public PatientIdentifierType newObject() { @@ -58,6 +58,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PATIENT_IDENTIFIER_TYPE_UUID; + return RestTestConstants1_9.PATIENT_IDENTIFIER_TYPE_UUID; } } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientResource1_9Test.java index 9b54383f4..8f5b852f8 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientResource1_9Test.java @@ -12,7 +12,7 @@ import org.openmrs.Patient; import org.openmrs.api.PatientService; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class PatientResource1_9Test extends BaseDelegatingResourceTest { @@ -46,7 +46,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PATIENT_UUID; + return RestTestConstants1_9.PATIENT_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientStateResource1_9Test.java similarity index 90% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientStateResource1_9Test.java index d5d17cae1..1c1501e08 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PatientStateResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PatientStateResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.PatientState; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class PatientStateResource1_8Test extends BaseDelegatingResourceTest { +public class PatientStateResource1_9Test extends BaseDelegatingResourceTest { @Override public PatientState newObject() { @@ -50,6 +50,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PATIENT_STATE_UUID; + return RestTestConstants1_9.PATIENT_STATE_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAddressResource1_9Test.java similarity index 94% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAddressResource1_9Test.java index 69839c25f..3935c18fd 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAddressResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAddressResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.PersonAddress; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class PersonAddressResource1_8Test extends BaseDelegatingResourceTest { +public class PersonAddressResource1_9Test extends BaseDelegatingResourceTest { @Override public PersonAddress newObject() { @@ -74,7 +74,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PERSON_ADDRESS_UUID; + return RestTestConstants1_9.PERSON_ADDRESS_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeResource1_9Test.java similarity index 86% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeResource1_9Test.java index 5417167e5..9023db505 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeResource1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; @@ -33,15 +33,16 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalToIgnoringCase; -public class PersonAttributeResource1_8Test extends BaseModuleWebContextSensitiveTest { +public class PersonAttributeResource1_9Test extends BaseModuleWebContextSensitiveTest { - public static final String PERSON_ATTRIBUTE_JSON = "{\"value\": \"Bangalore\", \"uuid\": \"592349ed-d012-4552-a274-d5d8e73b9401\", \"attributeType\": { \"uuid\": \"54fc8400-1683-4d71-a1ac-98d40836ff7c\" }}"; + public static final String PERSON_ATTRIBUTE_JSON = "{\"value\": \"Bangalore\", \"uuid\": \"592349ed-d012-4552-a274-d5d8e73b9401\"," + + "\"attributeType\": { \"uuid\": \"54fc8400-1683-4d71-a1ac-98d40836ff7c\" }}"; public static final String PERSON_ATTRIBUTE_JSON_WITHOUT_UUID = "{\"value\": \"Bangalore\", \"uuid\": \"\", \"attributeType\": { \"uuid\": \"54fc8400-1683-4d71-a1ac-98d40836ff7c\" }}"; - + private SimpleObject personAttributeSimpleObject = new SimpleObject(); - private PersonAttributeResource1_8 resource; + private PersonAttributeResource1_9 resource; @Autowired private ConceptService conceptService; @@ -55,7 +56,7 @@ public class PersonAttributeResource1_8Test extends BaseModuleWebContextSensitiv @Before public void beforeEachTests() throws Exception { personAttributeSimpleObject.putAll(new ObjectMapper().readValue(PERSON_ATTRIBUTE_JSON, HashMap.class)); - resource = (PersonAttributeResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( + resource = (PersonAttributeResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( PersonAttribute.class); } @@ -141,27 +142,29 @@ public void getDisplayString_shouldGetDisplayStringForString() { assertThat(displayString, equalToIgnoringCase("A Value")); } - - @Test - public void setValue_shouldSetProperAttributableIdIfFound() { - PersonAttributeType type = new PersonAttributeType(); - type.setFormat("org.openmrs.Location"); - type.setName("Second Home"); - type.setDescription("Testing Attributable domain objects"); - type.setSortWeight(5.5); - type.setSearchable(false); - type = personService.savePersonAttributeType(type); + + @Test + public void setValue_shouldSetProperAttributableIdIfFound() { + PersonAttributeType type = new PersonAttributeType(); + type.setFormat("org.openmrs.Location"); + type.setName("Second Home"); + type.setDescription("Testing Attributable domain objects"); + type.setSortWeight(5.5); + type.setSearchable(false); + type = personService.savePersonAttributeType(type); - //Get the first location in from the list - Location location = locationService.getAllLocations().get(0); + //Get the first location in from the list + Location location = locationService.getAllLocations().get(0); - PersonAttribute attribute = new PersonAttribute(type, null); - attribute.setAttributeType(type); - Assert.assertNull(attribute.getValue()); + PersonAttribute attribute = new PersonAttribute(type, null); + attribute.setAttributeType(type); - resource.setValue(attribute, location.getUuid()); - Assert.assertEquals(location.getId().toString(), attribute.getValue()); - } + Assert.assertNull(attribute.getValue()); + + resource.setValue(attribute, location.getUuid()); + + Assert.assertEquals(location.getId(), Integer.valueOf(attribute.getValue())); + } @Test public void setValue_shouldSetPassedValueIfCouldNotBeConvertedToAttributable() throws ClassNotFoundException { diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResource1_9Test.java similarity index 92% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResource1_9Test.java index 4e033de6a..e413d0bcb 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonAttributeTypeResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResource1_9Test.java @@ -7,15 +7,15 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.junit.Before; import org.openmrs.PersonAttributeType; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class PersonAttributeTypeResource1_8Test extends BaseDelegatingResourceTest { +public class PersonAttributeTypeResource1_9Test extends BaseDelegatingResourceTest { private static final String ACTIVE_LIST_INITIAL_XML = "personAttributeTypeWithConcept.xml"; @@ -63,6 +63,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PERSON_ATTRIBUTE_TYPE_UUID; + return RestTestConstants1_9.PERSON_ATTRIBUTE_TYPE_UUID; } } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResourceWithConcept1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResourceWithConcept1_9Test.java new file mode 100644 index 000000000..fe0cb0030 --- /dev/null +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonAttributeTypeResourceWithConcept1_9Test.java @@ -0,0 +1,49 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ + package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; + + import static org.junit.Assert.assertEquals; + + import org.junit.Before; + import org.openmrs.PersonAttributeType; + import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.rest.SimpleObject; +import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; + + public class PersonAttributeTypeResourceWithConcept1_9Test extends BaseDelegatingResourceTest { + + private static final String ACTIVE_LIST_INITIAL_XML = "personAttributeTypeWithConcept.xml"; + + @Before + public void init() throws Exception { + executeDataSet(ACTIVE_LIST_INITIAL_XML); + } + + @Override + public PersonAttributeType newObject() { + return Context.getPersonService().getPersonAttributeTypeByUuid(getUuidProperty()); + } + + @Override + public void validateFullRepresentation() throws Exception { + SimpleObject concept = getRepresentation().get("concept"); + assertEquals("d102c80f-1yz9-4da3-bb88-8122ce8868dd", concept.get("uuid")); + } + + @Override + public String getDisplayProperty() { + return "Caste"; + } + + @Override + public String getUuidProperty() { + return "55e6ce9e-25bf-11e3-a013-3c0754156a5d"; + } + } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonNameResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonNameResource1_9Test.java index 9e6e1f4c5..fb7982599 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonNameResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonNameResource1_9Test.java @@ -11,11 +11,10 @@ import org.openmrs.PersonName; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PersonNameResource1_8; -public class PersonNameResource1_9Test extends BaseDelegatingResourceTest { +public class PersonNameResource1_9Test extends BaseDelegatingResourceTest { @Override public PersonName newObject() { @@ -55,7 +54,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PERSON_NAME_UUID; + return RestTestConstants1_9.PERSON_NAME_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonResource1_9Test.java similarity index 92% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonResource1_9Test.java index e00c3a0e4..6993827e4 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PersonResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PersonResource1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.junit.Assert; import org.junit.Test; @@ -16,7 +16,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.RestUtil; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; import org.springframework.mock.web.MockHttpServletRequest; @@ -26,7 +26,7 @@ import static org.junit.Assert.assertFalse; -public class PersonResource1_8Test extends BaseDelegatingResourceTest { +public class PersonResource1_9Test extends BaseDelegatingResourceTest { @Override public Person newObject() { @@ -75,18 +75,18 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PERSON_UUID; + return RestTestConstants1_9.PERSON_UUID; } @Test public void getAttributes_shouldReturnAllAttributes() throws Exception { - PersonResource1_8 resource = getResource(); + PersonResource1_9 resource = getResource(); - List attributes1 = PersonResource1_8.getAttributes(resource + List attributes1 = PersonResource1_9.getAttributes(resource .getByUniqueId("df8ae447-6745-45be-b859-403241d9913c")); Assert.assertEquals(2, attributes1.size()); - List attributes2 = PersonResource1_8.getAttributes(resource + List attributes2 = PersonResource1_9.getAttributes(resource .getByUniqueId("341b4e41-790c-484f-b6ed-71dc8da222de")); Assert.assertEquals(3, attributes2.size()); } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PrivilegeResource1_9Test.java similarity index 93% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PrivilegeResource1_9Test.java index 0d931aa01..8389c3ba0 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/PrivilegeResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/PrivilegeResource1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import java.util.UUID; @@ -15,7 +15,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class PrivilegeResource1_8Test extends BaseDelegatingResourceTest { +public class PrivilegeResource1_9Test extends BaseDelegatingResourceTest { private String uuid; diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProblemResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProblemResource1_9Test.java index 13a57d75b..abdf8a38d 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProblemResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProblemResource1_9Test.java @@ -16,7 +16,7 @@ import org.openmrs.activelist.Problem; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; @@ -76,7 +76,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PROBLEM_UUID; + return RestTestConstants1_9.PROBLEM_UUID; } @Test diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramResource1_9Test.java similarity index 92% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramResource1_9Test.java index 327556c76..48a9fe0a7 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.Program; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class ProgramResource1_8Test extends BaseDelegatingResourceTest { +public class ProgramResource1_9Test extends BaseDelegatingResourceTest { @Override public Program newObject() { @@ -54,6 +54,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PROGRAM_UUID; + return RestTestConstants1_9.PROGRAM_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowResource1_9Test.java similarity index 90% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowResource1_9Test.java index 6c6537ad9..c11a8e2de 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.ProgramWorkflow; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class ProgramWorkflowResource1_8Test extends BaseDelegatingResourceTest { +public class ProgramWorkflowResource1_9Test extends BaseDelegatingResourceTest { @Override public ProgramWorkflow newObject() { @@ -51,6 +51,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.WORKFLOW_UUID; + return RestTestConstants1_9.WORKFLOW_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowStateResource1_9Test.java similarity index 90% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowStateResource1_9Test.java index 0e7f78498..5fd69a1ab 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/ProgramWorkflowStateResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/ProgramWorkflowStateResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.ProgramWorkflowState; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class ProgramWorkflowStateResource1_8Test extends BaseDelegatingResourceTest { +public class ProgramWorkflowStateResource1_9Test extends BaseDelegatingResourceTest { @Override public ProgramWorkflowState newObject() { @@ -52,6 +52,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.STATE_UUID; + return RestTestConstants1_9.STATE_UUID; } } diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipResource1_9Test.java index 454f50984..337e1bb0d 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipResource1_9Test.java @@ -17,7 +17,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; import java.util.List; @@ -73,7 +73,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.RELATIONSHIP_UUID; + return RestTestConstants1_9.RELATIONSHIP_UUID; } @Test diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipTypeResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipTypeResource1_9Test.java similarity index 90% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipTypeResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipTypeResource1_9Test.java index c45f73d10..f243af57f 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RelationshipTypeResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RelationshipTypeResource1_9Test.java @@ -7,21 +7,21 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.junit.Test; import org.openmrs.RelationshipType; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; /** * Contains tests for the - * {@link org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.RelationShipTypeResource1_8} + * {@link RelationshipTypeResource1_9} */ -public class RelationshipTypeResource1_8Test extends BaseDelegatingResourceTest { +public class RelationshipTypeResource1_9Test extends BaseDelegatingResourceTest { @Override public RelationshipType newObject() { @@ -61,7 +61,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.RELATIONSHIP_TYPE_UUID; + return RestTestConstants1_9.RELATIONSHIP_TYPE_UUID; } @Test diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RoleResource1_9Test.java similarity index 91% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RoleResource1_9Test.java index 213d49e19..201284f0b 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/RoleResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/RoleResource1_9Test.java @@ -7,14 +7,14 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.openmrs.Role; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; -public class RoleResource1_8Test extends BaseDelegatingResourceTest { +public class RoleResource1_9Test extends BaseDelegatingResourceTest { @Override public Role newObject() { @@ -46,6 +46,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.ROLE_UUID; + return RestTestConstants1_9.ROLE_UUID; } } diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/SystemInformationResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemInformationResource1_9Test.java similarity index 98% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/SystemInformationResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemInformationResource1_9Test.java index b03012a5b..80994c04e 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/SystemInformationResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/SystemInformationResource1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.apache.struts.mock.MockHttpServletResponse; import org.junit.Assert; @@ -20,7 +20,7 @@ import java.util.Map; import org.springframework.mock.web.MockHttpServletRequest; -public class SystemInformationResource1_8Test extends BaseModuleWebContextSensitiveTest { +public class SystemInformationResource1_9Test extends BaseModuleWebContextSensitiveTest { private AdministrationService administrationService; diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskDefinitionResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskDefinitionResource1_9Test.java similarity index 93% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskDefinitionResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskDefinitionResource1_9Test.java index 06b450563..6dccceaf0 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/TaskDefinitionResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/TaskDefinitionResource1_9Test.java @@ -7,15 +7,15 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; import org.openmrs.scheduler.TaskDefinition; import java.util.Date; -public class TaskDefinitionResource1_8Test extends BaseDelegatingResourceTest { +public class TaskDefinitionResource1_9Test extends BaseDelegatingResourceTest { @Override public TaskDefinition newObject() { @@ -37,7 +37,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.TASK_DEFINITION_UUID; + return RestTestConstants1_9.TASK_DEFINITION_UUID; } @Override diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UpdateUserResource1_8Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UpdateUserResource1_9Test.java similarity index 90% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UpdateUserResource1_8Test.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UpdateUserResource1_9Test.java index c939146d9..e035e1ba7 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_8/UpdateUserResource1_8Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UpdateUserResource1_9Test.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9; import org.codehaus.jackson.map.ObjectMapper; import org.junit.Assert; @@ -17,7 +17,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.UserAndPassword1_8; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.UserAndPassword1_9; import org.openmrs.web.test.BaseModuleWebContextSensitiveTest; import java.util.HashMap; @@ -26,14 +26,14 @@ /** * Integration tests for the framework that lets a resource handle an entire class hierarchy */ -public class UpdateUserResource1_8Test extends BaseModuleWebContextSensitiveTest { +public class UpdateUserResource1_9Test extends BaseModuleWebContextSensitiveTest { - private UserResource1_8 resource; + private UserResource1_9 resource; @Before public void beforeEachTests() throws Exception { - resource = (UserResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( - UserAndPassword1_8.class); + resource = (UserResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( + UserAndPassword1_9.class); } @Test diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UserResource1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UserResource1_9Test.java index 43786a1cb..9450edf4a 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UserResource1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs1_9/UserResource1_9Test.java @@ -19,20 +19,19 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.RestUtil; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.UserResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.UserAndPassword1_8; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.UserAndPassword1_9; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; -public class UserResource1_9Test extends BaseDelegatingResourceTest { +public class UserResource1_9Test extends BaseDelegatingResourceTest { @Override - public UserAndPassword1_8 newObject() { - UserAndPassword1_8 userAndPassword = new UserAndPassword1_8(Context.getUserService() + public UserAndPassword1_9 newObject() { + UserAndPassword1_9 userAndPassword = new UserAndPassword1_9(Context.getUserService() .getUserByUuid(getUuidProperty())); userAndPassword.setPassword("topsecret"); return userAndPassword; @@ -72,7 +71,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.USER_UUID; + return RestTestConstants1_9.USER_UUID; } /** @@ -115,7 +114,7 @@ private void assertSearch(final String userName, final Collection roles, request.addParameter("q", userName); if (roles != null) { final String rolesAsCommaSeparatedString = StringUtils.join(roles, ","); - request.addParameter(UserResource1_8.PARAMETER_ROLES, rolesAsCommaSeparatedString); + request.addParameter(UserResource1_9.PARAMETER_ROLES, rolesAsCommaSeparatedString); } final RequestContext context = RestUtil.getRequestContext(request, new MockHttpServletResponse()); diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/EncounterSearchHandler1_9Test.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/EncounterSearchHandler1_9Test.java index 0af61da9c..aa7e9ea8a 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/EncounterSearchHandler1_9Test.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/EncounterSearchHandler1_9Test.java @@ -14,7 +14,6 @@ import org.openmrs.Encounter; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; import org.openmrs.module.webservices.rest.web.v1_0.controller.RestControllerTestUtils; @@ -45,7 +44,7 @@ public void shouldReturnEncountersWithNumericObsValues() throws Exception { req.addParameter("s", "byObs"); req.addParameter("patient", RestTestConstants1_9.PATIENT_WITH_OBS_UUID); // CD4 count concept - req.addParameter("obsConcept", RestTestConstants1_8.CONCEPT_NUMERIC_UUID); + req.addParameter("obsConcept", RestTestConstants1_9.CONCEPT_NUMERIC_UUID); req.addParameter("obsValues", "150,175"); SimpleObject result = deserialize(handle(req)); @@ -161,7 +160,7 @@ public void shouldThrowExceptionForInvalidNumericConcept() throws Exception { req.addParameter("s", "byObs"); req.addParameter("patient", RestTestConstants1_9.PATIENT_WITH_OBS_UUID); // CD4 count concept - req.addParameter("obsConcept", RestTestConstants1_8.CONCEPT_NUMERIC_UUID); + req.addParameter("obsConcept", RestTestConstants1_9.CONCEPT_NUMERIC_UUID); req.addParameter("obsValues", "abc,175"); handle(req); diff --git a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/FormSearchHandlerTest.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/FormSearchHandlerTest.java similarity index 95% rename from omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/FormSearchHandlerTest.java rename to omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/FormSearchHandlerTest.java index afa5ea024..f9ad8988e 100644 --- a/omod-1.8/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_8/FormSearchHandlerTest.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/FormSearchHandlerTest.java @@ -7,7 +7,7 @@ * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS * graphic logo is a trademark of OpenMRS Inc. */ -package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_8; +package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9; import java.util.List; @@ -17,7 +17,7 @@ import org.openmrs.api.FormService; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -41,7 +41,7 @@ public String getURI() { @Override public String getUuid() { - return RestTestConstants1_8.FORM_UUID; + return RestTestConstants1_9.FORM2_UUID; } @Override @@ -51,7 +51,7 @@ public long getAllCount() { /** * @verifies return location by tag uuid - * @see FormSearchHandler1_8#getSearchConfig() + * @see FormSearchHandler1_9#getSearchConfig() */ @Test public void getSearchConfig_shouldReturnPublishedForms() throws Exception { diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/LocationSearchHandlerTest.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/LocationSearchHandlerTest.java new file mode 100644 index 000000000..7122908e6 --- /dev/null +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/LocationSearchHandlerTest.java @@ -0,0 +1,94 @@ +/** + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under + * the terms of the Healthcare Disclaimer located at http://openmrs.org/license. + * + * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS + * graphic logo is a trademark of OpenMRS Inc. + */ +package org.openmrs.module.webservices.rest.web.v1_0.search.openmrs1_9; + +import org.apache.commons.beanutils.PropertyUtils; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.openmrs.Location; +import org.openmrs.api.LocationService; +import org.openmrs.api.context.Context; +import org.openmrs.module.webservices.rest.SimpleObject; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; +import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; +import org.springframework.mock.web.MockHttpServletRequest; +import org.springframework.web.bind.annotation.RequestMethod; + +import java.util.List; + +public class LocationSearchHandlerTest extends MainResourceControllerTest { + + private LocationService service; + + private static final String LOCATION_TAG_INITIAL_XML = "customLocationTagDataset.xml"; + + @Before + public void init() throws Exception { + service = Context.getLocationService(); + executeDataSet(LOCATION_TAG_INITIAL_XML); + } + + /** + * @see org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest#getURI() + */ + @Override + public String getURI() { + return "location"; + } + + /** + * @see org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest#getAllCount() + */ + @Override + public long getAllCount() { + return service.getAllLocations(false).size(); + } + + /** + * @see org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest#getUuid() + */ + @Override + public String getUuid() { + return RestTestConstants1_9.LOCATION2_UUID; + } + + /** + * @verifies return location by tag uuid + * @see LocationSearchHandler#getSearchConfig() + */ + @Test + public void getSearchConfig_shouldReturnLocationByTagUuid() throws Exception { + MockHttpServletRequest req = request(RequestMethod.GET, getURI()); + req.addParameter("tag", "0940c6d4-47ed-11df-bc8b-001e378eb67e"); + + SimpleObject result = deserialize(handle(req)); + List hits = (List) result.get("results"); + Assert.assertEquals(2, hits.size()); + List locations = service.getAllLocations(); + Assert.assertEquals(service.getLocation(1).getUuid(), PropertyUtils.getProperty(hits.get(0), "uuid")); + Assert.assertEquals(service.getLocation(2).getUuid(), PropertyUtils.getProperty(hits.get(1), "uuid")); + } + + /** + * @verifies return location by tag name + * @see LocationSearchHandler#getSearchConfig() + */ + @Test + public void getSearchConfig_shouldReturnLocationByTagName() throws Exception { + MockHttpServletRequest req = request(RequestMethod.GET, getURI()); + req.addParameter("tag", "General Hospital"); + + SimpleObject result = deserialize(handle(req)); + List hits = (List) result.get("results"); + Assert.assertEquals(1, hits.size()); + Assert.assertEquals(service.getLocation(1).getUuid(), PropertyUtils.getProperty(hits.get(0), "uuid")); + } +} diff --git a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/PatientByIdentifierSearchHandlerTest1_9.java b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/PatientByIdentifierSearchHandlerTest1_9.java index 9fc6981e1..40ed0a7e6 100644 --- a/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/PatientByIdentifierSearchHandlerTest1_9.java +++ b/omod-1.9/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs1_9/PatientByIdentifierSearchHandlerTest1_9.java @@ -14,7 +14,7 @@ import org.junit.Test; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -44,7 +44,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.PATIENT_UUID; + return RestTestConstants1_9.PATIENT_UUID; } @Test diff --git a/omod-1.8/src/test/resources/EncounterWithObsGroup.xml b/omod-1.9/src/test/resources/EncounterWithObsGroup.xml similarity index 100% rename from omod-1.8/src/test/resources/EncounterWithObsGroup.xml rename to omod-1.9/src/test/resources/EncounterWithObsGroup.xml diff --git a/omod-1.8/src/test/resources/EncountersForDifferentTypesWithObservations.xml b/omod-1.9/src/test/resources/EncountersForDifferentTypesWithObservations.xml similarity index 100% rename from omod-1.8/src/test/resources/EncountersForDifferentTypesWithObservations.xml rename to omod-1.9/src/test/resources/EncountersForDifferentTypesWithObservations.xml diff --git a/omod-1.8/src/test/resources/PersonControllerTest-otherPersonData.xml b/omod-1.9/src/test/resources/PersonControllerTest-otherPersonData.xml similarity index 100% rename from omod-1.8/src/test/resources/PersonControllerTest-otherPersonData.xml rename to omod-1.9/src/test/resources/PersonControllerTest-otherPersonData.xml diff --git a/omod-1.8/src/test/resources/create_patient.json b/omod-1.9/src/test/resources/create_patient (Copy).json similarity index 100% rename from omod-1.8/src/test/resources/create_patient.json rename to omod-1.9/src/test/resources/create_patient (Copy).json diff --git a/omod-1.9/src/test/resources/create_patient.json b/omod-1.9/src/test/resources/create_patient.json new file mode 100644 index 000000000..61214ccc4 --- /dev/null +++ b/omod-1.9/src/test/resources/create_patient.json @@ -0,0 +1,58 @@ +{ + "identifiers": [ + { + "identifier": "id-B", + "identifierType": { + "uuid": "1a339fe9-38bc-4ab3-b180-320988c0b968" + }, + "location": { + "uuid": "8d6c993e-c2cc-11de-8d13-0010c6dffd0f" + }, + "preferred": true + } + ], + "person": { + "gender": "F", + "age": 33, + "birthdate": "1979-12-08T00:00:00.000+0530", + "birthdateEstimated": false, + "dead": false, + "names": [ + { + "givenName": "Ram", + "middleName": null, + "familyName": "Kabir", + "familyName2": null, + "voided": false, + "preferred": true + } + ], + "addresses": [ + { + "preferred": true, + "address1": null, + "address2": null, + "cityVillage": "Khodri", + "stateProvince": null, + "country": null, + "postalCode": null, + "countyDistrict": null, + "address3": null, + "address4": null, + "address5": null, + "address6": null, + "latitude": null, + "longitude": null, + "voided": false + } + ], + "attributes": [ + { + "value": "Bangalore", + "attributeType": { + "uuid": "54fc8400-1683-4d71-a1ac-98d40836ff7c" + } + } + ] + } +} \ No newline at end of file diff --git a/omod-1.8/src/test/resources/customActiveListTest.xml b/omod-1.9/src/test/resources/customActiveListTest.xml similarity index 100% rename from omod-1.8/src/test/resources/customActiveListTest.xml rename to omod-1.9/src/test/resources/customActiveListTest.xml diff --git a/omod-1.8/src/test/resources/customConceptDataset.xml b/omod-1.9/src/test/resources/customConceptDataset.xml similarity index 100% rename from omod-1.8/src/test/resources/customConceptDataset.xml rename to omod-1.9/src/test/resources/customConceptDataset.xml diff --git a/omod-1.8/src/test/resources/customLocationTagDataset.xml b/omod-1.9/src/test/resources/customLocationTagDataset.xml similarity index 100% rename from omod-1.8/src/test/resources/customLocationTagDataset.xml rename to omod-1.9/src/test/resources/customLocationTagDataset.xml diff --git a/omod-1.8/src/test/resources/customRelationshipTypes1_8.xml b/omod-1.9/src/test/resources/customRelationshipTypes1_8.xml similarity index 100% rename from omod-1.8/src/test/resources/customRelationshipTypes1_8.xml rename to omod-1.9/src/test/resources/customRelationshipTypes1_8.xml diff --git a/omod-1.8/src/test/resources/customTestDataset.xml b/omod-1.9/src/test/resources/customTestDataset.xml similarity index 100% rename from omod-1.8/src/test/resources/customTestDataset.xml rename to omod-1.9/src/test/resources/customTestDataset.xml diff --git a/omod-1.8/src/test/resources/formTestDataSet.xml b/omod-1.9/src/test/resources/formTestDataSet.xml similarity index 100% rename from omod-1.8/src/test/resources/formTestDataSet.xml rename to omod-1.9/src/test/resources/formTestDataSet.xml diff --git a/omod-1.8/src/test/resources/loctag_data.xml b/omod-1.9/src/test/resources/loctag_data.xml similarity index 100% rename from omod-1.8/src/test/resources/loctag_data.xml rename to omod-1.9/src/test/resources/loctag_data.xml diff --git a/omod-1.8/src/test/resources/numericConcept.xml b/omod-1.9/src/test/resources/numericConcept.xml similarity index 100% rename from omod-1.8/src/test/resources/numericConcept.xml rename to omod-1.9/src/test/resources/numericConcept.xml diff --git a/omod-1.8/src/test/resources/obsWithGroupMembers.xml b/omod-1.9/src/test/resources/obsWithGroupMembers.xml similarity index 100% rename from omod-1.8/src/test/resources/obsWithGroupMembers.xml rename to omod-1.9/src/test/resources/obsWithGroupMembers.xml diff --git a/omod-1.8/src/test/resources/org/openmrs/module/webservices/rest/include/mockModule.omod b/omod-1.9/src/test/resources/org/openmrs/module/webservices/rest/include/mockModule.omod similarity index 100% rename from omod-1.8/src/test/resources/org/openmrs/module/webservices/rest/include/mockModule.omod rename to omod-1.9/src/test/resources/org/openmrs/module/webservices/rest/include/mockModule.omod diff --git a/omod-1.9/src/test/resources/org/openmrs/module/webservices/rest/include/mockModule/mock.omod b/omod-1.9/src/test/resources/org/openmrs/module/webservices/rest/include/mockModule/mock.omod new file mode 100644 index 000000000..e69de29bb diff --git a/omod-1.8/src/test/resources/personAttributeTypeWithConcept.xml b/omod-1.9/src/test/resources/personAttributeTypeWithConcept.xml similarity index 100% rename from omod-1.8/src/test/resources/personAttributeTypeWithConcept.xml rename to omod-1.9/src/test/resources/personAttributeTypeWithConcept.xml diff --git a/omod-1.8/src/test/resources/resourceTestDataset.xml b/omod-1.9/src/test/resources/resourceTestDataset.xml similarity index 100% rename from omod-1.8/src/test/resources/resourceTestDataset.xml rename to omod-1.9/src/test/resources/resourceTestDataset.xml diff --git a/omod-1.8/src/test/resources/update_patient.json b/omod-1.9/src/test/resources/update_patient.json similarity index 100% rename from omod-1.8/src/test/resources/update_patient.json rename to omod-1.9/src/test/resources/update_patient.json diff --git a/omod-1.8/src/test/resources/update_user.json b/omod-1.9/src/test/resources/update_user.json similarity index 100% rename from omod-1.8/src/test/resources/update_user.json rename to omod-1.9/src/test/resources/update_user.json diff --git a/omod-2.0/pom.xml b/omod-2.0/pom.xml index 4ea6c8f83..299ab2bad 100644 --- a/omod-2.0/pom.xml +++ b/omod-2.0/pom.xml @@ -28,20 +28,6 @@ tests test - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - ${project.parent.groupId} diff --git a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptDatatypeResource2_0.java b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptDatatypeResource2_0.java index f7667f170..c4799759b 100644 --- a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptDatatypeResource2_0.java +++ b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptDatatypeResource2_0.java @@ -14,14 +14,14 @@ import org.openmrs.module.webservices.rest.web.annotation.Resource; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptDatatypeResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ConceptDatatypeResource1_9; /** * {@link Resource} for {@link ConceptDatatype}, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/conceptdatatype", supportedClass = ConceptDatatype.class, supportedOpenmrsVersions = { "2.0.* - 9.*" }) -public class ConceptDatatypeResource2_0 extends ConceptDatatypeResource1_8 { +public class ConceptDatatypeResource2_0 extends ConceptDatatypeResource1_9 { /** * @see DelegatingCrudResource#save(java.lang.Object) diff --git a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptSourceResource2_0.java b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptSourceResource2_0.java index 17739a445..e0fc4d995 100644 --- a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptSourceResource2_0.java +++ b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptSourceResource2_0.java @@ -15,13 +15,13 @@ import org.openmrs.module.webservices.rest.web.RestConstants; import org.openmrs.module.webservices.rest.web.annotation.Resource; import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.ConceptSourceResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.ConceptSourceResource1_9; /** * {@link Resource} for {@link ConceptSource}, supporting standard CRUD operations */ @Resource(name = RestConstants.VERSION_1 + "/conceptsource", supportedClass = ConceptSource.class, supportedOpenmrsVersions = { "2.0.*" }) -public class ConceptSourceResource2_0 extends ConceptSourceResource1_8 { +public class ConceptSourceResource2_0 extends ConceptSourceResource1_9 { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) diff --git a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientIdentifierTypeResource2_0.java b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientIdentifierTypeResource2_0.java index 7f5cfa719..fad87d8a1 100644 --- a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientIdentifierTypeResource2_0.java +++ b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientIdentifierTypeResource2_0.java @@ -14,14 +14,14 @@ import org.openmrs.module.webservices.rest.web.annotation.Resource; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientIdentifierTypeResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PatientIdentifierTypeResource1_9; /** * Allows standard CRUD for the {@link PatientIdentifierType} domain object */ @Resource(name = RestConstants.VERSION_1 + "/patientidentifiertype", supportedClass = PatientIdentifierType.class, supportedOpenmrsVersions = { "2.0.* - 9.*" }) -public class PatientIdentifierTypeResource2_0 extends PatientIdentifierTypeResource1_8 { +public class PatientIdentifierTypeResource2_0 extends PatientIdentifierTypeResource1_9 { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) diff --git a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonAddressResource2_0.java b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonAddressResource2_0.java index 9dbb6eae8..d9ec548ee 100644 --- a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonAddressResource2_0.java +++ b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonAddressResource2_0.java @@ -16,15 +16,15 @@ import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PersonAddressResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PersonResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PersonAddressResource1_9; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PersonResource1_9; /** * {@link Resource} for PersonAddress, supporting standard CRUD operations */ -@SubResource(parent = PersonResource1_8.class, path = "address", supportedClass = PersonAddress.class, supportedOpenmrsVersions = { +@SubResource(parent = PersonResource1_9.class, path = "address", supportedClass = PersonAddress.class, supportedOpenmrsVersions = { "2.0.* - 9.*" }) -public class PersonAddressResource2_0 extends PersonAddressResource1_8 { +public class PersonAddressResource2_0 extends PersonAddressResource1_9 { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) diff --git a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonNameResource2_0.java b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonNameResource2_0.java index d744480d9..13e270047 100644 --- a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonNameResource2_0.java +++ b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonNameResource2_0.java @@ -16,10 +16,10 @@ import org.openmrs.layout.name.NameTemplate; import org.openmrs.module.webservices.rest.web.annotation.SubResource; import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_11.PersonResource1_11; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PersonNameResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PersonNameResource1_9; @SubResource(parent = PersonResource1_11.class, path = "name", supportedClass = PersonName.class, supportedOpenmrsVersions = { "2.0.*" }) -public class PersonNameResource2_0 extends PersonNameResource1_8 { +public class PersonNameResource2_0 extends PersonNameResource1_9 { @Override public String getDisplayString(PersonName personName) { diff --git a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/UserResource2_0.java b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/UserResource2_0.java index 7d2868fdb..85667e951 100644 --- a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/UserResource2_0.java +++ b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/UserResource2_0.java @@ -15,15 +15,15 @@ import org.openmrs.module.webservices.rest.web.annotation.Resource; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.UserResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.UserAndPassword1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.UserResource1_9; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.UserAndPassword1_9; /** * {@link Resource} for User, supporting standard CRUD operations */ -@Resource(name = RestConstants.VERSION_1 + "/user", supportedClass = UserAndPassword1_8.class, supportedOpenmrsVersions = { +@Resource(name = RestConstants.VERSION_1 + "/user", supportedClass = UserAndPassword1_9.class, supportedOpenmrsVersions = { "2.0.* - 9.*" }) -public class UserResource2_0 extends UserResource1_8 { +public class UserResource2_0 extends UserResource1_9 { /** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#getRepresentationDescription(org.openmrs.module.webservices.rest.web.representation.Representation) @@ -41,13 +41,13 @@ public DelegatingResourceDescription getRepresentationDescription(Representation * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#save(java.lang.Object) */ @Override - public UserAndPassword1_8 save(UserAndPassword1_8 user) { + public UserAndPassword1_9 save(UserAndPassword1_9 user) { final User savedUser = createOrUpdateUser(user); refreshAuthenticatedUserIfNeeded(savedUser); - return new UserAndPassword1_8(savedUser); + return new UserAndPassword1_9(savedUser); } - private User createOrUpdateUser(UserAndPassword1_8 user) { + private User createOrUpdateUser(UserAndPassword1_9 user) { final User openmrsUser; if (user.getUser().getUserId() == null) { diff --git a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_0/EncounterSearchHandler2_0.java b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_0/EncounterSearchHandler2_0.java index 5ea5f84a8..2feaa37de 100644 --- a/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_0/EncounterSearchHandler2_0.java +++ b/omod-2.0/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_0/EncounterSearchHandler2_0.java @@ -31,8 +31,8 @@ import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.EncounterTypeResource1_8; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.EncounterTypeResource1_9; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PatientResource1_9; import org.openmrs.parameter.EncounterSearchCriteria; import org.openmrs.parameter.EncounterSearchCriteriaBuilder; import org.springframework.stereotype.Component; @@ -68,9 +68,9 @@ public PageableResult search(RequestContext context) throws ResponseException { Date fromDate = dateFrom != null ? (Date) ConversionUtil.convert(dateFrom, Date.class) : null; Date toDate = dateTo != null ? (Date) ConversionUtil.convert(dateTo, Date.class) : null; - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); - EncounterType encounterType = ((EncounterTypeResource1_8) Context.getService(RestService.class) + EncounterType encounterType = ((EncounterTypeResource1_9) Context.getService(RestService.class) .getResourceBySupportedClass(EncounterType.class)).getByUniqueId(encounterTypeUuid); if (patient != null) { diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/AlertController2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/AlertController2_0Test.java index d6e6b16e0..8340e0c38 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/AlertController2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/AlertController2_0Test.java @@ -17,7 +17,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.openmrs.notification.Alert; import org.openmrs.notification.AlertRecipient; @@ -45,7 +45,7 @@ public class AlertController2_0Test extends MainResourceControllerTest { public void setUp() { this.service = Context.getAlertService(); - User alertRecipient = Context.getUserService().getUserByUuid(RestTestConstants1_8.USER_UUID); + User alertRecipient = Context.getUserService().getUserByUuid(RestTestConstants1_9.USER_UUID); Alert activeAlert = new Alert(); activeAlert.setText("New Alert"); @@ -115,7 +115,7 @@ public void shouldGetAlertByUuid() throws Exception { public void shouldCreateAlert() throws Exception { long originalCount = service.getAllAlerts(true).size(); String json = "{\"text\": \"New alert\",\"satisfiedByAny\": true,\"recipients\": [{\"recipient\":\"" - + RestTestConstants1_8.USER_UUID + "\"}]}"; + + RestTestConstants1_9.USER_UUID + "\"}]}"; SimpleObject newAlert = deserialize(handle(newPostRequest(getURI(), json))); diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/AlertRecipientController2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/AlertRecipientController2_0Test.java index 9ceea4fb3..e3d82c00b 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/AlertRecipientController2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/AlertRecipientController2_0Test.java @@ -13,7 +13,7 @@ import org.junit.Test; import org.openmrs.User; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.openmrs.notification.Alert; import org.openmrs.notification.AlertRecipient; @@ -38,7 +38,7 @@ public class AlertRecipientController2_0Test extends MainResourceControllerTest public void setUp() { this.service = Context.getAlertService(); - User alertRecipient = Context.getUserService().getUserByUuid(RestTestConstants1_8.USER_UUID); + User alertRecipient = Context.getUserService().getUserByUuid(RestTestConstants1_9.USER_UUID); AlertRecipient recipient = new AlertRecipient(alertRecipient, false); recipient.setUuid(getUuid()); @@ -77,7 +77,7 @@ public void shouldAddRecipientToAlert() throws Exception { assertNotNull(existingAlert); assertNull(existingAlert.getRecipients()); - String json = "{\"recipient\": \"" + RestTestConstants1_8.USER_UUID + "\"}"; + String json = "{\"recipient\": \"" + RestTestConstants1_9.USER_UUID + "\"}"; handle(newPostRequest("alert/" + EMPTY_ALERT_UUID + "/recipient", json)); existingAlert = getAlertByUuid(EMPTY_ALERT_UUID); diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptDatatypeController2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptDatatypeController2_0Test.java index 9344d7ad6..a712f8843 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptDatatypeController2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptDatatypeController2_0Test.java @@ -20,7 +20,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; @@ -59,7 +59,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.CONCEPT_DATATYPE_UUID; + return RestTestConstants1_9.CONCEPT_DATATYPE_UUID; } @Test diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptProposalController2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptProposalController2_0Test.java index 7b64aee18..390e39fa6 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptProposalController2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptProposalController2_0Test.java @@ -15,7 +15,7 @@ import org.openmrs.ConceptName; import org.openmrs.ConceptProposal; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.openmrs.util.OpenmrsConstants; @@ -36,7 +36,7 @@ public void before() throws Exception { proposal.setFinalText("final text"); proposal.setState(OpenmrsConstants.CONCEPT_PROPOSAL_UNMAPPED); proposal.setComments("comments"); - proposal.setMappedConcept(Context.getConceptService().getConceptByUuid(RestTestConstants1_8.CONCEPT_UUID)); + proposal.setMappedConcept(Context.getConceptService().getConceptByUuid(RestTestConstants1_9.CONCEPT3_UUID)); Context.getConceptService().saveConceptProposal(proposal); } @@ -78,12 +78,12 @@ public void shouldPurgeProposal() throws Exception { @Test public void shouldUpdateProposal() throws Exception { - String json = "{\"mappedConcept\": \"" + RestTestConstants1_8.CONCEPT2_UUID + "\"}"; + String json = "{\"mappedConcept\": \"" + RestTestConstants1_9.CONCEPT2_UUID + "\"}"; handle(newPostRequest(getURI() + "/" + proposal.getUuid(), json)); ConceptProposal mappedProposal = Context.getConceptService().getConceptProposalByUuid(proposal.getUuid()); - assertEquals(RestTestConstants1_8.CONCEPT2_UUID, mappedProposal.getMappedConcept().getUuid()); + assertEquals(RestTestConstants1_9.CONCEPT2_UUID, mappedProposal.getMappedConcept().getUuid()); } @Test diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptSourceController2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptSourceController2_0Test.java index b5fd1623b..0676edc0c 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptSourceController2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptSourceController2_0Test.java @@ -20,7 +20,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; @@ -58,7 +58,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.CONCEPT_SOURCE_UUID; + return RestTestConstants1_9.CONCEPT_SOURCE_UUID; } @Test diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptStateConversionController2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptStateConversionController2_0Test.java index 7dfb28491..cff2ecf2d 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptStateConversionController2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ConceptStateConversionController2_0Test.java @@ -18,7 +18,7 @@ import org.openmrs.api.ProgramWorkflowService; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import static org.junit.Assert.assertEquals; @@ -31,8 +31,8 @@ public class ConceptStateConversionController2_0Test extends MainResourceControl @Before public void setUp() { - Concept concept = Context.getConceptService().getConceptByUuid(RestTestConstants1_8.CONCEPT2_UUID); - ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflowByUuid(RestTestConstants1_8.WORKFLOW_UUID); + Concept concept = Context.getConceptService().getConceptByUuid(RestTestConstants1_9.CONCEPT2_UUID); + ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflowByUuid(RestTestConstants1_9.WORKFLOW_UUID); ProgramWorkflowState state = new ProgramWorkflowState(); state.setConcept(concept); @@ -75,7 +75,7 @@ public void shouldCreateStateConversion() throws Exception { int countBefore = service.getAllConceptStateConversions().size(); Concept concept = Context.getConceptService().getConceptByUuid("0955b484-b364-43dd-909b-1fa3655eaad2"); - ProgramWorkflow workflow = service.getWorkflowByUuid(RestTestConstants1_8.WORKFLOW_UUID); + ProgramWorkflow workflow = service.getWorkflowByUuid(RestTestConstants1_9.WORKFLOW_UUID); ProgramWorkflowState state = new ProgramWorkflowState(); state.setConcept(concept); @@ -108,7 +108,7 @@ public void shouldPurgeStateConversion() throws Exception { ProgramWorkflowService service = Context.getProgramWorkflowService(); Concept concept = Context.getConceptService().getConceptByUuid("0955b484-b364-43dd-909b-1fa3655eaad2"); - ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflowByUuid(RestTestConstants1_8.WORKFLOW_UUID); + ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflowByUuid(RestTestConstants1_9.WORKFLOW_UUID); ProgramWorkflowState state = new ProgramWorkflowState(); state.setConcept(concept); diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/EncounterController2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/EncounterController2_0Test.java index 3f2321d7b..dad6c6138 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/EncounterController2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/EncounterController2_0Test.java @@ -22,7 +22,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; @@ -93,7 +93,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.ENCOUNTER_UUID; + return RestTestConstants1_9.ENCOUNTER2_UUID; } /** diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ProgramWorkflowController2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ProgramWorkflowController2_0Test.java index 0fa8df59a..5486dcf28 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ProgramWorkflowController2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ProgramWorkflowController2_0Test.java @@ -12,7 +12,7 @@ import org.openmrs.ProgramWorkflow; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.junit.Test; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; @@ -36,7 +36,7 @@ public String getURI() { @Override public String getUuid() { - return RestTestConstants1_8.WORKFLOW_UUID; + return RestTestConstants1_9.WORKFLOW_UUID; } @Override @@ -47,7 +47,7 @@ public long getAllCount() { @Test public void shouldCreateWorkflow() throws Exception { String json = - "{\"program\": \"" + RestTestConstants1_8.PROGRAM_UUID + "\",\"concept\": \"" + RestTestConstants1_8.CONCEPT_UUID + "\"}"; + "{\"program\": \"" + RestTestConstants1_9.PROGRAM_UUID + "\",\"concept\": \"" + RestTestConstants1_9.CONCEPT3_UUID + "\"}"; SimpleObject newWorkflow = deserialize(handle(newPostRequest(getURI(), json))); @@ -55,7 +55,7 @@ public void shouldCreateWorkflow() throws Exception { String uuid = newWorkflow.get("uuid"); ProgramWorkflow createdWorkflow = Context.getProgramWorkflowService().getWorkflowByUuid(uuid); - assertEquals(RestTestConstants1_8.PROGRAM_UUID, createdWorkflow.getProgram().getUuid()); - assertEquals(RestTestConstants1_8.CONCEPT_UUID, createdWorkflow.getConcept().getUuid()); + assertEquals(RestTestConstants1_9.PROGRAM_UUID, createdWorkflow.getProgram().getUuid()); + assertEquals(RestTestConstants1_9.CONCEPT3_UUID, createdWorkflow.getConcept().getUuid()); } } diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ProgramWorkflowStateController2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ProgramWorkflowStateController2_0Test.java index 40655ad71..2f23941ab 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ProgramWorkflowStateController2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/ProgramWorkflowStateController2_0Test.java @@ -14,7 +14,7 @@ import org.openmrs.ProgramWorkflowState; import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; import static org.junit.Assert.assertEquals; @@ -24,7 +24,7 @@ public class ProgramWorkflowStateController2_0Test extends MainResourceControlle @Override public String getURI() { - return "workflow/" + RestTestConstants1_8.WORKFLOW_UUID + "/state/"; + return "workflow/" + RestTestConstants1_9.WORKFLOW_UUID + "/state/"; } @Override @@ -40,7 +40,7 @@ public long getAllCount() { @Test public void shouldCreateWorkflowState() throws Exception { String json = - "{\"concept\": \"" + RestTestConstants1_8.CONCEPT_UUID + "\",\"initial\": true,\"terminal\": false}"; + "{\"concept\": \"" + RestTestConstants1_9.CONCEPT3_UUID + "\",\"initial\": true,\"terminal\": false}"; SimpleObject newWorkflowState = deserialize(handle(newPostRequest(getURI(), json))); @@ -48,7 +48,7 @@ public void shouldCreateWorkflowState() throws Exception { String uuid = newWorkflowState.get("uuid"); ProgramWorkflowState createdWorkflowState = Context.getProgramWorkflowService().getStateByUuid(uuid); - assertEquals(RestTestConstants1_8.CONCEPT_UUID, createdWorkflowState.getConcept().getUuid()); + assertEquals(RestTestConstants1_9.CONCEPT3_UUID, createdWorkflowState.getConcept().getUuid()); assertEquals(true, createdWorkflowState.getInitial()); assertEquals(false, createdWorkflowState.getTerminal()); } @@ -56,10 +56,10 @@ public void shouldCreateWorkflowState() throws Exception { @Test public void shouldDeleteWorkflowState() throws Exception { // create new state - ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflowByUuid(RestTestConstants1_8.WORKFLOW_UUID); + ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflowByUuid(RestTestConstants1_9.WORKFLOW_UUID); ProgramWorkflowState state = new ProgramWorkflowState(); - state.setConcept(Context.getConceptService().getConceptByUuid(RestTestConstants1_8.CONCEPT2_UUID)); + state.setConcept(Context.getConceptService().getConceptByUuid(RestTestConstants1_9.CONCEPT2_UUID)); state.setInitial(true); state.setTerminal(false); @@ -72,7 +72,7 @@ public void shouldDeleteWorkflowState() throws Exception { handle(newDeleteRequest(getURI() + "/" + state.getUuid())); // verify that state has been removed - workflow = Context.getProgramWorkflowService().getWorkflowByUuid(RestTestConstants1_8.WORKFLOW_UUID); + workflow = Context.getProgramWorkflowService().getWorkflowByUuid(RestTestConstants1_9.WORKFLOW_UUID); assertEquals(workflowSizeBefore - 1, workflow.getStates().size()); } } diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/UserController2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/UserController2_0Test.java index 203e9cd68..893a572fc 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/UserController2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_0/UserController2_0Test.java @@ -26,9 +26,8 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.test.Util; import org.openmrs.module.webservices.rest.web.RestConstants; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.UserAndPassword1_8; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.context.request.WebRequest; @@ -302,7 +301,7 @@ public String getURI() { */ @Override public String getUuid() { - return RestTestConstants1_8.USER_UUID; + return RestTestConstants1_9.USER_UUID; } /** diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/AlertRecipientResource2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/AlertRecipientResource2_0Test.java index bb3f876f1..214eafe9b 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/AlertRecipientResource2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/AlertRecipientResource2_0Test.java @@ -10,7 +10,7 @@ package org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_0; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; import org.openmrs.notification.AlertRecipient; @@ -20,7 +20,7 @@ public class AlertRecipientResource2_0Test extends BaseDelegatingResourceTest { @@ -34,6 +34,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.CONCEPT_NUMERIC_UUID; + return RestTestConstants1_9.CONCEPT_NUMERIC_UUID; } } diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptStateConversionResource2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptStateConversionResource2_0Test.java index fb8159cf6..8508d560c 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptStateConversionResource2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/ConceptStateConversionResource2_0Test.java @@ -14,7 +14,7 @@ import org.openmrs.ProgramWorkflow; import org.openmrs.ProgramWorkflowState; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class ConceptStateConversionResource2_0Test @@ -22,8 +22,8 @@ public class ConceptStateConversionResource2_0Test @Override public ConceptStateConversion newObject() { - Concept concept = Context.getConceptService().getConceptByUuid(RestTestConstants1_8.CONCEPT2_UUID); - ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflowByUuid(RestTestConstants1_8.WORKFLOW_UUID); + Concept concept = Context.getConceptService().getConceptByUuid(RestTestConstants1_9.CONCEPT2_UUID); + ProgramWorkflow workflow = Context.getProgramWorkflowService().getWorkflowByUuid(RestTestConstants1_9.WORKFLOW_UUID); ProgramWorkflowState state = new ProgramWorkflowState(); state.setConcept(concept); diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientIdentifierTypeResource2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientIdentifierTypeResource2_0Test.java index f2f43e15c..b182462e4 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientIdentifierTypeResource2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PatientIdentifierTypeResource2_0Test.java @@ -12,7 +12,7 @@ import org.openmrs.PatientIdentifierType; import org.openmrs.api.PatientService; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class PatientIdentifierTypeResource2_0Test extends BaseDelegatingResourceTest { @@ -60,6 +60,6 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PATIENT_IDENTIFIER_TYPE_UUID; + return RestTestConstants1_9.PATIENT_IDENTIFIER_TYPE_UUID; } } diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonAddressResource2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonAddressResource2_0Test.java index 77da9aead..ba733436d 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonAddressResource2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/PersonAddressResource2_0Test.java @@ -11,7 +11,7 @@ import org.openmrs.PersonAddress; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class PersonAddressResource2_0Test extends BaseDelegatingResourceTest { @@ -91,7 +91,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.PERSON_ADDRESS_UUID; + return RestTestConstants1_9.PERSON_ADDRESS_UUID; } } diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/UserResource2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/UserResource2_0Test.java index 965c5777e..9278d1f84 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/UserResource2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_0/UserResource2_0Test.java @@ -19,19 +19,19 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.RequestContext; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.RestUtil; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_8.UserAndPassword1_8; +import org.openmrs.module.webservices.rest.web.v1_0.wrapper.openmrs1_9.UserAndPassword1_9; import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.mock.web.MockHttpServletResponse; -public class UserResource2_0Test extends BaseDelegatingResourceTest { +public class UserResource2_0Test extends BaseDelegatingResourceTest { @Override - public UserAndPassword1_8 newObject() { - UserAndPassword1_8 userAndPassword = new UserAndPassword1_8(Context.getUserService() + public UserAndPassword1_9 newObject() { + UserAndPassword1_9 userAndPassword = new UserAndPassword1_9(Context.getUserService() .getUserByUuid(getUuidProperty())); userAndPassword.setPassword("topsecret"); return userAndPassword; @@ -70,7 +70,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.USER_UUID; + return RestTestConstants1_9.USER_UUID; } /** diff --git a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_0/EncounterSearchHandler2_0Test.java b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_0/EncounterSearchHandler2_0Test.java index 21874d9a0..4b645e6e0 100644 --- a/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_0/EncounterSearchHandler2_0Test.java +++ b/omod-2.0/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_0/EncounterSearchHandler2_0Test.java @@ -15,7 +15,6 @@ import org.junit.Test; import org.openmrs.Encounter; import org.openmrs.module.webservices.rest.SimpleObject; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.v1_0.controller.RestControllerTestUtils; import org.springframework.mock.web.MockHttpServletRequest; @@ -56,7 +55,7 @@ public void search_shouldReturnEncountersWithTotalCountFilteredByPatient() throw public void search_shouldReturnEncountersWithTotalCountFilteredByPatientAndEncounterType() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter("patient", RestTestConstants1_9.PATIENT_WITH_OBS_UUID); - req.addParameter("encounterType", RestTestConstants1_8.ENCOUNTER_TYPE_UUID); + req.addParameter("encounterType", RestTestConstants1_9.ENCOUNTER_TYPE_UUID); req.addParameter("totalCount", String.valueOf(Boolean.TRUE)); SimpleObject result = deserialize(handle(req)); diff --git a/omod-2.1/pom.xml b/omod-2.1/pom.xml index b44251f86..942c14f37 100644 --- a/omod-2.1/pom.xml +++ b/omod-2.1/pom.xml @@ -29,20 +29,6 @@ test - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - - ${project.parent.groupId} ${project.parent.artifactId}-omod-1.9 diff --git a/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortResource2_1.java b/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortResource2_1.java index da424571f..db0c2b6e3 100644 --- a/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortResource2_1.java +++ b/omod-2.1/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/CohortResource2_1.java @@ -19,14 +19,14 @@ import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.CohortResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.CohortResource1_9; /** * In openmrs-core 2.1 we did a complete rewrite of cohort membership, so although the Cohort class * itself didn't change we update the resource here. */ @Resource(name = RestConstants.VERSION_1 + "/cohort", supportedClass = Cohort.class, supportedOpenmrsVersions = { "2.1.* - 9.*" }) -public class CohortResource2_1 extends CohortResource1_8 { +public class CohortResource2_1 extends CohortResource1_9 { @Override public String getResourceVersion() { diff --git a/omod-2.1/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_1/PersonNameController2_1Test.java b/omod-2.1/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_1/PersonNameController2_1Test.java index fdbb9eabd..140f5c83a 100644 --- a/omod-2.1/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_1/PersonNameController2_1Test.java +++ b/omod-2.1/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_1/PersonNameController2_1Test.java @@ -21,8 +21,8 @@ import org.springframework.mock.web.MockHttpServletRequest; import org.springframework.web.bind.annotation.RequestMethod; -import static org.openmrs.module.webservices.rest.web.RestTestConstants1_8.PERSON_NAME_UUID; -import static org.openmrs.module.webservices.rest.web.RestTestConstants1_8.PERSON_UUID; +import static org.openmrs.module.webservices.rest.web.RestTestConstants1_9.PERSON_NAME_UUID; +import static org.openmrs.module.webservices.rest.web.RestTestConstants1_9.PERSON_UUID; /** * Tests functionality of {@link PersonNameController}. diff --git a/omod-2.1/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ObsResource2_1Test.java b/omod-2.1/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ObsResource2_1Test.java index 7a44af965..7a337c326 100644 --- a/omod-2.1/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ObsResource2_1Test.java +++ b/omod-2.1/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_1/ObsResource2_1Test.java @@ -11,7 +11,7 @@ import org.openmrs.Obs; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.resource.impl.BaseDelegatingResourceTest; public class ObsResource2_1Test extends BaseDelegatingResourceTest { @@ -42,7 +42,7 @@ public String getDisplayProperty() { @Override public String getUuidProperty() { - return RestTestConstants1_8.OBS_UUID; + return RestTestConstants1_9.OBS2_UUID; } } diff --git a/omod-2.2/pom.xml b/omod-2.2/pom.xml index b9737bc0d..01e0836fd 100644 --- a/omod-2.2/pom.xml +++ b/omod-2.2/pom.xml @@ -29,20 +29,6 @@ test - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - - ${project.parent.groupId} ${project.parent.artifactId}-omod-2.1 diff --git a/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/ConditionResource2_2.java b/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/ConditionResource2_2.java index eef3438d4..ccaaa2edd 100644 --- a/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/ConditionResource2_2.java +++ b/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/ConditionResource2_2.java @@ -33,7 +33,7 @@ import org.openmrs.module.webservices.rest.web.resource.impl.EmptySearchResult; import org.openmrs.module.webservices.rest.web.resource.impl.NeedsPaging; import org.openmrs.module.webservices.rest.web.response.ResponseException; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PatientResource1_9; /** * {@link Resource} for Condition, supporting standard CRUD operations @@ -241,7 +241,7 @@ protected PageableResult doSearch(RequestContext context) { if (StringUtils.isBlank(patientUuid)) { return new EmptySearchResult(); } - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); if (patient == null) { return new EmptySearchResult(); diff --git a/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/DiagnosisResource2_2.java b/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/DiagnosisResource2_2.java index 4be563061..727efd0b7 100644 --- a/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/DiagnosisResource2_2.java +++ b/omod-2.2/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_2/DiagnosisResource2_2.java @@ -40,7 +40,7 @@ import io.swagger.models.properties.IntegerProperty; import io.swagger.models.properties.RefProperty; import io.swagger.models.properties.StringProperty; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.PatientResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.PatientResource1_9; /** * {@link Resource} for Diagnosis, supporting standard CRUD operations @@ -235,7 +235,7 @@ protected PageableResult doSearch(RequestContext context) { return new EmptySearchResult(); } Date dateFrom = (Date) ConversionUtil.convert(fromDate, Date.class); - Patient patient = ((PatientResource1_8) Context.getService(RestService.class).getResourceBySupportedClass( + Patient patient = ((PatientResource1_9) Context.getService(RestService.class).getResourceBySupportedClass( Patient.class)).getByUniqueId(patientUuid); if (patient == null) { return new EmptySearchResult(); diff --git a/omod-2.2/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_2/ObsController2_2Test.java b/omod-2.2/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_2/ObsController2_2Test.java index 878588840..646c201c5 100644 --- a/omod-2.2/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_2/ObsController2_2Test.java +++ b/omod-2.2/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_2/ObsController2_2Test.java @@ -13,7 +13,7 @@ import org.openmrs.Obs; import org.openmrs.api.ObsService; import org.openmrs.api.context.Context; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ResourceDoesNotSupportOperationException; import org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest; @@ -46,7 +46,7 @@ public long getAllCount() { */ @Override public String getUuid() { - return RestTestConstants1_8.OBS_UUID; + return RestTestConstants1_9.OBS2_UUID; } /** diff --git a/omod-2.2/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_2/OrderSearchHandler2_2Test.java b/omod-2.2/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_2/OrderSearchHandler2_2Test.java index 7e64efc30..a56f7076b 100644 --- a/omod-2.2/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_2/OrderSearchHandler2_2Test.java +++ b/omod-2.2/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/search/openmrs2_2/OrderSearchHandler2_2Test.java @@ -15,7 +15,7 @@ import org.openmrs.module.webservices.rest.SimpleObject; import org.openmrs.module.webservices.rest.web.RequestContext; import org.openmrs.module.webservices.rest.web.RestTestConstants1_10; -import org.openmrs.module.webservices.rest.web.RestTestConstants1_8; +import org.openmrs.module.webservices.rest.web.RestTestConstants1_9; import org.openmrs.module.webservices.rest.web.response.ObjectNotFoundException; import org.openmrs.module.webservices.rest.web.v1_0.RestTestConstants2_2; import org.openmrs.module.webservices.rest.web.v1_0.controller.RestControllerTestUtils; @@ -38,7 +38,7 @@ protected String getURI() { public void getSearchConfig_shouldReturnOrdersByPatientIdentifier() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter("s", "default"); - req.addParameter("patient", RestTestConstants1_8.PATIENT_UUID); + req.addParameter("patient", RestTestConstants1_9.PATIENT_UUID); SimpleObject result = deserialize(handle(req)); List orders = result.get("results"); @@ -160,7 +160,7 @@ public void getSearchConfig_shouldIncludeVoidedOrders() throws Exception { public void getSearchConfig_shouldReturnOrdersMatchingAllCriteria() throws Exception { MockHttpServletRequest req = request(RequestMethod.GET, getURI()); req.addParameter("s", "default"); - req.addParameter("patient", RestTestConstants1_8.PATIENT_UUID); + req.addParameter("patient", RestTestConstants1_9.PATIENT_UUID); req.addParameter("careSetting", RestTestConstants2_2.OUTPATIENT_CARE_SETTING_UUID); req.addParameter("orderTypes", RestTestConstants1_10.DRUG_ORDER_TYPE_UUID); req.addParameter("concepts", RestTestConstants1_10.COUGH_SYRUP_UUID); diff --git a/omod-2.3/pom.xml b/omod-2.3/pom.xml index e19cca7c1..b963eb7dd 100644 --- a/omod-2.3/pom.xml +++ b/omod-2.3/pom.xml @@ -29,20 +29,6 @@ test - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - - ${project.parent.groupId} ${project.parent.artifactId}-omod-1.9 diff --git a/omod-2.4/pom.xml b/omod-2.4/pom.xml index b43706ab8..3d164fc55 100644 --- a/omod-2.4/pom.xml +++ b/omod-2.4/pom.xml @@ -31,20 +31,6 @@ test - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - - ${project.parent.groupId} ${project.parent.artifactId}-omod-1.9 diff --git a/omod-2.4/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_4/TaskDefinitionResource2_4.java b/omod-2.4/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_4/TaskDefinitionResource2_4.java index 9e60987ff..740ce78d5 100644 --- a/omod-2.4/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_4/TaskDefinitionResource2_4.java +++ b/omod-2.4/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/resource/openmrs2_4/TaskDefinitionResource2_4.java @@ -12,12 +12,12 @@ import org.openmrs.module.webservices.helper.TaskServiceWrapper2_4; import org.openmrs.module.webservices.rest.web.RestConstants; import org.openmrs.module.webservices.rest.web.annotation.Resource; -import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_8.TaskDefinitionResource1_8; +import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.TaskDefinitionResource1_9; import org.openmrs.scheduler.TaskDefinition; @Resource(name = RestConstants.VERSION_1 + "/taskdefinition", order = 2, supportedClass = TaskDefinition.class, supportedOpenmrsVersions = { "2.4.* - 9.*" }) -public class TaskDefinitionResource2_4 extends TaskDefinitionResource1_8 { +public class TaskDefinitionResource2_4 extends TaskDefinitionResource1_9 { private TaskServiceWrapper2_4 taskServiceWrapper = new TaskServiceWrapper2_4(); diff --git a/omod-2.4/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_4/TaskActionController2_4Test.java b/omod-2.4/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_4/TaskActionController2_4Test.java index 6fa58d53d..597b2d6c5 100644 --- a/omod-2.4/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_4/TaskActionController2_4Test.java +++ b/omod-2.4/src/test/java/org/openmrs/module/webservices/rest/web/v1_0/controller/openmrs2_4/TaskActionController2_4Test.java @@ -14,7 +14,7 @@ import org.openmrs.api.context.Context; import org.openmrs.module.webservices.helper.TaskServiceWrapper2_4; import org.openmrs.module.webservices.rest.web.api.RestService; -import org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_8.TaskActionController1_8Test; +import org.openmrs.module.webservices.rest.web.v1_0.controller.openmrs1_9.TaskActionController1_9Test; import org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs2_4.TaskDefinitionResource2_4; import org.openmrs.scheduler.SchedulerService; import org.openmrs.scheduler.TaskDefinition; @@ -30,7 +30,7 @@ import static org.openmrs.module.webservices.rest.web.v1_0.RestTestConstants2_4.NURSING_EDUCATION_UUID; import static org.openmrs.module.webservices.rest.web.v1_0.RestTestConstants2_4.TASK_SCHEDULER_XML; -public class TaskActionController2_4Test extends TaskActionController1_8Test { +public class TaskActionController2_4Test extends TaskActionController1_9Test { @Autowired RestService restService; @@ -91,7 +91,7 @@ public void shutdownTask_shouldDoNothingIfTaskAlreadyShutdown() throws Exception @Test public void shouldRunTask() throws Exception { TaskDefinition taskDefinition = getTaskByUuid(CHRONIC_CARE_UUID); - taskDefinition.setTaskClass(TaskActionController1_8Test.DummyTask.class.getName()); + taskDefinition.setTaskClass(TaskActionController1_9Test.DummyTask.class.getName()); assertEquals(4, schedulerService.getRegisteredTasks().size()); int countBefore = count; deserialize(handle(newPostRequest(getURI(), diff --git a/omod-2.5/pom.xml b/omod-2.5/pom.xml index f09d777c9..2dc8d3ea9 100644 --- a/omod-2.5/pom.xml +++ b/omod-2.5/pom.xml @@ -33,20 +33,6 @@ test - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - - ${project.parent.groupId} ${project.parent.artifactId}-omod-1.9 diff --git a/omod/pom.xml b/omod/pom.xml index c5e1978e0..0a8c6b964 100644 --- a/omod/pom.xml +++ b/omod/pom.xml @@ -23,18 +23,6 @@ tests test - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - - - ${project.parent.groupId} - ${project.parent.artifactId}-omod-1.8 - ${project.parent.version} - tests - test - ${project.parent.groupId} ${project.parent.artifactId}-omod-1.9 diff --git a/pom.xml b/pom.xml index 3ecd48a48..1b3c2a007 100644 --- a/pom.xml +++ b/pom.xml @@ -418,7 +418,6 @@ omod-common - omod-1.8 omod-1.9 omod-1.10 omod-1.11 @@ -444,7 +443,6 @@ omod-common - omod-1.8 omod-1.9 omod-1.10 omod-1.11 @@ -492,7 +490,6 @@ omod-common - omod-1.8 omod-1.9 omod-1.10 omod-1.11