Search in sources :

Example 1 with ElectionType

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;
}
Also used : ElectionType(org.broadinstitute.consent.http.enumeration.ElectionType) Election(org.broadinstitute.consent.http.models.Election) Date(java.util.Date)

Example 2 with ElectionType

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);
}
Also used : Consent(org.broadinstitute.consent.http.models.Consent) ElectionType(org.broadinstitute.consent.http.enumeration.ElectionType) DataAccessRequest(org.broadinstitute.consent.http.models.DataAccessRequest)

Example 3 with ElectionType

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());
}
Also used : DataAccessRequest(org.broadinstitute.consent.http.models.DataAccessRequest) Date(java.util.Date) Inject(com.google.inject.Inject) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) HashMap(java.util.HashMap) DatasetDTO(org.broadinstitute.consent.http.models.dto.DatasetDTO) UserRoles(org.broadinstitute.consent.http.enumeration.UserRoles) ArrayList(java.util.ArrayList) DatasetDAO(org.broadinstitute.consent.http.db.DatasetDAO) Map(java.util.Map) ElectionType(org.broadinstitute.consent.http.enumeration.ElectionType) AuthUser(org.broadinstitute.consent.http.models.AuthUser) BadRequestException(javax.ws.rs.BadRequestException) Role(org.broadinstitute.consent.http.models.Role) EnumSet(java.util.EnumSet) UserDAO(org.broadinstitute.consent.http.db.UserDAO) DataSet(org.broadinstitute.consent.http.models.DataSet) DacDAO(org.broadinstitute.consent.http.db.DacDAO) DataAccessRequestDAO(org.broadinstitute.consent.http.db.DataAccessRequestDAO) ConsentManage(org.broadinstitute.consent.http.models.ConsentManage) Collection(java.util.Collection) Set(java.util.Set) UserRole(org.broadinstitute.consent.http.models.UserRole) User(org.broadinstitute.consent.http.models.User) Collectors(java.util.stream.Collectors) NotFoundException(javax.ws.rs.NotFoundException) Dac(org.broadinstitute.consent.http.models.Dac) ElectionDAO(org.broadinstitute.consent.http.db.ElectionDAO) Objects(java.util.Objects) List(java.util.List) Election(org.broadinstitute.consent.http.models.Election) Optional(java.util.Optional) Collections(java.util.Collections) Consent(org.broadinstitute.consent.http.models.Consent) AuthUser(org.broadinstitute.consent.http.models.AuthUser) User(org.broadinstitute.consent.http.models.User) ElectionType(org.broadinstitute.consent.http.enumeration.ElectionType) Election(org.broadinstitute.consent.http.models.Election)

Aggregations

ElectionType (org.broadinstitute.consent.http.enumeration.ElectionType)3 Date (java.util.Date)2 Consent (org.broadinstitute.consent.http.models.Consent)2 DataAccessRequest (org.broadinstitute.consent.http.models.DataAccessRequest)2 Election (org.broadinstitute.consent.http.models.Election)2 Inject (com.google.inject.Inject)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 EnumSet (java.util.EnumSet)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)1 BadRequestException (javax.ws.rs.BadRequestException)1 NotFoundException (javax.ws.rs.NotFoundException)1