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;
83 List<TimelineEvent> events = eventManager.getEvents(timeRange, filterState.getActiveFilter());
85 if (events == null || events.isEmpty()) {
86 return Collections.emptyList();
89 ArrayList<CombinedEvent> combinedEvents =
new ArrayList<>();
91 Map<CombinedEventGroup, List<TimelineEvent>> groupedEventList = events.stream().collect(groupingBy(event ->
new CombinedEventGroup(event.getTime(),
event.getFileObjID(),
event.getFullDescription())));
93 for(Entry<CombinedEventGroup, List<TimelineEvent>> entry: groupedEventList.entrySet()){
94 List<TimelineEvent> groupedEvents = entry.getValue();
95 CombinedEventGroup group = entry.getKey();
97 Map<TimelineEventType, Long> eventMap =
new HashMap<>();
98 for(TimelineEvent event: groupedEvents) {
99 eventMap.put(event.getEventType(),
event.getEventID());
106 combinedEvents.add(
new CombinedEvent(group.getTime() * 1000, eventMap));
108 for(Entry<TimelineEventType, Long> singleEntry: eventMap.entrySet()) {
109 Map<TimelineEventType, Long> singleEventMap =
new HashMap<>();
110 singleEventMap.put(singleEntry.getKey(), singleEntry.getValue());
111 combinedEvents.add(
new CombinedEvent(group.getTime() * 1000, singleEventMap));
116 Collections.sort(combinedEvents,
new SortEventByTime());
118 return combinedEvents;
122 for (TimelineEventType type: eventTypes) {
123 if (type.getBaseType() != TimelineEventType.FILE_SYSTEM) {
135 final class CombinedEventGroup {
136 private final String description;
137 private final long time;
138 private final long fileID;
147 CombinedEventGroup(
long time,
long fileID, String description) {
148 this.description = description;
150 this.fileID = fileID;
163 public boolean equals (Object obj) {
164 if ( !(obj instanceof CombinedEventGroup)) {
168 CombinedEventGroup group = (CombinedEventGroup)obj;
170 return description.equals(group.description)
171 && time == group.time
172 && fileID == group.fileID;
176 public int hashCode() {
178 hash = 31 * hash + Objects.hashCode(this.description);
179 hash = 31 * hash + (int) (this.time ^ (this.time >>> 32));
180 hash = 31 * hash + (int) (this.fileID ^ (this.fileID >>> 32));
189 class SortEventByTime
implements Comparator<CombinedEvent> {
192 public int compare(CombinedEvent o1, CombinedEvent o2) {
193 return Long.compare(o1.getStartMillis(), o2.getStartMillis());
List< CombinedEvent > getCombinedEvents(Interval timeRange, RootFilterState filterState)
final TimelineManager eventManager
List< CombinedEvent > getCombinedEvents()
TimelineManager getEventManager()
boolean hasFileTypeEvents(Collection< TimelineEventType > eventTypes)
synchronized RootFilterState getFilterState()
final FilteredEventsModel eventsModel
synchronized Interval getTimeRange()
ListViewModel(FilteredEventsModel eventsModel)