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

DataBiosphere / consent / #5348

04 Sep 2024 02:03PM UTC coverage: 78.316% (+0.007%) from 78.309%
#5348

push

web-flow
DCJ-570: Add Associated DAA and DAA File info to Get All DACs  (#2397)

7 of 8 new or added lines in 2 files covered. (87.5%)

2 existing lines in 2 files now uncovered.

9885 of 12622 relevant lines covered (78.32%)

0.78 hits per line

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

93.18
/src/main/java/org/broadinstitute/consent/http/db/mapper/FileStorageObjectMapper.java
1
package org.broadinstitute.consent.http.db.mapper;
2

3

4
import com.google.cloud.storage.BlobId;
5
import java.sql.ResultSet;
6
import java.sql.SQLException;
7
import java.sql.Timestamp;
8
import java.util.Objects;
9
import org.broadinstitute.consent.http.enumeration.FileCategory;
10
import org.broadinstitute.consent.http.models.FileStorageObject;
11
import org.broadinstitute.consent.http.util.ConsentLogger;
12
import org.jdbi.v3.core.mapper.RowMapper;
13
import org.jdbi.v3.core.statement.StatementContext;
14

15
public class FileStorageObjectMapper implements RowMapper<FileStorageObject>, RowMapperHelper,
1✔
16
    ConsentLogger {
17

18
  @Override
19
  public FileStorageObject map(ResultSet r, StatementContext statementContext) throws SQLException {
20
    FileStorageObject file = new FileStorageObject();
1✔
21

22
    if (hasColumn(r, addPrefix("file_name"))) {
1✔
23
      file.setFileName(r.getString(addPrefix("file_name")));
1✔
24
    }
25

26
    if (hasColumn(r, addPrefix("file_storage_object_id"))) {
1✔
27
      file.setFileStorageObjectId(r.getInt(addPrefix("file_storage_object_id")));
1✔
28
    }
29

30
    if (hasColumn(r, addPrefix("entity_id"))) {
1✔
31
      file.setEntityId(r.getString(addPrefix("entity_id")));
1✔
32
    }
33

34
    if (hasColumn(r, addPrefix("gcs_file_uri"))) {
1✔
35
      String value = r.getString(addPrefix("gcs_file_uri"));
1✔
36
      try {
37
        file.setBlobId(BlobId.fromGsUtilUri(value));
1✔
38
      } catch (Exception e) {
1✔
39
        logException("Error parsing blob id: %s for fso id: %s".formatted(value, file.getFileStorageObjectId()), e);
1✔
40
        file.setBlobId(null);
1✔
41
      }
1✔
42
    }
43

44
    if (hasColumn(r, addPrefix("category"))) {
1✔
45
      String value = r.getString(addPrefix("category"));
1✔
46
      try {
47
        file.setCategory(FileCategory.findValue(value));
1✔
48
      } catch (Exception e) {
×
NEW
49
        logException("Error parsing file category: %s for fso id: %s".formatted(value, file.getFileStorageObjectId()), e);
×
UNCOV
50
        file.setCategory(null);
×
51
      }
1✔
52
    }
53

54
    if (hasColumn(r, addPrefix("media_type"))) {
1✔
55
      file.setMediaType(r.getString(addPrefix("media_type")));
1✔
56
    }
57

58
    if (hasNonZeroColumn(r, addPrefix("create_user_id"))) {
1✔
59
      file.setCreateUserId(r.getInt(addPrefix("create_user_id")));
1✔
60
    }
61

62
    if (hasColumn(r, addPrefix("create_date"))) {
1✔
63
      Timestamp createDate = r.getTimestamp(addPrefix("create_date"));
1✔
64
      file.setCreateDate((Objects.nonNull(createDate) ? createDate.toInstant() : null));
1✔
65
    }
66

67
    if (hasColumn(r, addPrefix("deleted"))) {
1✔
68
      file.setDeleted(r.getBoolean(addPrefix("deleted")));
1✔
69
    }
70

71
    if (hasNonZeroColumn(r, addPrefix("delete_user_id"))) {
1✔
72
      file.setDeleteUserId(r.getInt(addPrefix("delete_user_id")));
1✔
73
    }
74

75
    if (hasColumn(r, addPrefix("delete_date"))) {
1✔
76
      Timestamp deleteDate = r.getTimestamp(addPrefix("delete_date"));
1✔
77
      file.setDeleteDate((Objects.nonNull(deleteDate) ? deleteDate.toInstant() : null));
1✔
78
    }
79

80
    if (hasNonZeroColumn(r, addPrefix("update_user_id"))) {
1✔
81
      file.setUpdateUserId(r.getInt(addPrefix("update_user_id")));
1✔
82
    }
83

84
    if (hasColumn(r, addPrefix("update_date"))) {
1✔
85
      Timestamp updateDate = r.getTimestamp(addPrefix("update_date"));
1✔
86
      file.setUpdateDate((Objects.nonNull(updateDate) ? updateDate.toInstant() : null));
1✔
87
    }
88

89
    return file;
1✔
90
  }
91

92
  public String getPrefix() {
93
    return "";
1✔
94
  }
95

96
  private String addPrefix(String columnName) {
97
    return getPrefix() + columnName;
1✔
98
  }
99
}
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