dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #28550
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14266: Minor
------------------------------------------------------------
revno: 14266
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-03-17 17:54:54 +0100
message:
Minor
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.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/trackedentity/TrackedEntityInstanceQueryParams.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java 2014-03-17 14:55:54 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/trackedentity/TrackedEntityInstanceQueryParams.java 2014-03-17 16:54:54 +0000
@@ -77,6 +77,22 @@
// -------------------------------------------------------------------------
/**
+ * Indicates whether this params has any items with filter.
+ */
+ public boolean hasItemsWithFilter()
+ {
+ for ( QueryItem item : items )
+ {
+ if ( item.hasFilter() )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
* Indicates whether this params specifies a program.
*/
public boolean hasProgram()
@@ -99,6 +115,38 @@
{
return organisationUnitMode != null && organisationUnitMode.equals( mode );
}
+
+ /**
+ * Indicates whether paging is enabled.
+ */
+ public boolean isPaging()
+ {
+ return page != null || pageSize != null;
+ }
+
+ /**
+ * Returns the page number, falls back to default value of 1 if not specified.
+ */
+ public int getPageWithDefault()
+ {
+ return page != null && page > 0 ? page : 1;
+ }
+
+ /**
+ * Returns the page size, falls back to default value of 50 if not specified.
+ */
+ public int getPageSizeWithDefault()
+ {
+ return pageSize != null && pageSize >= 0 ? pageSize : 50;
+ }
+
+ /**
+ * Returns the offset based on the page number and page size.
+ */
+ public int getOffset()
+ {
+ return ( getPageWithDefault() - 1 ) * getPageSizeWithDefault();
+ }
// -------------------------------------------------------------------------
// Getters and setters