Search in sources :

Example 1 with Election

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

the class ElectionMapper method map.

@Override
public Election map(ResultSet r, StatementContext ctx) throws SQLException {
    Election election;
    if (electionMap.containsKey(r.getInt(ElectionFields.ID.getValue()))) {
        election = electionMap.get(r.getInt(ElectionFields.ID.getValue()));
    } else {
        election = new Election();
        election.setElectionId(r.getInt(ElectionFields.ID.getValue()));
    }
    if (r.getString(ElectionFields.TYPE.getValue()) != null) {
        election.setElectionType(r.getString(ElectionFields.TYPE.getValue()));
    }
    if (r.getString(ElectionFields.FINAL_VOTE.getValue()) != null) {
        election.setFinalVote(r.getBoolean(ElectionFields.FINAL_VOTE.getValue()));
    }
    if (r.getString(ElectionFields.FINAL_RATIONALE.getValue()) != null) {
        election.setFinalRationale(r.getString(ElectionFields.FINAL_RATIONALE.getValue()));
    }
    if (r.getString(ElectionFields.STATUS.getValue()) != null) {
        election.setStatus(r.getString(ElectionFields.STATUS.getValue()));
    }
    if (r.getDate(ElectionFields.CREATE_DATE.getValue()) != null) {
        election.setCreateDate(r.getDate(ElectionFields.CREATE_DATE.getValue()));
    }
    if (r.getDate(ElectionFields.FINAL_VOTE_DATE.getValue()) != null) {
        election.setFinalVoteDate(r.getDate(ElectionFields.FINAL_VOTE_DATE.getValue()));
    }
    if (r.getString(ElectionFields.REFERENCE_ID.getValue()) != null) {
        election.setReferenceId(r.getString(ElectionFields.REFERENCE_ID.getValue()));
    }
    if (r.getDate(ElectionFields.LAST_UPDATE.getValue()) != null) {
        election.setLastUpdate(r.getDate(ElectionFields.LAST_UPDATE.getValue()));
    }
    if (r.getString(ElectionFields.FINAL_ACCESS_VOTE.getValue()) != null) {
        election.setFinalAccessVote(r.getBoolean(ElectionFields.FINAL_ACCESS_VOTE.getValue()));
    }
    if (r.getObject(ElectionFields.DATASET_ID.getValue()) != null) {
        election.setDataSetId(r.getInt(ElectionFields.DATASET_ID.getValue()));
    }
    if (r.getString(ElectionFields.DATA_USE_LETTER.getValue()) != null) {
        election.setDataUseLetter(r.getString(ElectionFields.DATA_USE_LETTER.getValue()));
    }
    if (r.getString(ElectionFields.DUL_NAME.getValue()) != null) {
        election.setDulName(r.getString(ElectionFields.DUL_NAME.getValue()));
    }
    if (r.getObject(ElectionFields.VERSION.getValue()) != null) {
        election.setVersion(r.getInt(ElectionFields.VERSION.getValue()));
    }
    if (r.getString(ElectionFields.ARCHIVED.getValue()) != null) {
        election.setArchived(r.getBoolean(ElectionFields.ARCHIVED.getValue()));
    }
    electionMap.put(election.getElectionId(), election);
    return election;
}
Also used : Election(org.broadinstitute.consent.http.models.Election)

Example 2 with Election

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

the class VoteServiceTest method testCreateDataOwnersReviewVotes.

@Test
public void testCreateDataOwnersReviewVotes() {
    Election e = new Election();
    e.setElectionId(1);
    e.setDataSetId(1);
    when(dataSetAssociationDAO.getDataOwnersOfDataSet(anyInt())).thenReturn(Collections.singletonList(1));
    Vote v = new Vote();
    v.setVoteId(1);
    when(voteDAO.insertVote(anyInt(), anyInt(), any())).thenReturn(v.getVoteId());
    when(voteDAO.findVoteById(anyInt())).thenReturn(v);
    when(voteDAO.findVotesByElectionIdAndType(anyInt(), anyString())).thenReturn(Collections.singletonList(v));
    initService();
    List<Vote> votes = service.createDataOwnersReviewVotes(e);
    assertFalse(votes.isEmpty());
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Example 3 with Election

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

the class VoteServiceTest method testChairCreateVotesRP.

@Test
public void testChairCreateVotesRP() {
    setUpUserAndElectionVotes(UserRoles.CHAIRPERSON);
    initService();
    List<Vote> votes = service.createVotes(new Election(), ElectionType.RP, false);
    assertFalse(votes.isEmpty());
    // Should create 2 votes:
    // Chairperson as a chair
    // Chairperson as a dac member
    assertEquals(2, votes.size());
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Example 4 with Election

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

the class VoteServiceTest method testMemberCreateVotesDataAccessManualReview.

@Test
public void testMemberCreateVotesDataAccessManualReview() {
    setUpUserAndElectionVotes(UserRoles.MEMBER);
    initService();
    List<Vote> votes = service.createVotes(new Election(), ElectionType.DATA_ACCESS, false);
    assertFalse(votes.isEmpty());
    // Should create 1 member vote
    assertEquals(1, votes.size());
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Example 5 with Election

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

the class VoteServiceTest method testChairCreateVotesDataAccess.

@Test
public void testChairCreateVotesDataAccess() {
    setUpUserAndElectionVotes(UserRoles.CHAIRPERSON);
    initService();
    List<Vote> votes = service.createVotes(new Election(), ElectionType.DATA_ACCESS, false);
    assertFalse(votes.isEmpty());
    // Should create 4 votes:
    // Chairperson as a chair
    // Chairperson as a dac member
    // Final vote
    // Manual review Agreement vote
    assertEquals(4, votes.size());
}
Also used : Vote(org.broadinstitute.consent.http.models.Vote) Election(org.broadinstitute.consent.http.models.Election) Test(org.junit.Test)

Aggregations

Election (org.broadinstitute.consent.http.models.Election)178 Test (org.junit.Test)123 DataSet (org.broadinstitute.consent.http.models.DataSet)89 Vote (org.broadinstitute.consent.http.models.Vote)85 Consent (org.broadinstitute.consent.http.models.Consent)80 User (org.broadinstitute.consent.http.models.User)79 DataAccessRequest (org.broadinstitute.consent.http.models.DataAccessRequest)64 Dac (org.broadinstitute.consent.http.models.Dac)58 Date (java.util.Date)33 ElectionReviewVote (org.broadinstitute.consent.http.models.ElectionReviewVote)31 ArrayList (java.util.ArrayList)19 List (java.util.List)18 ElectionType (org.broadinstitute.consent.http.enumeration.ElectionType)18 DataAccessRequestData (org.broadinstitute.consent.http.models.DataAccessRequestData)17 NotFoundException (javax.ws.rs.NotFoundException)16 AuthUser (org.broadinstitute.consent.http.models.AuthUser)16 DarCollection (org.broadinstitute.consent.http.models.DarCollection)16 Collectors (java.util.stream.Collectors)15 Response (javax.ws.rs.core.Response)15 Inject (com.google.inject.Inject)11