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;
}
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());
}
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());
}
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());
}
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());
}
Aggregations