From 28d54b4820c19bcbd305f396227bf1df14131a77 Mon Sep 17 00:00:00 2001 From: Piotr Wargulak Date: Thu, 22 Feb 2024 17:22:56 +0100 Subject: [PATCH] O3-1494: Changes after 2nd code review --- .../report/service/ReportServiceTest.java | 18 +++++++++--------- ...questDTO.java => ReportRequestPageDTO.java} | 16 ++++++++-------- .../report/service/ReportService.java | 7 +++---- .../report/service/ReportServiceImpl.java | 4 ++-- .../report/service/db/HibernateReportDAO.java | 6 +++--- .../reporting/report/service/db/ReportDAO.java | 7 ++++--- 6 files changed, 29 insertions(+), 29 deletions(-) rename api/src/main/java/org/openmrs/module/reporting/report/{ReportRequestDTO.java => ReportRequestPageDTO.java} (68%) diff --git a/api-tests/src/test/java/org/openmrs/module/reporting/report/service/ReportServiceTest.java b/api-tests/src/test/java/org/openmrs/module/reporting/report/service/ReportServiceTest.java index 37724baa2..a828d37a3 100644 --- a/api-tests/src/test/java/org/openmrs/module/reporting/report/service/ReportServiceTest.java +++ b/api-tests/src/test/java/org/openmrs/module/reporting/report/service/ReportServiceTest.java @@ -27,7 +27,7 @@ import org.openmrs.module.reporting.report.ReportProcessorConfiguration; import org.openmrs.module.reporting.report.ReportRequest; import org.openmrs.module.reporting.report.ReportRequest.Priority; -import org.openmrs.module.reporting.report.ReportRequestDTO; +import org.openmrs.module.reporting.report.ReportRequestPageDTO; import org.openmrs.module.reporting.report.definition.ReportDefinition; import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService; import org.openmrs.module.reporting.report.processor.LoggingReportProcessor; @@ -529,9 +529,9 @@ public void purgeReportDesignsForReportDefinition_shouldDeleteAllAssociatedRepor @Test public void getReportRequestsWithPagination_shouldReturnAllReportRequestsPagedWithCorrectTotalCount() { final ReportService rs = Context.getService(ReportService.class); - final ReportRequestDTO result = rs.getReportRequestsWithPagination(null, null, null, 1,2); + final ReportRequestPageDTO result = rs.getReportRequestsWithPagination(null, null, null, 1,2); - assertEquals(4, result.getReportRequestCount()); + assertEquals(4, result.getTotalCount()); assertEquals(2, result.getReportRequests().size()); final List resultUuids = mapToReportRequestUuids(result.getReportRequests()); @@ -544,9 +544,9 @@ public void getReportRequestsWithPagination_shouldReturnReportRequestsForGivenRe final ReportService rs = Context.getService(ReportService.class); final ReportDefinition testReportDefinition = rs.getReportDesignByUuid("d7a82b63-1066-4c1d-9b43-b405851fc467").getReportDefinition(); - final ReportRequestDTO result = rs.getReportRequestsWithPagination(testReportDefinition, null, null, 1,2); + final ReportRequestPageDTO result = rs.getReportRequestsWithPagination(testReportDefinition, null, null, 1,2); - assertEquals(2, result.getReportRequestCount()); + assertEquals(2, result.getTotalCount()); assertEquals(2, result.getReportRequests().size()); final List resultUuids = mapToReportRequestUuids(result.getReportRequests()); @@ -559,9 +559,9 @@ public void getReportRequestsWithPagination_shouldReturnReportRequestsForRequest final ReportService rs = Context.getService(ReportService.class); final Date from = newDate(2013, Calendar.JANUARY, 21, 14, 8, 48); final Date to = newDate(2013, Calendar.JANUARY, 21, 14, 8, 49); - final ReportRequestDTO result = rs.getReportRequestsWithPagination(null, from, to, 1,2); + final ReportRequestPageDTO result = rs.getReportRequestsWithPagination(null, from, to, 1,2); - assertEquals(2, result.getReportRequestCount()); + assertEquals(2, result.getTotalCount()); assertEquals(2, result.getReportRequests().size()); final List resultUuids = mapToReportRequestUuids(result.getReportRequests()); @@ -572,9 +572,9 @@ public void getReportRequestsWithPagination_shouldReturnReportRequestsForRequest @Test public void getReportRequestsWithPagination_shouldReturnAPartialPageOfReportRequests() { final ReportService rs = Context.getService(ReportService.class); - final ReportRequestDTO result = rs.getReportRequestsWithPagination(null, null, null, 1, 2, ReportRequest.Status.FAILED); + final ReportRequestPageDTO result = rs.getReportRequestsWithPagination(null, null, null, 1, 2, ReportRequest.Status.FAILED); - assertEquals(1, result.getReportRequestCount()); + assertEquals(1, result.getTotalCount()); assertEquals(1, result.getReportRequests().size()); final List resultUuids = mapToReportRequestUuids(result.getReportRequests()); diff --git a/api/src/main/java/org/openmrs/module/reporting/report/ReportRequestDTO.java b/api/src/main/java/org/openmrs/module/reporting/report/ReportRequestPageDTO.java similarity index 68% rename from api/src/main/java/org/openmrs/module/reporting/report/ReportRequestDTO.java rename to api/src/main/java/org/openmrs/module/reporting/report/ReportRequestPageDTO.java index 014a74c8d..c7ae33315 100644 --- a/api/src/main/java/org/openmrs/module/reporting/report/ReportRequestDTO.java +++ b/api/src/main/java/org/openmrs/module/reporting/report/ReportRequestPageDTO.java @@ -11,15 +11,15 @@ import java.util.List; -public class ReportRequestDTO { +public class ReportRequestPageDTO { private List reportRequests; - private long reportRequestCount; + private long totalCount; - public ReportRequestDTO(List reportRequests, long reportRequestCount) { + public ReportRequestPageDTO(List reportRequests, long totalCount) { this.reportRequests = reportRequests; - this.reportRequestCount = reportRequestCount; + this.totalCount = totalCount; } public List getReportRequests() { @@ -30,11 +30,11 @@ public void setReportRequests(List reportRequests) { this.reportRequests = reportRequests; } - public long getReportRequestCount() { - return reportRequestCount; + public long getTotalCount() { + return totalCount; } - public void setReportRequestCount(long reportRequestCount) { - this.reportRequestCount = reportRequestCount; + public void setTotalCount(long totalCount) { + this.totalCount = totalCount; } } diff --git a/api/src/main/java/org/openmrs/module/reporting/report/service/ReportService.java b/api/src/main/java/org/openmrs/module/reporting/report/service/ReportService.java index 8321198d1..2d573140e 100644 --- a/api/src/main/java/org/openmrs/module/reporting/report/service/ReportService.java +++ b/api/src/main/java/org/openmrs/module/reporting/report/service/ReportService.java @@ -17,7 +17,7 @@ import org.openmrs.module.reporting.report.ReportProcessorConfiguration; import org.openmrs.module.reporting.report.ReportRequest; import org.openmrs.module.reporting.report.ReportRequest.Status; -import org.openmrs.module.reporting.report.ReportRequestDTO; +import org.openmrs.module.reporting.report.ReportRequestPageDTO; import org.openmrs.module.reporting.report.definition.ReportDefinition; import org.openmrs.module.reporting.report.processor.ReportProcessor; import org.openmrs.module.reporting.report.renderer.RenderingMode; @@ -176,12 +176,11 @@ public interface ReportService extends OpenmrsService { * @param pageSize page size, not null * @param statuses an array of Status, used to limit result to ReportRequests with status included in the array, null * or empty array means that all statuses are included, nullable - * @return {@link ReportRequestDTO} object which contains report requests and total count data, never null + * @return {@link ReportRequestPageDTO} object which contains report requests and total count data, never null * @since 1.27.0 */ @Transactional(readOnly = true) - public ReportRequestDTO getReportRequestsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, - Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status...statuses); + public ReportRequestPageDTO getReportRequestsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status...statuses); /** * Deletes the passed {@link ReportRequest} diff --git a/api/src/main/java/org/openmrs/module/reporting/report/service/ReportServiceImpl.java b/api/src/main/java/org/openmrs/module/reporting/report/service/ReportServiceImpl.java index a909e8f91..151e09bc7 100644 --- a/api/src/main/java/org/openmrs/module/reporting/report/service/ReportServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/reporting/report/service/ReportServiceImpl.java @@ -33,7 +33,7 @@ import org.openmrs.module.reporting.report.ReportRequest.Priority; import org.openmrs.module.reporting.report.ReportRequest.PriorityComparator; import org.openmrs.module.reporting.report.ReportRequest.Status; -import org.openmrs.module.reporting.report.ReportRequestDTO; +import org.openmrs.module.reporting.report.ReportRequestPageDTO; import org.openmrs.module.reporting.report.definition.ReportDefinition; import org.openmrs.module.reporting.report.definition.service.ReportDefinitionService; import org.openmrs.module.reporting.report.processor.ReportProcessor; @@ -229,7 +229,7 @@ public List getReportRequests(ReportDefinition reportDefinition, */ @Override @Transactional(readOnly = true) - public ReportRequestDTO getReportRequestsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status... statuses) { + public ReportRequestPageDTO getReportRequestsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status... statuses) { return reportDAO.getReportRequestsWithPagination(reportDefinition, requestOnOrAfter, requestOnOrBefore, pageNumber, pageSize, statuses); } diff --git a/api/src/main/java/org/openmrs/module/reporting/report/service/db/HibernateReportDAO.java b/api/src/main/java/org/openmrs/module/reporting/report/service/db/HibernateReportDAO.java index 3bbe6c80d..849f718f4 100644 --- a/api/src/main/java/org/openmrs/module/reporting/report/service/db/HibernateReportDAO.java +++ b/api/src/main/java/org/openmrs/module/reporting/report/service/db/HibernateReportDAO.java @@ -23,7 +23,7 @@ import org.openmrs.module.reporting.report.ReportProcessorConfiguration; import org.openmrs.module.reporting.report.ReportRequest; import org.openmrs.module.reporting.report.ReportRequest.Status; -import org.openmrs.module.reporting.report.ReportRequestDTO; +import org.openmrs.module.reporting.report.ReportRequestPageDTO; import org.openmrs.module.reporting.report.definition.ReportDefinition; import org.openmrs.module.reporting.report.renderer.ReportRenderer; @@ -220,7 +220,7 @@ public List getReportRequests(ReportDefinition reportDefinition, /** * @see ReportDAO#getReportRequestsWithPagination(ReportDefinition, Date, Date, Integer, Integer, Status...) */ - public ReportRequestDTO getReportRequestsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status...statuses) { + public ReportRequestPageDTO getReportRequestsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status...statuses) { Criteria c = sessionFactory.getCurrentSession().createCriteria(ReportRequest.class); if (reportDefinition != null) { @@ -252,7 +252,7 @@ public ReportRequestDTO getReportRequestsWithPagination(ReportDefinition reportD List reportRequests = c.list(); - return new ReportRequestDTO(reportRequests, count); + return new ReportRequestPageDTO(reportRequests, count); } /** diff --git a/api/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDAO.java b/api/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDAO.java index 7cb6a0d52..6837b4ab5 100644 --- a/api/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDAO.java +++ b/api/src/main/java/org/openmrs/module/reporting/report/service/db/ReportDAO.java @@ -14,7 +14,7 @@ import org.openmrs.module.reporting.report.ReportProcessorConfiguration; import org.openmrs.module.reporting.report.ReportRequest; import org.openmrs.module.reporting.report.ReportRequest.Status; -import org.openmrs.module.reporting.report.ReportRequestDTO; +import org.openmrs.module.reporting.report.ReportRequestPageDTO; import org.openmrs.module.reporting.report.definition.ReportDefinition; import org.openmrs.module.reporting.report.renderer.ReportRenderer; @@ -125,9 +125,10 @@ public List getReportDesigns(ReportDefinition reportDefinition, Cl public List getReportRequests(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer mostRecentNum, Status...statuses); /** - * @return {@link ReportRequestDTO} object which contains report requests and total count data + * @return {@link ReportRequestPageDTO} object which contains report requests and total count data + * @see org.openmrs.module.reporting.report.service.ReportService#getReportRequestsWithPagination(ReportDefinition, Date, Date, Integer, Integer, Status...) */ - ReportRequestDTO getReportRequestsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status...statuses); + ReportRequestPageDTO getReportRequestsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status...statuses); /** * Deletes the passed {@link ReportRequest}