dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #11969
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 3521: added paging to dhis-web-commons-ajax-json collections and added extra checks to avoid NPEs
------------------------------------------------------------
revno: 3521
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-05-06 12:49:36 +0200
message:
added paging to dhis-web-commons-ajax-json collections and added extra checks to avoid NPEs
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.ajax.js
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAvailablePeriodsAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionCombosAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetAction.java
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/GetDataElementNameAction.java
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/GetDataSetAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetExpressionTextAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupSetAction.java
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/GetIndicatorsAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitChildrenAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitGroupsAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitLevelsAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitsAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodTypesAction.java
dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodsAction.java
--
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-resources/src/main/webapp/dhis-web-commons/javascripts/commons.ajax.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.ajax.js 2011-05-06 08:09:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/commons.ajax.js 2011-05-06 10:49:36 +0000
@@ -32,22 +32,25 @@
if( dataElementsGroups.length == 0 )
{
- jQuery.getJSON('../dhis-web-commons-ajax-json/getDataElementGroups.action'
- , function( json ){
+ jQuery.getJSON('../dhis-web-commons-ajax-json/getDataElementGroups.action',
+ function( json )
+ {
target.append('<option value="' + ALL_KEY + '">ALL</option>');
dataElementsGroups.push( new DataElementGroup(ALL_KEY, 'ALL') );
+
jQuery.each( json.dataElementGroups, function(i, item){
dataElementsGroups.push( new DataElementGroup(item.id, item.name) );
target.append('<option value="' + item.id + '">' + item.name + '</option>');
});
- });
- }else{
+ }
+ );
+ } else {
jQuery.each( dataElementsGroups, function(i, item){
target.append('<option value="' + item.id + '">' + item.name + '</option>');
});
}
}
-
+
this.loadAllDataElements = function( jQuerySelectionString )
{
this.loadDataElementsByGroup( '0', jQuerySelectionString);
@@ -56,32 +59,34 @@
this.loadDataElementsByGroup = function( id, jQuerySelectionString )
{
var target = jQuery( jQuerySelectionString );
-
+
target.children().remove();
-
+
var des = dataElementGroupList[id];
-
+
if( des == null )
{
des = new Array();
-
- jQuery.getJSON('../dhis-web-commons-ajax-json/getDataElements.action'
- ,{id:id}
- , function( json ){
- jQuery.each( json.dataElements, function(i, item){
+
+ jQuery.getJSON('../dhis-web-commons-ajax-json/getDataElements.action',
+ {id:id},
+ function( json )
+ {
+ jQuery.each( json.dataElements, function(i, item) {
des.push( new DataElement(item.id, item.name) );
target.append('<option value="' + item.id + '">' + item.name + '</option>');
});
+
dataElementGroupList[id] = des;
- });
- }else{
- jQuery.each( des, function(i, item){
+ }
+ );
+ } else {
+ jQuery.each( des, function(i, item) {
target.append('<option value="' + item.id + '">' + item.name + '</option>');
});
}
}
-
this.loadIndicatorGroups = function( jQuerySelectionString )
{
var target = jQuery( jQuerySelectionString );
@@ -90,27 +95,29 @@
if( indicatorGroups.length == 0 )
{
- jQuery.getJSON('../dhis-web-commons-ajax-json/getIndicatorGroups.action'
- , function( json ){
+ jQuery.getJSON('../dhis-web-commons-ajax-json/getIndicatorGroups.action',
+ function( json )
+ {
target.append('<option value="' + ALL_KEY + '">ALL</option>');
indicatorGroups.push( new IndicatorGroup( ALL_KEY, 'ALL') );
jQuery.each( json.indicatorGroups, function(i, item){
indicatorGroups.push( new IndicatorGroup(item.id, item.name) );
target.append('<option value="' + item.id + '">' + item.name + '</option>');
});
- });
- }else{
+ }
+ );
+ } else {
jQuery.each( indicatorGroups, function(i, item){
target.append('<option value="' + item.id + '">' + item.name + '</option>');
});
}
}
-
+
this.loadAllIndicators = function( jQuerySelectionString )
{
this.loadIndicatorsByGroup( ALL_KEY, jQuerySelectionString );
}
-
+
this.loadIndicatorsByGroup = function( id, jQuerySelectionString )
{
var target = jQuery( jQuerySelectionString );
@@ -123,16 +130,19 @@
{
ins = new Array();
- jQuery.getJSON('../dhis-web-commons-ajax-json/getIndicators.action'
- ,{id:id}
- , function( json ){
+ jQuery.getJSON('../dhis-web-commons-ajax-json/getIndicators.action',
+ {id:id},
+ function( json )
+ {
jQuery.each( json.indicators, function(i, item){
ins.push( new Indicator(item.id, item.name) );
target.append('<option value="' + item.id + '">' + item.name + '</option>');
});
+
indicatorGroupList[id] = ins;
- });
- }else{
+ }
+ );
+ } else {
jQuery.each( ins, function(i, item){
target.append('<option value="' + item.id + '">' + item.name + '</option>');
});
@@ -150,22 +160,24 @@
if( options == null )
{
options = new Array();
-
- jQuery.getJSON('../dhis-web-commons-ajax-json/getCategoryOptionCombos.action'
- ,{id:id}
- , function( json ){
- jQuery.each( json.categoryOptionCombos, function(i, item){
+
+ jQuery.getJSON('../dhis-web-commons-ajax-json/getCategoryOptionCombos.action',
+ {id:id},
+ function( json )
+ {
+ jQuery.each( json.categoryOptionCombos, function(i, item) {
options.push( new OptionCombo(item.id, item.name) );
target.append('<option value="' + item.id + '">' + item.name + '</option>');
});
+
categoryOptionComboList[id] = options;
- });
- }else{
- jQuery.each( options, function(i, item){
+ }
+ );
+ } else {
+ jQuery.each( options, function(i, item) {
target.append('<option value="' + item.id + '">' + item.name + '</option>');
});
}
-
}
this.reloadOperands = function( currentpage )
@@ -189,7 +201,9 @@
this.jQuerySelectionString = jQuerySelectionString;
jQuery.getJSON( '../dhis-web-commons-ajax-json/getOperands.action',
- this.params, function( json ) {
+ this.params,
+ function( json )
+ {
jQuery.each( json.operands, function(i, item){
target.append('<option value="[' + item.operandId + ']">' + item.operandName + '</option>');
});
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAvailablePeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAvailablePeriodsAction.java 2010-07-18 15:17:23 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetAvailablePeriodsAction.java 2011-05-06 10:49:36 +0000
@@ -32,6 +32,7 @@
import java.util.List;
import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.paging.ActionPagingSupport;
import org.hisp.dhis.period.CalendarPeriodType;
import org.hisp.dhis.period.MonthlyPeriodType;
import org.hisp.dhis.period.Period;
@@ -40,13 +41,11 @@
import org.hisp.dhis.system.util.FilterUtils;
import org.hisp.dhis.util.SessionUtils;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Lars Helge Overland
*/
public class GetAvailablePeriodsAction
- implements Action
+ extends ActionPagingSupport<Period>
{
private I18nFormat format;
@@ -113,6 +112,13 @@
FilterUtils.filter( periods, new PastAndCurrentPeriodFilter() );
Collections.reverse( periods );
+
+ if ( usePaging )
+ {
+ this.paging = createPaging( periods.size() );
+
+ periods = periods.subList( paging.getStartPos(), paging.getEndPos() );
+ }
for ( Period period : periods )
{
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionCombosAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionCombosAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetCategoryOptionCombosAction.java 2011-05-06 10:49:36 +0000
@@ -30,6 +30,7 @@
import java.util.Set;
import org.hisp.dhis.dataelement.DataElement;
+import org.hisp.dhis.dataelement.DataElementCategoryCombo;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElementService;
@@ -80,10 +81,21 @@
public String execute()
{
- DataElement dataElement = dataElementService.getDataElement( id );
-
- categoryOptionCombos = dataElement.getCategoryCombo().getOptionCombos();
-
+ if ( id != null )
+ {
+ DataElement dataElement = dataElementService.getDataElement( id );
+
+ if ( dataElement != null )
+ {
+ DataElementCategoryCombo categoryCombo = dataElement.getCategoryCombo();
+
+ if ( categoryCombo != null )
+ {
+ categoryOptionCombos = categoryCombo.getOptionCombos();
+ }
+ }
+ }
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementAction.java 2011-05-06 10:49:36 +0000
@@ -41,20 +41,20 @@
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
+
private DataElementService dataElementService;
-
+
public void setDataElementService( DataElementService dataElementService )
{
this.dataElementService = dataElementService;
}
// -------------------------------------------------------------------------
- // Input
+ // Input
// -------------------------------------------------------------------------
-
+
private Integer id;
-
+
public void setId( Integer id )
{
this.id = id;
@@ -63,7 +63,7 @@
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
-
+
private DataElement dataElement;
public DataElement getDataElement()
@@ -74,10 +74,13 @@
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
-
+
public String execute()
{
- dataElement = dataElementService.getDataElement( id );
+ if ( id != null )
+ {
+ dataElement = dataElementService.getDataElement( id );
+ }
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupAction.java 2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupAction.java 2011-05-06 10:49:36 +0000
@@ -34,7 +34,8 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: GetDataElementGroupAction.java 2869 2007-02-20 14:26:09Z andegje $
+ * @version $Id: GetDataElementGroupAction.java 2869 2007-02-20 14:26:09Z
+ * andegje $
*/
public class GetDataElementGroupAction
implements Action
@@ -81,9 +82,11 @@
public String execute()
{
- dataElementGroup = dataElementService.getDataElementGroup( id );
-
- memberCount = dataElementGroup.getMembers().size();
+ if ( id != null )
+ {
+ dataElementGroup = dataElementService.getDataElementGroup( id );
+ memberCount = dataElementGroup.getMembers().size();
+ }
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetAction.java 2010-11-20 08:23:34 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupSetAction.java 2011-05-06 10:49:36 +0000
@@ -1,4 +1,5 @@
package org.hisp.dhis.commons.action;
+
/*
* Copyright (c) 2004-2010, University of Oslo
* All rights reserved.
@@ -36,7 +37,7 @@
* @version $Id$
*/
public class GetDataElementGroupSetAction
- implements Action
+ implements Action
{
// -------------------------------------------------------------------------
// Dependencies
@@ -48,7 +49,7 @@
{
this.dataElementService = dataElementService;
}
-
+
// -------------------------------------------------------------------------
// Input & Output
// -------------------------------------------------------------------------
@@ -59,9 +60,9 @@
{
this.id = id;
}
-
+
private DataElementGroupSet dataElementGroupSet;
-
+
public DataElementGroupSet getDataElementGroupSet()
{
return dataElementGroupSet;
@@ -70,9 +71,10 @@
public String execute()
throws Exception
{
-
- dataElementGroupSet = dataElementService.getDataElementGroupSet( id );
-
+ if ( id != null )
+ {
+ dataElementGroupSet = dataElementService.getDataElementGroupSet( id );
+ }
return SUCCESS;
}
=== 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-01-25 21:27:17 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementGroupsAction.java 2011-05-06 10:49:36 +0000
@@ -34,18 +34,15 @@
import org.hisp.dhis.dataelement.DataElementGroup;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataelement.comparator.DataElementGroupNameComparator;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.paging.ActionPagingSupport;
/**
* @author Tran Thanh Tri
* @version $Id: GetDataElementGroupsAction 2010-8-28$
*/
public class GetDataElementGroupsAction
- implements Action
+ extends ActionPagingSupport<DataElementGroup>
{
-
-
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -79,6 +76,13 @@
Collections.sort( this.dataElementGroups, new DataElementGroupNameComparator() );
+ if ( usePaging )
+ {
+ this.paging = createPaging( dataElementGroups.size() );
+
+ dataElementGroups = dataElementGroups.subList( paging.getStartPos(), paging.getEndPos() );
+ }
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementNameAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementNameAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementNameAction.java 2011-05-06 10:49:36 +0000
@@ -52,7 +52,7 @@
}
private DataElementCategoryService categoryService;
-
+
public void setCategoryService( DataElementCategoryService categoryService )
{
this.categoryService = categoryService;
@@ -93,12 +93,16 @@
public String execute()
{
- DataElement dataElement = dataElementService.getDataElement( dataElementId );
-
- DataElementCategoryOptionCombo categoryOptionCombo = categoryService.getDataElementCategoryOptionCombo( categoryOptionComboId );
-
- name = dataElement.getName() + " " + categoryOptionCombo.getName();
-
+ if ( dataElementId != null && categoryOptionComboId != null )
+ {
+ DataElement dataElement = dataElementService.getDataElement( dataElementId );
+
+ DataElementCategoryOptionCombo categoryOptionCombo = categoryService
+ .getDataElementCategoryOptionCombo( categoryOptionComboId );
+
+ name = dataElement.getName() + " " + categoryOptionCombo.getName();
+ }
+
return SUCCESS;
}
}
=== 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 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataElementsAction.java 2011-05-06 10:49:36 +0000
@@ -40,19 +40,18 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
+import org.hisp.dhis.paging.ActionPagingSupport;
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;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Lars Helge Overland
* @version $Id: GetDataElementsAction.java 2869 2007-02-20 14:26:09Z andegje $
*/
public class GetDataElementsAction
- implements Action
+ extends ActionPagingSupport<DataElement>
{
private final static int ALL = 0;
@@ -209,14 +208,21 @@
}
Collections.sort( dataElements, dataElementComparator );
-
- displayPropertyHandler.handle( dataElements );
if ( aggregate )
{
FilterUtils.filter( dataElements, new AggregatableDataElementFilter() );
}
+
+ if ( usePaging )
+ {
+ this.paging = createPaging( dataElements.size() );
+
+ dataElements = dataElements.subList( paging.getStartPos(), paging.getEndPos() );
+ }
+ displayPropertyHandler.handle( dataElements );
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetAction.java 2011-05-06 10:49:36 +0000
@@ -43,7 +43,7 @@
// -------------------------------------------------------------------------
private DataSetService dataSetService;
-
+
public void setDataSetService( DataSetService dataSetService )
{
this.dataSetService = dataSetService;
@@ -59,11 +59,11 @@
{
this.id = id;
}
-
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
-
+
private DataSet dataSet;
public DataSet getDataSet()
@@ -74,11 +74,14 @@
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
-
+
public String execute()
{
- dataSet = dataSetService.getDataSet( id );
-
+ if ( id != null )
+ {
+ dataSet = dataSetService.getDataSet( id );
+ }
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java 2010-12-30 09:13:41 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetDataSetsAction.java 2011-05-06 10:49:36 +0000
@@ -36,19 +36,18 @@
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.dataset.comparator.DataSetNameComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.user.CurrentUserService;
import org.hisp.dhis.user.UserAuthorityGroup;
import org.hisp.dhis.user.UserService;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Lars Helge Overland
* @version $Id$
*/
public class GetDataSetsAction
- implements Action
+ extends ActionPagingSupport<DataSet>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -98,7 +97,7 @@
public void setName( String name )
{
this.name = name;
- }
+ }
// -------------------------------------------------------------------------
// Output
@@ -124,8 +123,8 @@
}
else if ( id != null )
{
- dataSets = new ArrayList<DataSet>( dataSetService
- .getDataSetsByPeriodType( periodService.getPeriodType( id ) ) );
+ dataSets = new ArrayList<DataSet>(
+ dataSetService.getDataSetsByPeriodType( periodService.getPeriodType( id ) ) );
}
else if ( name != null )
{
@@ -148,6 +147,13 @@
Collections.sort( dataSets, new DataSetNameComparator() );
+ if ( usePaging )
+ {
+ this.paging = createPaging( dataSets.size() );
+
+ dataSets = dataSets.subList( paging.getStartPos(), paging.getEndPos() );
+ }
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetExpressionTextAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetExpressionTextAction.java 2011-01-25 21:27:17 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetExpressionTextAction.java 2011-05-06 10:49:36 +0000
@@ -95,5 +95,4 @@
}
}
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorAction.java 2011-05-06 10:49:36 +0000
@@ -48,37 +48,40 @@
{
this.indicatorService = indicatorService;
}
-
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
private Integer id;
-
+
public void setId( Integer id )
{
this.id = id;
}
-
+
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
- private Indicator indicator;
-
+ private Indicator indicator;
+
public Indicator getIndicator()
{
return indicator;
}
-
+
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
public String execute()
{
- indicator = indicatorService.getIndicator( id );
-
+ if ( id != null )
+ {
+ indicator = indicatorService.getIndicator( id );
+ }
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupAction.java 2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupAction.java 2011-05-06 10:49:36 +0000
@@ -34,7 +34,8 @@
/**
* @author Torgeir Lorange Ostby
- * @version $Id: GetIndicatorGroupAction.java 3305 2007-05-14 18:55:52Z larshelg $
+ * @version $Id: GetIndicatorGroupAction.java 3305 2007-05-14 18:55:52Z larshelg
+ * $
*/
public class GetIndicatorGroupAction
implements Action
@@ -49,7 +50,7 @@
{
this.indicatorService = indicatorService;
}
-
+
// -------------------------------------------------------------------------
// Input/output
// -------------------------------------------------------------------------
@@ -81,9 +82,11 @@
public String execute()
{
- indicatorGroup = indicatorService.getIndicatorGroup( id );
-
- memberCount = indicatorGroup.getMembers().size();
+ if ( id != null )
+ {
+ indicatorGroup = indicatorService.getIndicatorGroup( id );
+ memberCount = indicatorGroup.getMembers().size();
+ }
return SUCCESS;
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupSetAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupSetAction.java 2010-11-20 08:23:34 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupSetAction.java 2011-05-06 10:49:36 +0000
@@ -1,4 +1,5 @@
package org.hisp.dhis.commons.action;
+
/*
* Copyright (c) 2004-2010, University of Oslo
* All rights reserved.
@@ -72,8 +73,11 @@
public String execute()
throws Exception
{
- indicatorGroupSet = indicatorService.getIndicatorGroupSet( id );
-
+ if ( id != null )
+ {
+ indicatorGroupSet = indicatorService.getIndicatorGroupSet( id );
+ }
+
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 2010-08-31 08:12:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorGroupsAction.java 2011-05-06 10:49:36 +0000
@@ -34,14 +34,13 @@
import org.hisp.dhis.indicator.IndicatorGroup;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.comparator.IndicatorGroupNameComparator;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.paging.ActionPagingSupport;
/**
* @author Tran Thanh Tri
*/
public class GetIndicatorGroupsAction
- implements Action
+ extends ActionPagingSupport<IndicatorGroup>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -72,9 +71,16 @@
public String execute()
{
indicatorGroups = new ArrayList<IndicatorGroup>( indicatorService.getAllIndicatorGroups() );
-
+
Collections.sort( indicatorGroups, new IndicatorGroupNameComparator() );
+ if ( usePaging )
+ {
+ this.paging = createPaging( indicatorGroups.size() );
+
+ indicatorGroups = indicatorGroups.subList( paging.getStartPos(), paging.getEndPos() );
+ }
+
return SUCCESS;
}
}
=== 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 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetIndicatorsAction.java 2011-05-06 10:49:36 +0000
@@ -36,18 +36,17 @@
import org.hisp.dhis.indicator.IndicatorGroup;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.paging.ActionPagingSupport;
/**
* @author Lars Helge Overland
* @version $Id: GetIndicatorsAction.java 3305 2007-05-14 18:55:52Z larshelg $
*/
public class GetIndicatorsAction
- implements Action
+ extends ActionPagingSupport<Indicator>
{
private final static int ALL = 0;
-
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -58,7 +57,7 @@
{
this.indicatorService = indicatorService;
}
-
+
// -------------------------------------------------------------------------
// Comparator
// -------------------------------------------------------------------------
@@ -79,31 +78,32 @@
public void setDisplayPropertyHandler( DisplayPropertyHandler displayPropertyHandler )
{
this.displayPropertyHandler = displayPropertyHandler;
- }
-
+ }
+
// -------------------------------------------------------------------------
// Input & output
// -------------------------------------------------------------------------
-
+
private Integer id;
public void setId( Integer id )
{
this.id = id;
}
-
+
private List<Indicator> indicators;
public List<Indicator> getIndicators()
{
return indicators;
- }
+ }
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
- public String execute() throws Exception
+ public String execute()
+ throws Exception
{
if ( id == null || id == ALL )
{
@@ -112,9 +112,9 @@
else
{
IndicatorGroup indicatorGroup = indicatorService.getIndicatorGroup( id );
-
+
if ( indicatorGroup != null )
- {
+ {
indicators = new ArrayList<Indicator>( indicatorGroup.getMembers() );
}
else
@@ -122,11 +122,18 @@
indicators = new ArrayList<Indicator>();
}
}
-
+
Collections.sort( indicators, indicatorComparator );
-
+
+ if ( usePaging )
+ {
+ this.paging = createPaging( indicators.size() );
+
+ indicators = indicators.subList( paging.getStartPos(), paging.getEndPos() );
+ }
+
displayPropertyHandler.handle( indicators );
-
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitAction.java 2011-05-06 10:49:36 +0000
@@ -41,7 +41,7 @@
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
-
+
private OrganisationUnitService organisationUnitService;
public void setOrganisationUnitService( OrganisationUnitService organisationUnitService )
@@ -52,7 +52,7 @@
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
-
+
private Integer id;
public void setId( Integer id )
@@ -63,7 +63,7 @@
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
-
+
private OrganisationUnit organisationUnit;
public OrganisationUnit getOrganisationUnit()
@@ -74,11 +74,14 @@
// -------------------------------------------------------------------------
// Action implementation
// -------------------------------------------------------------------------
-
+
public String execute()
{
- organisationUnit = organisationUnitService.getOrganisationUnit( id );
-
+ if ( id != null )
+ {
+ organisationUnit = organisationUnitService.getOrganisationUnit( id );
+ }
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitChildrenAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitChildrenAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitChildrenAction.java 2011-05-06 10:49:36 +0000
@@ -35,15 +35,14 @@
import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.paging.ActionPagingSupport;
/**
* @author Lars Helge Overland
* @version $Id$
*/
public class GetOrganisationUnitChildrenAction
- implements Action
+ extends ActionPagingSupport<OrganisationUnit>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -77,7 +76,7 @@
{
this.organisationUnitComparator = organisationUnitComparator;
}
-
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -92,7 +91,7 @@
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
-
+
private List<OrganisationUnit> organisationUnits;
public List<OrganisationUnit> getOrganisationUnits()
@@ -108,11 +107,18 @@
throws Exception
{
OrganisationUnit unit = organisationUnitService.getOrganisationUnit( id );
-
+
organisationUnits = new ArrayList<OrganisationUnit>( unit.getChildren() );
Collections.sort( organisationUnits, organisationUnitComparator );
-
+
+ if ( usePaging )
+ {
+ this.paging = createPaging( organisationUnits.size() );
+
+ organisationUnits = organisationUnits.subList( paging.getStartPos(), paging.getEndPos() );
+ }
+
displayPropertyHandler.handle( organisationUnits );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitGroupsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitGroupsAction.java 2010-09-09 09:38:13 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitGroupsAction.java 2011-05-06 10:49:36 +0000
@@ -7,6 +7,7 @@
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupService;
import org.hisp.dhis.organisationunit.comparator.OrganisationUnitGroupNameComparator;
+import org.hisp.dhis.paging.ActionPagingSupport;
import com.opensymphony.xwork2.Action;
@@ -40,7 +41,7 @@
* @author Tran Thanh Tri
*/
public class GetOrganisationUnitGroupsAction
- implements Action
+ extends ActionPagingSupport<OrganisationUnitGroup>
{
// -------------------------------------------------------------------------
// Dependencies
@@ -68,12 +69,18 @@
public String execute()
throws Exception
{
- organisationUnitGroups = new ArrayList<OrganisationUnitGroup>( organisationUnitGroupService
- .getAllOrganisationUnitGroups() );
+ organisationUnitGroups = new ArrayList<OrganisationUnitGroup>(
+ organisationUnitGroupService.getAllOrganisationUnitGroups() );
Collections.sort( organisationUnitGroups, new OrganisationUnitGroupNameComparator() );
+ if ( usePaging )
+ {
+ this.paging = createPaging( organisationUnitGroups.size() );
+
+ organisationUnitGroups = organisationUnitGroups.subList( paging.getStartPos(), paging.getEndPos() );
+ }
+
return SUCCESS;
}
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitLevelsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitLevelsAction.java 2010-09-09 09:38:13 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitLevelsAction.java 2011-05-06 10:49:36 +0000
@@ -32,14 +32,13 @@
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.paging.ActionPagingSupport;
/**
* @author Tran Thanh Tri
*/
public class GetOrganisationUnitLevelsAction
- implements Action
+ extends ActionPagingSupport<OrganisationUnitLevel>
{
// -------------------------------------------------------------------------
@@ -68,10 +67,16 @@
public String execute()
throws Exception
{
- organisationUnitLevels = new ArrayList<OrganisationUnitLevel>( organisationUnitService
- .getOrganisationUnitLevels() );
+ organisationUnitLevels = new ArrayList<OrganisationUnitLevel>(
+ organisationUnitService.getOrganisationUnitLevels() );
+
+ if ( usePaging )
+ {
+ this.paging = createPaging( organisationUnitLevels.size() );
+
+ organisationUnitLevels = organisationUnitLevels.subList( paging.getStartPos(), paging.getEndPos() );
+ }
return SUCCESS;
}
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitsAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetOrganisationUnitsAction.java 2011-05-06 10:49:36 +0000
@@ -35,15 +35,15 @@
import org.hisp.dhis.options.displayproperty.DisplayPropertyHandler;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
-
-import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.paging.ActionPagingSupport;
/**
* @author Lars Helge Overland
- * @version $Id: GetOrganisationUnitsAction.java 2869 2007-02-20 14:26:09Z andegje $
+ * @version $Id: GetOrganisationUnitsAction.java 2869 2007-02-20 14:26:09Z
+ * andegje $
*/
public class GetOrganisationUnitsAction
- implements Action
+ extends ActionPagingSupport<OrganisationUnit>
{
private final static int ALL = 0;
@@ -79,7 +79,7 @@
{
this.organisationUnitComparator = organisationUnitComparator;
}
-
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -94,7 +94,7 @@
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
-
+
private List<OrganisationUnit> organisationUnits;
public List<OrganisationUnit> getOrganisationUnits()
@@ -115,11 +115,19 @@
}
else
{
- organisationUnits = new ArrayList<OrganisationUnit>( organisationUnitService.getOrganisationUnitsAtLevel( level ) );
+ organisationUnits = new ArrayList<OrganisationUnit>(
+ organisationUnitService.getOrganisationUnitsAtLevel( level ) );
}
-
+
Collections.sort( organisationUnits, organisationUnitComparator );
-
+
+ if ( usePaging )
+ {
+ this.paging = createPaging( organisationUnits.size() );
+
+ organisationUnits = organisationUnits.subList( paging.getStartPos(), paging.getEndPos() );
+ }
+
displayPropertyHandler.handle( organisationUnits );
return SUCCESS;
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodAction.java 2011-05-06 10:49:36 +0000
@@ -77,8 +77,11 @@
public String execute()
{
- period = periodService.getPeriod( id );
-
+ if ( id != null )
+ {
+ period = periodService.getPeriod( id );
+ }
+
return SUCCESS;
}
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodTypesAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodTypesAction.java 2010-09-30 09:37:41 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodTypesAction.java 2011-05-06 10:49:36 +0000
@@ -30,16 +30,15 @@
import java.util.ArrayList;
import java.util.List;
+import org.hisp.dhis.paging.ActionPagingSupport;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
-import com.opensymphony.xwork2.Action;
-
/**
* @author Tran Thanh Tri
*/
public class GetPeriodTypesAction
- implements Action
+ extends ActionPagingSupport<PeriodType>
{
// -------------------------------------------
// Dependency
@@ -69,7 +68,13 @@
{
periodTypes = new ArrayList<PeriodType>( periodService.getAllPeriodTypes() );
+ if ( usePaging )
+ {
+ this.paging = createPaging( periodTypes.size() );
+
+ periodTypes = periodTypes.subList( paging.getStartPos(), paging.getEndPos() );
+ }
+
return SUCCESS;
}
-
}
=== modified file 'dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodsAction.java'
--- dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodsAction.java 2010-04-12 21:23:33 +0000
+++ dhis-2/dhis-web/dhis-web-commons/src/main/java/org/hisp/dhis/commons/action/GetPeriodsAction.java 2011-05-06 10:49:36 +0000
@@ -33,6 +33,7 @@
import java.util.List;
import org.hisp.dhis.i18n.I18nFormat;
+import org.hisp.dhis.paging.ActionPagingSupport;
import org.hisp.dhis.period.Period;
import org.hisp.dhis.period.PeriodService;
import org.hisp.dhis.period.PeriodType;
@@ -45,7 +46,7 @@
* @version $Id: GetPeriodsAction.java 3272 2007-04-26 22:22:50Z larshelg $
*/
public class GetPeriodsAction
- implements Action
+ extends ActionPagingSupport<Period>
{
private final static String ALL = "ALL";
@@ -66,7 +67,7 @@
{
this.format = format;
}
-
+
// -------------------------------------------------------------------------
// Input
// -------------------------------------------------------------------------
@@ -81,7 +82,7 @@
// -------------------------------------------------------------------------
// Output
// -------------------------------------------------------------------------
-
+
private List<Period> periods;
public List<Period> getPeriods()
@@ -113,14 +114,21 @@
periods = new ArrayList<Period>( periodService.getPeriodsByPeriodType( periodType ) );
}
-
+
for ( Period period : periods )
{
period.setName( format.formatPeriod( period ) );
}
-
+
Collections.sort( periods, new PeriodComparator() );
+ if ( usePaging )
+ {
+ this.paging = createPaging( periods.size() );
+
+ periods = periods.subList( paging.getStartPos(), paging.getEndPos() );
+ }
+
return SUCCESS;
}
}