use of org.sagebionetworks.bridge.models.reports.ReportDataKey in project BridgeServer2 by Sage-Bionetworks.
the class ParticipantReportControllerTest method getParticipantReportIndex.
@Test
public void getParticipantReportIndex() throws Exception {
ReportIndex index = ReportIndex.create();
index.setIdentifier(REPORT_ID);
index.setPublic(true);
index.setStudyIds(USER_STUDY_IDS);
when(mockReportService.getReportIndex(any())).thenReturn(index);
ReportIndex result = controller.getParticipantReportIndex(REPORT_ID);
assertEquals(result.getIdentifier(), REPORT_ID);
assertEquals(result.getStudyIds(), USER_STUDY_IDS);
verify(mockReportService).getReportIndex(reportDataKeyCaptor.capture());
ReportDataKey key = reportDataKeyCaptor.getValue();
assertEquals(key.getAppId(), TEST_APP_ID);
assertEquals(key.getIdentifier(), REPORT_ID);
assertEquals(key.getReportType(), PARTICIPANT);
}
use of org.sagebionetworks.bridge.models.reports.ReportDataKey in project BridgeServer2 by Sage-Bionetworks.
the class ReportService method getParticipantReportV4.
/**
* Return set of participant report records based on the provided datetime range. Study memberships are enforced.
*/
public ForwardCursorPagedResourceList<ReportData> getParticipantReportV4(final String appId, final String userId, final String identifier, final String healthCode, final DateTime startTime, final DateTime endTime, final String offsetKey, final int pageSize) {
if (pageSize < API_MINIMUM_PAGE_SIZE || pageSize > API_MAXIMUM_PAGE_SIZE) {
throw new BadRequestException(BridgeConstants.PAGE_SIZE_ERROR);
}
RangeTuple<DateTime> finalTimes = validateDateTimeRange(startTime, endTime);
ReportDataKey key = new ReportDataKey.Builder().withHealthCode(healthCode).withReportType(ReportType.PARTICIPANT).withIdentifier(identifier).withAppId(appId).build();
Validate.entityThrowingException(ReportDataKeyValidator.INSTANCE, key);
ReportIndex index = reportIndexDao.getIndex(key);
checkParticipantReportAccess(userId, index);
return reportDataDao.getReportDataV4(key, finalTimes.getStart(), finalTimes.getEnd(), offsetKey, pageSize);
}
use of org.sagebionetworks.bridge.models.reports.ReportDataKey in project BridgeServer2 by Sage-Bionetworks.
the class ReportService method getStudyReportV4.
/**
* Return set of study report records based on the provided datetime range. Study memberships are enforced.
*/
public ForwardCursorPagedResourceList<ReportData> getStudyReportV4(final String appId, final String identifier, final DateTime startTime, final DateTime endTime, final String offsetKey, final int pageSize) {
if (pageSize < API_MINIMUM_PAGE_SIZE || pageSize > API_MAXIMUM_PAGE_SIZE) {
throw new BadRequestException(BridgeConstants.PAGE_SIZE_ERROR);
}
RangeTuple<DateTime> finalTimes = validateDateTimeRange(startTime, endTime);
ReportDataKey key = new ReportDataKey.Builder().withReportType(ReportType.STUDY).withIdentifier(identifier).withAppId(appId).build();
Validate.entityThrowingException(ReportDataKeyValidator.INSTANCE, key);
ReportIndex index = reportIndexDao.getIndex(key);
checkStudyReportAccess(index);
return reportDataDao.getReportDataV4(key, finalTimes.getStart(), finalTimes.getEnd(), offsetKey, pageSize);
}
use of org.sagebionetworks.bridge.models.reports.ReportDataKey in project BridgeServer2 by Sage-Bionetworks.
the class ReportService method deleteStudyReport.
/**
* Delete all records for a study report. Study memberships will be enforced.
*/
public void deleteStudyReport(String appId, String identifier) {
ReportDataKey key = new ReportDataKey.Builder().withReportType(ReportType.STUDY).withIdentifier(identifier).withAppId(appId).build();
Validate.entityThrowingException(ReportDataKeyValidator.INSTANCE, key);
ReportIndex index = reportIndexDao.getIndex(key);
checkStudyReportAccess(index);
reportDataDao.deleteReportData(key);
reportIndexDao.removeIndex(key);
}
use of org.sagebionetworks.bridge.models.reports.ReportDataKey in project BridgeServer2 by Sage-Bionetworks.
the class ReportService method getParticipantReport.
/**
* Return set of participant report records based on the provided local date range. Study memberships are
* enforced.
*/
public DateRangeResourceList<? extends ReportData> getParticipantReport(String appId, String userId, String identifier, String healthCode, LocalDate startDate, LocalDate endDate) {
RangeTuple<LocalDate> finalDates = validateLocalDateRange(startDate, endDate);
startDate = finalDates.getStart();
endDate = finalDates.getEnd();
ReportDataKey key = new ReportDataKey.Builder().withHealthCode(healthCode).withReportType(ReportType.PARTICIPANT).withIdentifier(identifier).withAppId(appId).build();
Validate.entityThrowingException(ReportDataKeyValidator.INSTANCE, key);
ReportIndex index = reportIndexDao.getIndex(key);
checkParticipantReportAccess(userId, index);
return reportDataDao.getReportData(key, startDate, endDate);
}
Aggregations