=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2012-02-01 10:50:31 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2012-03-28 12:26:52 +0000 @@ -151,6 +151,15 @@ Collection getDataElements( Collection identifiers ); /** + * Returns all DataElements with corresponding identifiers. Returns all + * DataElements if the given argument is null. + * + * @param uids the collection of uids. + * @return a collection of DataElements. + */ + Set getDataElementsByUid( Collection uids ); + + /** * Returns all DataElements with types that are possible to aggregate. The * types are currently INT and BOOL. * === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2012-02-01 10:50:31 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java 2012-03-28 12:26:52 +0000 @@ -28,6 +28,7 @@ */ import java.util.Collection; +import java.util.Set; /** * @author Lars Helge Overland @@ -54,6 +55,8 @@ Collection getAllIndicators(); Collection getIndicators( Collection identifiers ); + + Set getIndicatorsByUid( Collection uids ); Indicator getIndicatorByName( String name ); === modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2011-12-11 13:47:04 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java 2012-03-28 12:26:52 +0000 @@ -134,6 +134,14 @@ Collection getOrganisationUnits( Collection identifiers ); /** + * Returns all OrganisationUnits with corresponding identifiers. + * + * @param uids the collection of uids. + * @return a collection of OrganisationUnits. + */ + Set getOrganisationUnitsByUid( Collection uids ); + + /** * Returns an OrganisationUnit with a given name. * * @param name the name of the OrganisationUnit to return. === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2012-02-01 10:50:31 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2012-03-28 12:26:52 +0000 @@ -43,6 +43,7 @@ import org.hisp.dhis.dataelement.comparator.DataElementCategoryComboSizeComparator; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.i18n.I18nService; +import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.system.util.Filter; import org.hisp.dhis.system.util.FilterUtils; @@ -138,6 +139,18 @@ } } ); } + + public Set getDataElementsByUid( Collection uids ) + { + Set dataElements = new HashSet(); + + for ( String uid : uids ) + { + dataElements.add( dataElementStore.getByUid( uid ) ); + } + + return dataElements; + } public void setZeroIsSignificantForDataElements( Collection dataElementIds ) { === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2012-02-01 10:50:31 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2012-03-28 12:26:52 +0000 @@ -31,7 +31,9 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.Iterator; +import java.util.Set; import org.hisp.dhis.common.GenericIdentifiableObjectStore; import org.hisp.dhis.i18n.I18nService; @@ -132,6 +134,18 @@ } } ); } + + public Set getIndicatorsByUid( Collection uids ) + { + Set indicators = new HashSet(); + + for ( String uid : uids ) + { + indicators.add( indicatorStore.getByUid( uid ) ); + } + + return indicators; + } public Indicator getIndicatorByName( String name ) { === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2011-12-26 10:07:59 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2012-03-28 12:26:52 +0000 @@ -43,6 +43,7 @@ import org.apache.commons.logging.LogFactory; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.hierarchy.HierarchyViolationException; +import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.organisationunit.comparator.OrganisationUnitLevelComparator; import org.hisp.dhis.system.util.AuditLogUtil; import org.hisp.dhis.system.util.ConversionUtils; @@ -181,6 +182,18 @@ } } ); } + + public Set getOrganisationUnitsByUid( Collection uids ) + { + Set organisationUnits = new HashSet(); + + for ( String uid : uids ) + { + organisationUnits.add( organisationUnitStore.getByUid( uid ) ); + } + + return organisationUnits; + } public OrganisationUnit getOrganisationUnit( String uid ) { === modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesPluginAction.java' --- dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesPluginAction.java 2012-03-27 14:58:12 +0000 +++ dhis-2/dhis-web/dhis-web-visualizer/src/main/java/org/hisp/dhis/visualizer/action/GetAggregatedValuesPluginAction.java 2012-03-28 12:26:52 +0000 @@ -27,17 +27,22 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; +import static org.hisp.dhis.system.util.ConversionUtils.getIdentifiers; + import java.util.Collection; import java.util.HashSet; import java.util.List; +import java.util.Set; import org.hisp.dhis.aggregation.AggregatedDataValue; import org.hisp.dhis.aggregation.AggregatedDataValueService; import org.hisp.dhis.aggregation.AggregatedIndicatorValue; +import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.i18n.I18nFormat; +import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.indicator.IndicatorService; +import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; @@ -101,23 +106,23 @@ // Input // ------------------------------------------------------------------------- - private Collection indicatorIds; + private Collection indicatorIds; - public void setIndicatorIds( Collection indicatorIds ) + public void setIndicatorIds( Collection indicatorIds ) { this.indicatorIds = indicatorIds; } - private Collection dataElementIds; + private Collection dataElementIds; - public void setDataElementIds( Collection dataElementIds ) + public void setDataElementIds( Collection dataElementIds ) { this.dataElementIds = dataElementIds; } - private Collection organisationUnitIds; + private Collection organisationUnitIds; - public void setOrganisationUnitIds( Collection organisationUnitIds ) + public void setOrganisationUnitIds( Collection organisationUnitIds ) { this.organisationUnitIds = organisationUnitIds; } @@ -177,7 +182,7 @@ { this.last5Years = last5Years; } - + public String callback; public String getCallback() @@ -218,14 +223,14 @@ // ------------------------------------------------------------------------- // Action implementation // ------------------------------------------------------------------------- - + private List setNames( List periods ) { for ( Period period : periods ) { period.setName( format.formatPeriod( period ) ); } - + return periods; } @@ -233,8 +238,7 @@ throws Exception { if ( organisationUnitIds != null - && ( lastMonth || last12Months || lastQuarter || last4Quarters || lastSixMonth || - last2SixMonths || thisYear || last5Years ) ) + && (lastMonth || last12Months || lastQuarter || last4Quarters || lastSixMonth || last2SixMonths || thisYear || last5Years) ) { RelativePeriods rp = new RelativePeriods(); rp.setReportingMonth( lastMonth ); @@ -248,17 +252,18 @@ periods = periodService.reloadPeriods( setNames( rp.getRelativePeriods() ) ); - Collection periodIds = new ArrayList(); + Collection periodIds = getIdentifiers( Period.class, periods ); - for ( Period period : periods ) - { - periodIds.add( period.getId() ); - } + Set organisationUnits = organisationUnitService + .getOrganisationUnitsByUid( organisationUnitIds ); if ( indicatorIds != null ) { - indicatorValues = aggregatedDataValueService.getAggregatedIndicatorValues( indicatorIds, periodIds, - organisationUnitIds ); + Set indicators = indicatorService.getIndicatorsByUid( indicatorIds ); + + indicatorValues = aggregatedDataValueService.getAggregatedIndicatorValues( + getIdentifiers( Indicator.class, indicators ), periodIds, + getIdentifiers( OrganisationUnit.class, organisationUnits ) ); for ( AggregatedIndicatorValue value : indicatorValues ) { @@ -271,8 +276,10 @@ if ( dataElementIds != null ) { - dataValues = aggregatedDataValueService.getAggregatedDataValueTotals( dataElementIds, periodIds, - organisationUnitIds ); + Set dataElements = dataElementService.getDataElementsByUid( dataElementIds ); + + dataValues = aggregatedDataValueService.getAggregatedDataValueTotals( getIdentifiers( DataElement.class, dataElements ), periodIds, + getIdentifiers( OrganisationUnit.class, organisationUnits ) ); for ( AggregatedDataValue value : dataValues ) { === renamed file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.html' => 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html' --- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.html 2012-03-28 07:48:21 +0000 +++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html 2012-03-28 12:26:52 +0000 @@ -2,14 +2,14 @@ - + @@ -18,10 +18,10 @@ CONFIG TYPE DEFAULT DESCRIPTION type string 'column' (Optional) Chart types: 'column', 'stackedcolumn', 'bar', 'stackedbar', 'line', 'area', 'pie' - indicators [integer] (Required*) Indicator ids. Required if no data elements are provided. - dataelements [integer] (Required*) Data element ids. Required if no indicators are provided. + indicators [integer] (Required*) Indicator uids. Required if no data elements are provided. + dataelements [integer] (Required*) Data element uids. Required if no indicators are provided. periods [string] 'monthsThisYear' (Optional) Relative period names. - organisationunits [integer] (Required) Organisation unit ids. + organisationunits [integer] (Required) Organisation unit uids. series string 'data' (Optional) Series: 'data', 'period' or 'organisationunit' category string 'period' (Optional) Category: 'indicator', 'dataelement', 'period' or 'organisationunit' filter string 'organisationunit' (Optional) Filter: 'indicator', 'dataelement', 'period' or 'organisationunit' @@ -35,7 +35,7 @@ --> - +

My chart 1

@@ -44,7 +44,7 @@ + === modified file 'dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js' --- dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js 2012-03-27 15:30:24 +0000 +++ dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/plugin.js 2012-03-28 12:26:52 +0000 @@ -64,7 +64,7 @@ getIdsFromObjects: function(indicators) { var a = [] for (var i = 0; i < indicators.length; i++) { - a.push(indicators[i].internalId); + a.push(indicators[i].id); } return a; } @@ -73,7 +73,7 @@ getIdsFromObjects: function(dataelements) { var a = [] for (var i = 0; i < dataelements.length; i++) { - a.push(dataelements[i].internalId); + a.push(dataelements[i].id); } return a; } @@ -119,7 +119,7 @@ getIdsFromObjects: function(organisationunits) { var a = [] for (var i = 0; i < organisationunits.length; i++) { - a.push(organisationunits[i].internalId); + a.push(organisationunits[i].id); } return a; }