From 420eee58c68c42b4544edc75ce5db1395751386c Mon Sep 17 00:00:00 2001 From: "Samuel H. Kenyon" Date: Wed, 23 Apr 2014 15:13:40 -0400 Subject: [PATCH] Changed query for tags associated with this artifact to match the actual DB schema, and extracted that to a method --- .../autopsy/report/ReportGenerator.java | 35 ++++++++++--------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java b/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java index 2400f38c88..6a3a7d82b0 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportGenerator.java @@ -47,6 +47,7 @@ import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.SwingWorker; import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; 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. - HashSet uniqueTagNames = new HashSet<>(); - 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)) { - continue; - } - String tagsList = makeCommaSeparatedList(uniqueTagNames); + // Get any tags that associated with this artifact and apply the tag filter. + HashSet uniqueTagNames = getUniqueTagNames(rs.getLong("artifact_id")); + if(failsTagFilter(uniqueTagNames, tagNamesFilter)) { + continue; + } + String tagsList = makeCommaSeparatedList(uniqueTagNames); Long objId = rs.getLong("obj_id"); //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. - HashSet uniqueTagNames = new HashSet<>(); - 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 - } + HashSet uniqueTagNames = getUniqueTagNames(rs.getLong("artifact_id")); if(failsTagFilter(uniqueTagNames, tagNamesFilter)) { continue; } @@ -1664,6 +1657,16 @@ import org.sleuthkit.datamodel.TskData; return ReportGenerator.this.getMappedAttributes(attributes); } } + + private HashSet getUniqueTagNames(long artifactId) throws SQLException { + HashSet 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; + } + } -