Search in sources :

Example 1 with DataAccessRequestData

use of org.broadinstitute.consent.http.models.DataAccessRequestData in project consent by DataBiosphere.

the class SummaryServiceTest method createDAR.

private DataAccessRequest createDAR(String referenceId, Integer userId) {
    DataAccessRequestData data = new DataAccessRequestData();
    data.setDatasetIds(List.of(1));
    data.setReferenceId(referenceId);
    data.setDarCode("DAR-" + RandomUtils.nextInt(100, 200));
    data.setProjectTitle("Project-TEST");
    DataAccessRequest dar = new DataAccessRequest();
    dar.setReferenceId(referenceId);
    dar.setUserId(userId);
    dar.setData(data);
    dar.setSortDate(new Timestamp(new Date().getTime()));
    return dar;
}
Also used : DataAccessRequestData(org.broadinstitute.consent.http.models.DataAccessRequestData) DataAccessRequest(org.broadinstitute.consent.http.models.DataAccessRequest) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 2 with DataAccessRequestData

use of org.broadinstitute.consent.http.models.DataAccessRequestData in project consent by DataBiosphere.

the class MatchServiceTest method getSampleDataAccessRequest.

private DataAccessRequest getSampleDataAccessRequest(String referenceId) {
    DataAccessRequest dar = new DataAccessRequest();
    dar.setReferenceId(referenceId);
    DataAccessRequestData data = new DataAccessRequestData();
    data.setReferenceId(referenceId);
    data.setHmb(true);
    data.setDatasetIds(Collections.singletonList(1));
    dar.setData(data);
    return dar;
}
Also used : DataAccessRequestData(org.broadinstitute.consent.http.models.DataAccessRequestData) DataAccessRequest(org.broadinstitute.consent.http.models.DataAccessRequest)

Example 3 with DataAccessRequestData

use of org.broadinstitute.consent.http.models.DataAccessRequestData in project consent by DataBiosphere.

the class DarCollectionResourceTest method testResubmitDarCollection_CollectionNotCanceled.

@Test
public void testResubmitDarCollection_CollectionNotCanceled() {
    int userId = 1;
    User user = mock(User.class);
    when(userService.findUserByEmail(anyString())).thenReturn(user);
    when(user.getDacUserId()).thenReturn(userId);
    DarCollection collection = mock(DarCollection.class);
    when(collection.getCreateUserId()).thenReturn(userId);
    DataAccessRequest dar = mock(DataAccessRequest.class);
    DataAccessRequestData data = mock(DataAccessRequestData.class);
    String referenceId = UUID.randomUUID().toString();
    when(data.getStatus()).thenReturn("Not Canceled");
    when(dar.getData()).thenReturn(data);
    when(dar.getReferenceId()).thenReturn(referenceId);
    Map<String, DataAccessRequest> darMap = Map.of(dar.getReferenceId(), dar);
    when(collection.getDars()).thenReturn(darMap);
    when(darCollectionService.getByCollectionId(any())).thenReturn(collection);
    initResource();
    Response response = resource.resubmitDarCollection(authUser, 1);
    assertEquals(HttpStatusCodes.STATUS_CODE_BAD_REQUEST, response.getStatus());
}
Also used : DataAccessRequestData(org.broadinstitute.consent.http.models.DataAccessRequestData) Response(javax.ws.rs.core.Response) PaginationResponse(org.broadinstitute.consent.http.models.PaginationResponse) AuthUser(org.broadinstitute.consent.http.models.AuthUser) User(org.broadinstitute.consent.http.models.User) DataAccessRequest(org.broadinstitute.consent.http.models.DataAccessRequest) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) DarCollection(org.broadinstitute.consent.http.models.DarCollection) Test(org.junit.Test)

Example 4 with DataAccessRequestData

use of org.broadinstitute.consent.http.models.DataAccessRequestData in project consent by DataBiosphere.

the class DarCollectionResourceTest method mockDataAccessRequestWithDatasetIds.

private DataAccessRequest mockDataAccessRequestWithDatasetIds() {
    DataAccessRequest dar = new DataAccessRequest();
    DataAccessRequestData data = new DataAccessRequestData();
    data.setDatasetIds(List.of(RandomUtils.nextInt(1, 100)));
    dar.setData(data);
    return dar;
}
Also used : DataAccessRequestData(org.broadinstitute.consent.http.models.DataAccessRequestData) DataAccessRequest(org.broadinstitute.consent.http.models.DataAccessRequest)

Example 5 with DataAccessRequestData

use of org.broadinstitute.consent.http.models.DataAccessRequestData in project consent by DataBiosphere.

the class DataAccessRequestResourceVersion2 method updatePartialDataAccessRequest.

@PUT
@Consumes("application/json")
@Produces("application/json")
@Path("/draft/{referenceId}")
@RolesAllowed(RESEARCHER)
public Response updatePartialDataAccessRequest(@Auth AuthUser authUser, @PathParam("referenceId") String referenceId, String dar) {
    try {
        User user = findUserByEmail(authUser.getEmail());
        DataAccessRequest originalDar = dataAccessRequestService.findByReferenceId(referenceId);
        checkAuthorizedUpdateUser(user, originalDar);
        DataAccessRequestData data = DataAccessRequestData.fromString(dar);
        // Keep dar data reference id in sync with the dar until we fully deprecate
        // it in dar data.
        data.setReferenceId(originalDar.getReferenceId());
        originalDar.setData(data);
        DataAccessRequest updatedDar = dataAccessRequestService.updateByReferenceIdVersion2(user, originalDar);
        return Response.ok().entity(updatedDar.convertToSimplifiedDar()).build();
    } catch (Exception e) {
        return createExceptionResponse(e);
    }
}
Also used : DataAccessRequestData(org.broadinstitute.consent.http.models.DataAccessRequestData) AuthUser(org.broadinstitute.consent.http.models.AuthUser) User(org.broadinstitute.consent.http.models.User) DataAccessRequest(org.broadinstitute.consent.http.models.DataAccessRequest) ForbiddenException(javax.ws.rs.ForbiddenException) IOException(java.io.IOException) NotFoundException(javax.ws.rs.NotFoundException) Path(javax.ws.rs.Path) RolesAllowed(javax.annotation.security.RolesAllowed) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Aggregations

DataAccessRequestData (org.broadinstitute.consent.http.models.DataAccessRequestData)50 DataAccessRequest (org.broadinstitute.consent.http.models.DataAccessRequest)45 Test (org.junit.Test)24 User (org.broadinstitute.consent.http.models.User)22 DarCollection (org.broadinstitute.consent.http.models.DarCollection)18 AuthUser (org.broadinstitute.consent.http.models.AuthUser)15 Election (org.broadinstitute.consent.http.models.Election)15 Date (java.util.Date)12 Vote (org.broadinstitute.consent.http.models.Vote)9 ArrayList (java.util.ArrayList)8 DataSet (org.broadinstitute.consent.http.models.DataSet)8 IOException (java.io.IOException)7 Dac (org.broadinstitute.consent.http.models.Dac)7 DataAccessRequestManage (org.broadinstitute.consent.http.models.DataAccessRequestManage)7 Consent (org.broadinstitute.consent.http.models.Consent)6 File (java.io.File)5 List (java.util.List)5 NotFoundException (javax.ws.rs.NotFoundException)5 Collection (java.util.Collection)4 Collections (java.util.Collections)4