use of org.broadinstitute.consent.http.enumeration.ElectionType in project consent by DataBiosphere.
the class SummaryServiceTest method createElection.
private Election createElection(String electionType) {
ElectionType type = ElectionType.getFromValue(electionType);
Election e = new Election();
e.setReferenceId(UUID.randomUUID().toString());
e.setElectionType(type.getValue());
e.setElectionId(type.ordinal());
e.setCreateDate(new Date());
e.setLastUpdate(new Date());
e.setFinalVote(true);
e.setFinalVoteDate(new Date());
e.setFinalAccessVote(true);
return e;
}
use of org.broadinstitute.consent.http.enumeration.ElectionType in project consent by DataBiosphere.
the class PendingCaseService method createMissingUserVotes.
private void createMissingUserVotes(Election e, User user) {
ElectionType type = ElectionType.getFromValue(e.getElectionType());
boolean isManualReview = false;
if (type.equals(ElectionType.DATA_ACCESS)) {
DataAccessRequest dar = dataAccessRequestService.findByReferenceId(e.getReferenceId());
isManualReview = dar.requiresManualReview();
}
if (type.equals(ElectionType.TRANSLATE_DUL)) {
Consent c = consentDAO.findConsentById(e.getReferenceId());
isManualReview = c.getRequiresManualReview();
}
logger.info(String.format("Creating missing votes for user id '%s', election id '%s', reference id '%s' ", user.getDacUserId(), e.getElectionId(), e.getReferenceId()));
voteService.createVotesForUser(user, e, type, isManualReview);
}
use of org.broadinstitute.consent.http.enumeration.ElectionType in project consent by DataBiosphere.
the class DacService method addDacMember.
public User addDacMember(Role role, User user, Dac dac) throws IllegalArgumentException {
dacDAO.addDacMember(role.getRoleId(), user.getDacUserId(), dac.getDacId());
User updatedUser = userDAO.findUserById(user.getDacUserId());
List<Election> elections = electionDAO.findOpenElectionsByDacId(dac.getDacId());
for (Election e : elections) {
IllegalArgumentException noTypeException = new IllegalArgumentException("Unable to determine election type for election id: " + e.getElectionId());
if (Objects.isNull(e.getElectionType())) {
throw noTypeException;
}
Optional<ElectionType> type = EnumSet.allOf(ElectionType.class).stream().filter(t -> t.getValue().equalsIgnoreCase(e.getElectionType())).findFirst();
if (!type.isPresent()) {
throw noTypeException;
}
boolean isManualReview = type.get().equals(ElectionType.DATA_ACCESS) && hasUseRestriction(e.getReferenceId());
voteService.createVotesForUser(updatedUser, e, type.get(), isManualReview);
}
return userDAO.findUserById(updatedUser.getDacUserId());
}
Aggregations