Search in sources :

Example 1 with MobileModel

use of org.hisp.dhis.api.mobile.model.MobileModel in project dhis2-core by dhis2.

the class MobileOrganisationUnitController method getAllDataForOrgUnitLWUIT.

@RequestMapping(method = RequestMethod.GET, value = "{clientVersion}/LWUIT/orgUnits/{id}/all")
@ResponseBody
public org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel getAllDataForOrgUnitLWUIT(@PathVariable String clientVersion, @PathVariable int id) {
    org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel mobileModel = new org.hisp.dhis.api.mobile.model.LWUITmodel.MobileModel();
    mobileModel.setClientVersion(clientVersion);
    OrganisationUnit unit = getUnit(id);
    mobileModel.setPrograms(programService.getProgramsLWUIT(unit));
    mobileModel.setServerCurrentDate(new Date());
    mobileModel.setRelationshipTypes(programService.getAllRelationshipTypes());
    return mobileModel;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) MobileModel(org.hisp.dhis.api.mobile.model.MobileModel) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with MobileModel

use of org.hisp.dhis.api.mobile.model.MobileModel in project dhis2-core by dhis2.

the class MobileOrganisationUnitController method getAllDataForOrgUnit.

// For client version 2.9 and higher
@RequestMapping(method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/all")
@ResponseBody
public MobileModel getAllDataForOrgUnit(@PathVariable String clientVersion, @PathVariable int id, @RequestHeader("accept-language") String locale) {
    MobileModel mobileModel = new MobileModel();
    mobileModel.setClientVersion(clientVersion);
    OrganisationUnit unit = getUnit(id);
    // mobileModel.setActivityPlan(
    // activityReportingService.getCurrentActivityPlan( unit, locale ) );
    // mobileModel.setPrograms( programService.getPrograms( unit, locale )
    // );
    mobileModel.setDatasets(facilityReportingService.getMobileDataSetsForUnit(unit, locale));
    mobileModel.setServerCurrentDate(new Date());
    mobileModel.setLocales(getLocalStrings(localeService.getAllLocales()));
    mobileModel.setSmsCommands(this.getMobileSMSCommands(smsCommandService.getJ2MESMSCommands()));
    return mobileModel;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) MobileModel(org.hisp.dhis.api.mobile.model.MobileModel) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with MobileModel

use of org.hisp.dhis.api.mobile.model.MobileModel in project dhis2-core by dhis2.

the class MobileOrganisationUnitController method updatePrograms.

@RequestMapping(method = RequestMethod.POST, value = "{clientVersion}/orgUnits/{id}/activitiyplan")
@ResponseBody
public MobileModel updatePrograms(@PathVariable String clientVersion, @PathVariable int id, @RequestHeader("accept-language") String locale, @RequestBody ModelList programsFromClient) {
    MobileModel model = new MobileModel();
    model.setClientVersion(clientVersion);
    model.setPrograms(programService.updateProgram(programsFromClient, locale, getUnit(id)));
    model.setActivityPlan(activityReportingService.getCurrentActivityPlan(getUnit(id), locale));
    model.setServerCurrentDate(new Date());
    return model;
}
Also used : MobileModel(org.hisp.dhis.api.mobile.model.MobileModel) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 4 with MobileModel

use of org.hisp.dhis.api.mobile.model.MobileModel in project dhis2-core by dhis2.

the class MobileOrganisationUnitController method updatePrograms2_8.

@RequestMapping(method = RequestMethod.POST, value = "orgUnits/{id}/activitiyplan")
@ResponseBody
public MobileModel updatePrograms2_8(@PathVariable int id, @RequestHeader("accept-language") String locale, @RequestBody ModelList programsFromClient) {
    MobileModel model = new MobileModel();
    model.setClientVersion(DataStreamSerializable.TWO_POINT_EIGHT);
    model.setPrograms(programService.updateProgram(programsFromClient, locale, getUnit(id)));
    model.setActivityPlan(activityReportingService.getCurrentActivityPlan(getUnit(id), locale));
    model.setServerCurrentDate(new Date());
    return model;
}
Also used : MobileModel(org.hisp.dhis.api.mobile.model.MobileModel) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 5 with MobileModel

use of org.hisp.dhis.api.mobile.model.MobileModel in project dhis2-core by dhis2.

the class MobileOrganisationUnitController method getAllDataForOrgUnit2_8.

// For client version 2.8 and lower
@RequestMapping(method = RequestMethod.GET, value = "orgUnits/{id}/all")
@ResponseBody
public MobileModel getAllDataForOrgUnit2_8(@PathVariable int id, @RequestHeader("accept-language") String locale) {
    MobileModel mobileModel = new MobileModel();
    mobileModel.setClientVersion(DataStreamSerializable.TWO_POINT_EIGHT);
    OrganisationUnit unit = getUnit(id);
    mobileModel.setActivityPlan(activityReportingService.getCurrentActivityPlan(unit, locale));
    mobileModel.setPrograms(programService.getPrograms(unit, locale));
    mobileModel.setDatasets(facilityReportingService.getMobileDataSetsForUnit(unit, locale));
    mobileModel.setServerCurrentDate(new Date());
    mobileModel.setLocales(getLocalStrings(localeService.getAllLocales()));
    return mobileModel;
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) MobileModel(org.hisp.dhis.api.mobile.model.MobileModel) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Date (java.util.Date)5 MobileModel (org.hisp.dhis.api.mobile.model.MobileModel)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)5 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)3