Search in sources :

Example 1 with STUDY_COORDINATOR

use of org.sagebionetworks.bridge.Roles.STUDY_COORDINATOR in project BridgeServer2 by Sage-Bionetworks.

the class StudyParticipantController method listParticipantReportIndices.

/* --------------------------------------------------------------- */
/* STUDY-SCOPED PARTICIPANT REPORTS */
/* --------------------------------------------------------------- */
// INDICES
@GetMapping("/v5/studies/{studyId}/participants/reports")
public ReportTypeResourceList<? extends ReportIndex> listParticipantReportIndices(@PathVariable String studyId) {
    UserSession session = getAuthenticatedSession(STUDY_DESIGNER, STUDY_COORDINATOR);
    // this test is done in the service, but it will miss cases where there are no
    // indices. Fail faster.
    CAN_READ_PARTICIPANT_REPORTS.checkAndThrow(STUDY_ID, studyId);
    List<ReportIndex> list = reportService.getReportIndices(session.getAppId(), PARTICIPANT).getItems().stream().filter(index -> index.getStudyIds().contains(studyId)).collect(Collectors.toList());
    return new ReportTypeResourceList<>(list, true).withRequestParam(ResourceList.STUDY_ID, studyId).withRequestParam(ResourceList.REPORT_TYPE, PARTICIPANT);
}
Also used : ReportIndex(org.sagebionetworks.bridge.models.reports.ReportIndex) ReportDataKey(org.sagebionetworks.bridge.models.reports.ReportDataKey) PathVariable(org.springframework.web.bind.annotation.PathVariable) StudyParticipant(org.sagebionetworks.bridge.models.accounts.StudyParticipant) DateTimeZone(org.joda.time.DateTimeZone) RequestParam(org.springframework.web.bind.annotation.RequestParam) PARTICIPANT(org.sagebionetworks.bridge.models.reports.ReportType.PARTICIPANT) PagedResourceList(org.sagebionetworks.bridge.models.PagedResourceList) Study(org.sagebionetworks.bridge.models.studies.Study) IF_MODIFIED_SINCE(org.apache.http.HttpHeaders.IF_MODIFIED_SINCE) Autowired(org.springframework.beans.factory.annotation.Autowired) StudyService(org.sagebionetworks.bridge.services.StudyService) RequestInfo(org.sagebionetworks.bridge.models.RequestInfo) STUDY_COORDINATOR(org.sagebionetworks.bridge.Roles.STUDY_COORDINATOR) ResourceList(org.sagebionetworks.bridge.models.ResourceList) AccountId(org.sagebionetworks.bridge.models.accounts.AccountId) ReportData(org.sagebionetworks.bridge.models.reports.ReportData) Timeline(org.sagebionetworks.bridge.models.schedules2.timelines.Timeline) NotificationMessage(org.sagebionetworks.bridge.models.notifications.NotificationMessage) StudyActivityEventService(org.sagebionetworks.bridge.services.StudyActivityEventService) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) CacheKey.scheduleModificationTimestamp(org.sagebionetworks.bridge.cache.CacheKey.scheduleModificationTimestamp) NotificationRegistration(org.sagebionetworks.bridge.models.notifications.NotificationRegistration) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) StudyActivityEventRequest(org.sagebionetworks.bridge.models.activities.StudyActivityEventRequest) PostMapping(org.springframework.web.bind.annotation.PostMapping) INSTANCE(org.sagebionetworks.bridge.models.schedules2.timelines.Scheduler.INSTANCE) AccountSummary(org.sagebionetworks.bridge.models.accounts.AccountSummary) ImmutableSet(com.google.common.collect.ImmutableSet) TIMELINE_RETRIEVED(org.sagebionetworks.bridge.models.activities.ActivityEventObjectType.TIMELINE_RETRIEVED) CAN_EDIT_STUDY_PARTICIPANTS(org.sagebionetworks.bridge.AuthUtils.CAN_EDIT_STUDY_PARTICIPANTS) CAN_READ_PARTICIPANT_REPORTS(org.sagebionetworks.bridge.AuthUtils.CAN_READ_PARTICIPANT_REPORTS) ObjectWriter(com.fasterxml.jackson.databind.ObjectWriter) Schedule2(org.sagebionetworks.bridge.models.schedules2.Schedule2) EtagCacheKey(org.sagebionetworks.bridge.spring.util.EtagCacheKey) ReportTypeResourceList(org.sagebionetworks.bridge.models.ReportTypeResourceList) StatusMessage(org.sagebionetworks.bridge.models.StatusMessage) NOT_MODIFIED(org.springframework.http.HttpStatus.NOT_MODIFIED) Set(java.util.Set) APPLICATION_JSON_UTF8_VALUE(org.springframework.http.MediaType.APPLICATION_JSON_UTF8_VALUE) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) STUDY_DESIGNER(org.sagebionetworks.bridge.Roles.STUDY_DESIGNER) REQUEST_INFO_WRITER(org.sagebionetworks.bridge.models.RequestInfo.REQUEST_INFO_WRITER) Account(org.sagebionetworks.bridge.models.accounts.Account) UserAdminService(org.sagebionetworks.bridge.services.UserAdminService) ReportIndex(org.sagebionetworks.bridge.models.reports.ReportIndex) EnrollmentService(org.sagebionetworks.bridge.services.EnrollmentService) List(java.util.List) API_DEFAULT_PAGE_SIZE(org.sagebionetworks.bridge.BridgeConstants.API_DEFAULT_PAGE_SIZE) ParticipantService(org.sagebionetworks.bridge.services.ParticipantService) SubpopulationGuid(org.sagebionetworks.bridge.models.subpopulations.SubpopulationGuid) EtagSupport(org.sagebionetworks.bridge.spring.util.EtagSupport) EnrollmentDetail(org.sagebionetworks.bridge.models.studies.EnrollmentDetail) ForwardCursorPagedResourceList(org.sagebionetworks.bridge.models.ForwardCursorPagedResourceList) BridgeUtils(org.sagebionetworks.bridge.BridgeUtils) UploadView(org.sagebionetworks.bridge.models.upload.UploadView) TRUE(java.lang.Boolean.TRUE) Enrollment(org.sagebionetworks.bridge.models.studies.Enrollment) Phone(org.sagebionetworks.bridge.models.accounts.Phone) ParticipantSchedule(org.sagebionetworks.bridge.models.schedules2.participantschedules.ParticipantSchedule) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) BridgeUtils.participantEligibleForDeletion(org.sagebionetworks.bridge.BridgeUtils.participantEligibleForDeletion) StudyActivityEventIdsMap(org.sagebionetworks.bridge.models.activities.StudyActivityEventIdsMap) AccountSummarySearch(org.sagebionetworks.bridge.models.AccountSummarySearch) ReportService(org.sagebionetworks.bridge.services.ReportService) Schedule2Service(org.sagebionetworks.bridge.services.Schedule2Service) App(org.sagebionetworks.bridge.models.apps.App) CAN_EXPORT_PARTICIPANTS(org.sagebionetworks.bridge.AuthUtils.CAN_EXPORT_PARTICIPANTS) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ParticipantRosterRequest(org.sagebionetworks.bridge.models.ParticipantRosterRequest) BridgeUtils.addToSet(org.sagebionetworks.bridge.BridgeUtils.addToSet) StudyActivityEvent(org.sagebionetworks.bridge.models.activities.StudyActivityEvent) PROMOTIONAL(org.sagebionetworks.bridge.models.sms.SmsType.PROMOTIONAL) BridgeUtils.getDateTimeOrDefault(org.sagebionetworks.bridge.BridgeUtils.getDateTimeOrDefault) ChannelType(org.sagebionetworks.bridge.services.AuthenticationService.ChannelType) IdentifierHolder(org.sagebionetworks.bridge.models.accounts.IdentifierHolder) SUPERADMIN(org.sagebionetworks.bridge.Roles.SUPERADMIN) DateTime(org.joda.time.DateTime) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) UnauthorizedException(org.sagebionetworks.bridge.exceptions.UnauthorizedException) HttpStatus(org.springframework.http.HttpStatus) STUDY_ID(org.sagebionetworks.bridge.AuthEvaluatorField.STUDY_ID) ResponseEntity(org.springframework.http.ResponseEntity) OK(org.springframework.http.HttpStatus.OK) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) ReportTypeResourceList(org.sagebionetworks.bridge.models.ReportTypeResourceList) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 TRUE (java.lang.Boolean.TRUE)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 IF_MODIFIED_SINCE (org.apache.http.HttpHeaders.IF_MODIFIED_SINCE)1 DateTime (org.joda.time.DateTime)1 DateTimeZone (org.joda.time.DateTimeZone)1 STUDY_ID (org.sagebionetworks.bridge.AuthEvaluatorField.STUDY_ID)1 CAN_EDIT_STUDY_PARTICIPANTS (org.sagebionetworks.bridge.AuthUtils.CAN_EDIT_STUDY_PARTICIPANTS)1 CAN_EXPORT_PARTICIPANTS (org.sagebionetworks.bridge.AuthUtils.CAN_EXPORT_PARTICIPANTS)1 CAN_READ_PARTICIPANT_REPORTS (org.sagebionetworks.bridge.AuthUtils.CAN_READ_PARTICIPANT_REPORTS)1 API_DEFAULT_PAGE_SIZE (org.sagebionetworks.bridge.BridgeConstants.API_DEFAULT_PAGE_SIZE)1 BridgeUtils (org.sagebionetworks.bridge.BridgeUtils)1 BridgeUtils.addToSet (org.sagebionetworks.bridge.BridgeUtils.addToSet)1 BridgeUtils.getDateTimeOrDefault (org.sagebionetworks.bridge.BridgeUtils.getDateTimeOrDefault)1 BridgeUtils.participantEligibleForDeletion (org.sagebionetworks.bridge.BridgeUtils.participantEligibleForDeletion)1 STUDY_COORDINATOR (org.sagebionetworks.bridge.Roles.STUDY_COORDINATOR)1