dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #12066
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3601: added support for getting indicators based on dataset (ajax)
------------------------------------------------------------
revno: 3601
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-05-12 18:16:32 +0200
message:
added support for getting indicators based on dataset (ajax)
modified:
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorsAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml
--
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-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorsAction.java 2011-05-06 10:49:36 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorsAction.java 2011-05-12 16:16:32 +0000
@@ -32,6 +32,9 @@
import java.util.Comparator;
import java.util.List;
+import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataset.DataSet;
+import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorGroup;
import org.hisp.dhis.indicator.IndicatorService;
@@ -58,6 +61,13 @@
this.indicatorService = indicatorService;
}
+ private DataSetService dataSetService;
+
+ public void setDataSetService( DataSetService dataSetService )
+ {
+ this.dataSetService = dataSetService;
+ }
+
// -------------------------------------------------------------------------
// Comparator
// -------------------------------------------------------------------------
@@ -91,6 +101,13 @@
this.id = id;
}
+ private Integer dataSetId;
+
+ public void setDataSetId( Integer dataSetId )
+ {
+ this.dataSetId = dataSetId;
+ }
+
private List<Indicator> indicators;
public List<Indicator> getIndicators()
@@ -105,11 +122,7 @@
public String execute()
throws Exception
{
- if ( id == null || id == ALL )
- {
- indicators = new ArrayList<Indicator>( indicatorService.getAllIndicators() );
- }
- else
+ if ( id != null && id != ALL )
{
IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( id );
@@ -117,11 +130,25 @@
{
indicators = new ArrayList<Indicator>( indicatorGroup.getMembers() );
}
- else
+ }
+ else if ( dataSetId != null )
+ {
+ DataSet dataset = dataSetService.getDataSet( dataSetId );
+
+ if ( dataset != null )
{
- indicators = new ArrayList<Indicator>();
+ indicators = new ArrayList<Indicator>( dataset.getIndicators() );
}
}
+ else
+ {
+ indicators = new ArrayList<Indicator>( indicatorService.getAllIndicators() );
+ }
+
+ if ( indicators == null )
+ {
+ indicators = new ArrayList<Indicator>();
+ }
Collections.sort( indicators, indicatorComparator );
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml'
--- dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2011-05-06 12:55:00 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2011-05-12 16:16:32 +0000
@@ -395,6 +395,7 @@
<bean id="org.hisp.dhis.commons.action.GetIndicatorsAction" class="org.hisp.dhis.commons.action.GetIndicatorsAction" scope="prototype">
<property name="indicatorService" ref="org.hisp.dhis.indicator.IndicatorService" />
+ <property name="dataSetService" ref="org.hisp.dhis.dataset.DataSetService" />
</bean>
<bean id="org.hisp.dhis.commons.action.GetOperandsAction" class="org.hisp.dhis.commons.action.GetOperandsAction" scope="prototype">