=== added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroupSets.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroupSets.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonDataElementGroupSets.vm 2011-05-24 09:42:48 +0000 @@ -0,0 +1,13 @@ +#set( $size = $dataElementGroupSets.size() ) +{ "dataElementGroupSets": [ +#foreach( $dataElementGroupSet in $dataElementGroupSets ) + { + "id": ${dataElementGroupSet.id} , + "name": "$!encoder.jsonEncode( ${dataElementGroupSet.name} )" + }#if( $velocityCount < $size ),#end +#end +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} === added file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicatorGroupSets.vm' --- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicatorGroupSets.vm 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ajax/jsonIndicatorGroupSets.vm 2011-05-24 09:42:48 +0000 @@ -0,0 +1,13 @@ +#set( $size = $indicatorGroupSets.size() ) +{ "indicatorGroupSets": [ +#foreach( $indicatorGroupSet in $indicatorGroupSets ) + { + "id": $!{indicatorGroupSet.id}, + "name": "$!encoder.jsonEncode( ${indicatorGroupSet.name} )" + }#if( $velocityCount < $size ),#end +#end +] +#if( $usePaging ), + "paging":#parse( "/dhis-web-commons/ajax/jsonPaging.vm" ) +#end +} === added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetsAction.java 2011-05-24 09:42:48 +0000 @@ -0,0 +1,100 @@ +package org.hisp.dhis.commons.action; + +/* + * 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.Collections; +import java.util.List; + +import org.hisp.dhis.dataelement.DataElementGroupSet; +import org.hisp.dhis.dataelement.DataElementService; +import org.hisp.dhis.dataelement.comparator.DataElementGroupSetNameComparator; +import org.hisp.dhis.paging.ActionPagingSupport; +import org.hisp.dhis.system.util.IdentifiableObjectUtils; + +/** + * @author mortenoh + */ +public class GetDataElementGroupSetsAction + extends ActionPagingSupport +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private DataElementService dataElementService; + + public void setDataElementService( DataElementService dataElementService ) + { + this.dataElementService = dataElementService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String key; + + public void setKey( String key ) + { + this.key = key; + } + + private List dataElementGroupSets; + + public List getDataElementGroupSets() + { + return dataElementGroupSets; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + public String execute() + throws Exception + { + dataElementGroupSets = new ArrayList( dataElementService.getAllDataElementGroupSets() ); + + if ( key != null ) + { + dataElementGroupSets = IdentifiableObjectUtils.filterNameByKey( dataElementGroupSets, key, true ); + } + + Collections.sort( dataElementGroupSets, new DataElementGroupSetNameComparator() ); + + if ( usePaging ) + { + this.paging = createPaging( dataElementGroupSets.size() ); + + dataElementGroupSets = dataElementGroupSets.subList( paging.getStartPos(), paging.getEndPos() ); + } + + return SUCCESS; + } +} \ No newline at end of file === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupsAction.java 2011-05-06 10:49:36 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupsAction.java 2011-05-24 09:42:48 +0000 @@ -35,10 +35,11 @@ import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataelement.comparator.DataElementGroupNameComparator; import org.hisp.dhis.paging.ActionPagingSupport; +import org.hisp.dhis.system.util.IdentifiableObjectUtils; /** * @author Tran Thanh Tri - * @version $Id: GetDataElementGroupsAction 2010-8-28$ + * @author mortenoh */ public class GetDataElementGroupsAction extends ActionPagingSupport @@ -58,6 +59,13 @@ // Input & output // ------------------------------------------------------------------------- + private String key; + + public void setKey( String key ) + { + this.key = key; + } + private List dataElementGroups; public List getDataElementGroups() @@ -74,6 +82,11 @@ { dataElementGroups = new ArrayList( dataElementService.getAllDataElementGroups() ); + if ( key != null ) + { + dataElementGroups = IdentifiableObjectUtils.filterNameByKey( dataElementGroups, key, true ); + } + Collections.sort( this.dataElementGroups, new DataElementGroupNameComparator() ); if ( usePaging ) @@ -82,7 +95,7 @@ dataElementGroups = dataElementGroups.subList( paging.getStartPos(), paging.getEndPos() ); } - + return SUCCESS; } } === added file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupSetsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupSetsAction.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupSetsAction.java 2011-05-24 09:42:48 +0000 @@ -0,0 +1,101 @@ +package org.hisp.dhis.commons.action; + +/* + * 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.Collections; +import java.util.List; + +import org.hisp.dhis.indicator.IndicatorGroupSet; +import org.hisp.dhis.indicator.IndicatorService; +import org.hisp.dhis.indicator.comparator.IndicatorGroupSetNameComparator; +import org.hisp.dhis.paging.ActionPagingSupport; +import org.hisp.dhis.system.util.IdentifiableObjectUtils; + +/** + * @author mortenoh + */ +public class GetIndicatorGroupSetsAction + extends ActionPagingSupport +{ + // ------------------------------------------------------------------------- + // Dependencies + // ------------------------------------------------------------------------- + + private IndicatorService indicatorService; + + public void setIndicatorService( IndicatorService indicatorService ) + { + this.indicatorService = indicatorService; + } + + // ------------------------------------------------------------------------- + // Input & Output + // ------------------------------------------------------------------------- + + private String key; + + public void setKey( String key ) + { + this.key = key; + } + + private List indicatorGroupSets; + + public List getIndicatorGroupSets() + { + return indicatorGroupSets; + } + + // ------------------------------------------------------------------------- + // Action implementation + // ------------------------------------------------------------------------- + + @Override + public String execute() + throws Exception + { + indicatorGroupSets = new ArrayList( indicatorService.getAllIndicatorGroupSets() ); + + if ( key != null ) + { + indicatorGroupSets = IdentifiableObjectUtils.filterNameByKey( indicatorGroupSets, key, true ); + } + + Collections.sort( indicatorGroupSets, new IndicatorGroupSetNameComparator() ); + + if ( usePaging ) + { + this.paging = createPaging( indicatorGroupSets.size() ); + + indicatorGroupSets = indicatorGroupSets.subList( paging.getStartPos(), paging.getEndPos() ); + } + + return SUCCESS; + } +} === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupsAction.java' --- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupsAction.java 2011-05-06 10:49:36 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupsAction.java 2011-05-24 09:42:48 +0000 @@ -35,9 +35,10 @@ import org.hisp.dhis.indicator.IndicatorService; import org.hisp.dhis.indicator.comparator.IndicatorGroupNameComparator; import org.hisp.dhis.paging.ActionPagingSupport; +import org.hisp.dhis.system.util.IdentifiableObjectUtils; /** - * @author Tran Thanh Tri + * @author mortenoh */ public class GetIndicatorGroupsAction extends ActionPagingSupport @@ -54,9 +55,16 @@ } // ------------------------------------------------------------------------- - // Output + // Input & Output // ------------------------------------------------------------------------- + private String key; + + public void setKey( String key ) + { + this.key = key; + } + private List indicatorGroups; public List getIndicatorGroups() @@ -72,6 +80,11 @@ { indicatorGroups = new ArrayList( indicatorService.getAllIndicatorGroups() ); + if ( key != null ) + { + indicatorGroups = IdentifiableObjectUtils.filterNameByKey( indicatorGroups, key, true ); + } + Collections.sort( indicatorGroups, new IndicatorGroupNameComparator() ); if ( usePaging ) === 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-23 10:33:52 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/META-INF/dhis/beans.xml 2011-05-24 09:42:48 +0000 @@ -357,6 +357,11 @@ + + + + @@ -401,6 +406,11 @@ + + + + === modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml' --- dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2011-05-23 10:33:52 +0000 +++ dhis-2/dhis-web/dhis-web-commons/src/main/resources/dhis-web-commons.xml 2011-05-24 09:42:48 +0000 @@ -487,6 +487,13 @@ plainTextError + + + /dhis-web-commons/ajax/jsonDataElementGroupSets.vm + plainTextError + + /dhis-web-commons/ajax/jsonDataElements.vm @@ -546,6 +553,13 @@ plainTextError + + + /dhis-web-commons/ajax/jsonIndicatorGroupSets.vm + plainTextError + + /dhis-web-commons/ajax/jsonIndicators.vm