• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DataBiosphere / consent / #6038

09 Jun 2025 03:55PM UTC coverage: 78.96% (+0.01%) from 78.949%
#6038

push

web-flow
DT-1792: Restrict researcher actions on summaries with closeouts (#2555)

9 of 9 new or added lines in 3 files covered. (100.0%)

1 existing line in 1 file now uncovered.

10144 of 12847 relevant lines covered (78.96%)

0.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.11
/src/main/java/org/broadinstitute/consent/http/db/mapper/DarCollectionSummaryReducer.java
1
package org.broadinstitute.consent.http.db.mapper;
2

3
import java.util.Map;
4
import java.util.Objects;
5
import org.broadinstitute.consent.http.models.CloseoutSupplement;
6
import org.broadinstitute.consent.http.models.DarCollectionSummary;
7
import org.broadinstitute.consent.http.models.Election;
8
import org.broadinstitute.consent.http.models.Vote;
9
import org.broadinstitute.consent.http.util.gson.GsonUtil;
10
import org.jdbi.v3.core.mapper.MappingException;
11
import org.jdbi.v3.core.mapper.NoSuchMapperException;
12
import org.jdbi.v3.core.result.LinkedHashMapRowReducer;
13
import org.jdbi.v3.core.result.RowView;
14

15
public class DarCollectionSummaryReducer implements
1✔
16
    LinkedHashMapRowReducer<Integer, DarCollectionSummary>, RowMapperHelper {
17

18
  @Override
19
  public void accumulate(Map<Integer, DarCollectionSummary> map, RowView rowView) {
20

21
    DarCollectionSummary summary = map.computeIfAbsent(
1✔
22
        rowView.getColumn("dar_collection_id", Integer.class),
1✔
23
        id -> rowView.getRow(DarCollectionSummary.class)
1✔
24
    );
25
    Election election;
26
    Vote vote;
27
    Integer datasetId;
28
    String darStatus;
29
    String darReferenceId;
30

31
    try {
32
      if (hasColumn(rowView, "closeout", String.class)) {
1✔
33
        String string = rowView.getColumn("closeout", String.class);
1✔
34
        CloseoutSupplement closeout = GsonUtil.getInstance().fromJson(string, CloseoutSupplement.class);
1✔
35
        summary.setCloseoutSupplement(closeout);
1✔
36
      }
37

38
      datasetId = rowView.getColumn("dd_datasetid", Integer.class);
1✔
39
      if (Objects.nonNull(datasetId)) {
1✔
40
        summary.addDatasetId(datasetId);
1✔
41
      }
42

43
      if (hasColumn(rowView, "dac_name", String.class)) {
1✔
44
        if (Objects.nonNull(rowView.getColumn("dac_name", String.class))) {
1✔
45
          summary.addDacName(rowView.getColumn("dac_name", String.class));
1✔
46
        }
47
      }
48

49
      try {
50
        darReferenceId = rowView.getColumn("latest_dar_reference_id", String.class);
1✔
51
        if (Objects.nonNull(darReferenceId)) {
1✔
52
          summary.setLatestReferenceId(darReferenceId);
1✔
53
        }
54
        hasOptionalColumn(rowView, "latest_dar_parent_id", Integer.class)
1✔
55
            .ifPresent(darParentId -> summary.addParentChildRelationship(darParentId, darReferenceId));
1✔
56
        darStatus = rowView.getColumn("dar_status", String.class);
1✔
57
        if (Objects.nonNull(darStatus)) {
1✔
58
          summary.addStatus(darStatus, darReferenceId);
1✔
59
        }
UNCOV
60
      } catch (MappingException e) {
×
61
        //ignore exception, it means dar_status and dar_reference_id wasn't included for this query
62
      }
1✔
63

64
      try {
65
        election = rowView.getRow(Election.class);
1✔
66
        if (Objects.nonNull(election.getElectionId())) {
1✔
67
          summary.addElection(election);
1✔
68
          summary.addDatasetId(election.getDatasetId());
1✔
69
        }
70
      } catch (MappingException e) {
×
71
        // Indicates that we do not have an election for this summary
72
      }
1✔
73

74
      try {
75
        vote = rowView.getRow(Vote.class);
1✔
76
        if (Objects.nonNull(vote.getVoteId())) {
1✔
77
          summary.addVote(vote);
1✔
78
        }
79
      } catch (MappingException e) {
×
80
        // Indicates that we do not have an election for this summary
81
      }
1✔
82

83
    } catch (NoSuchMapperException e) {
1✔
84
      //ignore these exceptions, just means there's no elections and votes on the collection for this query
85
    }
1✔
86
  }
1✔
87
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc