mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-06 21:00:22 +00:00
Merge pull request #4597 from raman-bt/1183-mark-group-unseen
1183: Mark group as 'unseen' for all examiners
This commit is contained in:
commit
ee655997f8
@ -88,7 +88,7 @@ public class NextUnseenGroup extends Action {
|
||||
if (group.isPresent()) {
|
||||
// NOTE: We need to wait for current group to be marked as seen because the 'advance'
|
||||
// method grabs the top of the unseen list
|
||||
groupManager.markGroupSeen(group.get(), true)
|
||||
groupManager.markGroupSeen(group.get())
|
||||
.addListener(this::advanceToNextUnseenGroup, MoreExecutors.newDirectExecutorService());
|
||||
return;
|
||||
}
|
||||
|
@ -1141,42 +1141,65 @@ public final class DrawableDB {
|
||||
}
|
||||
|
||||
/**
|
||||
* Record in the DB that the group with the given key has the given seen
|
||||
* state for the given examiner id.
|
||||
* Record in the DB that the group with the given key is seen
|
||||
* by given examiner id.
|
||||
*
|
||||
* @param groupKey
|
||||
* @param seen
|
||||
* @param examinerID
|
||||
* @param groupKey key identifying the group.
|
||||
* @param examinerID examiner id.
|
||||
*
|
||||
* @throws TskCoreException
|
||||
*/
|
||||
public void markGroupSeen(GroupKey<?> groupKey, boolean seen, long examinerID) throws TskCoreException {
|
||||
public void markGroupSeen(GroupKey<?> groupKey, long examinerID) throws TskCoreException {
|
||||
|
||||
/*
|
||||
* Check the groupSeenCache to see if the seen status for this group was set recently.
|
||||
* If recently set to the same value, there's no need to update it
|
||||
* If recently set to seen, there's no need to update it
|
||||
*/
|
||||
Boolean cachedValue = groupSeenCache.getIfPresent(groupKey);
|
||||
if (cachedValue != null && cachedValue == seen) {
|
||||
if (cachedValue != null && cachedValue == true) {
|
||||
return;
|
||||
}
|
||||
|
||||
// query to find the group id from attribute/value
|
||||
String innerQuery = String.format("( SELECT group_id FROM " + GROUPS_TABLENAME
|
||||
+ " WHERE attribute = \'%s\' AND value = \'%s\' and data_source_obj_id = %d )",
|
||||
String innerQuery = String.format("( SELECT group_id FROM " + GROUPS_TABLENAME //NON-NLS
|
||||
+ " WHERE attribute = \'%s\' AND value = \'%s\' and data_source_obj_id = %d )", //NON-NLS
|
||||
SleuthkitCase.escapeSingleQuotes(groupKey.getAttribute().attrName.toString()),
|
||||
SleuthkitCase.escapeSingleQuotes(groupKey.getValueDisplayName()),
|
||||
groupKey.getAttribute() == DrawableAttribute.PATH ? groupKey.getDataSourceObjId() : 0);
|
||||
|
||||
String insertSQL = String.format(" (group_id, examiner_id, seen) VALUES (%s, %d, %d)", innerQuery, examinerID, seen ? 1 : 0);
|
||||
String insertSQL = String.format(" (group_id, examiner_id, seen) VALUES (%s, %d, %d)", innerQuery, examinerID, 1); //NON-NLS
|
||||
if (DbType.POSTGRESQL == tskCase.getDatabaseType()) {
|
||||
insertSQL += String.format(" ON CONFLICT (group_id, examiner_id) DO UPDATE SET seen = %d", seen ? 1 : 0);
|
||||
insertSQL += String.format(" ON CONFLICT (group_id, examiner_id) DO UPDATE SET seen = %d", 1); //NON-NLS
|
||||
}
|
||||
|
||||
tskCase.getCaseDbAccessManager().insertOrUpdate(GROUPS_SEEN_TABLENAME, insertSQL);
|
||||
|
||||
groupSeenCache.put(groupKey, seen);
|
||||
groupSeenCache.put(groupKey, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Record in the DB that given group is unseen.
|
||||
* The group is marked unseen for ALL examiners that have seen the group.
|
||||
*
|
||||
* @param groupKey key identifying the group.
|
||||
*
|
||||
* @throws TskCoreException
|
||||
*/
|
||||
public void markGroupUnseen(GroupKey<?> groupKey) throws TskCoreException {
|
||||
|
||||
/*
|
||||
* Check the groupSeenCache to see if the seen status for this group was set recently.
|
||||
* If recently set to unseen, there's no need to update it
|
||||
*/
|
||||
Boolean cachedValue = groupSeenCache.getIfPresent(groupKey);
|
||||
if (cachedValue != null && cachedValue == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
String updateSQL = String.format(" SET seen = 0 WHERE group_id in ( " + getGroupIdQuery(groupKey) + ")" ); //NON-NLS
|
||||
tskCase.getCaseDbAccessManager().update(GROUPS_SEEN_TABLENAME, updateSQL);
|
||||
|
||||
groupSeenCache.put(groupKey, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -264,24 +264,23 @@ public class GroupManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* 'Save' the given group as seen in the drawable db.
|
||||
* Marks the given group as 'seen' by the current examiner, in drawable db.
|
||||
*
|
||||
* @param group The DrawableGroup to mark as seen.
|
||||
* @param seen The seen state to set for the given group.
|
||||
*
|
||||
* @return A ListenableFuture that encapsulates saving the seen state to the
|
||||
* DB.
|
||||
*
|
||||
*
|
||||
*/
|
||||
public ListenableFuture<?> markGroupSeen(DrawableGroup group, boolean seen) {
|
||||
public ListenableFuture<?> markGroupSeen(DrawableGroup group) {
|
||||
return exec.submit(() -> {
|
||||
try {
|
||||
Examiner examiner = controller.getSleuthKitCase().getCurrentExaminer();
|
||||
getDrawableDB().markGroupSeen(group.getGroupKey(), seen, examiner.getId());
|
||||
getDrawableDB().markGroupSeen(group.getGroupKey(), examiner.getId());
|
||||
// only update and reshuffle if its new results
|
||||
if (group.isSeen() != seen) {
|
||||
group.setSeen(seen);
|
||||
if (group.isSeen() != true) {
|
||||
group.setSeen(true);
|
||||
updateUnSeenGroups(group);
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
@ -290,6 +289,30 @@ public class GroupManager {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the given group as unseen in the drawable db.
|
||||
*
|
||||
* @param group The DrawableGroup.
|
||||
*
|
||||
* @return A ListenableFuture that encapsulates saving the seen state to the
|
||||
* DB.
|
||||
*/
|
||||
public ListenableFuture<?> markGroupUnseen(DrawableGroup group) {
|
||||
return exec.submit(() -> {
|
||||
try {
|
||||
|
||||
getDrawableDB().markGroupUnseen(group.getGroupKey());
|
||||
// only update and reshuffle if its new results
|
||||
if (group.isSeen() != false) {
|
||||
group.setSeen(false);
|
||||
updateUnSeenGroups(group);
|
||||
}
|
||||
} catch (TskCoreException ex) {
|
||||
logger.log(Level.SEVERE, String.format("Error setting group: %s to unseen.", group.getGroupKey().getValue().toString()), ex); //NON-NLS
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update unseenGroups list accordingly based on the current status of
|
||||
* 'group'. Removes it if it is seen or adds it if it is unseen.
|
||||
@ -325,7 +348,7 @@ public class GroupManager {
|
||||
|
||||
// If we're grouping by category, we don't want to remove empty groups.
|
||||
if (group.getFileIDs().isEmpty()) {
|
||||
markGroupSeen(group, true);
|
||||
markGroupSeen(group);
|
||||
if (groupKey.getAttribute() != DrawableAttribute.CATEGORY) {
|
||||
if (analyzedGroups.contains(group)) {
|
||||
analyzedGroups.remove(group);
|
||||
@ -570,7 +593,7 @@ public class GroupManager {
|
||||
|
||||
// reset the seen status for the group (if it is currently considered analyzed)
|
||||
if (group != null) {
|
||||
markGroupSeen(group, false);
|
||||
markGroupUnseen(group);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user