use of org.broadinstitute.consent.http.models.ConsentManage in project consent by DataBiosphere.
the class ConsentManageMapper method map.
public ConsentManage map(ResultSet r, StatementContext ctx) throws SQLException {
ConsentManage consentManage = new ConsentManage();
consentManage.setConsentId(r.getString("consentId"));
consentManage.setConsentName(r.getString("name"));
consentManage.setCreateDate(r.getTimestamp("createDate"));
if (r.getObject("dac_id") != null) {
consentManage.setDacId(r.getInt("dac_id"));
}
consentManage.setSortDate(r.getTimestamp("sortDate"));
consentManage.setElectionId(r.getInt(ElectionFields.ID.getValue()));
consentManage.setElectionStatus(r.getString(ElectionFields.STATUS.getValue()));
consentManage.setVersion(r.getInt(ElectionFields.VERSION.getValue()) < 10 ? '0' + String.valueOf(r.getInt(ElectionFields.VERSION.getValue())) : String.valueOf(r.getInt(ElectionFields.VERSION.getValue())));
consentManage.setArchived(r.getBoolean(ElectionFields.ARCHIVED.getValue()));
consentManage.setEditable(true);
consentManage.setGroupName(r.getString("groupName"));
consentManage.setUpdateStatus(r.getBoolean("updated"));
return consentManage;
}
use of org.broadinstitute.consent.http.models.ConsentManage in project consent by DataBiosphere.
the class ConsentDAOTest method testFindConsentManageByStatus.
@Test
public void testFindConsentManageByStatus() {
Consent consent = createConsent(null);
DataSet dataset = createDataset();
createAssociation(consent.getConsentId(), dataset.getDataSetId());
Election election = createAccessElection(consent.getConsentId(), dataset.getDataSetId());
List<ConsentManage> consentManages = consentDAO.findConsentManageByStatus(election.getStatus());
List<String> consentIds = consentManages.stream().map(ConsentManage::getConsentId).collect(Collectors.toList());
assertTrue(consentIds.contains(consent.getConsentId()));
}
use of org.broadinstitute.consent.http.models.ConsentManage in project consent by DataBiosphere.
the class ConsentService method describeConsentManage.
public List<ConsentManage> describeConsentManage(AuthUser authUser) {
List<ConsentManage> consentManageList = new ArrayList<>();
consentManageList.addAll(collectUnreviewedConsents(consentDAO.findUnreviewedConsents()));
consentManageList.addAll(consentDAO.findConsentManageByStatus(ElectionStatus.OPEN.getValue()));
consentManageList.addAll(consentDAO.findConsentManageByStatus(ElectionStatus.CANCELED.getValue()));
List<ConsentManage> closedElections = consentDAO.findConsentManageByStatus(ElectionStatus.CLOSED.getValue());
closedElections.forEach(consentManage -> {
Boolean vote = voteDAO.findChairPersonVoteByElectionId(consentManage.getElectionId());
consentManage.setVote(vote != null && vote ? "Approved" : "Denied");
});
consentManageList.addAll(closedElections);
consentManageList.sort((c1, c2) -> c2.getSortDate().compareTo(c1.getSortDate()));
List<Election> openElections = electionDAO.findElectionsWithFinalVoteByTypeAndStatus(ElectionType.DATA_ACCESS.getValue(), ElectionStatus.OPEN.getValue());
if (!openElections.isEmpty()) {
List<String> referenceIds = openElections.stream().map(Election::getReferenceId).collect(Collectors.toList());
List<DataAccessRequest> dataAccessRequests = dataAccessRequestDAO.findByReferenceIds(referenceIds);
List<String> datasetIds = dataAccessRequests.stream().filter(Objects::nonNull).map(DataAccessRequest::getData).filter(Objects::nonNull).map(DataAccessRequestData::getDatasetDetail).filter(Objects::nonNull).flatMap(List::stream).map(DatasetDetailEntry::getDatasetId).filter(Objects::nonNull).collect(Collectors.toList());
List<String> consentIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(datasetIds)) {
List<Integer> datasetIdIntValues = datasetIds.stream().map(Integer::valueOf).collect(Collectors.toList());
consentIds.addAll(consentDAO.getAssociationConsentIdsFromDatasetIds(datasetIdIntValues));
}
for (ConsentManage consentManage : consentManageList) {
if (consentIds.stream().anyMatch(cm -> cm.equals(consentManage.getConsentId()))) {
consentManage.setEditable(false);
} else {
consentManage.setEditable(true);
}
}
}
return dacService.filterConsentManageByDAC(consentManageList, authUser);
}
Aggregations