=== modified file 'dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java' --- dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java 2012-12-18 08:47:37 +0000 +++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java 2012-12-26 08:33:13 +0000 @@ -49,6 +49,7 @@ import org.hisp.dhis.api.mobile.model.DataValue; import org.hisp.dhis.api.mobile.model.Section; import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementOperand; import org.hisp.dhis.dataelement.comparator.DataElementSortOrderComparator; import org.hisp.dhis.dataset.CompleteDataSetRegistration; import org.hisp.dhis.dataset.CompleteDataSetRegistrationService; @@ -93,7 +94,7 @@ private CompleteDataSetRegistrationService registrationService; private CurrentUserService currentUserService; - + private OrganisationUnitService oUnitService; // ------------------------------------------------------------------------- @@ -251,7 +252,6 @@ Section section = new Section(); section.setId( 0 ); section.setName( "" ); - section.setDataElements( getDataElements( locale, dataElements ) ); sectionList.add( section ); } @@ -259,12 +259,26 @@ { for ( org.hisp.dhis.dataset.Section s : sections ) { + Section section = new Section(); section.setId( s.getId() ); section.setName( s.getName() ); - + + //Remove grey fields(in order to not display them on mobile) List dataElementList = getDataElements( locale, s.getDataElements() ); - section.setDataElements( dataElementList ); + + List dataElementListFinal = new ArrayList( dataElementList ); + + int tempI = 0; + for ( int i = 0; i < dataElementList.size(); i++ ) + { + if ( isGreyField( s, dataElementList.get( i ).getId() ) ) + { + dataElementListFinal.remove( i - tempI ); + tempI++; + } + } + section.setDataElements( dataElementListFinal ); sectionList.add( section ); } } @@ -431,6 +445,20 @@ return persistedPeriod; } + private boolean isGreyField( org.hisp.dhis.dataset.Section section, int id ) + { + boolean isGrayField = false; + + for ( DataElementOperand operand : section.getGreyedFields() ) + { + if ( id == operand.getDataElement().getId() ) + { + isGrayField = true; + } + } + return isGrayField; + } + // ------------------------------------------------------------------------- // Dependency setters // ------------------------------------------------------------------------- @@ -476,13 +504,13 @@ { this.registrationService = registrationService; } - + @Required public void setCurrentUserService( CurrentUserService currentUserService ) { this.currentUserService = currentUserService; } - + @Required public void setoUnitService( OrganisationUnitService oUnitService ) { @@ -494,7 +522,7 @@ { Contact contact = new Contact(); - + List listOfContacts = new ArrayList(); List listOfOrgUnit = (List) oUnitService.getAllOrganisationUnits(); @@ -504,11 +532,10 @@ String contactDetail = each.getName() + "/" + each.getPhoneNumber(); listOfContacts.add( contactDetail ); } - + contact.setListOfContacts( listOfContacts ); - + return contact; } - - + } === modified file 'dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java' --- dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2012-12-18 08:47:37 +0000 +++ dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java 2012-12-26 08:33:13 +0000 @@ -105,7 +105,7 @@ public String saveActivityReport2_8( @PathVariable int id, @RequestBody ActivityValue activityValue ) throws NotAllowedException { - //FIXME set the last argument to 0 to fix compilation error + // FIXME set the last argument to 0 to fix compilation error activityReportingService.saveActivityReport( getUnit( id ), activityValue, 0 ); return ACTIVITY_REPORT_UPLOADED; } @@ -212,7 +212,7 @@ public String saveActivityReport( @PathVariable int id, @RequestBody ActivityValue activityValue ) throws NotAllowedException { - //FIXME set the last argument to 0 to fix compilation error + // FIXME set the last argument to 0 to fix compilation error activityReportingService.saveActivityReport( getUnit( id ), activityValue, 0 ); return ACTIVITY_REPORT_UPLOADED; } @@ -223,7 +223,7 @@ throws NotAllowedException { ActivityPlan activityPlan = activityReportingService.getActivitiesByIdentifier( identifier ); - + activityPlan.setClientVersion( DataStreamSerializable.TWO_POINT_NINE ); return activityPlan; } @@ -234,13 +234,14 @@ { return facilityReportingService.getDataSetsForLocale( getUnit( id ), locale ); } - + @RequestMapping( method = RequestMethod.GET, value = "{clientVersion}/orgUnits/{id}/updateContactForMobile" ) @ResponseBody public Contact updateContactForMobile() { return facilityReportingService.updateContactForMobile(); } + // Supportive methods private Collection getLocalStrings( Collection locales )