dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35163
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18054: BUGFIX: Grey fields bug
------------------------------------------------------------
revno: 18054
committer: sherylyn.marie
branch nick: dhis2
timestamp: Tue 2015-01-20 00:40:59 +0800
message:
BUGFIX: Grey fields bug
modified:
dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.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 2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-services/dhis-service-mobile/src/main/java/org/hisp/dhis/mobile/service/FacilityReportingServiceImpl.java 2015-01-19 16:40:59 +0000
@@ -53,6 +53,7 @@
import org.hisp.dhis.api.mobile.model.DataSetValue;
import org.hisp.dhis.api.mobile.model.DataSetValueList;
import org.hisp.dhis.api.mobile.model.DataValue;
+import org.hisp.dhis.api.mobile.model.Model;
import org.hisp.dhis.api.mobile.model.Section;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementOperand;
@@ -290,11 +291,27 @@
for ( int i = 0; i < dataElementList.size(); i++ )
{
- if ( isGreyField( sec, dataElementList.get( i ).getId() ) )
+ List<Model> categoryOptionCombos = dataElementList.get( i ).getCategoryOptionCombos().getModels();
+ List<Model> newCategoryOptionCombos = new ArrayList<Model>();
+
+ for ( int j = 0; j < categoryOptionCombos.size(); j++ )
+ {
+ if ( !isGreyField( sec, dataElementList.get( i ).getId(), categoryOptionCombos.get( j ).getId() ) )
+ {
+ newCategoryOptionCombos.add( categoryOptionCombos.get( j ) );
+ }
+ }
+
+ if ( newCategoryOptionCombos.isEmpty() )
{
dataElementListFinal.remove( i - tempI );
tempI++;
}
+ else
+ {
+ dataElementListFinal.get( i - tempI ).getCategoryOptionCombos()
+ .setModels( newCategoryOptionCombos );
+ }
}
section.setDataElements( dataElementListFinal );
@@ -374,7 +391,7 @@
}
DataElementCategoryOptionCombo optionCombo = categoryService.getDefaultDataElementCategoryOptionCombo();
-
+
CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period,
unit, optionCombo );
@@ -416,7 +433,7 @@
for ( int i = 0; i < periods.size(); i++ )
{
Period period = getPeriod( periods.elementAt( i ), apiDataSet.getPeriodType() );
-
+
if ( period != null )
{
Collection<org.hisp.dhis.dataelement.DataElement> dataElements = apiDataSet.getDataElements();
@@ -436,10 +453,10 @@
DataValue dv = new DataValue();
dv.setCategoryOptComboID( dataValue.getCategoryOptionCombo().getId() );
dv.setClientVersion( dataSet.getClientVersion() );
- dv.setId( dataValue.getDataElement().getId() );
+ dv.setId( dataValue.getDataElement().getId() );
dv.setValue( dataValue.getValue() );
dataSetValue.getDataValues().add( dv );
-
+
}
dataSetValueList.getDataSetValues().add( dataSetValue );
}
@@ -520,11 +537,12 @@
return persistedPeriod;
}
- private boolean isGreyField( org.hisp.dhis.dataset.Section section, int id )
+ private boolean isGreyField( org.hisp.dhis.dataset.Section section, int id, int categoryOptionComboId )
{
for ( DataElementOperand operand : section.getGreyedFields() )
{
- if ( id == operand.getDataElement().getId() )
+ if ( id == operand.getDataElement().getId()
+ && categoryOptionComboId == operand.getCategoryOptionCombo().getId() )
{
return true;
}