Skip to content

Commit

Permalink
O3-1494: Changes after 2nd code review
Browse files Browse the repository at this point in the history
  • Loading branch information
pwargulak committed Feb 22, 2024
1 parent 533d2b5 commit 28d54b4
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String> resultUuids = mapToReportRequestUuids(result.getReportRequests());
Expand All @@ -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<String> resultUuids = mapToReportRequestUuids(result.getReportRequests());
Expand All @@ -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<String> resultUuids = mapToReportRequestUuids(result.getReportRequests());
Expand All @@ -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<String> resultUuids = mapToReportRequestUuids(result.getReportRequests());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@

import java.util.List;

public class ReportRequestDTO {
public class ReportRequestPageDTO {

private List<ReportRequest> reportRequests;

private long reportRequestCount;
private long totalCount;

public ReportRequestDTO(List<ReportRequest> reportRequests, long reportRequestCount) {
public ReportRequestPageDTO(List<ReportRequest> reportRequests, long totalCount) {
this.reportRequests = reportRequests;
this.reportRequestCount = reportRequestCount;
this.totalCount = totalCount;
}

public List<ReportRequest> getReportRequests() {
Expand All @@ -30,11 +30,11 @@ public void setReportRequests(List<ReportRequest> 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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -229,7 +229,7 @@ public List<ReportRequest> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -220,7 +220,7 @@ public List<ReportRequest> 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) {
Expand Down Expand Up @@ -252,7 +252,7 @@ public ReportRequestDTO getReportRequestsWithPagination(ReportDefinition reportD

List<ReportRequest> reportRequests = c.list();

return new ReportRequestDTO(reportRequests, count);
return new ReportRequestPageDTO(reportRequests, count);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -125,9 +125,10 @@ public List<ReportDesign> getReportDesigns(ReportDefinition reportDefinition, Cl
public List<ReportRequest> 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}
Expand Down

0 comments on commit 28d54b4

Please sign in to comment.