dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #17454
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6949: Added option for retrieving minmal report table data to api
------------------------------------------------------------
revno: 6949
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2012-05-15 22:20:50 +0200
message:
Added option for retrieving minmal report table data to api
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java
dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.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-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2012-05-14 18:21:39 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTableService.java 2012-05-15 20:20:50 +0000
@@ -109,38 +109,40 @@
* Instantiates and populates a Grid populated with data from the ReportTable
* with the given identifier.
*
- * @param id the ReportTable identifier.
- * @param format the I18nFormat.
- * @param reportingPeriod the reporting period number.
- * @param organisationUnitId the organisation unit number.
+ * @param id the ReportTable identifier.
+ * @param format the I18nFormat.
+ * @param reportingPeriod the reporting date.
+ * @param organisationUnitId the organisation unit identifier.
* @return a Grid.
*/
Grid getReportTableGrid( int id, I18nFormat format, Date reportingPeriod, Integer organisationUnitId );
/**
+ * Instantiates and populates a Grid populated with data from the ReportTable
+ * with the given identifier.
*
+ * @param uid the ReportTable unique identifier.
+ * @param format the I18nFormat.
+ * @param reportingPeriod the reporting date.
+ * @param organisationUnitUid the organisation unit uid.
+ * @return a Grid.
+ */
+ Grid getReportTableGrid( String uid, I18nFormat format, Date reportingPeriod, String organisationUnitUid );
+
+ /**
+ * Instantiates and populates a Grid populated with data from the given
+ * ReportTable.
*
- * @param reportTable
- * @param format
- * @param reportingPeriod
- * @param organisationUnitUid
- * @return
+ * @param reportTable the ReportTable.
+ * @param format the I18nFormat.
+ * @param reportingPeriod the reporting date.
+ * @param organisationUnitUid the organisation unit uid.
+ * @param minimal indicates whether to include visible columns only in the Grid.
+ * @return a Grid.
*/
- Grid getReportTableGrid( ReportTable reportTable, I18nFormat format, Date reportingPeriod, String organisationUnitUid );
+ Grid getReportTableGrid( ReportTable reportTable, I18nFormat format, Date reportingPeriod, String organisationUnitUid, boolean minimal );
/**
- * Instantiates and populates a Grid populated with data from the ReportTable
- * with the given identifier.
- *
- * @param uid the ReportTable unique identifier.
- * @param format the I18nFormat.
- * @param reportingPeriod the reporting period number.
- * @param organisationUnitUid the organisation unit number.
- * @return a Grid.
- */
- Grid getReportTableGrid( String uid, I18nFormat format, Date reportingPeriod, String organisationUnitUid );
-
- /**
* If report table mode, this method will return the report table with the
* given identifier. If report mode, this method will return the report
* tables associated with the report.
=== modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java'
--- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2012-05-14 18:21:39 +0000
+++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2012-05-15 20:20:50 +0000
@@ -141,10 +141,10 @@
reportTable = initDynamicMetaObjects( reportTable, reportingPeriod, organisationUnitId, format );
- return getGrid( reportTable );
+ return getGrid( reportTable, false );
}
- public Grid getReportTableGrid( ReportTable reportTable, I18nFormat format, Date reportingPeriod, String organisationUnitUid )
+ public Grid getReportTableGrid( ReportTable reportTable, I18nFormat format, Date reportingPeriod, String organisationUnitUid, boolean minimal )
{
OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( organisationUnitUid );
@@ -152,7 +152,7 @@
reportTable = initDynamicMetaObjects( reportTable, reportingPeriod, organisationUnitId, format );
- return getGrid( reportTable );
+ return getGrid( reportTable, minimal );
}
public ReportTable getReportTable( String uid, String mode )
@@ -360,7 +360,7 @@
* @param reportTable the report table.
* @return a grid.
*/
- private Grid getGrid( ReportTable reportTable )
+ private Grid getGrid( ReportTable reportTable, boolean minimal )
{
final String subtitle = StringUtils.trimToEmpty( reportTable.getParentOrganisationUnitName() ) + SPACE
+ StringUtils.trimToEmpty( reportTable.getReportingPeriodName() );
@@ -373,14 +373,17 @@
// Headers
// ---------------------------------------------------------------------
- for ( String column : reportTable.getIndexColumns() ) // Index columns
- {
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, Integer.class.getName(), true, true ) );
- }
-
- for ( String column : reportTable.getIndexUidColumns() ) // Index uid columns
- {
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), true, true ) );
+ if ( !minimal )
+ {
+ for ( String column : reportTable.getIndexColumns() ) // Index columns
+ {
+ grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, Integer.class.getName(), true, true ) );
+ }
+
+ for ( String column : reportTable.getIndexUidColumns() ) // Index uid columns
+ {
+ grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), true, true ) );
+ }
}
for ( String column : reportTable.getIndexNameColumns() ) // Index name columns
@@ -388,22 +391,25 @@
grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), false, true ) );
}
- for ( String column : reportTable.getIndexCodeColumns() ) // Index code columns
- {
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), true, true ) );
- }
-
- for ( String column : reportTable.getIndexDescriptionColumns() ) // Index description columns
- {
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), true, true ) );
- }
-
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( REPORTING_MONTH_COLUMN_NAME ), REPORTING_MONTH_COLUMN_NAME,
- String.class.getName(), true, true ) );
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( PARAM_ORGANISATIONUNIT_COLUMN_NAME ),
- PARAM_ORGANISATIONUNIT_COLUMN_NAME, String.class.getName(), true, true ) );
- grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME ),
- ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME, String.class.getName(), true, true ) );
+ if ( !minimal )
+ {
+ for ( String column : reportTable.getIndexCodeColumns() ) // Index code columns
+ {
+ grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), true, true ) );
+ }
+
+ for ( String column : reportTable.getIndexDescriptionColumns() ) // Index description columns
+ {
+ grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( column ), column, String.class.getName(), true, true ) );
+ }
+
+ grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( REPORTING_MONTH_COLUMN_NAME ), REPORTING_MONTH_COLUMN_NAME,
+ String.class.getName(), true, true ) );
+ grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( PARAM_ORGANISATIONUNIT_COLUMN_NAME ),
+ PARAM_ORGANISATIONUNIT_COLUMN_NAME, String.class.getName(), true, true ) );
+ grid.addHeader( new GridHeader( PRETTY_COLUMNS.get( ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME ),
+ ORGANISATION_UNIT_IS_PARENT_COLUMN_NAME, String.class.getName(), true, true ) );
+ }
final int startColumnIndex = grid.getHeaders().size();
final int numberOfColumns = reportTable.getColumns().size();
@@ -437,14 +443,17 @@
{
grid.addRow();
- for ( NameableObject object : row ) // Index columns
- {
- grid.addValue( object.getId() );
- }
-
- for ( NameableObject object : row ) // Index uid columns
- {
- grid.addValue( object.getUid() );
+ if ( !minimal )
+ {
+ for ( NameableObject object : row ) // Index columns
+ {
+ grid.addValue( object.getId() );
+ }
+
+ for ( NameableObject object : row ) // Index uid columns
+ {
+ grid.addValue( object.getUid() );
+ }
}
for ( NameableObject object : row ) // Index name columns
@@ -452,20 +461,23 @@
grid.addValue( object.getName() );
}
- for ( NameableObject object : row ) // Index code columns
- {
- grid.addValue( object.getCode() );
- }
-
- for ( NameableObject object : row ) // Index description columns
- {
- grid.addValue( object.getDescription() );
- }
-
- grid.addValue( reportTable.getReportingPeriodName() );
- grid.addValue( reportTable.getParentOrganisationUnitName() );
- grid.addValue( isCurrentParent( row ) ? YES : NO );
-
+ if ( !minimal )
+ {
+ for ( NameableObject object : row ) // Index code columns
+ {
+ grid.addValue( object.getCode() );
+ }
+
+ for ( NameableObject object : row ) // Index description columns
+ {
+ grid.addValue( object.getDescription() );
+ }
+
+ grid.addValue( reportTable.getReportingPeriodName() );
+ grid.addValue( reportTable.getParentOrganisationUnitName() );
+ grid.addValue( isCurrentParent( row ) ? YES : NO );
+ }
+
for ( List<NameableObject> column : reportTable.getColumns() ) // Values
{
grid.addValue( map.get( getIdentifier( row, column ) ) );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java 2012-05-15 15:28:44 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java 2012-05-15 20:20:50 +0000
@@ -162,8 +162,9 @@
@RequestParam(required=false, value="de") List<String> dataElements,
@RequestParam(required=false, value="ds") List<String> dataSets,
@RequestParam(value="ou") List<String> orgUnits,
- @RequestParam(required=false) List<String> crossTab,
+ @RequestParam(required=false, value="crosstab") List<String> crossTab,
@RequestParam(required=false) boolean orgUnitIsParent,
+ @RequestParam(required=false) boolean minimal,
RelativePeriods relatives,
Model model,
HttpServletResponse response ) throws Exception
@@ -209,7 +210,7 @@
table.setRelatives( relatives );
- Grid grid = reportTableService.getReportTableGrid( table, i18nManager.getI18nFormat(), new Date(), null );
+ Grid grid = reportTableService.getReportTableGrid( table, i18nManager.getI18nFormat(), new Date(), null, minimal );
model.addAttribute( "model", grid );
model.addAttribute( "view", "detailed" );