Autopsy  4.12.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
SingleDetailsViewEvent.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2018-2019 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.timeline.ui.detailview.datamodel;
20 
21 import com.google.common.collect.ImmutableMap;
22 import com.google.common.collect.ImmutableSortedSet;
23 import java.util.Collections;
24 import java.util.Comparator;
25 import java.util.Optional;
26 import java.util.Set;
27 import java.util.SortedSet;
28 import org.joda.time.Interval;
29 import org.sleuthkit.datamodel.TimelineEvent;
30 import org.sleuthkit.datamodel.TimelineEventType;
31 
35 public class SingleDetailsViewEvent implements DetailViewEvent {
36 
37  private final long eventID;
42  private final long fileObjId;
43 
48  private final Long artifactID;
49 
53  private final long dataSourceObjId;
54 
58  private final long time;
62  private final TimelineEventType type;
63 
68  private final ImmutableMap<TimelineEvent.DescriptionLevel, String> descriptions;
69 
74  private final boolean hashHit;
75 
79  private final boolean tagged;
80 
85  private MultiEvent<?> parent = null;
86 
102  public SingleDetailsViewEvent(long eventID, long dataSourceObjId, long fileObjId, Long artifactID, long time, TimelineEventType type, String fullDescription, String medDescription, String shortDescription, boolean hashHit, boolean tagged) {
103  this.eventID = eventID;
104  this.dataSourceObjId = dataSourceObjId;
105  this.fileObjId = fileObjId;
106  this.artifactID = Long.valueOf(0).equals(artifactID) ? null : artifactID;
107  this.time = time;
108  this.type = type;
109  descriptions = ImmutableMap.<TimelineEvent.DescriptionLevel, String>of(TimelineEvent.DescriptionLevel.FULL, fullDescription,
110  TimelineEvent.DescriptionLevel.MEDIUM, medDescription,
111  TimelineEvent.DescriptionLevel.SHORT, shortDescription);
112  this.hashHit = hashHit;
113  this.tagged = tagged;
114  }
115 
116  public SingleDetailsViewEvent(TimelineEvent singleEvent) {
117  this(singleEvent.getEventID(),
118  singleEvent.getDataSourceObjID(),
119  singleEvent.getFileObjID(),
120  singleEvent.getArtifactID().orElse(null),
121  singleEvent.getTime(),
122  singleEvent.getEventType(),
123  singleEvent.getFullDescription(),
124  singleEvent.getMedDescription(),
125  singleEvent.getShortDescription(),
126  singleEvent.isHashHit(),
127  singleEvent.isTagged());
128  }
129 
140  SingleDetailsViewEvent singleEvent = new SingleDetailsViewEvent(eventID, dataSourceObjId, fileObjId, artifactID, time, type, descriptions.get(TimelineEvent.DescriptionLevel.FULL), descriptions.get(TimelineEvent.DescriptionLevel.MEDIUM), descriptions.get(TimelineEvent.DescriptionLevel.SHORT), hashHit, tagged);
141  singleEvent.parent = newParent;
142  return singleEvent;
143  }
144 
150  public boolean isTagged() {
151  return tagged;
152  }
153 
162  public boolean isHashHit() {
163  return hashHit;
164  }
165 
172  public Optional<Long> getArtifactID() {
173  return Optional.ofNullable(artifactID);
174  }
175 
181  public long getEventID() {
182  return eventID;
183  }
184 
191  public long getFileID() {
192  return fileObjId;
193  }
194 
200  public long getTime() {
201  return time;
202  }
203 
204  @Override
205  public TimelineEventType getEventType() {
206  return type;
207  }
208 
214  public String getFullDescription() {
215  return getDescription(TimelineEvent.DescriptionLevel.FULL);
216  }
217 
223  public String getMedDescription() {
224  return getDescription(TimelineEvent.DescriptionLevel.MEDIUM);
225  }
226 
232  public String getShortDescription() {
233  return getDescription(TimelineEvent.DescriptionLevel.SHORT);
234  }
235 
243  public String getDescription(TimelineEvent.DescriptionLevel lod) {
244  return descriptions.get(lod);
245  }
246 
252  public long getDataSourceObjID() {
253  return dataSourceObjId;
254  }
255 
256  @Override
257  public Set<Long> getEventIDs() {
258  return Collections.singleton(eventID);
259  }
260 
261  @Override
262  public Set<Long> getEventIDsWithHashHits() {
263  return isHashHit() ? Collections.singleton(eventID) : Collections.emptySet();
264  }
265 
266  @Override
267  public Set<Long> getEventIDsWithTags() {
268  return isTagged() ? Collections.singleton(eventID) : Collections.emptySet();
269  }
270 
271  @Override
272  public long getEndMillis() {
273  return time * 1000;
274  }
275 
276  @Override
277  public long getStartMillis() {
278  return time * 1000;
279  }
280 
281  @Override
282  public int hashCode() {
283  int hash = 7;
284  hash = 13 * hash + (int) (this.eventID ^ (this.eventID >>> 32));
285  return hash;
286  }
287 
288  @Override
289  public boolean equals(Object obj) {
290  if (obj == null) {
291  return false;
292  }
293  if (getClass() != obj.getClass()) {
294  return false;
295  }
297  return this.eventID == other.eventID;
298  }
299 
300  @Override
301  public SortedSet<EventCluster> getClusters() {
302  EventCluster eventCluster = new EventCluster(new Interval(time * 1000, time * 1000), type, getEventIDs(), getEventIDsWithHashHits(), getEventIDsWithTags(), getFullDescription(), TimelineEvent.DescriptionLevel.FULL);
303  return ImmutableSortedSet.orderedBy(Comparator.comparing(EventCluster::getStartMillis)).add(eventCluster).build();
304  }
305 
306  @Override
307  public String getDescription() {
308  return getFullDescription();
309  }
310 
311  @Override
312  public TimelineEvent.DescriptionLevel getDescriptionLevel() {
313  return TimelineEvent.DescriptionLevel.FULL;
314  }
315 
324  @Override
325  public Optional<EventStripe> getParentStripe() {
326  if (parent == null) {
327  return Optional.empty();
328  } else if (parent instanceof EventStripe) {
329  return Optional.of((EventStripe) parent);
330  } else {
331  return parent.getParentStripe();
332  }
333  }
334 }
final ImmutableMap< TimelineEvent.DescriptionLevel, String > descriptions
SingleDetailsViewEvent(long eventID, long dataSourceObjId, long fileObjId, Long artifactID, long time, TimelineEventType type, String fullDescription, String medDescription, String shortDescription, boolean hashHit, boolean tagged)

Copyright © 2012-2018 Basis Technology. Generated on: Wed Sep 18 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.