=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java 2012-11-12 12:47:02 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/GetDataValuesForDataSetAction.java 2013-01-28 09:58:12 +0000 @@ -190,20 +190,21 @@ // Data values & Min-max data elements // --------------------------------------------------------------------- - if ( !multiOrganisationUnit ) - { - dataValues = dataValueService.getDataValues( organisationUnit, period, dataSet.getDataElements() ); - minMaxDataElements = minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataSet.getDataElements() ); - } - else + dataValues.addAll( dataValueService.getDataValues( organisationUnit, period, dataSet.getDataElements() ) ); + minMaxDataElements.addAll( minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataSet + .getDataElements() ) ); + + if ( multiOrganisationUnit ) { for ( OrganisationUnit ou : children ) { - // make sure that the orgUnit have this dataSet (the same data elements can be contained in another dataSet) + // make sure that the orgUnit have this dataSet (the same data + // elements can be contained in another dataSet) if ( ou.getDataSets().contains( dataSet ) ) { dataValues.addAll( dataValueService.getDataValues( ou, period, dataSet.getDataElements() ) ); - minMaxDataElements.addAll( minMaxDataElementService.getMinMaxDataElements( ou, dataSet.getDataElements() ) ); + minMaxDataElements.addAll( minMaxDataElementService.getMinMaxDataElements( ou, dataSet + .getDataElements() ) ); } } } @@ -216,7 +217,8 @@ { if ( !multiOrganisationUnit ) { - CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, organisationUnit ); + CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, + period, organisationUnit ); if ( registration != null ) { @@ -231,7 +233,8 @@ { complete = true; - // if this is multiOrg, and one of the children is locked. Then just lock everything down. + // if this is multiOrg, and one of the children is locked. Then + // just lock everything down. for ( OrganisationUnit ou : children ) { if ( ou.getDataSets().contains( dataSet ) ) @@ -243,7 +246,8 @@ break; } - CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( dataSet, period, ou ); + CompleteDataSetRegistration registration = registrationService.getCompleteDataSetRegistration( + dataSet, period, ou ); if ( complete && registration == null ) { === modified file 'local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/de/action/GetDataValuesForDataSetAction.java' --- local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/de/action/GetDataValuesForDataSetAction.java 2013-01-10 10:13:56 +0000 +++ local/vn/dhis-web-spreadsheet-reporting/src/main/java/org/hisp/dhis/reportsheet/de/action/GetDataValuesForDataSetAction.java 2013-01-28 09:58:12 +0000 @@ -215,72 +215,70 @@ // Data values & Min-max data elements // --------------------------------------------------------------------- - if ( !multiOrganisationUnit ) - { - dataValues.addAll( dataValueService.getDataValues( organisationUnit, period, dataSet.getDataElements() ) ); - minMaxDataElements = minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataSet - .getDataElements() ); - - // --------------------------------------------------------------------- - // Modified 1 - // --------------------------------------------------------------------- - - Set compulsoryElements = new HashSet(); - - for ( DataElementOperand operand : dataSet.getCompulsoryDataElementOperands() ) - { - compulsoryElements.add( operand.getDataElement() ); - } - - for ( DataValue dv : dataValues ) - { - Iterator iterator = compulsoryElements.iterator(); - - while ( iterator.hasNext() ) - { - if ( iterator.next().equals( dv.getDataElement() ) ) - { - iterator.remove(); - } - } - } - - if ( !compulsoryElements.isEmpty() ) - { - Collection periods = localPeriodService.getPreviousPeriods( period ); - - Collection previousDataValues = localDataValueService.getDataValues( organisationUnit, - compulsoryElements, periods ); - - Map dataValueMap = new HashMap(); - - for ( DataValue dv : previousDataValues ) - { - String key = dv.getDataElement().getId() + SEPARATE + dv.getOptionCombo().getId(); - - if ( !dataValueMap.containsKey( key ) - || dv.getPeriod().getStartDate().after( dataValueMap.get( key ).getPeriod().getStartDate() ) ) - { - dataValueMap.put( key, dv ); - } - } - - if ( !dataValueMap.isEmpty() ) - { - dataValues.addAll( dataValueMap.values() ); - } - - periods = null; - previousDataValues = null; - dataValueMap = null; - compulsoryElements = null; - } - - // --------------------------------------------------------------------- - // End of modified 1 - // --------------------------------------------------------------------- - } - else + dataValues.addAll( dataValueService.getDataValues( organisationUnit, period, dataSet.getDataElements() ) ); + minMaxDataElements.addAll( minMaxDataElementService.getMinMaxDataElements( organisationUnit, dataSet + .getDataElements() ) ); + + // --------------------------------------------------------------------- + // Modified 1 + // --------------------------------------------------------------------- + + Set compulsoryElements = new HashSet(); + + for ( DataElementOperand operand : dataSet.getCompulsoryDataElementOperands() ) + { + compulsoryElements.add( operand.getDataElement() ); + } + + for ( DataValue dv : dataValues ) + { + Iterator iterator = compulsoryElements.iterator(); + + while ( iterator.hasNext() ) + { + if ( iterator.next().equals( dv.getDataElement() ) ) + { + iterator.remove(); + } + } + } + + if ( !compulsoryElements.isEmpty() ) + { + Collection periods = localPeriodService.getPreviousPeriods( period ); + + Collection previousDataValues = localDataValueService.getDataValues( organisationUnit, + compulsoryElements, periods ); + + Map dataValueMap = new HashMap(); + + for ( DataValue dv : previousDataValues ) + { + String key = dv.getDataElement().getId() + SEPARATE + dv.getOptionCombo().getId(); + + if ( !dataValueMap.containsKey( key ) + || dv.getPeriod().getStartDate().after( dataValueMap.get( key ).getPeriod().getStartDate() ) ) + { + dataValueMap.put( key, dv ); + } + } + + if ( !dataValueMap.isEmpty() ) + { + dataValues.addAll( dataValueMap.values() ); + } + + periods = null; + previousDataValues = null; + dataValueMap = null; + compulsoryElements = null; + } + + // --------------------------------------------------------------------- + // End of modified 1 + // --------------------------------------------------------------------- + + if ( multiOrganisationUnit ) { for ( OrganisationUnit ou : children ) { @@ -296,14 +294,14 @@ // Modified 2 // --------------------------------------------------------------------- - Set compulsoryElements = new HashSet(); + Set compulsoryElements2 = new HashSet(); for ( DataElementOperand operand : dataSet.getCompulsoryDataElementOperands() ) { - compulsoryElements.add( operand.getDataElement() ); + compulsoryElements2.add( operand.getDataElement() ); } - Iterator iterator = compulsoryElements.iterator(); + Iterator iterator = compulsoryElements2.iterator(); for ( DataValue dv : dataValues ) { @@ -316,12 +314,12 @@ } } - if ( !compulsoryElements.isEmpty() ) + if ( !compulsoryElements2.isEmpty() ) { Collection periods = localPeriodService.getPreviousPeriods( period ); Collection previousDataValues = localDataValueService.getDataValues( ou, - compulsoryElements, periods ); + compulsoryElements2, periods ); Map dataValueMap = new HashMap(); @@ -342,7 +340,7 @@ periods = null; previousDataValues = null; dataValueMap = null; - compulsoryElements = null; + compulsoryElements2 = null; } // ---------------------------------------------------------------------