Search in sources :

Example 1 with StudyActivityEventRequest

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;
}
Also used : StudyActivityEventRequest(org.sagebionetworks.bridge.models.activities.StudyActivityEventRequest) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) StudyActivityEventIdsMap(org.sagebionetworks.bridge.models.activities.StudyActivityEventIdsMap) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 2 with StudyActivityEventRequest

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;
}
Also used : Account(org.sagebionetworks.bridge.models.accounts.Account) StudyActivityEventRequest(org.sagebionetworks.bridge.models.activities.StudyActivityEventRequest) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) StudyActivityEventIdsMap(org.sagebionetworks.bridge.models.activities.StudyActivityEventIdsMap) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 3 with StudyActivityEventRequest

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;
}
Also used : Account(org.sagebionetworks.bridge.models.accounts.Account) StudyActivityEventRequest(org.sagebionetworks.bridge.models.activities.StudyActivityEventRequest) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) StudyActivityEventIdsMap(org.sagebionetworks.bridge.models.activities.StudyActivityEventIdsMap) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 4 with StudyActivityEventRequest

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;
}
Also used : StudyActivityEventRequest(org.sagebionetworks.bridge.models.activities.StudyActivityEventRequest) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) StudyActivityEventIdsMap(org.sagebionetworks.bridge.models.activities.StudyActivityEventIdsMap) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Aggregations

UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)4 StudyActivityEventIdsMap (org.sagebionetworks.bridge.models.activities.StudyActivityEventIdsMap)4 StudyActivityEventRequest (org.sagebionetworks.bridge.models.activities.StudyActivityEventRequest)4 EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)2 Account (org.sagebionetworks.bridge.models.accounts.Account)2 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)2 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)2