mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-14 17:06:16 +00:00
Testing map lookup before using query to get hasVisibleContentChildren
This commit is contained in:
parent
d0308d2b91
commit
c0ea7776e5
@ -48,6 +48,8 @@ public abstract class AbstractContentNode<T extends Content> extends ContentNode
|
|||||||
*/
|
*/
|
||||||
T content;
|
T content;
|
||||||
private static final Logger logger = Logger.getLogger(AbstractContentNode.class.getName());
|
private static final Logger logger = Logger.getLogger(AbstractContentNode.class.getName());
|
||||||
|
private static int tempCountQueries = 0;
|
||||||
|
private static int tempCountMapLookups = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles aspects that depend on the Content object
|
* Handles aspects that depend on the Content object
|
||||||
@ -110,6 +112,21 @@ public abstract class AbstractContentNode<T extends Content> extends ContentNode
|
|||||||
*/
|
*/
|
||||||
public static boolean contentHasVisibleContentChildren(Content c){
|
public static boolean contentHasVisibleContentChildren(Content c){
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
tempCountMapLookups++;
|
||||||
|
if( ! c.hasChildren()) {
|
||||||
|
//if( ! Case.getCurrentCaseThrows().getSleuthkitCase().getHasChildren(c.getId())) {
|
||||||
|
//System.out.println("Map lookups: " + tempCountMapLookups + " queries: " + tempCountQueries);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (TskCoreException ex) {
|
||||||
|
|
||||||
|
logger.log(Level.SEVERE, "Error checking if the node has children, for content: " + c, ex); //NON-NLS
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tempCountQueries++;
|
||||||
String query = "SELECT COUNT(obj_id) AS count FROM "
|
String query = "SELECT COUNT(obj_id) AS count FROM "
|
||||||
+ " ( SELECT obj_id FROM tsk_objects WHERE par_obj_id = " + c.getId() + " AND type = "
|
+ " ( SELECT obj_id FROM tsk_objects WHERE par_obj_id = " + c.getId() + " AND type = "
|
||||||
+ TskData.ObjectType.ARTIFACT.getObjectType()
|
+ TskData.ObjectType.ARTIFACT.getObjectType()
|
||||||
@ -122,6 +139,7 @@ public abstract class AbstractContentNode<T extends Content> extends ContentNode
|
|||||||
|
|
||||||
try (SleuthkitCase.CaseDbQuery dbQuery = Case.getCurrentCaseThrows().getSleuthkitCase().executeQuery(query)) {
|
try (SleuthkitCase.CaseDbQuery dbQuery = Case.getCurrentCaseThrows().getSleuthkitCase().executeQuery(query)) {
|
||||||
ResultSet resultSet = dbQuery.getResultSet();
|
ResultSet resultSet = dbQuery.getResultSet();
|
||||||
|
//System.out.println("Map lookups: " + tempCountMapLookups + " queries: " + tempCountQueries);
|
||||||
if(resultSet.next()){
|
if(resultSet.next()){
|
||||||
return (0 < resultSet.getInt("count"));
|
return (0 < resultSet.getInt("count"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user