20 package org.sleuthkit.autopsy.geolocation.datamodel;
 
   22 import java.sql.ResultSet;
 
   23 import java.sql.SQLException;
 
   24 import java.util.ArrayList;
 
   25 import java.util.List;
 
   26 import java.util.logging.Level;
 
   29 import org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
 
   45             BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID(), 
 
   46             BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_CREATED.getTypeID());
 
   49                     BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE.getTypeID(),
 
   50                     BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_LATITUDE_START.getTypeID(),
 
   51                     BlackboardAttribute.ATTRIBUTE_TYPE.TSK_GEO_WAYPOINTS.getTypeID());
 
   56             = 
"SELECT artifact_id, artifact_type_id " 
   57             + 
"FROM blackboard_attributes " 
   58             + 
"WHERE attribute_type_id IN (%s) ";  
 
   62             = 
"SELECT artifact_id " 
   63             + 
"FROM blackboard_attributes " 
   64             + 
"WHERE attribute_type_id IN (%s) ";  
 
   68             = 
"SELECT blackboard_attributes.artifact_id " 
   69             + 
"FROM blackboard_attributes, blackboard_artifacts " 
   70             + 
"WHERE blackboard_attributes.artifact_id = blackboard_artifacts.artifact_id " 
   71             + 
"AND blackboard_attributes.attribute_type_id IN(%s) " 
   72             + 
"AND data_source_obj_id IN (%s)"; 
 
   76             = 
"SELECT MAX(value_int64) - (%d * 86400)"  
   77             + 
"FROM blackboard_attributes " 
   78             + 
"WHERE attribute_type_id IN(%s) " 
   86             = 
"SELECT DISTINCT artifact_id, artifact_type_id " 
   87             + 
"FROM blackboard_attributes " 
   88             + 
"WHERE artifact_id NOT IN (%s) " 
   89             + 
"AND artifact_id IN (%s)"; 
 
  101         void process(List<Waypoint> wwaypoints);
 
  125         List<Waypoint> points = 
new ArrayList<>();
 
  143     public static List<Route> 
getRoutes(List<Waypoint> waypoints) {
 
  144         List<Route> routeList = 
new ArrayList<>();
 
  146             GeoPath path = point.getParentGeoPath();
 
  147             if (path instanceof 
Route) {
 
  148                 Route route = (Route) path;
 
  149                 if (!routeList.contains(route)) {
 
  150                     routeList.add(route);
 
  165     public static List<Track> 
getTracks(List<Waypoint> waypoints) {
 
  166         List<Track> trackList = 
new ArrayList<>();
 
  168             GeoPath path = point.getParentGeoPath();
 
  169             if (path instanceof 
Track) {
 
  170                 Track route = (Track) path;
 
  171                 if (!trackList.contains(route)) {
 
  172                     trackList.add(route);
 
  189     @SuppressWarnings(
"deprecation")
 
  191         List<BlackboardArtifact> artifacts = null;
 
  193             artifacts = skCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_GPS_TRACKPOINT);
 
  194         } 
catch (TskCoreException ex) {
 
  195             throw new GeoLocationDataException(
"Unable to get artifacts for type: TSK_GPS_TRACKPOINT", ex);
 
  198         List<Waypoint> points = 
new ArrayList<>();
 
  199         for (BlackboardArtifact artifact : artifacts) {
 
  201                 Waypoint point = 
new TrackpointWaypoint(artifact);
 
  203             } 
catch (GeoLocationDataException ex) {
 
  204                 logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_TRACKPOINT artifactID: %d", artifact.getArtifactID()));
 
  218         List<Waypoint> specificPoints = 
new ArrayList<>();
 
  221             if (point instanceof TrackpointWaypoint) {
 
  222                 specificPoints.add(point);
 
  226         return specificPoints;
 
  239         List<BlackboardArtifact> artifacts = null;
 
  241             artifacts = skCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_METADATA_EXIF);
 
  242         } 
catch (TskCoreException ex) {
 
  246         List<Waypoint> points = 
new ArrayList<>();
 
  247         if (artifacts != null) {
 
  248             for (BlackboardArtifact artifact : artifacts) {
 
  250                     Waypoint point = 
new EXIFWaypoint(artifact);
 
  270         List<Waypoint> specificPoints = 
new ArrayList<>();
 
  273             if (point instanceof EXIFWaypoint) {
 
  274                 specificPoints.add(point);
 
  278         return specificPoints;
 
  291         List<BlackboardArtifact> artifacts = null;
 
  293             artifacts = skCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_GPS_SEARCH);
 
  294         } 
catch (TskCoreException ex) {
 
  298         List<Waypoint> points = 
new ArrayList<>();
 
  299         if (artifacts != null) {
 
  300             for (BlackboardArtifact artifact : artifacts) {
 
  302                     Waypoint point = 
new SearchWaypoint(artifact);
 
  305                     logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_SEARCH artifactID: %d", artifact.getArtifactID()));
 
  320         List<Waypoint> specificPoints = 
new ArrayList<>();
 
  323             if (point instanceof SearchWaypoint) {
 
  324                 specificPoints.add(point);
 
  328         return specificPoints;
 
  341         List<BlackboardArtifact> artifacts = null;
 
  343             artifacts = skCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_GPS_LAST_KNOWN_LOCATION);
 
  344         } 
catch (TskCoreException ex) {
 
  348         List<Waypoint> points = 
new ArrayList<>();
 
  349         if (artifacts != null) {
 
  350             for (BlackboardArtifact artifact : artifacts) {
 
  352                     Waypoint point = 
new LastKnownWaypoint(artifact);
 
  355                     logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_LAST_KNOWN_LOCATION artifactID: %d", artifact.getArtifactID()));
 
  371         List<Waypoint> specificPoints = 
new ArrayList<>();
 
  374             if (point instanceof LastKnownWaypoint) {
 
  375                 specificPoints.add(point);
 
  379         return specificPoints;
 
  392         List<BlackboardArtifact> artifacts = null;
 
  394             artifacts = skCase.getBlackboardArtifacts(ARTIFACT_TYPE.TSK_GPS_BOOKMARK);
 
  395         } 
catch (TskCoreException ex) {
 
  399         List<Waypoint> points = 
new ArrayList<>();
 
  400         if (artifacts != null) {
 
  401             for (BlackboardArtifact artifact : artifacts) {
 
  403                     Waypoint point = 
new BookmarkWaypoint(artifact);
 
  406                     logger.log(Level.WARNING, String.format(
"No longitude or latitude available for TSK_GPS_BOOKMARK artifactID: %d", artifact.getArtifactID()), ex);
 
  422         List<Waypoint> specificPoints = 
new ArrayList<>();
 
  425             if (point instanceof BookmarkWaypoint) {
 
  426                 specificPoints.add(point);
 
  430         return specificPoints;
 
  467         String query = 
buildQuery(dataSources, showAll, cntDaysFromRecent, noTimeStamp);
 
  469         logger.log(Level.INFO, query);
 
  474             if (query.startsWith(
"SELECT")) { 
 
  475                 query = query.replaceFirst(
"SELECT", 
""); 
 
  478             skCase.getCaseDbAccessManager().select(query, 
new CaseDbAccessManager.CaseDbAccessQueryCallback() {
 
  480                 public void process(ResultSet rs) {
 
  481                     List<Waypoint> waypoints = 
new ArrayList<>();
 
  484                             int artifact_type_id = rs.getInt(
"artifact_type_id"); 
 
  485                             long artifact_id = rs.getLong(
"artifact_id"); 
 
  487                             ARTIFACT_TYPE type = ARTIFACT_TYPE.fromID(artifact_type_id);
 
  488                             if (artifactTypes.contains(type)) {
 
  493                         queryCallBack.process(waypoints);
 
  495                         logger.log(Level.WARNING, 
"Failed to filter waypoint.", ex); 
 
  500         } 
catch (TskCoreException ex) {
 
  501             logger.log(Level.WARNING, 
"Failed to filter waypoint.", ex);  
 
  551     static private String 
buildQuery(List<DataSource> dataSources, 
boolean showAll, 
int cntDaysFromRecent, 
boolean noTimeStamp) {
 
  552         String mostRecentQuery = 
"";
 
  554         if (!showAll && cntDaysFromRecent > 0) {
 
  562             mostRecentQuery = String.format(
"AND value_int64 > (%s)", 
 
  564                             cntDaysFromRecent, TIME_TYPE_IDS,
 
  577         query += mostRecentQuery;
 
  579         if (showAll || noTimeStamp) {
 
  600         if (dataSources == null || dataSources.isEmpty()) {
 
  608         String dataSourceList = 
"";
 
  609         for (DataSource source : dataSources) {
 
  610             dataSourceList += Long.toString(source.getId()) + 
",";
 
  613         if (!dataSourceList.isEmpty()) {
 
  615             dataSourceList = dataSourceList.substring(0, dataSourceList.length() - 1);
 
  633         List<Waypoint> waypoints = 
new ArrayList<>();
 
  635             case TSK_METADATA_EXIF:
 
  636                 waypoints.add(
new EXIFWaypoint(artifact));
 
  638             case TSK_GPS_BOOKMARK:
 
  639                 waypoints.add(
new BookmarkWaypoint(artifact));
 
  641             case TSK_GPS_TRACKPOINT:
 
  642                 waypoints.add(
new TrackpointWaypoint(artifact));
 
  645                 waypoints.add(
new SearchWaypoint(artifact));
 
  651             case TSK_GPS_LAST_KNOWN_LOCATION:
 
  652                 waypoints.add(
new LastKnownWaypoint(artifact));
 
  656                 waypoints.addAll(track.
getPath());
 
  659                 waypoints.add(
new CustomArtifactWaypoint(artifact));
 
static List< Waypoint > getLastKnownWaypoints(List< Waypoint > waypoints)
static final String TIME_TYPE_IDS
static String buildQuery(List< DataSource > dataSources, boolean showAll, int cntDaysFromRecent, boolean noTimeStamp)
static final Logger logger
static List< Waypoint > getBookmarkWaypoints(SleuthkitCase skCase)
static List< Waypoint > getWaypointForArtifact(BlackboardArtifact artifact, ARTIFACT_TYPE type)
void process(List< Waypoint > wwaypoints)
static List< Waypoint > getBookmarkWaypoints(List< Waypoint > waypoints)
static void getAllWaypoints(SleuthkitCase skCase, List< DataSource > dataSources, List< ARTIFACT_TYPE > artifactTypes, boolean showAll, int cntDaysFromRecent, boolean noTimeStamp, WaypointFilterQueryCallBack queryCallBack)
List< Waypoint > getRoute()
static List< Waypoint > getSearchWaypoints(SleuthkitCase skCase)
static final String GEO_ATTRIBUTE_TYPE_IDS
static List< Waypoint > getSearchWaypoints(List< Waypoint > waypoints)
static List< Track > getTracks(List< Waypoint > waypoints)
static List< Waypoint > getTrackpointWaypoints(SleuthkitCase skCase)
static final String GEO_ARTIFACT_QUERY_ID_ONLY
static final String GEO_ARTIFACT_WITH_DATA_SOURCES_QUERY
static List< Route > getRoutes(List< Waypoint > waypoints)
static List< Waypoint > getAllWaypoints(SleuthkitCase skCase)
static String getWaypointListQuery(List< DataSource > dataSources)
final List< Waypoint > getPath()
static final String MOST_RECENT_TIME
static List< Waypoint > getEXIFWaypoints(List< Waypoint > waypoints)
static List< Waypoint > getTrackpointWaypoints(List< Waypoint > waypoints)
static String buildQueryForWaypointsWOTimeStamps(List< DataSource > dataSources)
static final String GEO_ARTIFACT_QUERY
static final String SELECT_WO_TIMESTAMP
synchronized static Logger getLogger(String name)
static List< Waypoint > getLastKnownWaypoints(SleuthkitCase skCase)
static List< Waypoint > getEXIFWaypoints(SleuthkitCase skCase)