19 package org.sleuthkit.autopsy.datasourcesummary.datamodel;
21 import java.util.Collections;
22 import java.util.HashMap;
23 import java.util.List;
25 import java.util.logging.Level;
53 List<BlackboardArtifact> listOfArtifacts = skCase.getBlackboardArtifacts(BlackboardArtifact.ARTIFACT_TYPE.TSK_DATA_SOURCE_USAGE);
54 Map<Long, String> typeMap =
new HashMap<>();
55 for (BlackboardArtifact typeArtifact : listOfArtifacts) {
56 BlackboardAttribute descriptionAttr = typeArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DESCRIPTION));
57 if (typeArtifact.getDataSource() != null && descriptionAttr != null) {
58 long dsId = typeArtifact.getDataSource().getId();
59 String type = typeMap.get(typeArtifact.getDataSource().getId());
61 type = descriptionAttr.getValueString();
63 type = type +
", " + descriptionAttr.getValueString();
65 typeMap.put(dsId, type);
70 logger.log(Level.WARNING,
"Unable to get types of files for all datasources, providing empty results", ex);
71 return Collections.emptyMap();
85 final String countFilesQuery =
"data_source_obj_id, COUNT(*) AS value FROM tsk_files"
86 +
" WHERE meta_type=" + TskData.TSK_FS_META_TYPE_ENUM.TSK_FS_META_TYPE_REG.getValue()
87 +
" AND type<>" + TskData.TSK_DB_FILES_TYPE_ENUM.VIRTUAL_DIR.getFileType()
88 +
" AND dir_type<>" + TskData.TSK_FS_NAME_TYPE_ENUM.VIRT_DIR.getValue()
90 +
" GROUP BY data_source_obj_id";
93 logger.log(Level.WARNING,
"Unable to get counts of files for all datasources, providing empty results", ex);
94 return Collections.emptyMap();
108 final String countArtifactsQuery =
"data_source_obj_id, COUNT(*) AS value"
109 +
" FROM blackboard_artifacts WHERE review_status_id !=" + BlackboardArtifact.ReviewStatus.REJECTED.getID()
110 +
" GROUP BY data_source_obj_id";
113 logger.log(Level.WARNING,
"Unable to get counts of artifacts for all datasources, providing empty results", ex);
114 return Collections.emptyMap();
129 final String countFileTagsQuery =
"data_source_obj_id, COUNT(*) AS value"
130 +
" FROM content_tags as content_tags, tsk_files as tsk_files"
131 +
" WHERE content_tags.obj_id = tsk_files.obj_id"
132 +
" GROUP BY data_source_obj_id";
134 Map<Long, Long> tagCountMap =
new HashMap<>(
getValuesMap(countFileTagsQuery));
135 final String countArtifactTagsQuery =
"data_source_obj_id, COUNT(*) AS value"
136 +
" FROM blackboard_artifact_tags as artifact_tags, blackboard_artifacts AS arts"
137 +
" WHERE artifact_tags.artifact_id = arts.artifact_id"
138 +
" GROUP BY data_source_obj_id";
140 getValuesMap(countArtifactTagsQuery).forEach((key, value) -> tagCountMap.merge(key, value, (value1, value2) -> value1 + value2));
143 logger.log(Level.WARNING,
"Unable to get counts of tags for all datasources, providing empty results", ex);
144 return Collections.emptyMap();
161 DataSourceSingleValueCallback callback =
new DataSourceSingleValueCallback();
162 skCase.getCaseDbAccessManager().select(query, callback);
163 return callback.getMapOfValues();
static Map< Long, Long > getCountsOfFiles()
static Map< Long, Long > getCountsOfTags()
SleuthkitCase getSleuthkitCase()
static Map< Long, Long > getValuesMap(String query)
synchronized static Logger getLogger(String name)
static Map< Long, Long > getCountsOfArtifacts()
static Case getCurrentCaseThrows()
static final Logger logger
static Map< Long, String > getDataSourceTypes()