mirror of
https://github.com/elisspace/autopsy.git
synced 2026-10-03 15:59:52 +00:00
Address PR feedback
This commit is contained in:
@@ -30,7 +30,15 @@ import java.util.List;
|
||||
*/
|
||||
final public class CommonAttributeValueList {
|
||||
|
||||
/**
|
||||
* The list of value nodes, which begins empty.
|
||||
*/
|
||||
private final List<CommonAttributeValue> metadataList;
|
||||
|
||||
/**
|
||||
* The backing list of value nodes, which will be dynamically loaded
|
||||
* when requested.
|
||||
*/
|
||||
private final List<CommonAttributeValue> delayedMetadataList;
|
||||
|
||||
/**
|
||||
@@ -49,21 +57,41 @@ final public class CommonAttributeValueList {
|
||||
this.delayedMetadataList = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of value nodes. Will be empty if
|
||||
* displayDelayedMetadata() has not been called for the
|
||||
* parent InstanceCountNode
|
||||
* @return metadataList the list of nodes
|
||||
*/
|
||||
public List<CommonAttributeValue> getMetadataList() {
|
||||
return Collections.unmodifiableList(this.metadataList);
|
||||
}
|
||||
|
||||
public int getCommonAttributeListSize() {
|
||||
/**
|
||||
* Return the size of the backing list, in case
|
||||
* displayDelayedMetadata() has not be called yet.
|
||||
* @return int the number of matches for this value
|
||||
*/
|
||||
int getCommonAttributeListSize() {
|
||||
return this.delayedMetadataList.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamically load the list CommonAttributeValue when called. Until called
|
||||
* metadataList should be empty. The parent node, InstanceCountNode, will
|
||||
* trigger the factory call and refresh.
|
||||
*/
|
||||
public void displayDelayedMetadata() {
|
||||
if (metadataList.isEmpty()) {
|
||||
this.metadataList.addAll(this.delayedMetadataList);
|
||||
}
|
||||
}
|
||||
|
||||
public void addMetadataToList(CommonAttributeValue metadata) {
|
||||
/**
|
||||
* A a value node to the list, to be loaded later.
|
||||
* @param metadata the node to add
|
||||
*/
|
||||
void addMetadataToList(CommonAttributeValue metadata) {
|
||||
delayedMetadataList.add(metadata);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.logging.Level;
|
||||
import javax.swing.SwingWorker;
|
||||
import org.openide.nodes.ChildFactory;
|
||||
import org.openide.nodes.Children;
|
||||
import org.openide.nodes.Node;
|
||||
@@ -76,26 +73,14 @@ final public class InstanceCountNode extends DisplayableItemNode {
|
||||
return this.instanceCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the node, by dynamically loading in the children when called, and
|
||||
* calling the CommonAttributeValueNodeFactory to generate nodes for the
|
||||
* children in attributeValues.
|
||||
*/
|
||||
public void refresh() {
|
||||
new SwingWorker<Void, Void>() {
|
||||
|
||||
@Override
|
||||
protected Void doInBackground() throws Exception {
|
||||
attributeValues.displayDelayedMetadata();
|
||||
setChildren(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList()), false));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
super.done();
|
||||
try {
|
||||
get();
|
||||
} catch (InterruptedException | ExecutionException ex) {
|
||||
logger.log(Level.SEVERE, "Unexpected exception while loading common search result instances", ex); //NON-NLS
|
||||
}
|
||||
}
|
||||
}.execute();
|
||||
attributeValues.displayDelayedMetadata();
|
||||
setChildren(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList()), true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,7 +132,7 @@ final public class InstanceCountNode extends DisplayableItemNode {
|
||||
|
||||
/**
|
||||
* ChildFactory which builds CommonFileParentNodes from the
|
||||
* CommonFilesMetaaData models.
|
||||
* CommonAttributeValue metadata models.
|
||||
*/
|
||||
static class CommonAttributeValueNodeFactory extends ChildFactory<String> {
|
||||
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public final class DelayedLoadChildNodesOnTreeExpansion implements TreeExpansion
|
||||
|
||||
@Override
|
||||
public synchronized void treeCollapsed(final TreeExpansionEvent event) {
|
||||
|
||||
// Do nothing on collapse. Netbeans should manage nodes falling out of scope and GC.
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -129,6 +129,10 @@ public class TableFilterNode extends FilterNode {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the inner node, which depending on the actual node type that was wrapped
|
||||
* could trigger a dynamic refresh of the children, if supported.
|
||||
*/
|
||||
void refresh() {
|
||||
DataResultFilterNode innerNode = getLookup().lookup(DataResultFilterNode.class);
|
||||
innerNode.refresh();
|
||||
|
||||
@@ -140,6 +140,11 @@ public class DataResultFilterNode extends FilterNode {
|
||||
this.sourceEm = em;
|
||||
}
|
||||
|
||||
/**
|
||||
* Refreshes the inner node. If the actual underlying node is an InstanceCountNode,
|
||||
* refresh() that node, which refreshes the children.
|
||||
*
|
||||
*/
|
||||
public void refresh() {
|
||||
if (getOriginal() instanceof InstanceCountNode) {
|
||||
InstanceCountNode innerNode = getLookup().lookup(InstanceCountNode.class);
|
||||
|
||||
+4
-3
@@ -57,6 +57,7 @@ import org.sleuthkit.autopsy.commonfilesearch.CentralRepoCommonAttributeInstance
|
||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.DataSourceLoader;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeValue;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeValueList;
|
||||
import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
|
||||
@@ -309,9 +310,9 @@ class InterCaseTestUtils {
|
||||
|
||||
int tally = 0;
|
||||
|
||||
for(Map.Entry<Integer, List<CommonAttributeValue>> entry : searchDomain.getMetadata().entrySet()){
|
||||
|
||||
for(CommonAttributeValue value : entry.getValue()){
|
||||
for(Map.Entry<Integer, CommonAttributeValueList> entry : searchDomain.getMetadata().entrySet()){
|
||||
entry.getValue().displayDelayedMetadata();
|
||||
for(CommonAttributeValue value : entry.getValue().getMetadataList()) {
|
||||
|
||||
for(AbstractCommonAttributeInstance commonAttribute : value.getInstances()){
|
||||
|
||||
|
||||
+4
-2
@@ -37,6 +37,7 @@ import org.sleuthkit.autopsy.commonfilesearch.AbstractCommonAttributeInstance;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeSearchResults;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.DataSourceLoader;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeValue;
|
||||
import org.sleuthkit.autopsy.commonfilesearch.CommonAttributeValueList;
|
||||
import org.sleuthkit.autopsy.testutils.CaseUtils;
|
||||
import org.sleuthkit.autopsy.testutils.IngestUtils;
|
||||
import org.sleuthkit.datamodel.AbstractFile;
|
||||
@@ -205,8 +206,9 @@ class IntraCaseTestUtils {
|
||||
static Map<Long, String> mapFileInstancesToDataSources(CommonAttributeSearchResults metadata) {
|
||||
Map<Long, String> instanceIdToDataSource = new HashMap<>();
|
||||
|
||||
for (Map.Entry<Integer, List<CommonAttributeValue>> entry : metadata.getMetadata().entrySet()) {
|
||||
for (CommonAttributeValue md : entry.getValue()) {
|
||||
for (Map.Entry<Integer, CommonAttributeValueList> entry : metadata.getMetadata().entrySet()) {
|
||||
entry.getValue().displayDelayedMetadata();
|
||||
for (CommonAttributeValue md : entry.getValue().getMetadataList()) {
|
||||
for (AbstractCommonAttributeInstance fim : md.getInstances()) {
|
||||
instanceIdToDataSource.put(fim.getAbstractFileObjectId(), fim.getDataSource());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user