← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9398: disable grey fields on j2me

 

------------------------------------------------------------
revno: 9398
committer: Lai <lai.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-12-26 15:33:13 +0700
message:
  disable grey fields on j2me
modified:
  dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java
  dhis-2/dhis-web/dhis-web-api-mobile/src/main/java/org/hisp/dhis/api/mobile/controller/MobileOrganisationUnitController.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== 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<DataElement> dataElementList = getDataElements( locale, s.getDataElements() );
-                section.setDataElements( dataElementList );
+
+                List<DataElement> dataElementListFinal = new ArrayList<DataElement>( 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<String> listOfContacts = new ArrayList<String>();
 
         List<OrganisationUnit> listOfOrgUnit = (List<OrganisationUnit>) 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<String> getLocalStrings( Collection<Locale> locales )