=== 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 2010-01-25 07:24:27 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementService.java 2010-01-25 15:21:02 +0000 @@ -33,6 +33,7 @@ import java.util.Set; import org.hisp.dhis.hierarchy.HierarchyViolationException; +import org.hisp.dhis.period.PeriodType; /** * Defines service functionality for DataElements and DataElementGroups. @@ -212,6 +213,14 @@ Collection getDataElementsByType( String type ); /** + * Returns the DataElements with the given PeriodType. + * + * @param periodType the PeriodType. + * @return a Collection of DataElements. + */ + Collection getDataElementsByPeriodType( PeriodType periodType ); + + /** * Returns all DataElements with the given category combo. * * @param categoryCombo the DataElementCategoryCombo. @@ -220,12 +229,23 @@ Collection getDataElementByCategoryCombo( DataElementCategoryCombo categoryCombo ); /** - * @param dataElements - * @return grouped dataElements based on their categoryCombo + * Returns a Map with DataElementCategoryCombo as key and a Collection of + * the DataElements belonging to the DataElementCategoryCombo from the given + * argument List of DataElements as value. + * + * @param dataElements the DataElements to include. + * @return grouped DataElements based on their DataElementCategoryCombo. */ Map> getGroupedDataElementsByCategoryCombo( List dataElements ); + /** + * Returns the DataElementCategoryCombos associated with the given argument + * list of DataElements. + * + * @param dataElements the DataElements. + * @return a list of DataElements. + */ List getDataElementCategoryCombos( List dataElements ); /** === 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 2010-01-25 14:08:24 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2010-01-25 15:21:02 +0000 @@ -45,6 +45,7 @@ import org.hisp.dhis.common.comparator.CategoryComboSizeComparator; import org.hisp.dhis.hierarchy.HierarchyViolationException; import org.hisp.dhis.i18n.I18nService; +import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.system.util.Filter; import org.hisp.dhis.system.util.FilterUtils; import org.hisp.dhis.system.util.UUIdUtils; @@ -246,6 +247,19 @@ { return i18n( i18nService, dataElementStore.getDataElementsByType( type ) ); } + + public Collection getDataElementsByPeriodType( final PeriodType periodType ) + { + Collection dataElements = getAllDataElements(); + + return FilterUtils.filter( dataElements, new Filter() + { + public boolean retain( DataElement dataElement ) + { + return dataElement.getPeriodType() != null && dataElement.getPeriodType().equals( periodType ); + } + } ); + } public Collection getDataElementsByDomainType( String domainType ) { === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementsAction.java 2009-11-21 16:44:08 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementsAction.java 2010-01-25 15:21:02 +0000 @@ -40,6 +40,8 @@ import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler; +import org.hisp.dhis.period.PeriodService; +import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.system.filter.AggregatableDataElementFilter; import org.hisp.dhis.system.util.FilterUtils; @@ -78,6 +80,13 @@ { this.dataSetService = dataSetService; } + + private PeriodService periodService; + + public void setPeriodService( PeriodService periodService ) + { + this.periodService = periodService; + } // ------------------------------------------------------------------------- // Comparator @@ -125,6 +134,13 @@ { this.dataSetId = dataSetId; } + + private String periodTypeName; + + public void setPeriodTypeName( String periodTypeName ) + { + this.periodTypeName = periodTypeName; + } private boolean aggregate = false; @@ -154,10 +170,6 @@ { dataElements = new ArrayList( dataElementGroup.getMembers() ); } - else - { - dataElements = new ArrayList(); - } } else if ( categoryComboId != null && categoryComboId != ALL ) { @@ -167,10 +179,6 @@ { dataElements = new ArrayList( dataElementService.getDataElementByCategoryCombo( categoryCombo ) ); } - else - { - dataElements = new ArrayList(); - } } else if ( dataSetId != null ) { @@ -180,9 +188,14 @@ { dataElements = new ArrayList( dataset.getDataElements() ); } - else + } + else if ( periodTypeName != null ) + { + PeriodType periodType = periodService.getPeriodTypeByName( periodTypeName ); + + if ( periodType != null ) { - dataElements = new ArrayList(); + dataElements = new ArrayList( dataElementService.getDataElementsByPeriodType( periodType ) ); } } else @@ -190,6 +203,11 @@ dataElements = new ArrayList( dataElementService.getAllDataElements() ); } + if ( dataElements == null ) + { + dataElements = new ArrayList(); + } + Collections.sort( dataElements, dataElementComparator ); displayPropertyHandler.handle( dataElements ); === 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 2010-01-25 11:54:22 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2010-01-25 15:21:02 +0000 @@ -536,9 +536,9 @@ - + +