19 package org.sleuthkit.autopsy.timeline.ui.listvew.datamodel;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.Collections;
24 import java.util.Comparator;
25 import java.util.HashMap;
26 import java.util.List;
28 import java.util.Map.Entry;
29 import java.util.Objects;
30 import static java.util.stream.Collectors.groupingBy;
31 import org.joda.time.Interval;
84 List<TimelineEvent> events = eventManager.getEvents(timeRange, filterState.getActiveFilter());
86 if (events == null || events.isEmpty()) {
87 return Collections.emptyList();
90 ArrayList<CombinedEvent> combinedEvents =
new ArrayList<>();
92 Map<CombinedEventGroup, List<TimelineEvent>> groupedEventList = events.stream().collect(groupingBy(event ->
new CombinedEventGroup(event.getTime(),
event.getContentObjID(),
event.getDescription(TimelineLevelOfDetail.HIGH))));
94 for(Entry<CombinedEventGroup, List<TimelineEvent>> entry: groupedEventList.entrySet()){
95 List<TimelineEvent> groupedEvents = entry.getValue();
96 CombinedEventGroup group = entry.getKey();
98 Map<TimelineEventType, Long> eventMap =
new HashMap<>();
99 for(TimelineEvent event: groupedEvents) {
100 eventMap.put(event.getEventType(),
event.getEventID());
107 combinedEvents.add(
new CombinedEvent(group.getTime() * 1000, eventMap));
109 for(Entry<TimelineEventType, Long> singleEntry: eventMap.entrySet()) {
110 Map<TimelineEventType, Long> singleEventMap =
new HashMap<>();
111 singleEventMap.put(singleEntry.getKey(), singleEntry.getValue());
112 combinedEvents.add(
new CombinedEvent(group.getTime() * 1000, singleEventMap));
117 Collections.sort(combinedEvents,
new SortEventByTime());
119 return combinedEvents;
123 for (TimelineEventType type: eventTypes) {
124 if (type.getCategory() != TimelineEventType.FILE_SYSTEM) {
136 final class CombinedEventGroup {
137 private final String description;
138 private final long time;
139 private final long fileID;
148 CombinedEventGroup(
long time,
long fileID, String description) {
149 this.description = description;
151 this.fileID = fileID;
164 public boolean equals (Object obj) {
165 if ( !(obj instanceof CombinedEventGroup)) {
169 CombinedEventGroup group = (CombinedEventGroup)obj;
171 return description.equals(group.description)
172 && time == group.time
173 && fileID == group.fileID;
177 public int hashCode() {
179 hash = 31 * hash + Objects.hashCode(this.description);
180 hash = 31 * hash + (int) (this.time ^ (this.time >>> 32));
181 hash = 31 * hash + (int) (this.fileID ^ (this.fileID >>> 32));
190 class SortEventByTime
implements Comparator<CombinedEvent> {
193 public int compare(CombinedEvent o1, CombinedEvent o2) {
194 return Long.compare(o1.getStartMillis(), o2.getStartMillis());
final EventsModel eventsModel
List< CombinedEvent > getCombinedEvents(Interval timeRange, RootFilterState filterState)
synchronized RootFilterState getEventFilterState()
TimelineManager getEventManager()
final TimelineManager eventManager
List< CombinedEvent > getCombinedEvents()
ListViewModel(EventsModel eventsModel)
boolean hasFileTypeEvents(Collection< TimelineEventType > eventTypes)
synchronized Interval getTimeRange()