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

DataBiosphere / consent / #5337

30 Aug 2024 05:42PM UTC coverage: 78.081% (-0.07%) from 78.147%
#5337

push

web-flow
DCJ-637: Delete /api/dataRequest APIs and associated code (#2388)

9953 of 12747 relevant lines covered (78.08%)

0.78 hits per line

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

92.0
/src/main/java/org/broadinstitute/consent/http/db/mapper/ElectionMapper.java
1
package org.broadinstitute.consent.http.db.mapper;
2

3
import java.sql.ResultSet;
4
import java.sql.SQLException;
5
import java.util.HashMap;
6
import java.util.Map;
7
import org.broadinstitute.consent.http.enumeration.ElectionFields;
8
import org.broadinstitute.consent.http.models.Election;
9
import org.jdbi.v3.core.mapper.RowMapper;
10
import org.jdbi.v3.core.statement.StatementContext;
11

12
public class ElectionMapper implements RowMapper<Election>, RowMapperHelper {
1✔
13

14
  private final Map<Integer, Election> electionMap = new HashMap<>();
1✔
15

16
  @Override
17
  public Election map(ResultSet r, StatementContext ctx) throws SQLException {
18
    Election election;
19
    if (electionMap.containsKey(r.getInt(ElectionFields.ID.getValue()))) {
1✔
20
      election = electionMap.get(r.getInt(ElectionFields.ID.getValue()));
1✔
21
    } else {
22
      election = new Election();
1✔
23
      election.setElectionId(r.getInt(ElectionFields.ID.getValue()));
1✔
24
    }
25
    if (hasColumn(r, ElectionFields.TYPE.getValue())
1✔
26
        && r.getString(ElectionFields.TYPE.getValue()) != null) {
1✔
27
      election.setElectionType(r.getString(ElectionFields.TYPE.getValue()));
1✔
28
    }
29
    if (hasColumn(r, ElectionFields.FINAL_VOTE.getValue())
1✔
30
        && r.getString(ElectionFields.FINAL_VOTE.getValue()) != null) {
1✔
31
      election.setFinalVote(r.getBoolean(ElectionFields.FINAL_VOTE.getValue()));
1✔
32
    }
33
    if (hasColumn(r, ElectionFields.FINAL_RATIONALE.getValue())
1✔
34
        && r.getString(ElectionFields.FINAL_RATIONALE.getValue()) != null) {
1✔
35
      election.setFinalRationale(r.getString(ElectionFields.FINAL_RATIONALE.getValue()));
1✔
36
    }
37
    if (hasColumn(r, ElectionFields.STATUS.getValue())
1✔
38
        && r.getString(ElectionFields.STATUS.getValue()) != null) {
1✔
39
      election.setStatus(r.getString(ElectionFields.STATUS.getValue()));
1✔
40
    }
41
    if (hasColumn(r, ElectionFields.CREATE_DATE.getValue())
1✔
42
        && r.getDate(ElectionFields.CREATE_DATE.getValue()) != null) {
1✔
43
      election.setCreateDate(r.getDate(ElectionFields.CREATE_DATE.getValue()));
1✔
44
    }
45
    if (hasColumn(r, ElectionFields.FINAL_VOTE_DATE.getValue())
1✔
46
        && r.getDate(ElectionFields.FINAL_VOTE_DATE.getValue()) != null) {
1✔
47
      election.setFinalVoteDate(r.getDate(ElectionFields.FINAL_VOTE_DATE.getValue()));
1✔
48
    }
49
    if (hasColumn(r, ElectionFields.REFERENCE_ID.getValue())
1✔
50
        && r.getString(ElectionFields.REFERENCE_ID.getValue()) != null) {
1✔
51
      election.setReferenceId(r.getString(ElectionFields.REFERENCE_ID.getValue()));
1✔
52
    }
53
    if (hasColumn(r, ElectionFields.LAST_UPDATE.getValue())
1✔
54
        && r.getDate(ElectionFields.LAST_UPDATE.getValue()) != null) {
1✔
55
      election.setLastUpdate(r.getDate(ElectionFields.LAST_UPDATE.getValue()));
×
56
    }
57
    if (hasColumn(r, ElectionFields.FINAL_ACCESS_VOTE.getValue())
1✔
58
        && r.getString(ElectionFields.FINAL_ACCESS_VOTE.getValue()) != null) {
1✔
59
      election.setFinalAccessVote(r.getBoolean(ElectionFields.FINAL_ACCESS_VOTE.getValue()));
×
60
    }
61
    if (hasColumn(r, ElectionFields.DATASET_ID.getValue())
1✔
62
        && r.getObject(ElectionFields.DATASET_ID.getValue()) != null) {
1✔
63
      election.setDataSetId(r.getInt(ElectionFields.DATASET_ID.getValue()));
1✔
64
    }
65
    if (hasColumn(r, ElectionFields.DATA_USE_LETTER.getValue())
1✔
66
        && r.getString(ElectionFields.DATA_USE_LETTER.getValue()) != null) {
1✔
67
      election.setDataUseLetter(r.getString(ElectionFields.DATA_USE_LETTER.getValue()));
×
68
    }
69
    if (hasColumn(r, ElectionFields.DUL_NAME.getValue())
1✔
70
        && r.getString(ElectionFields.DUL_NAME.getValue()) != null) {
1✔
71
      election.setDulName(r.getString(ElectionFields.DUL_NAME.getValue()));
×
72
    }
73
    if (hasColumn(r, ElectionFields.VERSION.getValue())
1✔
74
        && r.getObject(ElectionFields.VERSION.getValue()) != null) {
1✔
75
      election.setVersion(r.getInt(ElectionFields.VERSION.getValue()));
1✔
76
    }
77
    if (hasColumn(r, ElectionFields.ARCHIVED.getValue())
1✔
78
        && r.getString(ElectionFields.ARCHIVED.getValue()) != null) {
1✔
79
      election.setArchived(r.getBoolean(ElectionFields.ARCHIVED.getValue()));
1✔
80
    }
81
    electionMap.put(election.getElectionId(), election);
1✔
82
    return election;
1✔
83
  }
84
}
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