use of org.hisp.dhis.api.mobile.model.MobileOrgUnitLinks in project dhis2-core by dhis2.
the class OrgUnitsTest method createOrgUnit.
private MobileOrgUnitLinks createOrgUnit() {
MobileOrgUnitLinks orgUnit = new MobileOrgUnitLinks();
orgUnit.setId(1);
orgUnit.setName("name");
orgUnit.setDownloadAllUrl("all");
orgUnit.setUpdateActivityPlanUrl("activitiyplan");
orgUnit.setUploadFacilityReportUrl("dataSets");
orgUnit.setDownloadFacilityReportUrl("dataSetValue");
orgUnit.setUploadActivityReportUrl("activities");
orgUnit.setUpdateDataSetUrl("updateDataSets");
orgUnit.setChangeUpdateDataSetLangUrl("changeLanguageDataSet");
orgUnit.setSearchUrl("search");
orgUnit.setUpdateNewVersionUrl("updateNewVersionUrl");
orgUnit.setSendFeedbackUrl("sendFeedback");
orgUnit.setFindUserUrl("findUser");
orgUnit.setSendMessageUrl("sendMessage");
orgUnit.setDownloadMessageConversationUrl("downloadMessageConversation");
orgUnit.setGetMessageUrl("getMessage");
orgUnit.setReplyMessageUrl("replyMessage");
orgUnit.setDownloadInterpretationUrl("downloadInterpretation");
orgUnit.setPostInterpretationUrl("postInterpretation");
orgUnit.setPostCommentUrl("postComment");
orgUnit.setUpdateContactUrl("updateContactForMobile");
orgUnit.setFindPatientUrl("findPatient");
orgUnit.setRegisterPersonUrl("registerPerson");
orgUnit.setUploadProgramStageUrl("uploadProgramStage");
orgUnit.setEnrollProgramUrl("enrollProgram");
orgUnit.setGetVariesInfoUrl("getVariesInfo");
orgUnit.setAddRelationshipUrl("addRelationship");
orgUnit.setDownloadAnonymousProgramUrl("downloadAnonymousProgram");
orgUnit.setFindProgramUrl("findProgram");
orgUnit.setFindPatientInAdvancedUrl("findPatientInAdvanced");
orgUnit.setFindPatientsUrl("findPatients");
orgUnit.setFindVisitScheduleUrl("findVisitSchedule");
orgUnit.setFindLostToFollowUpUrl("findLostToFollowUp");
orgUnit.setHandleLostToFollowUpUrl("handleLostToFollowUp");
orgUnit.setGenerateRepeatableEventUrl("generateRepeatableEvent");
orgUnit.setUploadSingleEventWithoutRegistration("uploadSingleEventWithoutRegistration");
orgUnit.setCompleteProgramInstanceUrl("completeProgramInstance");
orgUnit.setRegisterRelativeUrl("registerRelative");
return orgUnit;
}
use of org.hisp.dhis.api.mobile.model.MobileOrgUnitLinks in project dhis2-core by dhis2.
the class OrgUnitsTest method testSerialization.
@Test
public void testSerialization() throws IOException {
MobileOrgUnitLinks unit = createOrgUnit();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
OrgUnits units = new OrgUnits();
units.setOrgUnits(Arrays.asList(new MobileOrgUnitLinks[] { unit }));
units.serializeVersion2_10(dos);
dos.flush();
OrgUnits units2 = new OrgUnits();
units2.deSerialize(new DataInputStream(new ByteArrayInputStream(baos.toByteArray())));
List<MobileOrgUnitLinks> unitList = units2.getOrgUnits();
assertEquals(1, unitList.size());
MobileOrgUnitLinks unit2 = unitList.get(0);
assertEquals(unit.getName(), unit2.getName());
assertEquals(unit.getId(), unit2.getId());
}
use of org.hisp.dhis.api.mobile.model.MobileOrgUnitLinks in project dhis2-core by dhis2.
the class OrgUnitTest method testSerialization.
@Test
public void testSerialization() throws IOException {
MobileOrgUnitLinks unit = new MobileOrgUnitLinks();
unit.setId(1);
unit.setName("name");
unit.setDownloadAllUrl("downloadAllUrl");
unit.setDownloadFacilityReportUrl("downloadFacilityReportUrl");
unit.setUpdateActivityPlanUrl("updateActivityPlanUrl");
unit.setUploadFacilityReportUrl("uploadFacilityReportUrl");
unit.setUploadActivityReportUrl("uploadActivityReportUrl");
unit.setUpdateDataSetUrl("updateDataSetUrl");
unit.setChangeUpdateDataSetLangUrl("changeUpdateDataSetLangUrl");
unit.setSearchUrl("search");
unit.setUpdateNewVersionUrl("");
unit.setSendFeedbackUrl("sendFeedbackUrl");
unit.setFindUserUrl("findUserUrl");
unit.setSendMessageUrl("sendMessageUrl");
unit.setDownloadMessageConversationUrl("downloadMessageConversationUrl");
unit.setGetMessageUrl("getMessageUrl");
unit.setReplyMessageUrl("replyMessageUrl");
unit.setDownloadInterpretationUrl("downloadInterpretationUrl");
unit.setPostInterpretationUrl("postInterpretationUrl");
unit.setPostCommentUrl("postCommentUrl");
unit.setUpdateContactUrl("updateContactUrl");
unit.setFindPatientUrl("findPatientUrl");
unit.setUploadProgramStageUrl("uploadProgramStageUrl");
unit.setEnrollProgramUrl("enrollProgramUrl");
unit.setRegisterPersonUrl("registerPersonUrl");
unit.setGetVariesInfoUrl("getVariesInfoUrl");
unit.setAddRelationshipUrl("addRelationshipUrl");
unit.setDownloadAnonymousProgramUrl("downloadAnonymousProgramUrl");
unit.setFindProgramUrl("findProgramUrl");
unit.setFindPatientInAdvancedUrl("findPatientInAdvanced");
unit.setFindPatientsUrl("findPatientsUrl");
unit.setFindVisitScheduleUrl("findVisitSchedule");
unit.setFindLostToFollowUpUrl("findLostToFollowUpUrl");
unit.setHandleLostToFollowUpUrl("handleLostToFollowUpUrl");
unit.setGenerateRepeatableEventUrl("generateRepeatableEventUrl");
unit.setUploadSingleEventWithoutRegistration("uploadSingleEventWithoutRegistration");
unit.setCompleteProgramInstanceUrl("completeProgramInstance");
unit.setRegisterRelativeUrl("registerRelativeUrl");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
unit.serialize(dos);
dos.flush();
MobileOrgUnitLinks unit2 = new MobileOrgUnitLinks();
unit2.deSerialize(new DataInputStream(new ByteArrayInputStream(baos.toByteArray())));
assertEquals(unit.getName(), unit2.getName());
assertEquals(unit.getId(), unit2.getId());
}
use of org.hisp.dhis.api.mobile.model.MobileOrgUnitLinks in project dhis2-core by dhis2.
the class MobileClientController method getOrgUnitsForUser2_8.
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
public OrgUnits getOrgUnitsForUser2_8(HttpServletRequest request) throws NotAllowedException {
User user = currentUserService.getCurrentUser();
if (user == null) {
throw NotAllowedException.NO_USER;
}
Collection<OrganisationUnit> units = user.getOrganisationUnits();
List<MobileOrgUnitLinks> unitList = new ArrayList<>();
for (OrganisationUnit unit : units) {
unitList.add(getOrgUnit(unit, request));
}
OrgUnits orgUnits = new OrgUnits(unitList);
orgUnits.setClientVersion(DataStreamSerializable.TWO_POINT_EIGHT);
return orgUnits;
}
use of org.hisp.dhis.api.mobile.model.MobileOrgUnitLinks in project dhis2-core by dhis2.
the class MobileClientController method getOrgUnit.
private MobileOrgUnitLinks getOrgUnit(OrganisationUnit unit, HttpServletRequest request) {
MobileOrgUnitLinks orgUnit = new MobileOrgUnitLinks();
orgUnit.setId(unit.getId());
orgUnit.setName(unit.getShortName());
orgUnit.setDownloadAllUrl(getUrl(request, unit.getId(), "all"));
orgUnit.setUpdateActivityPlanUrl(getUrl(request, unit.getId(), "activitiyplan"));
orgUnit.setUploadFacilityReportUrl(getUrl(request, unit.getId(), "dataSets"));
orgUnit.setDownloadFacilityReportUrl(getUrl(request, unit.getId(), "dataSetValue"));
orgUnit.setUploadActivityReportUrl(getUrl(request, unit.getId(), "activities"));
orgUnit.setUpdateDataSetUrl(getUrl(request, unit.getId(), "updateDataSets"));
orgUnit.setChangeUpdateDataSetLangUrl(getUrl(request, unit.getId(), "changeLanguageDataSet"));
orgUnit.setSearchUrl(getUrl(request, unit.getId(), "search"));
orgUnit.setUpdateNewVersionUrl(getUrl(request, unit.getId(), "updateNewVersionUrl"));
orgUnit.setSendFeedbackUrl(getUrl(request, unit.getId(), "sendFeedback"));
orgUnit.setFindUserUrl(getUrl(request, unit.getId(), "findUser"));
orgUnit.setSendMessageUrl(getUrl(request, unit.getId(), "sendMessage"));
orgUnit.setDownloadMessageConversationUrl(getUrl(request, unit.getId(), "downloadMessageConversation"));
orgUnit.setGetMessageUrl(getUrl(request, unit.getId(), "getMessage"));
orgUnit.setReplyMessageUrl(getUrl(request, unit.getId(), "replyMessage"));
orgUnit.setDownloadInterpretationUrl(getUrl(request, unit.getId(), "downloadInterpretation"));
orgUnit.setPostInterpretationUrl(getUrl(request, unit.getId(), "postInterpretation"));
orgUnit.setPostCommentUrl(getUrl(request, unit.getId(), "postComment"));
orgUnit.setUpdateContactUrl(getUrl(request, unit.getId(), "updateContactForMobile"));
orgUnit.setFindPatientUrl(getUrl(request, unit.getId(), "findPatient"));
orgUnit.setRegisterPersonUrl(getUrl(request, unit.getId(), "registerPerson"));
orgUnit.setUploadProgramStageUrl(getUrl(request, unit.getId(), "uploadProgramStage"));
orgUnit.setEnrollProgramUrl(getUrl(request, unit.getId(), "enrollProgram"));
orgUnit.setGetVariesInfoUrl(getUrl(request, unit.getId(), "getVariesInfo"));
orgUnit.setAddRelationshipUrl(getUrl(request, unit.getId(), "addRelationship"));
orgUnit.setDownloadAnonymousProgramUrl(getUrl(request, unit.getId(), "downloadAnonymousProgram"));
orgUnit.setFindProgramUrl(getUrl(request, unit.getId(), "findProgram"));
orgUnit.setFindPatientInAdvancedUrl(getUrl(request, unit.getId(), "findPatientInAdvanced"));
orgUnit.setFindPatientsUrl(getUrl(request, unit.getId(), "findPatients"));
orgUnit.setFindVisitScheduleUrl(getUrl(request, unit.getId(), "findVisitSchedule"));
orgUnit.setFindLostToFollowUpUrl(getUrl(request, unit.getId(), "findLostToFollowUp"));
orgUnit.setHandleLostToFollowUpUrl(getUrl(request, unit.getId(), "handleLostToFollowUp"));
orgUnit.setGenerateRepeatableEventUrl(getUrl(request, unit.getId(), "generateRepeatableEvent"));
orgUnit.setUploadSingleEventWithoutRegistration(getUrl(request, unit.getId(), "uploadSingleEventWithoutRegistration"));
orgUnit.setCompleteProgramInstanceUrl(getUrl(request, unit.getId(), "completeProgramInstance"));
orgUnit.setRegisterRelativeUrl(getUrl(request, unit.getId(), "registerRelative"));
// generate URL for download new version
String full = UrlUtils.buildFullRequestUrl(request);
String root = full.substring(0, full.length() - UrlUtils.buildRequestUrl(request).length());
String updateNewVersionUrl = root + "/dhis-web-api-mobile/updateClient.action";
orgUnit.setUpdateNewVersionUrl(updateNewVersionUrl);
return orgUnit;
}
Aggregations