dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16709
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6419: (DV) Plugin now uses uids (chart favorites, indicators, data elements, organisation units).
Merge authors:
Jan Henrik Øverland (janhenrik-overland)
------------------------------------------------------------
revno: 6419 [merge]
committer: Jan Henrik Overland <janhenrik.overland@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-03-28 14:53:53 +0200
message:
(DV) Plugin now uses uids (chart favorites, indicators, data elements, organisation units).
renamed:
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
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitService.java
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/indicator/DefaultIndicatorService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java
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/webapp/dhis-web-visualizer/app/plugin/plugin.js
dhis-2/dhis-web/dhis-web-visualizer/src/main/webapp/dhis-web-visualizer/app/plugin/index.html
--
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/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<DataElement> getDataElements( Collection<Integer> 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<DataElement> getDataElementsByUid( Collection<String> 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<Indicator> getAllIndicators();
Collection<Indicator> getIndicators( Collection<Integer> identifiers );
+
+ Set<Indicator> getIndicatorsByUid( Collection<String> 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<OrganisationUnit> getOrganisationUnits( Collection<Integer> identifiers );
/**
+ * Returns all OrganisationUnits with corresponding identifiers.
+ *
+ * @param uids the collection of uids.
+ * @return a collection of OrganisationUnits.
+ */
+ Set<OrganisationUnit> getOrganisationUnitsByUid( Collection<String> 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<DataElement> getDataElementsByUid( Collection<String> uids )
+ {
+ Set<DataElement> dataElements = new HashSet<DataElement>();
+
+ for ( String uid : uids )
+ {
+ dataElements.add( dataElementStore.getByUid( uid ) );
+ }
+
+ return dataElements;
+ }
public void setZeroIsSignificantForDataElements( Collection<Integer> 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<Indicator> getIndicatorsByUid( Collection<String> uids )
+ {
+ Set<Indicator> indicators = new HashSet<Indicator>();
+
+ 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<OrganisationUnit> getOrganisationUnitsByUid( Collection<String> uids )
+ {
+ Set<OrganisationUnit> organisationUnits = new HashSet<OrganisationUnit>();
+
+ 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<Integer> indicatorIds;
+ private Collection<String> indicatorIds;
- public void setIndicatorIds( Collection<Integer> indicatorIds )
+ public void setIndicatorIds( Collection<String> indicatorIds )
{
this.indicatorIds = indicatorIds;
}
- private Collection<Integer> dataElementIds;
+ private Collection<String> dataElementIds;
- public void setDataElementIds( Collection<Integer> dataElementIds )
+ public void setDataElementIds( Collection<String> dataElementIds )
{
this.dataElementIds = dataElementIds;
}
- private Collection<Integer> organisationUnitIds;
+ private Collection<String> organisationUnitIds;
- public void setOrganisationUnitIds( Collection<Integer> organisationUnitIds )
+ public void setOrganisationUnitIds( Collection<String> 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<Period> setNames( List<Period> 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<Integer> periodIds = new ArrayList<Integer>();
+ Collection<Integer> periodIds = getIdentifiers( Period.class, periods );
- for ( Period period : periods )
- {
- periodIds.add( period.getId() );
- }
+ Set<OrganisationUnit> organisationUnits = organisationUnitService
+ .getOrganisationUnitsByUid( organisationUnitIds );
if ( indicatorIds != null )
{
- indicatorValues = aggregatedDataValueService.getAggregatedIndicatorValues( indicatorIds, periodIds,
- organisationUnitIds );
+ Set<Indicator> 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<DataElement> 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 @@
<head>
<link rel="stylesheet" type="text/css" href="http://extjs-public.googlecode.com/svn/tags/extjs-4.0.7/release/resources/css/ext-all-gray.css" />
<script type="text/javascript" src="http://extjs-public.googlecode.com/svn/tags/extjs-4.0.7/release/ext-all.js"></script>
- <script type="text/javascript" src="http://apps.dhis2.org/demo/dhis-web-visualizer/app/plugin/plugin.js"></script>
+ <script type="text/javascript" src="http://apps.dhis2.org/dev/dhis-web-visualizer/app/plugin/plugin.js"></script>
<style>
body {margin: 0 0 0 60px;}
h1 {font-size: 20px; margin: 20px 0;}
- #chart1 {width: 600px; height: 400px; border: 2px solid #ddd; margin-bottom: 100px;}
+ #chart1 {width: 900px; height: 400px; border: 2px solid #ddd; margin-bottom: 100px;}
#chart2 {width: 1400px; height: 400px; border: 2px solid #ccc; margin-bottom: 100px;}
</style>
@@ -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 @@
-->
</head>
-<body>
+<body>
<h1>My chart 1</h1>
<div id="chart1"></div>
@@ -44,7 +44,7 @@
<script>
Ext.onReady( function() {
- var url = 'http://apps.dhis2.org/demo/';
+ var url = 'http://apps.dhis2.org/dev/';
DHIS.getChart({
uid: 'R0DVGvXDUNP',
@@ -54,13 +54,14 @@
DHIS.getChart({
type: 'stackedcolumn',
- indicators: [52486, 52491],
+ indicators: ['Uvn6LCg7dVU', 'OdiHJayrsKo'],
periods: 'last12Months',
- organisationunits: [525],
+ organisationunits: ['ImspTQPwCqd'],
el: 'chart2',
url: url
- });
+ });
+
});
- </script>
+ </script>
</body>
</html>
=== 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;
}