=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java 2013-04-26 13:15:53 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/ReportService.java 2013-07-04 09:08:12 +0000 @@ -46,9 +46,12 @@ final String REPORTTYPE_XLS = "xls"; final String PARAM_RELATIVE_PERIODS = "periods"; + final String PARAM_RELATIVE_ISO_PERIODS = "periods_iso"; final String PARAM_ORG_UNITS = "organisationunits"; + final String PARAM_ORG_UNITS_UID = "organisationunits_uid"; final String PARAM_ORGANISATIONUNIT_LEVEL = "organisationunit_level"; final String PARAM_ORGANISATIONUNIT_LEVEL_COLUMN = "organisationunit_level_column"; + final String PARAM_ORGANISATIONUNIT_UID_LEVEL_COLUMN = "organisationunit_uid_level_column"; final String PARAM_ORGANISATIONUNIT_COLUMN_NAME = "organisationunit_name"; final String PARAM_PERIOD_NAME = "period_name"; === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java 2013-05-19 18:49:47 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/report/impl/DefaultReportService.java 2013-07-04 09:08:12 +0000 @@ -48,6 +48,7 @@ import org.hisp.dhis.common.GenericIdentifiableObjectStore; import org.hisp.dhis.common.Grid; +import org.hisp.dhis.common.IdentifiableObjectUtils; import org.hisp.dhis.constant.ConstantService; import org.hisp.dhis.i18n.I18nFormat; import org.hisp.dhis.organisationunit.OrganisationUnit; @@ -73,7 +74,8 @@ public class DefaultReportService implements ReportService { - public static final String ORGANISATIONUNIT_LEVEL_COLUMN_PREFIX = "idlevel"; + public static final String ORGUNIT_LEVEL_COLUMN_PREFIX = "idlevel"; + public static final String ORGUNIT_UID_LEVEL_COLUMN_PREFIX = "uidlevel"; // ------------------------------------------------------------------------- // Dependencies @@ -151,7 +153,8 @@ params.put( PARAM_ORGANISATIONUNIT_COLUMN_NAME, orgUnit.getName() ); params.put( PARAM_ORGANISATIONUNIT_LEVEL, level ); - params.put( PARAM_ORGANISATIONUNIT_LEVEL_COLUMN, ORGANISATIONUNIT_LEVEL_COLUMN_PREFIX + level ); + params.put( PARAM_ORGANISATIONUNIT_LEVEL_COLUMN, ORGUNIT_LEVEL_COLUMN_PREFIX + level ); + params.put( PARAM_ORGANISATIONUNIT_UID_LEVEL_COLUMN, ORGUNIT_UID_LEVEL_COLUMN_PREFIX + level ); } JasperPrint print = null; @@ -175,14 +178,19 @@ { if ( report.hasRelativePeriods() ) { - Collection periods = periodService.reloadPeriods( report.getRelatives().getRelativePeriods( reportDate, null, false ) ); - String periodString = getCommaDelimitedString( getIdentifiers( Period.class, periods ) ); - params.put( PARAM_RELATIVE_PERIODS, periodString ); + List relativePeriods = report.getRelatives().getRelativePeriods( reportDate, null, false ); + + String periodString = getCommaDelimitedString( getIdentifiers( Period.class, periodService.reloadPeriods( relativePeriods ) ) ); + String isoPeriodString = getCommaDelimitedString( IdentifiableObjectUtils.getUids( relativePeriods ) ); + + params.put( PARAM_RELATIVE_PERIODS, periodString ); + params.put( PARAM_RELATIVE_ISO_PERIODS, isoPeriodString ); } if ( report.hasReportParams() && report.getReportParams().isParamOrganisationUnit() && orgUnit != null ) { params.put( PARAM_ORG_UNITS, String.valueOf( orgUnit.getId() ) ); + params.put( PARAM_ORG_UNITS_UID, String.valueOf( orgUnit.getUid() ) ); } Connection connection = DataSourceUtils.getConnection( dataSource ); === modified file 'dhis-2/dhis-support/dhis-support-system/src/main/resources/jasper-report-template.jrxml' --- dhis-2/dhis-support/dhis-support-system/src/main/resources/jasper-report-template.jrxml 2013-01-25 15:24:37 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/resources/jasper-report-template.jrxml 2013-07-04 09:08:12 +0000 @@ -1,104 +1,137 @@ - - - - - - - - - - - - - - <band height="248" splitType="Stretch"> - <staticText> - <reportElement uuid="ac60f476-8e83-423f-b4a9-626128dc5563" x="0" y="14" width="558" height="37"/> - <textElement> - <font size="11" isBold="true"/> - </textElement> - <text><![CDATA[This template contains a set of parameters which you can use directly in SQL to make dynamic reports]]></text> - </staticText> - <staticText> - <reportElement uuid="b9814cb8-49b5-46c1-a31a-b9e0b3c38b91" x="0" y="73" width="383" height="20"/> - <textElement/> - <text><![CDATA[periods: string of comma-separated identifiers of selected relative period]]></text> - </staticText> - <staticText> - <reportElement uuid="97dcf9d1-0d3b-4573-86b9-3b6349187063" x="0" y="115" width="383" height="20"/> - <textElement/> - <text><![CDATA[organisationunits: identifier of selected organisation unit]]></text> - </staticText> - <staticText> - <reportElement uuid="22c8da34-3b81-43c0-ac15-733ae130ea6c" x="0" y="136" width="383" height="20"/> - <textElement/> - <text><![CDATA[organisationunit_name: name of selected organisation unit]]></text> - </staticText> - <staticText> - <reportElement uuid="c43ce8d1-73fe-47aa-9005-e8ff1ef77865" x="0" y="157" width="383" height="20"/> - <textElement/> - <text><![CDATA[organisationunit_level: level of selected organisation unit]]></text> - </staticText> - <staticText> - <reportElement uuid="f5e4800f-0f16-4ea4-ac58-985b46b32373" x="0" y="178" width="383" height="33"/> - <textElement/> - <text><![CDATA[organisationunit_level_column: name of the corresponding column in _orgunitstructure resource table]]></text> - </staticText> - <textField> - <reportElement uuid="83d8575f-02ee-4a79-b438-86d4047cef2c" x="385" y="73" width="181" height="20"/> - <textElement/> - <textFieldExpression><![CDATA[$P!{periods}]]></textFieldExpression> - </textField> - <textField> - <reportElement uuid="78bd3c7a-312a-49a5-9ec6-aa1a6a054620" x="385" y="115" width="181" height="20"/> - <textElement/> - <textFieldExpression><![CDATA[$P!{organisationunits}]]></textFieldExpression> - </textField> - <textField> - <reportElement uuid="ced2e65b-fbd3-415f-b621-a32c2d747515" x="385" y="136" width="181" height="20"/> - <textElement/> - <textFieldExpression><![CDATA[$P!{organisationunit_name}]]></textFieldExpression> - </textField> - <textField> - <reportElement uuid="99fc81bf-ac4a-445a-9864-eafe0b7f8d40" x="385" y="157" width="181" height="20"/> - <textElement/> - <textFieldExpression><![CDATA[$P{organisationunit_level}]]></textFieldExpression> - </textField> - <textField> - <reportElement uuid="671106c8-b073-447f-ae80-5d616d191836" x="385" y="178" width="181" height="20"/> - <textElement/> - <textFieldExpression><![CDATA[$P!{organisationunit_level_column}]]></textFieldExpression> - </textField> - <staticText> - <reportElement uuid="b9814cb8-49b5-46c1-a31a-b9e0b3c38b91" x="0" y="94" width="383" height="20"/> - <textElement/> - <text><![CDATA[period_name: name of selected period]]></text> - </staticText> - <textField> - <reportElement uuid="066345c4-7cac-4e08-8d46-7d2cfbaa8b9e" x="385" y="94" width="181" height="20"/> - <textElement/> - <textFieldExpression><![CDATA[$P!{period_name}]]></textFieldExpression> - </textField> - </band> - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + <band height="315" splitType="Stretch"> + <staticText> + <reportElement uuid="ac60f476-8e83-423f-b4a9-626128dc5563" x="0" y="14" width="558" height="37"/> + <textElement> + <font size="11" isBold="true"/> + </textElement> + <text><![CDATA[This template contains a set of parameters which you can use directly in SQL to make dynamic reports]]></text> + </staticText> + <staticText> + <reportElement uuid="b9814cb8-49b5-46c1-a31a-b9e0b3c38b91" x="0" y="73" width="366" height="20"/> + <textElement/> + <text><![CDATA[periods: string of comma-separated db ids of selected relative period]]></text> + </staticText> + <staticText> + <reportElement uuid="97dcf9d1-0d3b-4573-86b9-3b6349187063" x="0" y="136" width="366" height="20"/> + <textElement/> + <text><![CDATA[organisationunits: db id of selected organisation unit]]></text> + </staticText> + <staticText> + <reportElement uuid="22c8da34-3b81-43c0-ac15-733ae130ea6c" x="0" y="178" width="366" height="20"/> + <textElement/> + <text><![CDATA[organisationunit_name: name of selected organisation unit]]></text> + </staticText> + <staticText> + <reportElement uuid="c43ce8d1-73fe-47aa-9005-e8ff1ef77865" x="0" y="199" width="366" height="20"/> + <textElement/> + <text><![CDATA[organisationunit_level: level of selected organisation unit]]></text> + </staticText> + <staticText> + <reportElement uuid="f5e4800f-0f16-4ea4-ac58-985b46b32373" x="0" y="220" width="366" height="33"/> + <textElement/> + <text><![CDATA[organisationunit_level_column: name of the corresponding id column in _orgunitstructure resource table]]></text> + </staticText> + <textField> + <reportElement uuid="83d8575f-02ee-4a79-b438-86d4047cef2c" x="367" y="73" width="205" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{periods}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="78bd3c7a-312a-49a5-9ec6-aa1a6a054620" x="367" y="136" width="205" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{organisationunits}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="ced2e65b-fbd3-415f-b621-a32c2d747515" x="367" y="178" width="205" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{organisationunit_name}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="99fc81bf-ac4a-445a-9864-eafe0b7f8d40" x="367" y="199" width="205" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{organisationunit_level}]]></textFieldExpression> + </textField> + <textField> + <reportElement uuid="671106c8-b073-447f-ae80-5d616d191836" x="367" y="220" width="205" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{organisationunit_level_column}]]></textFieldExpression> + </textField> + <staticText> + <reportElement uuid="b9814cb8-49b5-46c1-a31a-b9e0b3c38b91" x="0" y="115" width="366" height="20"/> + <textElement/> + <text><![CDATA[period_name: name of selected period]]></text> + </staticText> + <textField> + <reportElement uuid="066345c4-7cac-4e08-8d46-7d2cfbaa8b9e" x="367" y="115" width="205" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{period_name}]]></textFieldExpression> + </textField> + <staticText> + <reportElement uuid="b9814cb8-49b5-46c1-a31a-b9e0b3c38b91" x="0" y="94" width="366" height="20"/> + <textElement/> + <text><![CDATA[periods_iso: string of comma-separated iso ids of selected relative period]]></text> + </staticText> + <textField> + <reportElement uuid="83d8575f-02ee-4a79-b438-86d4047cef2c" x="367" y="94" width="205" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{periods_iso}]]></textFieldExpression> + </textField> + <staticText> + <reportElement uuid="97dcf9d1-0d3b-4573-86b9-3b6349187063" x="0" y="157" width="366" height="20"/> + <textElement/> + <text><![CDATA[organisationunits_uid: uid of selected organisation unit]]></text> + </staticText> + <textField> + <reportElement uuid="78bd3c7a-312a-49a5-9ec6-aa1a6a054620" x="367" y="157" width="205" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{organisationunits_uid}]]></textFieldExpression> + </textField> + <staticText> + <reportElement uuid="f5e4800f-0f16-4ea4-ac58-985b46b32373" x="1" y="255" width="366" height="33"/> + <textElement/> + <text><![CDATA[organisationunit_level_uid_column: name of the corresponding id column in _orgunitstructure resource table]]></text> + </staticText> + <textField> + <reportElement uuid="671106c8-b073-447f-ae80-5d616d191836" x="368" y="255" width="205" height="20"/> + <textElement/> + <textFieldExpression><![CDATA[$P{organisationunit_uid_level_column}]]></textFieldExpression> + </textField> + </band> + + + + + + + + + + + + + + + + + + +