use of org.hisp.dhis.api.mobile.model.MobileOrgUnitLinks in project dhis2-core by dhis2.
the class MobileClientController method getOrgUnitsForUser.
@RequestMapping(method = RequestMethod.GET, value = "/{version:.+}")
@ResponseBody
public OrgUnits getOrgUnitsForUser(HttpServletRequest request, @PathVariable String version) 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(version);
return orgUnits;
}
Aggregations