Changed query for tags associated with this artifact to match the actual DB schema, and extracted that to a method

This commit is contained in:
Samuel H. Kenyon 2014-04-23 15:13:40 -04:00
parent 8b9742ea91
commit 420eee58c6

View File

@ -47,6 +47,7 @@ import javax.swing.JDialog;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.SwingWorker; import javax.swing.SwingWorker;
import org.openide.filesystems.FileUtil; import org.openide.filesystems.FileUtil;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.coreutils.EscapeUtil; import org.sleuthkit.autopsy.coreutils.EscapeUtil;
@ -909,16 +910,12 @@ import org.sleuthkit.datamodel.TskData;
} }
} }
// Get any tags that associated with this artifact and apply the tag filter. // Get any tags that associated with this artifact and apply the tag filter.
HashSet<String> uniqueTagNames = new HashSet<>(); HashSet<String> uniqueTagNames = getUniqueTagNames(rs.getLong("artifact_id"));
ResultSet tagNameRows = skCase.runQuery("SELECT display_name FROM tag_names WHERE artifact_id = " + rs.getLong("artifact_id")); //NON-NLS if(failsTagFilter(uniqueTagNames, tagNamesFilter)) {
while (tagNameRows.next()) { continue;
uniqueTagNames.add(tagNameRows.getString("display_name")); //NON-NLS }
} String tagsList = makeCommaSeparatedList(uniqueTagNames);
if(failsTagFilter(uniqueTagNames, tagNamesFilter)) {
continue;
}
String tagsList = makeCommaSeparatedList(uniqueTagNames);
Long objId = rs.getLong("obj_id"); //NON-NLS Long objId = rs.getLong("obj_id"); //NON-NLS
String keyword = rs.getString("keyword"); //NON-NLS String keyword = rs.getString("keyword"); //NON-NLS
@ -1050,11 +1047,7 @@ import org.sleuthkit.datamodel.TskData;
} }
// Get any tags that associated with this artifact and apply the tag filter. // Get any tags that associated with this artifact and apply the tag filter.
HashSet<String> uniqueTagNames = new HashSet<>(); HashSet<String> uniqueTagNames = getUniqueTagNames(rs.getLong("artifact_id"));
ResultSet tagNameRows = skCase.runQuery("SELECT display_name FROM tag_names WHERE artifact_id = " + rs.getLong("artifact_id")); //NON-NLS
while (tagNameRows.next()) {
uniqueTagNames.add(tagNameRows.getString("display_name")); //NON-NLS
}
if(failsTagFilter(uniqueTagNames, tagNamesFilter)) { if(failsTagFilter(uniqueTagNames, tagNamesFilter)) {
continue; continue;
} }
@ -1664,6 +1657,16 @@ import org.sleuthkit.datamodel.TskData;
return ReportGenerator.this.getMappedAttributes(attributes); return ReportGenerator.this.getMappedAttributes(attributes);
} }
} }
private HashSet<String> getUniqueTagNames(long artifactId) throws SQLException {
HashSet<String> uniqueTagNames = new HashSet<>();
ResultSet tagNameRows = skCase.runQuery("SELECT display_name, artifact_id FROM tag_names AS tn, blackboard_artifact_tags AS bat " + //NON-NLS
"WHERE tn.tag_name_id = bat.tag_name_id AND bat.artifact_id = " + artifactId); //NON-NLS
while (tagNameRows.next()) {
uniqueTagNames.add(tagNameRows.getString("display_name")); //NON-NLS
}
return uniqueTagNames;
}
} }