dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15298
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5480: start of a simple pager for webapi
------------------------------------------------------------
revno: 5480
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2011-12-19 18:20:37 +0100
message:
start of a simple pager for webapi
added:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Pager.java
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attributes.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Charts.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/Constants.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategories.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombos.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombos.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptions.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSets.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroups.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElements.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/CompleteDataSetRegistrations.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSets.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Documents.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSets.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroups.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicators.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/Maps.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSets.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroups.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevels.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnits.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Reports.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTables.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViews.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroups.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRules.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/IdentifiableObjectParams.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-api/src/main/java/org/hisp/dhis/attribute/Attributes.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attributes.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/Attributes.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.AttributeXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class Attributes extends BaseLinkableObject
{
+ private Pager pager;
+
private List<Attribute> attributes = new ArrayList<Attribute>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "attributeType" )
@XmlJavaTypeAdapter( AttributeXmlAdapter.class )
@JsonProperty( value = "attributeTypes" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Charts.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Charts.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/chart/Charts.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.ChartXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class Charts extends BaseLinkableObject
{
+ private Pager pager;
+
private List<Chart> charts = new ArrayList<Chart>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "chart" )
@XmlJavaTypeAdapter( ChartXmlAdapter.class )
@JsonProperty( value = "charts" )
=== added file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Pager.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Pager.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/Pager.java 2011-12-19 17:20:37 +0000
@@ -0,0 +1,104 @@
+package org.hisp.dhis.common;
+
+import org.codehaus.jackson.annotate.JsonProperty;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@XmlRootElement( name = "pager", namespace = Dxf2Namespace.NAMESPACE )
+@XmlAccessorType( value = XmlAccessType.NONE )
+public class Pager
+{
+ public static final int DEFAULT_PAGE_SIZE = 50;
+
+ private int page = 1;
+
+ private int total = 0;
+
+ private int pageSize = Pager.DEFAULT_PAGE_SIZE;
+
+ public Pager()
+ {
+
+ }
+
+ public Pager( int page, int total )
+ {
+ this.page = page;
+ this.total = total;
+
+ if ( this.page > getPageCount() )
+ {
+ this.page = getPageCount();
+ }
+
+ if ( this.page < 1 )
+ {
+ this.page = 1;
+ }
+ }
+
+ public Pager( int page, int total, int pageSize )
+ {
+ this.page = page;
+ this.total = total;
+ this.pageSize = pageSize;
+
+ if ( this.page > getPageCount() )
+ {
+ this.page = getPageCount();
+ }
+
+ if ( this.page < 1 )
+ {
+ this.page = 1;
+ }
+ }
+
+ @XmlElement
+ @JsonProperty
+ public int getPage()
+ {
+ return page;
+ }
+
+ @XmlElement
+ @JsonProperty
+ public int getTotal()
+ {
+ return total;
+ }
+
+ @XmlElement
+ @JsonProperty
+ public int getPageSize()
+ {
+ return pageSize;
+ }
+
+ @XmlElement
+ @JsonProperty
+ public int getPageCount()
+ {
+ int pageCount = 1;
+ int totalTmp = total;
+
+ while ( totalTmp > pageSize )
+ {
+ totalTmp -= pageSize;
+ pageCount++;
+ }
+
+ return pageCount;
+ }
+
+ public int getOffset()
+ {
+ return (page * pageSize) - pageSize;
+ }
+}
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/Constants.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/Constants.java 2011-12-11 00:00:06 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/constant/Constants.java 2011-12-19 17:20:37 +0000
@@ -33,6 +33,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.ConstantXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -50,8 +51,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class Constants extends BaseLinkableObject
{
+ private Pager pager;
+
private List<Constant> constants = new ArrayList<Constant>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "constant" )
@XmlJavaTypeAdapter( ConstantXmlAdapter.class )
@JsonProperty( value = "constants" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategories.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategories.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategories.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.CategoryXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class DataElementCategories extends BaseLinkableObject
{
+ private Pager pager;
+
private List<DataElementCategory> categories = new ArrayList<DataElementCategory>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "category" )
@XmlJavaTypeAdapter( CategoryXmlAdapter.class )
@JsonProperty( value = "categories" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombos.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombos.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryCombos.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.CategoryComboXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class DataElementCategoryCombos extends BaseLinkableObject
{
+ private Pager pager;
+
private List<DataElementCategoryCombo> categoryCombos = new ArrayList<DataElementCategoryCombo>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "categoryCombo" )
@XmlJavaTypeAdapter( CategoryComboXmlAdapter.class )
@JsonProperty( value = "categoryCombos" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombos.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombos.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptionCombos.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.CategoryOptionComboXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class DataElementCategoryOptionCombos extends BaseLinkableObject
{
+ private Pager pager;
+
private List<DataElementCategoryOptionCombo> categoryOptionCombos = new ArrayList<DataElementCategoryOptionCombo>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "categoryOptionCombo" )
@XmlJavaTypeAdapter( CategoryOptionComboXmlAdapter.class )
@JsonProperty( value = "categoryOptionCombos" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptions.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptions.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementCategoryOptions.java 2011-12-19 17:20:37 +0000
@@ -5,6 +5,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.CategoryOptionXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -22,8 +23,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class DataElementCategoryOptions extends BaseLinkableObject
{
+ private Pager pager;
+
private List<DataElementCategoryOption> categoryOptions = new ArrayList<DataElementCategoryOption>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "categoryOption" )
@XmlJavaTypeAdapter( CategoryOptionXmlAdapter.class )
@JsonProperty( value = "categoryOptions" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSets.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSets.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroupSets.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.DataElementGroupSetXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class DataElementGroupSets extends BaseLinkableObject
{
+ private Pager pager;
+
private List<DataElementGroupSet> dataElementGroupSets = new ArrayList<DataElementGroupSet>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "dataElementGroupSet" )
@XmlJavaTypeAdapter( DataElementGroupSetXmlAdapter.class )
@JsonProperty( value = "dataElementGroupSets" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroups.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroups.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElementGroups.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.DataElementGroupXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class DataElementGroups extends BaseLinkableObject
{
+ private Pager pager;
+
private List<DataElementGroup> dataElementGroups = new ArrayList<DataElementGroup>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "dataElementGroup" )
@XmlJavaTypeAdapter( DataElementGroupXmlAdapter.class )
@JsonProperty( value = "dataElementGroups" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElements.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElements.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElements.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.DataElementXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class DataElements extends BaseLinkableObject
{
+ private Pager pager;
+
private List<DataElement> dataElements = new ArrayList<DataElement>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "dataElement" )
@XmlJavaTypeAdapter( DataElementXmlAdapter.class )
@JsonProperty( value = "dataElements" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/CompleteDataSetRegistrations.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/CompleteDataSetRegistrations.java 2011-12-10 16:56:25 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/CompleteDataSetRegistrations.java 2011-12-19 17:20:37 +0000
@@ -38,6 +38,7 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -46,8 +47,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class CompleteDataSetRegistrations extends BaseLinkableObject
{
+ private Pager pager;
+
private List<CompleteDataSetRegistration> completeDataSetRegistrations = new ArrayList<CompleteDataSetRegistration>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "completeDataSetRegistration" )
@JsonProperty( value = "completeDataSetRegistrations" )
public List<CompleteDataSetRegistration> getCompleteDataSetRegistrations()
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSets.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSets.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataset/DataSets.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.DataSetXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class DataSets extends BaseLinkableObject
{
+ private Pager pager;
+
private List<DataSet> dataSets = new ArrayList<DataSet>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "dataSet" )
@XmlJavaTypeAdapter( DataSetXmlAdapter.class )
@JsonProperty( value = "dataSets" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Documents.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Documents.java 2011-12-10 23:22:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/document/Documents.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.DocumentXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class Documents extends BaseLinkableObject
{
+ private Pager pager;
+
private List<Document> documents = new ArrayList<Document>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "document" )
@XmlJavaTypeAdapter( DocumentXmlAdapter.class )
@JsonProperty( value = "documents" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSets.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSets.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroupSets.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.IndicatorGroupSetXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class IndicatorGroupSets extends BaseLinkableObject
{
+ private Pager pager;
+
private List<IndicatorGroupSet> indicatorGroupSets = new ArrayList<IndicatorGroupSet>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "indicatorGroupSet" )
@XmlJavaTypeAdapter( IndicatorGroupSetXmlAdapter.class )
@JsonProperty( value = "indicatorGroupSets" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroups.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroups.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/IndicatorGroups.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.IndicatorGroupXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class IndicatorGroups extends BaseLinkableObject
{
+ private Pager pager;
+
private List<IndicatorGroup> indicatorGroups = new ArrayList<IndicatorGroup>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "indicatorGroup" )
@XmlJavaTypeAdapter( IndicatorGroupXmlAdapter.class )
@JsonProperty( value = "indicatorGroups" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicators.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicators.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/indicator/Indicators.java 2011-12-19 17:20:37 +0000
@@ -33,6 +33,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.IndicatorXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -50,8 +51,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class Indicators extends BaseLinkableObject
{
+ private Pager pager;
+
private List<Indicator> indicators = new ArrayList<Indicator>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "indicator" )
@XmlJavaTypeAdapter( IndicatorXmlAdapter.class )
@JsonProperty( value = "indicators" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/Maps.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/Maps.java 2011-12-13 09:43:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/mapping/Maps.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.MapViewXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -46,8 +47,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class Maps extends BaseLinkableObject
{
+ private Pager pager;
+
private List<MapView> maps = new ArrayList<MapView>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "map" )
@XmlJavaTypeAdapter( MapViewXmlAdapter.class )
@JsonProperty( value = "maps" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSets.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSets.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroupSets.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.OrganisationUnitGroupSetXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class OrganisationUnitGroupSets extends BaseLinkableObject
{
+ private Pager pager;
+
private List<OrganisationUnitGroupSet> organisationUnitGroupSets = new ArrayList<OrganisationUnitGroupSet>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "organisationUnitGroupSet" )
@XmlJavaTypeAdapter( OrganisationUnitGroupSetXmlAdapter.class )
@JsonProperty( value = "organisationUnitGroupSets" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroups.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroups.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitGroups.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.OrganisationUnitGroupXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class OrganisationUnitGroups extends BaseLinkableObject
{
+ private Pager pager;
+
private List<OrganisationUnitGroup> organisationUnitGroups = new ArrayList<OrganisationUnitGroup>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "organisationUnitGroup" )
@XmlJavaTypeAdapter( OrganisationUnitGroupXmlAdapter.class )
@JsonProperty( value = "organisationUnitGroups" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevels.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevels.java 2011-12-03 14:31:45 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnitLevels.java 2011-12-19 17:20:37 +0000
@@ -30,6 +30,7 @@
import org.codehaus.jackson.annotate.JsonProperty;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -45,8 +46,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class OrganisationUnitLevels extends BaseLinkableObject
{
+ private Pager pager;
+
private List<OrganisationUnitLevel> organisationUnitLevels = new ArrayList<OrganisationUnitLevel>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "organisationUnitLevel" )
@JsonProperty( value = "organisationUnitLevels" )
public List<OrganisationUnitLevel> getOrganisationUnitLevels()
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnits.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnits.java 2011-12-09 20:53:07 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/organisationunit/OrganisationUnits.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.OrganisationUnitXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class OrganisationUnits extends BaseLinkableObject
{
+ private Pager pager;
+
private List<OrganisationUnit> organisationUnits = new ArrayList<OrganisationUnit>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "organisationUnit" )
@XmlJavaTypeAdapter( OrganisationUnitXmlAdapter.class )
@JsonProperty( value = "organisationUnits" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Reports.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Reports.java 2011-12-13 14:04:12 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/report/Reports.java 2011-12-19 17:20:37 +0000
@@ -41,6 +41,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.ReportXmlAdapter;
@XmlRootElement( name = "reports", namespace = Dxf2Namespace.NAMESPACE )
@@ -48,8 +49,22 @@
public class Reports
extends BaseLinkableObject
{
+ private Pager pager;
+
private List<Report> reports = new ArrayList<Report>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "report" )
@XmlJavaTypeAdapter( ReportXmlAdapter.class )
@JsonProperty( value = "reports" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTables.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTables.java 2011-12-14 10:03:38 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/reporttable/ReportTables.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.ReportTableXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class ReportTables extends BaseLinkableObject
{
+ private Pager pager;
+
private List<ReportTable> reportTables = new ArrayList<ReportTable>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "reportTable" )
@XmlJavaTypeAdapter( ReportTableXmlAdapter.class )
@JsonProperty( value = "reportTables" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViews.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViews.java 2011-12-11 00:21:52 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/sqlview/SqlViews.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.SqlViewXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class SqlViews extends BaseLinkableObject
{
+ private Pager pager;
+
private List<SqlView> sqlViews = new ArrayList<SqlView>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "sqlView" )
@XmlJavaTypeAdapter( SqlViewXmlAdapter.class )
@JsonProperty( value = "sqlViews" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java 2011-12-13 18:41:43 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/user/Users.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.UserXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class Users extends BaseLinkableObject
{
+ private Pager pager;
+
private List<User> users = new ArrayList<User>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "user" )
@XmlJavaTypeAdapter( UserXmlAdapter.class )
@JsonProperty( value = "users" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroups.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroups.java 2011-12-10 23:22:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRuleGroups.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.ValidationRuleGroupXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class ValidationRuleGroups extends BaseLinkableObject
{
+ private Pager pager;
+
private List<ValidationRuleGroup> validationRuleGroups = new ArrayList<ValidationRuleGroup>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "validationRuleGroup" )
@XmlJavaTypeAdapter( ValidationRuleGroupXmlAdapter.class )
@JsonProperty( value = "validationRuleGroups" )
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRules.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRules.java 2011-12-10 23:22:51 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/validation/ValidationRules.java 2011-12-19 17:20:37 +0000
@@ -32,6 +32,7 @@
import org.hisp.dhis.common.BaseIdentifiableObject;
import org.hisp.dhis.common.BaseLinkableObject;
import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.common.adapter.ValidationRuleXmlAdapter;
import javax.xml.bind.annotation.XmlAccessType;
@@ -49,8 +50,22 @@
@XmlAccessorType( value = XmlAccessType.NONE )
public class ValidationRules extends BaseLinkableObject
{
+ private Pager pager;
+
private List<ValidationRule> validationRules = new ArrayList<ValidationRule>();
+ @XmlElement
+ @JsonProperty
+ public Pager getPager()
+ {
+ return pager;
+ }
+
+ public void setPager( Pager pager )
+ {
+ this.pager = pager;
+ }
+
@XmlElement( name = "validationRule" )
@XmlJavaTypeAdapter( ValidationRuleXmlAdapter.class )
@JsonProperty( value = "validationRules" )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java 2011-12-14 15:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataElementController.java 2011-12-19 17:20:37 +0000
@@ -27,16 +27,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.InputStream;
-import java.util.ArrayList;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.ObjectPersister;
import org.hisp.dhis.api.utils.WebLinkPopulator;
import org.hisp.dhis.api.view.Jaxb2Utils;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementService;
import org.hisp.dhis.dataelement.DataElements;
@@ -51,6 +46,12 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -74,7 +75,23 @@
public String getDataElements( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataElements dataElements = new DataElements();
- dataElements.setDataElements( new ArrayList<DataElement>( dataElementService.getAllDataElements() ) );
+
+ if ( params.isPaging() )
+ {
+ int total = dataElementService.getDataElementCount();
+
+ Pager pager = new Pager( params.getPage(), total );
+ dataElements.setPager( pager );
+
+ List<DataElement> dataElementList = new ArrayList<DataElement>(
+ dataElementService.getDataElementsBetween( pager.getOffset(), pager.getPageSize() ) );
+
+ dataElements.setDataElements( dataElementList );
+ }
+ else
+ {
+ dataElements.setDataElements( new ArrayList<DataElement>( dataElementService.getAllDataElements() ) );
+ }
if ( params.hasLinks() )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2011-12-12 11:37:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/DataSetController.java 2011-12-19 17:20:37 +0000
@@ -29,6 +29,7 @@
import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.dataset.DataSets;
@@ -46,6 +47,7 @@
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.List;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -65,7 +67,23 @@
public String getDataSets( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
DataSets dataSets = new DataSets();
- dataSets.setDataSets( new ArrayList<DataSet>( dataSetService.getAllDataSets() ) );
+
+ if ( params.isPaging() )
+ {
+ int total = dataSetService.getDataSetCount();
+
+ Pager pager = new Pager( params.getPage(), total );
+ dataSets.setPager( pager );
+
+ List<DataSet> dataSetList = new ArrayList<DataSet>(
+ dataSetService.getDataSetsBetween( pager.getOffset(), pager.getPageSize() ) );
+
+ dataSets.setDataSets( dataSetList );
+ }
+ else
+ {
+ dataSets.setDataSets( new ArrayList<DataSet>( dataSetService.getAllDataSets() ) );
+ }
if ( params.hasLinks() )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java 2011-12-12 11:37:04 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndicatorController.java 2011-12-19 17:20:37 +0000
@@ -29,6 +29,7 @@
import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.hisp.dhis.api.utils.WebLinkPopulator;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.indicator.Indicator;
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.indicator.Indicators;
@@ -46,6 +47,7 @@
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.List;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -67,7 +69,23 @@
public String getIndicators( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
Indicators indicators = new Indicators();
- indicators.setIndicators( new ArrayList<Indicator>( indicatorService.getAllIndicators() ) );
+
+ if ( params.isPaging() )
+ {
+ int total = indicatorService.getIndicatorCount();
+
+ Pager pager = new Pager( params.getPage(), total );
+ indicators.setPager( pager );
+
+ List<Indicator> indicatorList = new ArrayList<Indicator>(
+ indicatorService.getIndicatorsBetween( pager.getOffset(), pager.getPageSize() ) );
+
+ indicators.setIndicators( indicatorList );
+ }
+ else
+ {
+ indicators.setIndicators( new ArrayList<Indicator>( indicatorService.getAllIndicators() ) );
+ }
if ( params.hasLinks() )
{
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java 2011-12-14 15:28:36 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitController.java 2011-12-19 17:20:37 +0000
@@ -4,6 +4,7 @@
import org.hisp.dhis.api.utils.ObjectPersister;
import org.hisp.dhis.api.utils.WebLinkPopulator;
import org.hisp.dhis.api.view.Jaxb2Utils;
+import org.hisp.dhis.common.Pager;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.organisationunit.OrganisationUnits;
@@ -22,6 +23,7 @@
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.List;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -47,9 +49,17 @@
{
OrganisationUnits organisationUnits = new OrganisationUnits();
- if ( params.hasNoPaging() )
+ if ( params.isPaging() )
{
- organisationUnits.setOrganisationUnits( new ArrayList<OrganisationUnit>( organisationUnitService.getAllOrganisationUnits() ) );
+ int total = organisationUnitService.getNumberOfOrganisationUnits();
+
+ Pager pager = new Pager( params.getPage(), total );
+ organisationUnits.setPager( pager );
+
+ List<OrganisationUnit> organisationUnitList = new ArrayList<OrganisationUnit>(
+ organisationUnitService.getOrganisationUnitsBetween( pager.getOffset(), pager.getPageSize() ) );
+
+ organisationUnits.setOrganisationUnits( organisationUnitList );
}
else
{
@@ -123,8 +133,7 @@
response.setStatus( HttpServletResponse.SC_CREATED );
response.setHeader( "Location", DataElementController.RESOURCE_PATH + "/" + organisationUnit.getUid() );
}
- }
- catch ( Exception e )
+ } catch ( Exception e )
{
response.setStatus( HttpServletResponse.SC_CONFLICT );
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java 2011-12-16 11:41:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportController.java 2011-12-19 17:20:37 +0000
@@ -76,7 +76,7 @@
{
Reports reports = new Reports();
- if ( params.hasNoPaging() )
+ if ( params.isPaging() )
{
reports.setReports( new ArrayList<Report>( reportService.getAllReports() ) );
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java 2011-12-15 19:02:36 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ReportTableController.java 2011-12-19 17:20:37 +0000
@@ -79,7 +79,7 @@
{
ReportTables reportTables = new ReportTables();
- if ( params.hasNoPaging() )
+ if ( params.isPaging() )
{
reportTables.setReportTables( new ArrayList<ReportTable>( reportTableService.getAllReportTables() ) );
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/IdentifiableObjectParams.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/IdentifiableObjectParams.java 2011-12-07 13:29:09 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/IdentifiableObjectParams.java 2011-12-19 17:20:37 +0000
@@ -44,11 +44,9 @@
* Paging related
*/
- private boolean noPaging = false;
-
- private int offset = 1;
-
- private int limit = 50;
+ private boolean paging = true;
+
+ private int page = 1;
public IdentifiableObjectParams()
{
@@ -85,33 +83,23 @@
this.nameLike = nameLike;
}
- public boolean hasNoPaging()
- {
- return noPaging;
- }
-
- public void setNoPaging( boolean noPaging )
- {
- this.noPaging = noPaging;
- }
-
- public int getOffset()
- {
- return offset;
- }
-
- public void setOffset( int offset )
- {
- this.offset = offset;
- }
-
- public int getLimit()
- {
- return limit;
- }
-
- public void setLimit( int limit )
- {
- this.limit = limit;
+ public boolean isPaging()
+ {
+ return paging;
+ }
+
+ public void setPaging( boolean paging )
+ {
+ this.paging = paging;
+ }
+
+ public int getPage()
+ {
+ return page;
+ }
+
+ public void setPage( int page )
+ {
+ this.page = page;
}
}