use of org.sagebionetworks.bridge.models.activities.StudyActivityEventRequest in project BridgeServer2 by Sage-Bionetworks.
the class ActivityEventController method deleteActivityEventForSelf.
@DeleteMapping("/v5/studies/{studyId}/participants/self/activityevents/{eventId}")
public StatusMessage deleteActivityEventForSelf(@PathVariable String studyId, @PathVariable String eventId, @RequestParam(required = false) String showError) {
UserSession session = getAuthenticatedAndConsentedSession();
if (!session.getParticipant().getStudyIds().contains(studyId)) {
throw new EntityNotFoundException(Account.class);
}
StudyActivityEventRequest request = new StudyActivityEventRequest(eventId, null, null, null);
StudyActivityEventIdsMap eventMap = studyService.getStudyActivityEventIdsMap(session.getAppId(), studyId);
boolean showErrorBool = "true".equals(showError);
studyActivityEventService.deleteEvent(request.parse(eventMap).withAppId(session.getAppId()).withStudyId(studyId).withUserId(session.getId()).build(), showErrorBool);
return EVENT_DELETED_MSG;
}
use of org.sagebionetworks.bridge.models.activities.StudyActivityEventRequest in project BridgeServer2 by Sage-Bionetworks.
the class StudyParticipantController method deleteActivityEvent.
@DeleteMapping("/v5/studies/{studyId}/participants/{userId}/activityevents/{eventId}")
public StatusMessage deleteActivityEvent(@PathVariable String studyId, @PathVariable String userId, @PathVariable String eventId, @RequestParam(required = false) String showError) {
UserSession session = getAdministrativeSession();
Account account = getValidAccountInStudy(session.getAppId(), studyId, userId);
StudyActivityEventRequest request = new StudyActivityEventRequest(eventId, null, null, null);
StudyActivityEventIdsMap eventMap = studyService.getStudyActivityEventIdsMap(session.getAppId(), studyId);
boolean showErrorBool = "true".equals(showError);
studyActivityEventService.deleteEvent(request.parse(eventMap).withAppId(session.getAppId()).withStudyId(studyId).withUserId(account.getId()).build(), showErrorBool);
return EVENT_DELETED_MSG;
}
use of org.sagebionetworks.bridge.models.activities.StudyActivityEventRequest in project BridgeServer2 by Sage-Bionetworks.
the class StudyParticipantController method publishActivityEvent.
@PostMapping("/v5/studies/{studyId}/participants/{userId}/activityevents")
@ResponseStatus(HttpStatus.CREATED)
public StatusMessage publishActivityEvent(@PathVariable String studyId, @PathVariable String userId, @RequestParam(required = false) String showError, @RequestParam(required = false) String updateBursts) {
UserSession session = getAdministrativeSession();
Account account = getValidAccountInStudy(session.getAppId(), studyId, userId);
StudyActivityEventRequest request = parseJson(StudyActivityEventRequest.class);
StudyActivityEventIdsMap eventMap = studyService.getStudyActivityEventIdsMap(session.getAppId(), studyId);
boolean showErrorBool = "true".equals(showError);
boolean updateBurstsBool = !"false".equals(updateBursts);
studyActivityEventService.publishEvent(request.parse(eventMap).withAppId(session.getAppId()).withStudyId(studyId).withUserId(account.getId()).build(), showErrorBool, updateBurstsBool);
return EVENT_RECORDED_MSG;
}
use of org.sagebionetworks.bridge.models.activities.StudyActivityEventRequest in project BridgeServer2 by Sage-Bionetworks.
the class ActivityEventController method publishActivityEventForSelf.
@PostMapping("/v5/studies/{studyId}/participants/self/activityevents")
@ResponseStatus(HttpStatus.CREATED)
public StatusMessage publishActivityEventForSelf(@PathVariable String studyId, @RequestParam(required = false) String showError, @RequestParam(required = false) String updateBursts) {
UserSession session = getAuthenticatedAndConsentedSession();
if (!session.getParticipant().getStudyIds().contains(studyId)) {
throw new EntityNotFoundException(Account.class);
}
StudyActivityEventRequest request = parseJson(StudyActivityEventRequest.class);
StudyActivityEventIdsMap eventMap = studyService.getStudyActivityEventIdsMap(session.getAppId(), studyId);
boolean showErrorBool = "true".equals(showError);
boolean updateBurstsBool = !"false".equals(updateBursts);
studyActivityEventService.publishEvent(request.parse(eventMap).withAppId(session.getAppId()).withStudyId(studyId).withUserId(session.getId()).build(), showErrorBool, updateBurstsBool);
return EVENT_RECORDED_MSG;
}
Aggregations