=== added file 'dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/IdentifiableObjectUtils.java' --- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/IdentifiableObjectUtils.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/IdentifiableObjectUtils.java 2011-05-22 19:09:48 +0000 @@ -0,0 +1,64 @@ +package org.hisp.dhis.system.util; + +/* + * Copyright (c) 2004-2010, University of Oslo + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * * Neither the name of the HISP project nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; + +import org.hisp.dhis.common.IdentifiableObject; + +/* + * @author mortenoh + */ +public class IdentifiableObjectUtils +{ + public static List filterNameByKey( List identifiableObjects, String key, + boolean ignoreCase ) + { + List objects = new ArrayList(); + ListIterator iterator = identifiableObjects.listIterator(); + + if ( ignoreCase ) + { + key = key.toLowerCase(); + } + + while ( iterator.hasNext() ) + { + T object = iterator.next(); + + if ( object.getName().toLowerCase().indexOf( key ) != -1 ) + { + objects.add( object ); + } + } + + return objects; + } +} === modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js 2011-05-20 09:56:37 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/jQuery/jquery.dhisPaging.js 2011-05-22 19:09:48 +0000 @@ -226,7 +226,7 @@ }); $filter_button.click(function() { - params.key = escape( $filter_input.val() ); + params.key = $filter_input.val(); if(params.key.length === 0) { delete params.key; === 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 2011-05-20 09:56:37 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementsAction.java 2011-05-22 19:09:48 +0000 @@ -27,13 +27,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.net.URLDecoder; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; -import java.util.ListIterator; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataelement.DataElementCategoryCombo; @@ -48,6 +46,7 @@ import org.hisp.dhis.period.PeriodType; import org.hisp.dhis.system.filter.AggregatableDataElementFilter; import org.hisp.dhis.system.util.FilterUtils; +import org.hisp.dhis.system.util.IdentifiableObjectUtils; /** * @author Lars Helge Overland @@ -150,7 +149,7 @@ { this.key = key; } - + private List removeDataSets = new ArrayList(); public void setRemoveDataSets( String removeDataSets ) @@ -267,22 +266,11 @@ } } - if( key != null ) + if ( key != null ) { - ListIterator iterator = dataElements.listIterator(); - key = URLDecoder.decode( key, "UTF-8" ).toLowerCase(); - - while( iterator.hasNext() ) - { - DataElement dataElement = iterator.next(); - - if ( dataElement.getName().toLowerCase().indexOf( key ) == -1) - { - iterator.remove(); - } - } + dataElements = IdentifiableObjectUtils.filterNameByKey( dataElements, key, true ); } - + Collections.sort( dataElements, dataElementComparator ); if ( aggregate ) === 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-20 09:56:37 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorsAction.java 2011-05-22 19:09:48 +0000 @@ -27,13 +27,11 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import java.net.URLDecoder; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; -import java.util.ListIterator; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; @@ -42,6 +40,7 @@ import org.hisp.dhis.indicator.IndicatorService; import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler; import org.hisp.dhis.paging.ActionPagingSupport; +import org.hisp.dhis.system.util.IdentifiableObjectUtils; /** * @author Lars Helge Overland @@ -209,18 +208,7 @@ if ( key != null ) { - ListIterator iterator = indicators.listIterator(); - key = URLDecoder.decode( key, "UTF-8" ).toLowerCase(); - - while ( iterator.hasNext() ) - { - Indicator indicator = iterator.next(); - - if ( indicator.getName().toLowerCase().indexOf( key ) == -1) - { - iterator.remove(); - } - } + indicators = IdentifiableObjectUtils.filterNameByKey( indicators, key, true ); } Collections.sort( indicators, indicatorComparator );