mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
Merge pull request #4672 from millmanorama/1216-drop-immutablesets
1216 fix merge
This commit is contained in:
commit
cd2e7159a0
@ -26,11 +26,15 @@ import com.google.common.eventbus.Subscribe;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.SortedSet;
|
||||||
|
import java.util.TreeSet;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
@ -254,7 +258,7 @@ final public class DetailsViewModel {
|
|||||||
.sorted(new DetailViewEvent.StartComparator())
|
.sorted(new DetailViewEvent.StartComparator())
|
||||||
.iterator();
|
.iterator();
|
||||||
EventCluster current = iterator.next();
|
EventCluster current = iterator.next();
|
||||||
|
|
||||||
//JM Todo: maybe we can collect all clusters to merge in one go, rather than piece by piece for performance.
|
//JM Todo: maybe we can collect all clusters to merge in one go, rather than piece by piece for performance.
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
EventCluster next = iterator.next();
|
EventCluster next = iterator.next();
|
||||||
@ -287,4 +291,19 @@ final public class DetailsViewModel {
|
|||||||
.sorted(new DetailViewEvent.StartComparator())
|
.sorted(new DetailViewEvent.StartComparator())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Make a sorted copy of the given set using the given comparator to sort
|
||||||
|
* it.
|
||||||
|
*
|
||||||
|
* @param <X> The type of elements in the set.
|
||||||
|
* @param setA The set of elements to copy into the new sorted set.
|
||||||
|
* @param comparator The comparator to sort the new set by.
|
||||||
|
*
|
||||||
|
* @return A sorted copy of the given set.
|
||||||
|
*/
|
||||||
|
static <X> SortedSet<X> copyAsSortedSet(Collection<X> setA, Comparator<X> comparator) {
|
||||||
|
TreeSet<X> treeSet = new TreeSet<>(comparator);
|
||||||
|
treeSet.addAll(setA);
|
||||||
|
return treeSet;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,11 @@ package org.sleuthkit.autopsy.timeline.ui.detailview.datamodel;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import static java.util.Collections.emptySet;
|
import static java.util.Collections.emptySet;
|
||||||
import static java.util.Collections.singleton;
|
import static java.util.Collections.singleton;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
|
||||||
import org.joda.time.Interval;
|
import org.joda.time.Interval;
|
||||||
import org.sleuthkit.autopsy.timeline.utils.IntervalUtils;
|
import org.sleuthkit.autopsy.timeline.utils.IntervalUtils;
|
||||||
import org.sleuthkit.datamodel.DescriptionLoD;
|
import org.sleuthkit.datamodel.DescriptionLoD;
|
||||||
@ -222,7 +222,7 @@ public class EventCluster implements MultiEvent<EventStripe> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SortedSet<EventCluster> getClusters() {
|
public SortedSet<EventCluster> getClusters() {
|
||||||
return new TreeSet<>(singleton(this));
|
return DetailsViewModel.copyAsSortedSet(singleton(this), Comparator.comparing(cluster -> true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -20,15 +20,12 @@ package org.sleuthkit.autopsy.timeline.ui.detailview.datamodel;
|
|||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import java.util.Collection;
|
|
||||||
import static java.util.Collections.singleton;
|
import static java.util.Collections.singleton;
|
||||||
import java.util.Comparator;
|
|
||||||
import static java.util.Comparator.comparing;
|
import static java.util.Comparator.comparing;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.SortedSet;
|
import java.util.SortedSet;
|
||||||
import java.util.TreeSet;
|
|
||||||
import org.sleuthkit.datamodel.DescriptionLoD;
|
import org.sleuthkit.datamodel.DescriptionLoD;
|
||||||
import org.sleuthkit.datamodel.timeline.EventType;
|
import org.sleuthkit.datamodel.timeline.EventType;
|
||||||
|
|
||||||
@ -90,7 +87,7 @@ public final class EventStripe implements MultiEvent<EventCluster> {
|
|||||||
return new EventStripe(parent, this.type, this.description, this.lod, clusters, eventIDs, tagged, hashHits);
|
return new EventStripe(parent, this.type, this.description, this.lod, clusters, eventIDs, tagged, hashHits);
|
||||||
}
|
}
|
||||||
|
|
||||||
private EventStripe(EventCluster parent, EventType type, String description,
|
private EventStripe(EventCluster parent, EventType type, String description,
|
||||||
DescriptionLoD lod, SortedSet<EventCluster> clusters,
|
DescriptionLoD lod, SortedSet<EventCluster> clusters,
|
||||||
Set<Long> eventIDs, Set<Long> tagged, Set<Long> hashHits) {
|
Set<Long> eventIDs, Set<Long> tagged, Set<Long> hashHits) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
@ -105,9 +102,8 @@ public final class EventStripe implements MultiEvent<EventCluster> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EventStripe(EventCluster cluster) {
|
public EventStripe(EventCluster cluster) {
|
||||||
this.clusters = copyAsSortedSet(singleton(cluster.withParent(this)),
|
this.clusters = DetailsViewModel.copyAsSortedSet(singleton(cluster.withParent(this)),
|
||||||
comparing(EventCluster::getStartMillis));
|
comparing(EventCluster::getStartMillis));
|
||||||
|
|
||||||
|
|
||||||
type = cluster.getEventType();
|
type = cluster.getEventType();
|
||||||
description = cluster.getDescription();
|
description = cluster.getDescription();
|
||||||
@ -119,14 +115,14 @@ public final class EventStripe implements MultiEvent<EventCluster> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private EventStripe(EventStripe stripeA, EventStripe stripeB) {
|
private EventStripe(EventStripe stripeA, EventStripe stripeB) {
|
||||||
clusters = copyAsSortedSet(Sets.union(stripeB.getClusters(), stripeB.getClusters()), comparing(EventCluster::getStartMillis));
|
clusters = DetailsViewModel.copyAsSortedSet(Sets.union(stripeA.getClusters(), stripeB.getClusters()), comparing(EventCluster::getStartMillis));
|
||||||
|
|
||||||
type = stripeA.getEventType();
|
type = stripeA.getEventType();
|
||||||
description = stripeA.getDescription();
|
description = stripeA.getDescription();
|
||||||
lod = stripeA.getDescriptionLoD();
|
lod = stripeA.getDescriptionLoD();
|
||||||
eventIDs = Sets.union(stripeB.getEventIDs(), stripeB.getEventIDs());
|
eventIDs = Sets.union(stripeA.getEventIDs(), stripeB.getEventIDs());
|
||||||
tagged = Sets.union(stripeB.getEventIDsWithTags(), stripeB.getEventIDsWithTags());
|
tagged = Sets.union(stripeA.getEventIDsWithTags(), stripeB.getEventIDsWithTags());
|
||||||
hashHits = Sets.union(stripeB.getEventIDsWithHashHits(), stripeB.getEventIDsWithHashHits());
|
hashHits = Sets.union(stripeA.getEventIDsWithHashHits(), stripeB.getEventIDsWithHashHits());
|
||||||
parent = stripeA.getParent().orElse(stripeB.getParent().orElse(null));
|
parent = stripeA.getParent().orElse(stripeB.getParent().orElse(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,10 +228,4 @@ public final class EventStripe implements MultiEvent<EventCluster> {
|
|||||||
return Objects.equals(this.eventIDs, other.eventIDs);
|
return Objects.equals(this.eventIDs, other.eventIDs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <X> SortedSet<X> copyAsSortedSet(Collection<X> setA, Comparator<X> comparator) {
|
|
||||||
|
|
||||||
TreeSet<X> treeSet = new TreeSet<>(comparator);
|
|
||||||
treeSet.addAll(setA);
|
|
||||||
return treeSet;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user