diff --git a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/PageParams.java b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/PageParams.java index c001f397e9a0..0b999e98bbe0 100644 --- a/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/PageParams.java +++ b/dhis-2/dhis-services/dhis-service-tracker/src/main/java/org/hisp/dhis/tracker/export/PageParams.java @@ -27,15 +27,22 @@ */ package org.hisp.dhis.tracker.export; +import java.util.Objects; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; -/** {@link PageParams} represent the parameters that configure the page of items to be returned. */ +/** + * {@link PageParams} represent the parameters that configure the page of items to be returned. By + * default, the total number of items will not be fetched. + */ @Getter @ToString @EqualsAndHashCode public class PageParams { + private static final int DEFAULT_PAGE = 1; + private static final int DEFAULT_PAGE_SIZE = 50; + /** The page number to be returned. */ final int page; @@ -46,8 +53,8 @@ public class PageParams { final boolean pageTotal; public PageParams(Integer page, Integer pageSize, Boolean pageTotal) { - this.page = page; - this.pageSize = pageSize; + this.page = Objects.requireNonNullElse(page, DEFAULT_PAGE); + this.pageSize = Objects.requireNonNullElse(pageSize, DEFAULT_PAGE_SIZE); this.pageTotal = Boolean.TRUE.equals(pageTotal); } } diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/enrollment/EnrollmentRequestParams.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/enrollment/EnrollmentRequestParams.java index 5677296793d0..855d445639c4 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/enrollment/EnrollmentRequestParams.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/enrollment/EnrollmentRequestParams.java @@ -49,15 +49,22 @@ import org.hisp.dhis.webapi.controller.tracker.view.TrackedEntity; /** Represents query parameters sent to {@link EnrollmentsExportController}. */ +@OpenApi.Shared(name = "EnrollmentRequestParams") @OpenApi.Property @Data @NoArgsConstructor public class EnrollmentRequestParams implements PageRequestParams { static final String DEFAULT_FIELDS_PARAM = "*,!relationships,!events,!attributes"; - private Integer page = 1; - private Integer pageSize = 50; + @OpenApi.Property(defaultValue = "1") + private Integer page; + + @OpenApi.Property(defaultValue = "50") + private Integer pageSize; + + @OpenApi.Property(defaultValue = "false") private Boolean totalPages = false; + private Boolean skipPaging = false; private List order = new ArrayList<>(); diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventRequestParams.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventRequestParams.java index 228c5eaa4019..5f3d53f7e963 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventRequestParams.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/event/EventRequestParams.java @@ -60,15 +60,22 @@ * * @author Giuseppe Nespolino */ +@OpenApi.Shared(name = "EventRequestParams") @OpenApi.Property @Data @NoArgsConstructor public class EventRequestParams implements PageRequestParams { static final String DEFAULT_FIELDS_PARAM = "*,!relationships"; - private Integer page = 1; - private Integer pageSize = 50; + @OpenApi.Property(defaultValue = "1") + private Integer page; + + @OpenApi.Property(defaultValue = "50") + private Integer pageSize; + + @OpenApi.Property(defaultValue = "false") private Boolean totalPages = false; + private Boolean skipPaging = false; private List order = new ArrayList<>(); diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/relationship/RelationshipRequestParams.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/relationship/RelationshipRequestParams.java index 213962fa8355..92aeca616728 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/relationship/RelationshipRequestParams.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/relationship/RelationshipRequestParams.java @@ -41,6 +41,7 @@ import org.hisp.dhis.webapi.controller.tracker.view.Event; import org.hisp.dhis.webapi.controller.tracker.view.TrackedEntity; +@OpenApi.Shared(name = "RelationshipRequestParams") @OpenApi.Property @Data @NoArgsConstructor @@ -48,9 +49,15 @@ public class RelationshipRequestParams implements PageRequestParams { static final String DEFAULT_FIELDS_PARAM = "relationship,relationshipType,createdAtClient,from[trackedEntity[trackedEntity],enrollment[enrollment],event[event]],to[trackedEntity[trackedEntity],enrollment[enrollment],event[event]]"; - private Integer page = 1; - private Integer pageSize = 50; + @OpenApi.Property(defaultValue = "1") + private Integer page; + + @OpenApi.Property(defaultValue = "50") + private Integer pageSize; + + @OpenApi.Property(defaultValue = "false") private Boolean totalPages = false; + private Boolean skipPaging = false; private List order = new ArrayList<>(); diff --git a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntityRequestParams.java b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntityRequestParams.java index 22e508da1fcc..3b31c872e576 100644 --- a/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntityRequestParams.java +++ b/dhis-2/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/tracker/export/trackedentity/TrackedEntityRequestParams.java @@ -56,15 +56,22 @@ * * @author Giuseppe Nespolino */ +@OpenApi.Shared(name = "TrackedEntityRequestParams") @OpenApi.Property @Data @NoArgsConstructor public class TrackedEntityRequestParams implements PageRequestParams { static final String DEFAULT_FIELDS_PARAM = "*,!relationships,!enrollments,!events,!programOwners"; - private Integer page = 1; - private Integer pageSize = 50; + @OpenApi.Property(defaultValue = "1") + private Integer page; + + @OpenApi.Property(defaultValue = "50") + private Integer pageSize; + + @OpenApi.Property(defaultValue = "false") private Boolean totalPages = false; + private Boolean skipPaging = false; private List order = new ArrayList<>();