dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #22408
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10759: Migrated data set report from data mart to analytics api as data source. Impl support for using o...
------------------------------------------------------------
revno: 10759
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2013-05-03 17:06:31 +0200
message:
Migrated data set report from data mart to analytics api as data source. Impl support for using org unit group sets as filter for data set report.
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportStore.java
dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/AnalyticsDataSetReportStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/JdbcDataSetReportStore.java
dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessOptionsAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GetDataSetReportOptionsAction.java
dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm
dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js
--
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-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportService.java 2012-10-18 19:13:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportService.java 2013-05-03 15:06:31 +0000
@@ -28,12 +28,14 @@
*/
import java.util.List;
+import java.util.Set;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.Period;
/**
@@ -52,9 +54,19 @@
* @param format the i18n format.
* @return
*/
- String getCustomDataSetReport( DataSet dataSet, OrganisationUnit unit, Period period, boolean selectedUnitOnly, I18nFormat format );
-
- List<Grid> getCustomDataSetReportAsGrid( DataSet dataSet, OrganisationUnit unit, Period period,
+ String getCustomDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups, boolean selectedUnitOnly, I18nFormat format );
+
+ /**
+ * Generates a list of Grids based on the HTML code for a custom data set report.
+ *
+ * @param dataSet the data set.
+ * @param unit the organisation unit.
+ * @param period the period.
+ * @param selectedUnitOnly indicates whether to use captured or aggregated data.
+ * @param format the i18n format.
+ * @return
+ */
+ List<Grid> getCustomDataSetReportAsGrid( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups,
boolean selectedUnitOnly, I18nFormat format );
/**
@@ -69,7 +81,7 @@
* @param i18n the i18n object.
* @return a Grid.
*/
- Grid getDefaultDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit, boolean selectedUnitOnly, I18nFormat format, I18n i18n );
+ Grid getDefaultDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups, boolean selectedUnitOnly, I18nFormat format, I18n i18n );
/**
* Generates a list of Grids representing a data set report. The data elements
@@ -83,5 +95,5 @@
* @param i18n the i18n object.
* @return a Grid.
*/
- List<Grid> getSectionDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit, boolean selectedUnitOnly, I18nFormat format, I18n i18n );
+ List<Grid> getSectionDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups, boolean selectedUnitOnly, I18nFormat format, I18n i18n );
}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportStore.java 2012-07-19 19:20:26 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/datasetreport/DataSetReportStore.java 2013-05-03 15:06:31 +0000
@@ -28,9 +28,11 @@
*/
import java.util.Map;
+import java.util.Set;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.Period;
/**
@@ -40,11 +42,11 @@
{
final String SEPARATOR = "-";
- Map<String, Double> getAggregatedValues( DataSet dataSet, Period period, OrganisationUnit unit, boolean rawData );
+ Map<String, Double> getAggregatedValues( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups, boolean rawData );
- Map<String, Double> getAggregatedSubTotals( DataSet dataSet, Period period, OrganisationUnit unit );
-
- Map<String, Double> getAggregatedTotals( DataSet dataSet, Period period, OrganisationUnit unit );
-
- Map<String, Double> getAggregatedIndicatorValues( DataSet dataSet, Period period, OrganisationUnit unit );
+ Map<String, Double> getAggregatedSubTotals( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups );
+
+ Map<String, Double> getAggregatedTotals( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups );
+
+ Map<String, Double> getAggregatedIndicatorValues( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups );
}
=== modified file 'dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java'
--- dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-05-02 20:51:27 +0000
+++ dhis-2/dhis-services/dhis-service-analytics/src/main/java/org/hisp/dhis/analytics/DataQueryParams.java 2013-05-03 15:06:31 +0000
@@ -32,6 +32,7 @@
import static org.hisp.dhis.analytics.DimensionType.ORGANISATIONUNIT;
import static org.hisp.dhis.analytics.DimensionType.ORGANISATIONUNIT_GROUPSET;
import static org.hisp.dhis.common.IdentifiableObjectUtils.asList;
+import static org.hisp.dhis.common.IdentifiableObjectUtils.getList;
import static org.hisp.dhis.system.util.CollectionUtils.emptyIfNull;
import java.util.ArrayList;
@@ -1067,4 +1068,9 @@
{
setFilterOptions( ORGUNIT_DIM_ID, DimensionType.ORGANISATIONUNIT, null, organisationUnits );
}
+
+ public void setFilter( String filter, DimensionType type, IdentifiableObject item )
+ {
+ setFilterOptions( filter, type, null, getList( item ) );
+ }
}
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java 2013-04-25 17:34:28 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/impl/DefaultDataSetReportService.java 2013-05-03 15:06:31 +0000
@@ -60,6 +60,7 @@
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.system.filter.AggregatableDataElementFilter;
import org.hisp.dhis.system.grid.GridUtils;
@@ -100,21 +101,22 @@
// DataSetReportService implementation
// -------------------------------------------------------------------------
- public String getCustomDataSetReport( DataSet dataSet, OrganisationUnit unit, Period period,
+ public String getCustomDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups,
boolean selectedUnitOnly, I18nFormat format )
{
- Map<String, Double> valueMap = dataSetReportStore.getAggregatedValues( dataSet, period, unit, selectedUnitOnly );
- valueMap.putAll( dataSetReportStore.getAggregatedTotals( dataSet, period, unit ) );
-
- Map<String, Double> indicatorValueMap = dataSetReportStore.getAggregatedIndicatorValues( dataSet, period, unit );
+ Map<String, Double> valueMap = dataSetReportStore.getAggregatedValues( dataSet, period, unit, groups, selectedUnitOnly );
+
+ valueMap.putAll( dataSetReportStore.getAggregatedTotals( dataSet, period, unit, groups ) );
+
+ Map<String, Double> indicatorValueMap = dataSetReportStore.getAggregatedIndicatorValues( dataSet, period, unit, groups );
return prepareReportContent( dataSet.getDataEntryForm(), valueMap, indicatorValueMap, format );
}
- public List<Grid> getCustomDataSetReportAsGrid( DataSet dataSet, OrganisationUnit unit, Period period,
+ public List<Grid> getCustomDataSetReportAsGrid( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups,
boolean selectedUnitOnly, I18nFormat format )
{
- String html = getCustomDataSetReport( dataSet, unit, period, selectedUnitOnly, format );
+ String html = getCustomDataSetReport( dataSet, period, unit, groups, selectedUnitOnly, format );
try
{
@@ -126,15 +128,15 @@
}
}
- public List<Grid> getSectionDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit,
+ public List<Grid> getSectionDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups,
boolean selectedUnitOnly, I18nFormat format, I18n i18n )
{
List<Section> sections = new ArrayList<Section>( dataSet.getSections() );
Collections.sort( sections, new SectionOrderComparator() );
- Map<String, Double> valueMap = dataSetReportStore.getAggregatedValues( dataSet, period, unit, selectedUnitOnly );
- Map<String, Double> subTotalMap = dataSetReportStore.getAggregatedSubTotals( dataSet, period, unit );
- Map<String, Double> totalMap = dataSetReportStore.getAggregatedTotals( dataSet, period, unit );
+ Map<String, Double> valueMap = dataSetReportStore.getAggregatedValues( dataSet, period, unit, groups, selectedUnitOnly );
+ Map<String, Double> subTotalMap = dataSetReportStore.getAggregatedSubTotals( dataSet, period, unit, groups );
+ Map<String, Double> totalMap = dataSetReportStore.getAggregatedTotals( dataSet, period, unit, groups );
List<Grid> grids = new ArrayList<Grid>();
@@ -235,15 +237,15 @@
return grids;
}
- public Grid getDefaultDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit, boolean selectedUnitOnly, I18nFormat format, I18n i18n )
+ public Grid getDefaultDataSetReport( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups, boolean selectedUnitOnly, I18nFormat format, I18n i18n )
{
List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
Collections.sort( dataElements, IdentifiableObjectNameComparator.INSTANCE );
FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );
- Map<String, Double> valueMap = dataSetReportStore.getAggregatedValues( dataSet, period, unit, selectedUnitOnly );
- Map<String, Double> indicatorValueMap = dataSetReportStore.getAggregatedIndicatorValues( dataSet, period, unit );
+ Map<String, Double> valueMap = dataSetReportStore.getAggregatedValues( dataSet, period, unit, groups, selectedUnitOnly );
+ Map<String, Double> indicatorValueMap = dataSetReportStore.getAggregatedIndicatorValues( dataSet, period, unit, groups );
// ---------------------------------------------------------------------
// Get category option combos
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/AnalyticsDataSetReportStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/AnalyticsDataSetReportStore.java 2013-05-02 20:55:43 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/AnalyticsDataSetReportStore.java 2013-05-03 15:06:31 +0000
@@ -34,9 +34,11 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import org.hisp.dhis.analytics.AnalyticsService;
import org.hisp.dhis.analytics.DataQueryParams;
+import org.hisp.dhis.analytics.DimensionType;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategory;
import org.hisp.dhis.dataset.DataSet;
@@ -44,6 +46,7 @@
import org.hisp.dhis.datasetreport.DataSetReportStore;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.system.filter.AggregatableDataElementFilter;
import org.hisp.dhis.system.util.FilterUtils;
@@ -60,14 +63,14 @@
{
this.analyticsService = analyticsService;
}
-
+
// -------------------------------------------------------------------------
// DataSetReportStore implementation
// -------------------------------------------------------------------------
@Override
- public Map<String, Double> getAggregatedValues( DataSet dataSet, Period period, OrganisationUnit unit,
- boolean rawData )
+ public Map<String, Double> getAggregatedValues( DataSet dataSet, Period period, OrganisationUnit unit,
+ Set<OrganisationUnitGroup> groups, boolean rawData )
{
List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
@@ -85,6 +88,14 @@
params.setOrganisationUnits( getList( unit ) );
params.enableCategoryOptionCombos();
+ if ( groups != null && !groups.isEmpty() )
+ {
+ for ( OrganisationUnitGroup group : groups )
+ {
+ params.setFilter( group.getGroupSet().getUid(), DimensionType.ORGANISATIONUNIT_GROUPSET, group );
+ }
+ }
+
Map<String, Double> map = analyticsService.getAggregatedDataValueMap( params );
Map<String, Double> dataMap = new HashMap<String, Double>();
@@ -99,7 +110,7 @@
}
@Override
- public Map<String, Double> getAggregatedSubTotals( DataSet dataSet, Period period, OrganisationUnit unit )
+ public Map<String, Double> getAggregatedSubTotals( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups )
{
Map<String, Double> dataMap = new HashMap<String, Double>();
@@ -124,6 +135,14 @@
params.setOrganisationUnits( getList( unit ) );
params.setCategory( category );
+ if ( groups != null && !groups.isEmpty() )
+ {
+ for ( OrganisationUnitGroup group : groups )
+ {
+ params.setFilter( group.getGroupSet().getUid(), DimensionType.ORGANISATIONUNIT_GROUPSET, group );
+ }
+ }
+
Map<String, Double> map = analyticsService.getAggregatedDataValueMap( params );
for ( Entry<String, Double> entry : map.entrySet() )
@@ -138,7 +157,7 @@
}
@Override
- public Map<String, Double> getAggregatedTotals( DataSet dataSet, Period period, OrganisationUnit unit )
+ public Map<String, Double> getAggregatedTotals( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups )
{
List<DataElement> dataElements = new ArrayList<DataElement>( dataSet.getDataElements() );
@@ -154,6 +173,14 @@
params.setDataElements( dataElements );
params.setPeriods( getList( period ) );
params.setOrganisationUnits( getList( unit ) );
+
+ if ( groups != null && !groups.isEmpty() )
+ {
+ for ( OrganisationUnitGroup group : groups )
+ {
+ params.setFilter( group.getGroupSet().getUid(), DimensionType.ORGANISATIONUNIT_GROUPSET, group );
+ }
+ }
Map<String, Double> map = analyticsService.getAggregatedDataValueMap( params );
@@ -169,7 +196,7 @@
}
@Override
- public Map<String, Double> getAggregatedIndicatorValues( DataSet dataSet, Period period, OrganisationUnit unit )
+ public Map<String, Double> getAggregatedIndicatorValues( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups )
{
List<Indicator> indicators = new ArrayList<Indicator>( dataSet.getIndicators() );
@@ -183,6 +210,14 @@
params.setIndicators( indicators );
params.setPeriods( getList( period ) );
params.setOrganisationUnits( getList( unit ) );
+
+ if ( groups != null && !groups.isEmpty() )
+ {
+ for ( OrganisationUnitGroup group : groups )
+ {
+ params.setFilter( group.getGroupSet().getUid(), DimensionType.ORGANISATIONUNIT_GROUPSET, group );
+ }
+ }
Map<String, Double> map = analyticsService.getAggregatedDataValueMap( params );
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/JdbcDataSetReportStore.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/JdbcDataSetReportStore.java 2013-05-02 13:32:45 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/datasetreport/jdbc/JdbcDataSetReportStore.java 2013-05-03 15:06:31 +0000
@@ -44,6 +44,7 @@
import org.hisp.dhis.datasetreport.DataSetReportStore;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.system.filter.AggregatableDataElementFilter;
import org.hisp.dhis.system.util.FilterUtils;
@@ -67,7 +68,8 @@
// DataSetReportStore implementation
// -------------------------------------------------------------------------
- public Map<String, Double> getAggregatedValues( DataSet dataSet, Period period, OrganisationUnit unit, boolean rawData )
+ public Map<String, Double> getAggregatedValues( DataSet dataSet, Period period, OrganisationUnit unit,
+ Set<OrganisationUnitGroup> groups, boolean rawData )
{
Map<String, Double> map = new HashMap<String, Double>();
@@ -109,7 +111,7 @@
return map;
}
- public Map<String, Double> getAggregatedSubTotals( DataSet dataSet, Period period, OrganisationUnit unit )
+ public Map<String, Double> getAggregatedSubTotals( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups )
{
Map<String, Double> map = new HashMap<String, Double>();
@@ -148,7 +150,7 @@
return map;
}
- public Map<String, Double> getAggregatedTotals( DataSet dataSet, Period period, OrganisationUnit unit )
+ public Map<String, Double> getAggregatedTotals( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups )
{
Map<String, Double> map = new HashMap<String, Double>();
@@ -181,7 +183,7 @@
return map;
}
- public Map<String, Double> getAggregatedIndicatorValues( DataSet dataSet, Period period, OrganisationUnit unit )
+ public Map<String, Double> getAggregatedIndicatorValues( DataSet dataSet, Period period, OrganisationUnit unit, Set<OrganisationUnitGroup> groups )
{
Map<String, Double> map = new HashMap<String, Double>();
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-05-02 20:55:43 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-05-03 15:06:31 +0000
@@ -126,7 +126,7 @@
<bean id="org.hisp.dhis.datasetreport.DataSetReportService" class="org.hisp.dhis.datasetreport.impl.DefaultDataSetReportService">
<property name="dataValueService" ref="org.hisp.dhis.datavalue.DataValueService" />
- <property name="dataSetReportStore" ref="org.hisp.dhis.datasetreport.DataSetReportStore" />
+ <property name="dataSetReportStore" ref="org.hisp.dhis.datasetreport.AnalyticsDataSetReportStore" />
</bean>
<bean id="org.hisp.dhis.datasetreport.DataSetReportStore" class="org.hisp.dhis.datasetreport.jdbc.JdbcDataSetReportStore">
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css 2013-05-03 13:06:49 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/css/widgets.css 2013-05-03 15:06:31 +0000
@@ -441,7 +441,7 @@
border: 1px solid #a4d2a3;
background-color: #d5efd5;
padding-top: 10px;
- padding-bottom: 5px;
+ padding-bottom: 10px;
padding-left: 20px;
margin-bottom: 15px;
border-radius: 3px;
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessOptionsAction.java 2013-04-30 11:25:21 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/completeness/action/GetDataCompletenessOptionsAction.java 2013-05-03 15:06:31 +0000
@@ -96,7 +96,7 @@
public String execute()
{
dataSets = new ArrayList<DataSet>( dataSetService.getAllDataSets() );
- groupSets = new ArrayList<OrganisationUnitGroupSet>( organisationUnitGroupService.getCompulsoryOrganisationUnitGroupSets() );
+ groupSets = new ArrayList<OrganisationUnitGroupSet>( organisationUnitGroupService.getAllOrganisationUnitGroupSets() );
Collections.sort( dataSets, IdentifiableObjectNameComparator.INSTANCE );
Collections.sort( groupSets, IdentifiableObjectNameComparator.INSTANCE );
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java 2013-03-19 17:09:10 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GenerateDataSetReportAction.java 2013-05-03 15:06:31 +0000
@@ -31,7 +31,9 @@
import static org.hisp.dhis.dataset.DataSet.TYPE_SECTION;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import javax.servlet.http.HttpServletResponse;
@@ -47,6 +49,8 @@
import org.hisp.dhis.i18n.I18n;
import org.hisp.dhis.i18n.I18nFormat;
import org.hisp.dhis.organisationunit.OrganisationUnit;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
@@ -62,6 +66,8 @@
public class GenerateDataSetReportAction
implements Action
{
+ private static final String SEP = ";";
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -93,6 +99,13 @@
{
this.organisationUnitService = organisationUnitService;
}
+
+ private OrganisationUnitGroupService organisationUnitGroupService;
+
+ public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+ {
+ this.organisationUnitGroupService = organisationUnitGroupService;
+ }
private PeriodService periodService;
@@ -142,6 +155,13 @@
{
this.ou = ou;
}
+
+ private String groups;
+
+ public void setGroups( String groups )
+ {
+ this.groups = groups;
+ }
private boolean selectedUnitOnly;
@@ -186,7 +206,7 @@
{
return selectedPeriod;
}
-
+
private CompleteDataSetRegistration registration;
public CompleteDataSetRegistration getRegistration()
@@ -244,6 +264,23 @@
}
selectedOrgunit = organisationUnitService.getOrganisationUnit( ou );
+
+ Set<OrganisationUnitGroup> ouGroups = new HashSet<OrganisationUnitGroup>();
+
+ if ( groups != null && groups.split( SEP ).length > 0 )
+ {
+ String[] groupIds = groups.split( SEP );
+
+ for ( String groupId : groupIds )
+ {
+ OrganisationUnitGroup group = organisationUnitGroupService.getOrganisationUnitGroup( groupId );
+
+ if ( group != null )
+ {
+ ouGroups.add( group );
+ }
+ }
+ }
String dataSetType = selectedDataSet.getDataSetType();
@@ -253,20 +290,20 @@
{
if ( type != null )
{
- grids = dataSetReportService.getCustomDataSetReportAsGrid( selectedDataSet, selectedOrgunit, selectedPeriod, selectedUnitOnly, format );
+ grids = dataSetReportService.getCustomDataSetReportAsGrid( selectedDataSet, selectedPeriod, selectedOrgunit, ouGroups, selectedUnitOnly, format );
}
else
{
- customDataEntryFormCode = dataSetReportService.getCustomDataSetReport( selectedDataSet, selectedOrgunit, selectedPeriod, selectedUnitOnly, format );
+ customDataEntryFormCode = dataSetReportService.getCustomDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, ouGroups, selectedUnitOnly, format );
}
}
else if ( TYPE_SECTION.equals( dataSetType ) )
{
- grids = dataSetReportService.getSectionDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, selectedUnitOnly, format, i18n );
+ grids = dataSetReportService.getSectionDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, ouGroups, selectedUnitOnly, format, i18n );
}
else
{
- grid = dataSetReportService.getDefaultDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, selectedUnitOnly, format, i18n );
+ grid = dataSetReportService.getDefaultDataSetReport( selectedDataSet, selectedPeriod, selectedOrgunit, ouGroups, selectedUnitOnly, format, i18n );
}
return type != null ? type : dataSetType;
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GetDataSetReportOptionsAction.java'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GetDataSetReportOptionsAction.java 2012-09-03 19:48:33 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/java/org/hisp/dhis/reporting/dataset/action/GetDataSetReportOptionsAction.java 2013-05-03 15:06:31 +0000
@@ -37,6 +37,8 @@
import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.oust.manager.SelectionTreeManager;
import org.hisp.dhis.period.Cal;
@@ -68,7 +70,14 @@
{
this.organisationUnitService = organisationUnitService;
}
-
+
+ private OrganisationUnitGroupService organisationUnitGroupService;
+
+ public void setOrganisationUnitGroupService( OrganisationUnitGroupService organisationUnitGroupService )
+ {
+ this.organisationUnitGroupService = organisationUnitGroupService;
+ }
+
private SelectionTreeManager selectionTreeManager;
public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
@@ -150,6 +159,13 @@
return periodType;
}
+ private List<OrganisationUnitGroupSet> groupSets = new ArrayList<OrganisationUnitGroupSet>();
+
+ public List<OrganisationUnitGroupSet> getGroupSets()
+ {
+ return groupSets;
+ }
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
@@ -174,6 +190,8 @@
selectionTreeManager.setSelectedOrganisationUnit( organisationUnitService.getOrganisationUnit( ou ) ); //TODO set unit state in client instead
}
+
+ groupSets = new ArrayList<OrganisationUnitGroupSet>( organisationUnitGroupService.getAllOrganisationUnitGroupSets() );
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-04-30 11:20:20 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/resources/META-INF/dhis/beans.xml 2013-05-03 15:06:31 +0000
@@ -177,6 +177,7 @@
scope="prototype">
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
<property name="selectionTreeManager" ref="org.hisp.dhis.oust.manager.SelectionTreeManager" />
</bean>
@@ -186,6 +187,7 @@
<property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
<property name="registrationService" ref="org.hisp.dhis.dataset.CompleteDataSetRegistrationService" />
<property name="organisationUnitService" ref="org.hisp.dhis.organisationunit.OrganisationUnitService" />
+ <property name="organisationUnitGroupService" ref="org.hisp.dhis.organisationunit.OrganisationUnitGroupService" />
<property name="periodService" ref="org.hisp.dhis.period.PeriodService" />
</bean>
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm 2013-04-29 13:14:35 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/dataSetReportForm.vm 2013-05-03 15:06:31 +0000
@@ -66,7 +66,9 @@
<input type="button" class="downloadButton" value="$i18n.getString( 'print' )" onclick="window.print()" style="width:140px; display:none;">
</div>
-<div id="criteria" class="inputCriteria" style="width:360px;height:450px;">
+<!-- Data set -->
+
+<div id="criteria" class="inputCriteria" style="width:360px;">
<div class="inputSection">
<label>$i18n.getString( "dataset" )</label><br>
<select id="dataSetId" name="dataSetId" style="width:330px">
@@ -77,6 +79,8 @@
</select>
</div>
+<!-- Period -->
+
<div class="inputSection">
<label>$i18n.getString( "report_period" )</label><br>
<select id="periodType" name="periodType" style="width:174px" onchange="displayPeriods()">
@@ -92,6 +96,8 @@
</select>
</div>
+<!-- Organisation unit -->
+
<div class="inputSection">
<label>$i18n.getString( "use_data_for_selected_unit_only" )</label>
<input type="checkbox" id="selectedUnitOnly" name="selectedUnitOnly" value="true">
@@ -99,9 +105,23 @@
<div class="inputSection">
<label>$i18n.getString( "report_organisation_unit" )</label><br>
-<div id="selectionTree" style="width:328px;height:200px;overflow:auto;border:1px solid #cccccc"></div>
+<div id="selectionTree" style="width:328px; height:200px; overflow:auto; border:1px solid #ccc; margin-bottom: 8px;"></div>
</div>
+<!-- Org unit group sets -->
+
+<div id="advancedOptions" style="display:none">
+#foreach( $groupSet in $groupSets )
+<select name="groupSet" data-uid="${groupSet.uid}" style="width:330px" class="advanced">
+ <option value="">[ $i18n.getString( "select" ) $encoder.htmlEncode( $groupSet.name ) / $i18n.getString( "view_all" ) ]</option>
+ #foreach( $group in $groupSet.organisationUnitGroups )
+ <option value="${group.uid}">$encoder.htmlEncode( $group.name )</option>
+ #end
+</select><br>
+#end </div>
+
+<div id="advancedOptionsLink" style="padding: 8px 0;"><a href="javascript:showAdvancedOptions()">$i18n.getString( "more_options" )</a></div>
+
<div class="inputSection">
<input type="button" value='$i18n.getString( "get_report" )' style="width:120px" onclick="validateDataSetReport()">
<input type="button" value='$i18n.getString( "cancel" )' style="width:120px" onclick="hideCriteria()">
=== modified file 'dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js'
--- dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js 2012-12-04 13:16:24 +0000
+++ dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/dataSetReport.js 2013-05-03 15:06:31 +0000
@@ -9,14 +9,29 @@
function getDataSetReport()
{
var dataSetReport = {
- dataSet: $( "#dataSetId" ).val(),
+ ds: $( "#dataSetId" ).val(),
periodType: $( "#periodType" ).val(),
- period: $( "#periodId" ).val(),
- orgUnit: selectionTreeSelection.getSelectedUid()[0],
+ pe: $( "#periodId" ).val(),
+ ou: selectionTreeSelection.getSelectedUid()[0],
selectedUnitOnly: $( "#selectedUnitOnly" ).is( ":checked" ),
offset: currentPeriodOffset
};
+ var groups = "";
+
+ $( "[name='groupSet']" ).each( function( index, value ) {
+ var item = $( this ).val();
+ if ( item )
+ {
+ groups += item + ";";
+ }
+ } );
+
+ if ( groups )
+ {
+ dataSetReport["groups"] = groups;
+ }
+
return dataSetReport;
}
@@ -33,7 +48,8 @@
selectionTreeSelection.setMultipleSelectionAllowed( false );
selectionTree.buildSelectionTree();
- $( "body" ).on( "oust.selected", function() {
+ $( "body" ).on( "oust.selected", function()
+ {
$( "body" ).off( "oust.selected" );
validateDataSetReport();
} );
@@ -82,12 +98,12 @@
{
var dataSetReport = getDataSetReport();
- if ( !dataSetReport.dataSet )
+ if ( !dataSetReport.ds )
{
setHeaderMessage( i18n_select_data_set );
return false;
}
- if ( !dataSetReport.period )
+ if ( !dataSetReport.pe )
{
setHeaderMessage( i18n_select_period );
return false;
@@ -103,9 +119,10 @@
hideContent();
showLoader();
- var currentParams = { ds: dataSetReport.dataSet, pe: dataSetReport.period, selectedUnitOnly: dataSetReport.selectedUnitOnly, ou: dataSetReport.orgUnit };
+ delete dataSetReport.periodType;
+ delete dataSetReport.offset;
- $.get( 'generateDataSetReport.action', currentParams, function( data ) {
+ $.get( 'generateDataSetReport.action', dataSetReport, function( data ) {
$( '#content' ).html( data );
hideLoader();
showContent();
@@ -118,10 +135,10 @@
var dataSetReport = getDataSetReport();
var url = "generateDataSetReport.action" +
- "?ds=" + dataSetReport.dataSet +
- "&pe=" + dataSetReport.period +
+ "?ds=" + dataSetReport.ds +
+ "&pe=" + dataSetReport.pe +
"&selectedUnitOnly=" + dataSetReport.selectedUnitOnly +
- "&ou=" + dataSetReport.orgUnit +
+ "&ou=" + dataSetReport.ou +
"&type=" + type;
window.location.href = url;
@@ -162,6 +179,12 @@
$( ".downloadButton" ).hide();
}
+function showAdvancedOptions()
+{
+ $( "#advancedOptionsLink" ).hide();
+ $( "#advancedOptions" ).show();
+}
+
//------------------------------------------------------------------------------
// Share
//------------------------------------------------------------------------------
@@ -186,8 +209,8 @@
text = $.trim( text );
var url = "../api/interpretations/dataSetReport/" + $( "#currentDataSetId" ).val() +
- "?pe=" + dataSetReport.period +
- "&ou=" + dataSetReport.orgUnit;
+ "?pe=" + dataSetReport.pe +
+ "&ou=" + dataSetReport.ou;
$.ajax( url, {
type: "POST",