19 package org.sleuthkit.autopsy.datasourcesummary.datamodel;
21 import java.sql.ResultSet;
22 import java.sql.SQLException;
23 import java.util.Collections;
24 import java.util.HashMap;
26 import java.util.logging.Level;
35 class DataSourceLabeledValueCallback
implements CaseDbAccessManager.CaseDbAccessQueryCallback {
37 private static final Logger logger = Logger.getLogger(DataSourceSingleValueCallback.class.getName());
38 private final Map<Long, Map<String, Long>> dataSourceObjIdLabeledValues =
new HashMap<>();
41 public void process(ResultSet rs) {
45 Long dataSourceObjId = rs.getLong(
"data_source_obj_id");
46 String labelForValue = rs.getString(
"label");
47 Long value = rs.getLong(
"value");
48 Map<String, Long> labelsMap = dataSourceObjIdLabeledValues.get(dataSourceObjId) == null ?
new HashMap<>() : dataSourceObjIdLabeledValues.get(dataSourceObjId);
49 labelsMap.put(labelForValue, value);
50 dataSourceObjIdLabeledValues.put(dataSourceObjId, labelsMap);
51 }
catch (SQLException ex) {
52 logger.log(Level.WARNING,
"Unable to get data_source_obj_id or value from result set", ex);
55 }
catch (SQLException ex) {
56 logger.log(Level.WARNING,
"Failed to get next result for valuess by datasource", ex);
67 Map<Long, Map<String, Long>> getMapOfLabeledValues() {
68 return Collections.unmodifiableMap(dataSourceObjIdLabeledValues);