20 package org.sleuthkit.autopsy.commonfilesearch;
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.HashMap;
25 import java.util.HashSet;
26 import java.util.List;
28 import java.util.Map.Entry;
30 import java.util.logging.Level;
66 this.instanceCountToAttributeValues =
new HashMap<>(metadata);
68 this.resultTypeId = resultType.getId();
69 this.mimeTypesToInclude = mimeTypesToFilterOn;
82 this.instanceCountToAttributeValues =
new HashMap<>(metadata);
85 this.mimeTypesToInclude =
new HashSet<>();
98 CommonAttributeValueList getAttributeValuesForInstanceCount(Integer instanceCount) {
99 return this.instanceCountToAttributeValues.get(instanceCount);
110 return Collections.unmodifiableMap(this.instanceCountToAttributeValues);
136 .filter(filterType -> filterType.getId() == this.
resultTypeId)
141 Map<Integer, List<CommonAttributeValue>> itemsToRemove =
new HashMap<>();
146 for (Entry<Integer, CommonAttributeValueList> listOfValues : Collections.unmodifiableMap(
this.instanceCountToAttributeValues).entrySet()) {
148 final Integer key = listOfValues.getKey();
155 boolean mimeTypeToRemove =
false;
156 if (!mimeTypesToInclude.isEmpty()) {
158 AbstractFile abstractFile = commonAttr.getAbstractFile();
159 if (abstractFile != null) {
160 String mimeType = commonAttr.getAbstractFile().getMIMEType();
161 if (mimeType != null && !mimeTypesToInclude.contains(mimeType)) {
162 if (itemsToRemove.containsKey(key)) {
163 itemsToRemove.get(key).add(value);
165 List<CommonAttributeValue> toRemove =
new ArrayList<>();
167 itemsToRemove.put(key, toRemove);
171 mimeTypeToRemove =
true;
175 if (mimeTypeToRemove) {
180 if (!mimeTypeToRemove && maximumPercentageThreshold != 0) {
183 attributeType, value.getValue()).doubleValue();
184 Double commonalityPercentage = uniqueTypeValueTuples / uniqueCaseDataSourceTuples * 100;
185 int frequencyPercentage = commonalityPercentage.intValue();
186 if (frequencyPercentage > maximumPercentageThreshold) {
187 if (itemsToRemove.containsKey(key)) {
188 itemsToRemove.get(key).add(value);
190 List<CommonAttributeValue> toRemove =
new ArrayList<>();
192 itemsToRemove.put(key, toRemove);
196 LOGGER.log(Level.WARNING,
"Unable to determine frequency percentage attribute - frequency filter may not be accurate for these results.", ex);
201 for (Entry<Integer, List<CommonAttributeValue>> valuesToRemove : itemsToRemove.entrySet()) {
202 final Integer key = valuesToRemove.getKey();
203 final List<CommonAttributeValue> values = valuesToRemove.getValue();
206 if (instanceCountValue != null) {
207 instanceCountValue.removeMetaData(value);
208 if (instanceCountValue.getDelayedMetadataList().isEmpty()) {
209 this.instanceCountToAttributeValues.remove(key);
226 count += md5.getInstanceCount();
Map< Integer, CommonAttributeValueList > getMetadata()
static final Logger LOGGER
static List< CorrelationAttributeInstance.Type > getDefaultCorrelationTypes()
Long getCountUniqueDataSources()
void filterMetadata(int maximumPercentageThreshold)
final Map< Integer, CommonAttributeValueList > instanceCountToAttributeValues
Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value)
final Set< String > mimeTypesToInclude
static EamDb getInstance()
synchronized static Logger getLogger(String name)
final int percentageThreshold
static final int FILES_TYPE_ID