19 package org.sleuthkit.autopsy.datasourcesummary.ui;
21 import java.sql.ResultSet;
22 import java.sql.SQLException;
23 import java.util.logging.Level;
29 import org.
sleuthkit.datamodel.IngestJobInfo.IngestJobStatusType;
36 class DataSourceSummary {
38 private static final Logger logger = Logger.getLogger(DataSourceSummary.class.getName());
39 private static final String INGEST_JOB_STATUS_QUERY =
"status_id FROM ingest_jobs WHERE obj_id=";
40 private final DataSource dataSource;
41 private IngestJobStatusType status = null;
42 private final String type;
43 private final long filesCount;
44 private final long resultsCount;
45 private final long tagsCount;
58 DataSourceSummary(DataSource dSource, String typeValue, Long numberOfFiles, Long numberOfResults, Long numberOfTags) {
60 getStatusFromDatabase();
61 type = typeValue == null ?
"" : typeValue;
62 filesCount = numberOfFiles == null ? 0 : numberOfFiles;
63 resultsCount = numberOfResults == null ? 0 : numberOfResults;
64 tagsCount = numberOfTags == null ? 0 : numberOfTags;
70 private void getStatusFromDatabase() {
72 IngestJobQueryCallback callback =
new IngestJobQueryCallback();
73 Case.getCurrentCaseThrows().getSleuthkitCase().getCaseDbAccessManager().select(INGEST_JOB_STATUS_QUERY + dataSource.getId(), callback);
74 status = callback.getStatus();
75 }
catch (NoCurrentCaseException | TskCoreException ex) {
76 logger.log(Level.WARNING,
"Error getting status for data source from case database", ex);
85 DataSource getDataSource() {
95 void setIngestStatus(IngestJobStatusType ingestStatus) {
96 status = ingestStatus;
113 long getFilesCount() {
122 long getResultsCount() {
132 IngestJobStatusType getIngestStatus() {
141 long getTagsCount() {
149 class IngestJobQueryCallback
implements CaseDbAccessManager.CaseDbAccessQueryCallback {
151 private IngestJobStatusType jobStatus = null;
154 public void process(ResultSet rs) {
157 IngestJobStatusType currentStatus = IngestJobStatusType.fromID(rs.getInt(
"status_id"));
158 if (currentStatus == IngestJobStatusType.COMPLETED) {
159 jobStatus = currentStatus;
160 }
else if (currentStatus == IngestJobStatusType.STARTED) {
161 jobStatus = currentStatus;
165 }
catch (SQLException ex) {
166 logger.log(Level.WARNING,
"Error getting status for ingest job", ex);
175 IngestJobStatusType getStatus() {