Search in sources :

Example 11 with UserSession

use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.

the class CompoundActivityDefinitionController method updateCompoundActivityDefinition.

/**
 * Update a compound activity definition.
 */
@PostMapping(path = "/v3/compoundactivitydefinitions/{taskId}", produces = { APPLICATION_JSON_UTF8_VALUE })
public String updateCompoundActivityDefinition(@PathVariable String taskId) throws JsonProcessingException, IOException {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    CompoundActivityDefinition requestDef = parseJson(CompoundActivityDefinition.class);
    CompoundActivityDefinition updatedDef = compoundActivityDefService.updateCompoundActivityDefinition(session.getAppId(), taskId, requestDef);
    return PUBLIC_DEFINITION_WRITER.writeValueAsString(updatedDef);
}
Also used : CompoundActivityDefinition(org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 12 with UserSession

use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.

the class CompoundActivityDefinitionController method createCompoundActivityDefinition.

/**
 * Creates a compound activity definition.
 */
@PostMapping(path = "/v3/compoundactivitydefinitions", produces = { APPLICATION_JSON_UTF8_VALUE })
@ResponseStatus(HttpStatus.CREATED)
public String createCompoundActivityDefinition() throws JsonProcessingException, IOException {
    UserSession session = getAuthenticatedSession(DEVELOPER);
    CompoundActivityDefinition requestDef = parseJson(CompoundActivityDefinition.class);
    CompoundActivityDefinition createdDef = compoundActivityDefService.createCompoundActivityDefinition(session.getAppId(), requestDef);
    return PUBLIC_DEFINITION_WRITER.writeValueAsString(createdDef);
}
Also used : CompoundActivityDefinition(org.sagebionetworks.bridge.models.schedules.CompoundActivityDefinition) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) PostMapping(org.springframework.web.bind.annotation.PostMapping) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus)

Example 13 with UserSession

use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.

the class ConsentController method getConsentSignatureV2.

// V2: consent to a specific subpopulation
@GetMapping(path = "/v3/subpopulations/{guid}/consents/signature", produces = { APPLICATION_JSON_UTF8_VALUE })
public String getConsentSignatureV2(@PathVariable String guid) throws Exception {
    UserSession session = getAuthenticatedAndConsentedSession();
    App app = appService.getApp(session.getAppId());
    ConsentSignature sig = consentService.getConsentSignature(app, SubpopulationGuid.create(guid), session.getId());
    return ConsentSignature.SIGNATURE_WRITER.writeValueAsString(sig);
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) ConsentSignature(org.sagebionetworks.bridge.models.subpopulations.ConsentSignature) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 14 with UserSession

use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.

the class ConsentController method withdrawConsent.

@Deprecated
@PostMapping("/v3/consents/signature/withdraw")
public JsonNode withdrawConsent() {
    UserSession session = getAuthenticatedSession();
    App app = appService.getApp(session.getAppId());
    return withdrawConsentV2(app.getIdentifier());
}
Also used : App(org.sagebionetworks.bridge.models.apps.App) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 15 with UserSession

use of org.sagebionetworks.bridge.models.accounts.UserSession in project BridgeServer2 by Sage-Bionetworks.

the class ActivityEventController method getActivityEventHistoryForSelf.

@GetMapping("/v5/studies/{studyId}/participants/self/activityevents/{eventId}")
public ResourceList<StudyActivityEvent> getActivityEventHistoryForSelf(@PathVariable String studyId, @PathVariable String eventId, @RequestParam(required = false) String offsetBy, @RequestParam(required = false) String pageSize) throws JsonProcessingException {
    UserSession session = getAuthenticatedAndConsentedSession();
    if (!session.getParticipant().getStudyIds().contains(studyId)) {
        throw new EntityNotFoundException(Account.class);
    }
    int offsetByInt = BridgeUtils.getIntOrDefault(offsetBy, 0);
    int pageSizeInt = BridgeUtils.getIntOrDefault(pageSize, API_DEFAULT_PAGE_SIZE);
    AccountId accountId = AccountId.forId(session.getAppId(), session.getId());
    return studyActivityEventService.getStudyActivityEventHistory(accountId, studyId, eventId, offsetByInt, pageSizeInt);
}
Also used : AccountId(org.sagebionetworks.bridge.models.accounts.AccountId) UserSession(org.sagebionetworks.bridge.models.accounts.UserSession) EntityNotFoundException(org.sagebionetworks.bridge.exceptions.EntityNotFoundException) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

UserSession (org.sagebionetworks.bridge.models.accounts.UserSession)483 PostMapping (org.springframework.web.bind.annotation.PostMapping)149 GetMapping (org.springframework.web.bind.annotation.GetMapping)114 App (org.sagebionetworks.bridge.models.apps.App)104 Test (org.testng.annotations.Test)102 StudyParticipant (org.sagebionetworks.bridge.models.accounts.StudyParticipant)89 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)65 StatusMessage (org.sagebionetworks.bridge.models.StatusMessage)60 Account (org.sagebionetworks.bridge.models.accounts.Account)56 BeforeMethod (org.testng.annotations.BeforeMethod)47 EntityNotFoundException (org.sagebionetworks.bridge.exceptions.EntityNotFoundException)45 DeleteMapping (org.springframework.web.bind.annotation.DeleteMapping)43 UnauthorizedException (org.sagebionetworks.bridge.exceptions.UnauthorizedException)38 CriteriaContext (org.sagebionetworks.bridge.models.CriteriaContext)31 DateTime (org.joda.time.DateTime)27 AccountId (org.sagebionetworks.bridge.models.accounts.AccountId)27 JsonNode (com.fasterxml.jackson.databind.JsonNode)21 ResourceList (org.sagebionetworks.bridge.models.ResourceList)21 SubpopulationGuid (org.sagebionetworks.bridge.models.subpopulations.SubpopulationGuid)21 BadRequestException (org.sagebionetworks.bridge.exceptions.BadRequestException)18