=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.java 2009-11-12 17:59:58 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/datadictionary/DefaultDataDictionaryService.java 2009-11-26 14:02:44 +0000 @@ -27,10 +27,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; import java.util.Collection; import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.springframework.transaction.annotation.Transactional; /** @@ -66,21 +67,17 @@ return dataDictionaryStore.get( id ); } - public Collection getDataDictionaries( Collection identifiers ) + public Collection getDataDictionaries( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllDataDictionaries(); - } - - Collection dictionaries = new ArrayList(); - - for ( Integer id : identifiers ) - { - dictionaries.add( getDataDictionary( id ) ); - } - - return dictionaries; + Collection dictionaries = getAllDataDictionaries(); + + return identifiers == null ? dictionaries : FilterUtils.filter( dictionaries, new Filter() + { + public boolean retain( DataDictionary object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public void deleteDataDictionary( DataDictionary dataDictionary ) === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2009-11-12 17:59:58 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementCategoryService.java 2009-11-26 14:02:44 +0000 @@ -39,6 +39,8 @@ import org.apache.commons.collections.CollectionUtils; import org.hisp.dhis.common.GenericIdentifiableObjectStore; import org.hisp.dhis.common.GenericStore; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.hisp.dhis.system.util.UUIdUtils; import org.springframework.transaction.annotation.Transactional; @@ -124,21 +126,17 @@ return dataElementCategoryStore.get( id ); } - public Collection getDataElementCategories( Collection identifiers ) + public Collection getDataElementCategories( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllDataElementCategories(); - } - - Collection categories = new ArrayList(); - - for ( Integer id : identifiers ) - { - categories.add( getDataElementCategory( id ) ); - } - - return categories; + Collection categories = getAllDataElementCategories(); + + return identifiers == null ? categories : FilterUtils.filter( categories, new Filter() + { + public boolean retain( DataElementCategory object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public DataElementCategory getDataElementCategoryByName( String name ) @@ -175,21 +173,17 @@ return dataElementCategoryOptionStore.getByName( name ); } - public Collection getDataElementCategoryOptions( Collection identifiers ) + public Collection getDataElementCategoryOptions( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllDataElementCategoryOptions(); - } - - Collection categoryOptions = new ArrayList(); - - for ( Integer id : identifiers ) - { - categoryOptions.add( getDataElementCategoryOption( id ) ); - } - - return categoryOptions; + Collection categoryOptions = getAllDataElementCategoryOptions(); + + return identifiers == null ? categoryOptions : FilterUtils.filter( categoryOptions, new Filter() + { + public boolean retain( DataElementCategoryOption object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public Collection getAllDataElementCategoryOptions() @@ -226,21 +220,17 @@ return dataElementCategoryComboStore.get( id ); } - public Collection getDataElementCategoryCombos( Collection identifiers ) + public Collection getDataElementCategoryCombos( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllDataElementCategoryCombos(); - } - - Collection categoryCombos = new ArrayList(); - - for ( Integer id : identifiers ) - { - categoryCombos.add( getDataElementCategoryCombo( id ) ); - } - - return categoryCombos; + Collection categoryCombo = getAllDataElementCategoryCombos(); + + return identifiers == null ? categoryCombo : FilterUtils.filter( categoryCombo, new Filter() + { + public boolean retain( DataElementCategoryCombo object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public DataElementCategoryCombo getDataElementCategoryComboByName( String name ) @@ -272,22 +262,17 @@ return dataElementCategoryOptionComboStore.get( id ); } - public Collection getDataElementCategoryOptionCombos( - Collection identifiers ) + public Collection getDataElementCategoryOptionCombos( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllDataElementCategoryOptionCombos(); - } - - Collection categoryOptionCombos = new ArrayList(); - - for ( Integer id : identifiers ) - { - categoryOptionCombos.add( getDataElementCategoryOptionCombo( id ) ); - } - - return categoryOptionCombos; + Collection categoryOptionCombos = getAllDataElementCategoryOptionCombos(); + + return identifiers == null ? categoryOptionCombos : FilterUtils.filter( categoryOptionCombos, new Filter() + { + public boolean retain( DataElementCategoryOptionCombo object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public DataElementCategoryOptionCombo getDataElementCategoryOptionCombo( Collection categoryOptions ) @@ -298,7 +283,7 @@ { return categoryOptionCombo; } - } // TODO Re-implement with a Hibernate Criteria + } return null; } === 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 2009-11-26 12:05:49 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataelement/DefaultDataElementService.java 2009-11-26 14:02:44 +0000 @@ -27,6 +27,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.hisp.dhis.i18n.I18nUtils.i18n; + import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -41,11 +43,11 @@ import org.hisp.dhis.common.GenericIdentifiableObjectStore; import org.hisp.dhis.hierarchy.HierarchyViolationException; import org.hisp.dhis.i18n.I18nService; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.hisp.dhis.system.util.UUIdUtils; import org.springframework.transaction.annotation.Transactional; -import static org.hisp.dhis.i18n.I18nUtils.*; - /** * @author Kristian Nordal * @version $Id: DefaultDataElementService.java 5243 2008-05-25 10:18:58Z @@ -154,40 +156,19 @@ return dataElements; } - public Collection getDataElements( Collection identifiers ) - { - if ( identifiers == null ) - { - return getAllDataElements(); - } - - Collection objects = new ArrayList(); - - for ( Integer id : identifiers ) - { - objects.add( getDataElement( id ) ); - } - - return objects; - } - - public Collection getCalculatedDataElements( Collection identifiers ) - { - if ( identifiers == null ) - { - return getAllCalculatedDataElements(); - } - - Collection objects = new ArrayList(); - - for ( Integer id : identifiers ) - { - objects.add( (CalculatedDataElement)getDataElement( id ) ); - } - - return objects; - } - + public Collection getDataElements( final Collection identifiers ) + { + Collection dataElements = getAllDataElements(); + + return identifiers == null ? dataElements : FilterUtils.filter( dataElements, new Filter() + { + public boolean retain( DataElement dataElement ) + { + return identifiers.contains( dataElement.getId() ); + } + } ); + } + public Collection getNonCalculatedDataElements( Collection identifiers ) { if ( identifiers == null ) @@ -277,6 +258,19 @@ return i18n( i18nService, dataElementStore.getAllCalculatedDataElements() ); } + public Collection getCalculatedDataElements( final Collection identifiers ) + { + Collection dataElements = getAllCalculatedDataElements(); + + return identifiers == null ? dataElements : FilterUtils.filter( dataElements, new Filter() + { + public boolean retain( CalculatedDataElement dataElement ) + { + return identifiers.contains( dataElement.getId() ); + } + } ); + } + public CalculatedDataElement getCalculatedDataElementByDataElement( DataElement dataElement ) { return i18n( i18nService, dataElementStore.getCalculatedDataElementByDataElement( dataElement ) ); @@ -368,12 +362,12 @@ public Map getCalculatedDataElementExpressionMap( Collection identifiers ) { + Collection dataElements = getCalculatedDataElements( identifiers ); + Map map = new HashMap(); - for ( Integer id : identifiers ) - { - CalculatedDataElement element = (CalculatedDataElement) getDataElement( id ); - + for ( CalculatedDataElement element : dataElements ) + { map.put( element.getId(), element.getExpression().getExpression() ); } @@ -417,21 +411,17 @@ return i18n( i18nService, dataElementGroupStore.get( id ) ); } - public Collection getDataElementGroups( Collection identifiers ) + public Collection getDataElementGroups( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllDataElementGroups(); - } - - Collection groups = new ArrayList(); - - for ( Integer id : identifiers ) - { - groups.add( getDataElementGroup( id ) ); - } - - return groups; + Collection groups = getAllDataElementGroups(); + + return identifiers == null ? groups : FilterUtils.filter( groups, new Filter() + { + public boolean retain( DataElementGroup object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public DataElementGroup getDataElementGroup( String uuid ) @@ -508,20 +498,16 @@ return i18n( i18nService, dataElementGroupSetStore.getAll() ); } - public Collection getDataElementGroupSets( Collection identifiers ) + public Collection getDataElementGroupSets( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllDataElementGroupSets(); - } - - Collection groupSets = new ArrayList(); - - for ( Integer id : identifiers ) - { - groupSets.add( getDataElementGroupSet( id ) ); - } - - return groupSets; + Collection groupSets = getAllDataElementGroupSets(); + + return identifiers == null ? groupSets : FilterUtils.filter( groupSets, new Filter() + { + public boolean retain( DataElementGroupSet object ) + { + return identifiers.contains( object.getId() ); + } + } ); } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2009-11-12 17:59:58 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataset/DefaultDataSetService.java 2009-11-26 14:02:44 +0000 @@ -27,6 +27,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import static org.hisp.dhis.i18n.I18nUtils.i18n; + import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; @@ -37,10 +39,10 @@ import org.hisp.dhis.i18n.I18nService; import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.source.Source; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.springframework.transaction.annotation.Transactional; -import static org.hisp.dhis.i18n.I18nUtils.*; - /** * @author Lars Helge Overland * @version $Id: DefaultDataSetService.java 6255 2008-11-10 16:01:24Z larshelg $ @@ -181,21 +183,17 @@ return i18n( i18nService, dataSetStore.getDataSetsByPeriodType( periodType ) ); } - public Collection getDataSets( Collection identifiers ) + public Collection getDataSets( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllDataSets(); - } - - Collection objects = new ArrayList(); - - for ( Integer id : identifiers ) - { - objects.add( getDataSet( id ) ); - } - - return objects; + Collection dataSets = getAllDataSets(); + + return identifiers == null ? dataSets : FilterUtils.filter( dataSets, new Filter() + { + public boolean retain( DataSet object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public List getAvailableDataSets() === 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 2009-11-12 17:59:58 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/indicator/DefaultIndicatorService.java 2009-11-26 14:02:44 +0000 @@ -27,18 +27,19 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; +import static org.hisp.dhis.i18n.I18nUtils.i18n; + import java.util.Collection; import java.util.Date; import java.util.Iterator; import org.hisp.dhis.common.GenericIdentifiableObjectStore; import org.hisp.dhis.i18n.I18nService; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.hisp.dhis.system.util.UUIdUtils; import org.springframework.transaction.annotation.Transactional; -import static org.hisp.dhis.i18n.I18nUtils.*; - /** * @author Lars Helge Overland * @version $Id$ @@ -137,21 +138,17 @@ return i18n( i18nService, indicatorStore.getAllIndicators() ); } - public Collection getIndicators( Collection identifiers ) + public Collection getIndicators( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllIndicators(); - } - - Collection objects = new ArrayList(); - - for ( Integer id : identifiers ) - { - objects.add( getIndicator( id ) ); - } - - return objects; + Collection indicators = getAllIndicators(); + + return identifiers == null ? indicators : FilterUtils.filter( indicators, new Filter() + { + public boolean retain( Indicator object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public Indicator getIndicatorByName( String name ) @@ -211,21 +208,17 @@ return i18n( i18nService, indicatorTypeStore.get( id ) ); } - public Collection getIndicatorTypes( Collection identifiers ) + public Collection getIndicatorTypes( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllIndicatorTypes(); - } - - Collection types = new ArrayList(); - - for ( Integer id : identifiers ) - { - types.add( getIndicatorType( id ) ); - } - - return types; + Collection types = getAllIndicatorTypes(); + + return identifiers == null ? types : FilterUtils.filter( types, new Filter() + { + public boolean retain( IndicatorType object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public Collection getAllIndicatorTypes() @@ -275,21 +268,17 @@ return i18n( i18nService, indicatorGroupStore.get( id ) ); } - public Collection getIndicatorGroups( Collection identifiers ) + public Collection getIndicatorGroups( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllIndicatorGroups(); - } - - Collection groups = new ArrayList(); - - for ( Integer id : identifiers ) - { - groups.add( getIndicatorGroup( id ) ); - } - - return groups; + Collection groups = getAllIndicatorGroups(); + + return identifiers == null ? groups : FilterUtils.filter( groups, new Filter() + { + public boolean retain( IndicatorGroup object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public IndicatorGroup getIndicatorGroup( String uuid ) @@ -368,20 +357,16 @@ return i18n( i18nService, indicatorGroupSetStore.getAll() ); } - public Collection getIndicatorGroupSets( Collection identifiers ) + public Collection getIndicatorGroupSets( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllIndicatorGroupSets(); - } - - Collection groupSets = new ArrayList(); - - for ( Integer id : identifiers ) - { - groupSets.add( getIndicatorGroupSet( id ) ); - } - - return groupSets; + Collection groupSets = getAllIndicatorGroupSets(); + + return identifiers == null ? groupSets : FilterUtils.filter( groupSets, new Filter() + { + public boolean retain( IndicatorGroupSet object ) + { + return identifiers.contains( object.getId() ); + } + } ); } } === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitGroupService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitGroupService.java 2009-11-12 17:59:58 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitGroupService.java 2009-11-26 14:02:44 +0000 @@ -32,6 +32,8 @@ import java.util.HashSet; import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.hisp.dhis.system.util.UUIdUtils; import org.springframework.transaction.annotation.Transactional; @@ -90,21 +92,17 @@ return organisationUnitGroupStore.get( id ); } - public Collection getOrganisationUnitGroups( Collection identifiers ) + public Collection getOrganisationUnitGroups( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllOrganisationUnitGroups(); - } - - Collection groups = new ArrayList(); - - for ( Integer id : identifiers ) - { - groups.add( getOrganisationUnitGroup( id ) ); - } - - return groups; + Collection objects = getAllOrganisationUnitGroups(); + + return identifiers == null ? objects : FilterUtils.filter( objects, new Filter() + { + public boolean retain( OrganisationUnitGroup object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public OrganisationUnitGroup getOrganisationUnitGroup( String uuid ) @@ -146,21 +144,17 @@ return organisationUnitGroupSetStore.get( id ); } - public Collection getOrganisationUnitGroupSets( Collection identifiers ) + public Collection getOrganisationUnitGroupSets( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllOrganisationUnitGroupSets(); - } - - Collection groupSets = new ArrayList(); - - for ( Integer id : identifiers ) - { - groupSets.add( getOrganisationUnitGroupSet( id ) ); - } - - return groupSets; + Collection objects = getAllOrganisationUnitGroupSets(); + + return identifiers == null ? objects : FilterUtils.filter( objects, new Filter() + { + public boolean retain( OrganisationUnitGroupSet object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public OrganisationUnitGroupSet getOrganisationUnitGroupSetByName( 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 2009-11-12 17:59:58 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/organisationunit/DefaultOrganisationUnitService.java 2009-11-26 14:02:44 +0000 @@ -42,6 +42,8 @@ import org.hisp.dhis.hierarchy.HierarchyViolationException; import org.hisp.dhis.organisationunit.comparator.OrganisationUnitLevelComparator; import org.hisp.dhis.source.SourceStore; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.hisp.dhis.system.util.UUIdUtils; import org.springframework.transaction.annotation.Transactional; @@ -142,21 +144,17 @@ return sourceStore.getAllSources(); } - public Collection getOrganisationUnits( Collection identifiers ) + public Collection getOrganisationUnits( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllOrganisationUnits(); - } - - Collection objects = new ArrayList(); - - for ( Integer id : identifiers ) - { - objects.add( getOrganisationUnit( id ) ); - } - - return objects; + Collection objects = getAllOrganisationUnits(); + + return identifiers == null ? objects : FilterUtils.filter( objects, new Filter() + { + public boolean retain( OrganisationUnit object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public OrganisationUnit getOrganisationUnit( String uuid ) @@ -482,21 +480,17 @@ return organisationUnitStore.getOrganisationUnitLevel( id ); } - public Collection getOrganisationUnitLevels( Collection identifiers ) + public Collection getOrganisationUnitLevels( final Collection identifiers ) { - if ( identifiers == null ) - { - return getOrganisationUnitLevels(); - } - - Collection levels = new ArrayList(); - - for ( Integer id : identifiers ) - { - levels.add( getOrganisationUnitLevel( id ) ); - } - - return levels; + Collection objects = getOrganisationUnitLevels(); + + return identifiers == null ? objects : FilterUtils.filter( objects, new Filter() + { + public boolean retain( OrganisationUnitLevel object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public void deleteOrganisationUnitLevel( OrganisationUnitLevel level ) === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java 2009-06-10 22:25:07 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/period/DefaultPeriodService.java 2009-11-26 14:02:44 +0000 @@ -37,6 +37,8 @@ import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.source.Source; import org.hisp.dhis.system.util.DateUtils; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.springframework.transaction.annotation.Transactional; /** @@ -87,21 +89,17 @@ return periodStore.getAllPeriods(); } - public Collection getPeriods( Collection identifiers ) + public Collection getPeriods( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllPeriods(); - } - - Collection objects = new ArrayList(); - - for ( Integer id : identifiers ) - { - objects.add( getPeriod( id ) ); - } - - return objects; + Collection periods = getAllPeriods(); + + return identifiers == null ? periods : FilterUtils.filter( periods, new Filter() + { + public boolean retain( Period object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public Collection getPeriodsByPeriodType( PeriodType periodType ) === modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java' --- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2009-10-27 15:12:01 +0000 +++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/validation/DefaultValidationRuleService.java 2009-11-26 14:02:44 +0000 @@ -29,7 +29,6 @@ import static org.hisp.dhis.system.util.MathUtils.expressionIsTrue; -import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.HashSet; @@ -42,6 +41,8 @@ import org.hisp.dhis.period.Period; import org.hisp.dhis.period.PeriodService; import org.hisp.dhis.source.Source; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.springframework.transaction.annotation.Transactional; /** @@ -272,21 +273,17 @@ return validationRuleStore.get( id ); } - public Collection getValidationRules( Collection identifiers ) + public Collection getValidationRules( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllValidationRules(); - } - - Collection rules = new ArrayList(); - - for ( Integer id : identifiers ) - { - rules.add( getValidationRule( id ) ); - } - - return rules; + Collection objects = getAllValidationRules(); + + return identifiers == null ? objects : FilterUtils.filter( objects, new Filter() + { + public boolean retain( ValidationRule object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public ValidationRule getValidationRuleByName( String name ) === modified file 'dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java' --- dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java 2009-11-26 10:38:53 +0000 +++ dhis-2/dhis-services/dhis-service-importexport/src/main/java/org/hisp/dhis/importexport/dxf/converter/DataElementConverter.java 2009-11-26 14:02:44 +0000 @@ -44,6 +44,7 @@ import org.hisp.dhis.importexport.converter.AbstractDataElementConverter; import org.hisp.dhis.importexport.mapping.NameMappingUtil; import org.hisp.dhis.system.util.DateUtils; +import org.hisp.dhis.system.util.TimeUtils; /** * @author Lars Helge Overland @@ -111,8 +112,11 @@ public void write( XMLWriter writer, ExportParams params ) { + TimeUtils.start(); Collection elements = dataElementService.getNonCalculatedDataElements( params.getDataElements() ); - + TimeUtils.markHMS( "Got de" ); + TimeUtils.stop(); + if ( elements != null && elements.size() > 0 ) { writer.openElement( COLLECTION_NAME ); === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/olap/DefaultOlapURLService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/olap/DefaultOlapURLService.java 2009-10-27 15:12:01 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/olap/DefaultOlapURLService.java 2009-11-26 14:02:44 +0000 @@ -27,10 +27,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.util.ArrayList; import java.util.Collection; import org.hisp.dhis.common.GenericIdentifiableObjectStore; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.springframework.transaction.annotation.Transactional; /** @@ -89,21 +90,17 @@ return olapURLStore.get( id ); } - public Collection getOlapURLs( Collection identifiers ) + public Collection getOlapURLs( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllOlapURLs(); - } - - Collection urls = new ArrayList(); - - for ( Integer id : identifiers ) - { - urls.add( getOlapURL( id ) ); - } - - return urls; + Collection objects = getAllOlapURLs(); + + return identifiers == null ? objects : FilterUtils.filter( objects, new Filter() + { + public boolean retain( OlapURL object ) + { + return identifiers.contains( object.getId() ); + } + } ); } public void deleteOlapURL( OlapURL olapURL ) === modified file 'dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java' --- dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2009-11-23 17:17:04 +0000 +++ dhis-2/dhis-services/dhis-service-reporting/src/main/java/org/hisp/dhis/reporttable/impl/DefaultReportTableService.java 2009-11-26 14:02:44 +0000 @@ -67,6 +67,8 @@ import org.hisp.dhis.reporttable.ReportTableService; import org.hisp.dhis.reporttable.jdbc.ReportTableManager; import org.hisp.dhis.system.grid.Grid; +import org.hisp.dhis.system.util.Filter; +import org.hisp.dhis.system.util.FilterUtils; import org.springframework.transaction.annotation.Transactional; /** @@ -487,21 +489,17 @@ } @Transactional - public Collection getReportTables( Collection identifiers ) + public Collection getReportTables( final Collection identifiers ) { - if ( identifiers == null ) - { - return getAllReportTables(); - } - - Collection tables = new ArrayList(); - - for ( Integer id : identifiers ) - { - tables.add( getReportTable( id ) ); - } - - return tables; + Collection objects = getAllReportTables(); + + return identifiers == null ? objects : FilterUtils.filter( objects, new Filter() + { + public boolean retain( ReportTable object ) + { + return identifiers.contains( object.getId() ); + } + } ); } @Transactional