org.hackystat.dailyprojectdata.resource.snapshot
Class SensorDataSnapshot

java.lang.Object
  extended by org.hackystat.dailyprojectdata.resource.snapshot.SensorDataSnapshot
All Implemented Interfaces:
java.lang.Iterable<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData>

public class SensorDataSnapshot
extends java.lang.Object
implements java.lang.Iterable<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData>

This class is deprecated, you should use the SensorBase REST API to retrieve snapshots. SensorDataSnapshot provides a generic means to retrieve and return the set of SensorData of a given SDT with the most recent 'runtime' value. It does this by retrieving "buckets" of data for a given interval size (defaulting to 30 minutes), starting at 11:30pm on the given day and working backward until a complete 'snapshot' has been achieved. The Snapshot algorithm is based upon a number of assumptions that may or may not be true in practice:

An alternative algorithm would return a data structure that provides a single entry for every resource found across all of the users, but using only the latest runtime when multiple entries for a single resource exist. The problem with this approach is that if a resource is deleted during a day, it will still be in the snapshot. This can cause bad data when a major refactoring occurs, resulting in many resources being renamed. In this case, many resources will be represented twice in the resulting snapshot--once with their old name and once with their new name. A potentially helpful extension would be to enable retrieval of a snapshot using only data that contains a property called "DailyProjectDataSnapshot" with a user defined value. This would enable users to define a daily process that creates "complete" versions of project data with a common runtime. This process could run at any time and all other data from other users, regardless of their runtime value, would be ignored.

Author:
jsakuda

Constructor Summary
SensorDataSnapshot(org.hackystat.sensorbase.client.SensorBaseClient client, java.lang.String user, java.lang.String project, java.lang.String sdt, org.hackystat.utilities.time.period.Day day)
          Creates a new snapshot.
SensorDataSnapshot(org.hackystat.sensorbase.client.SensorBaseClient client, java.lang.String user, java.lang.String project, java.lang.String sdt, org.hackystat.utilities.time.period.Day day, int bucketSize)
          Creates a new snapshot.
SensorDataSnapshot(org.hackystat.sensorbase.client.SensorBaseClient client, java.lang.String user, java.lang.String project, java.lang.String sdt, org.hackystat.utilities.time.period.Day day, int bucketSize, java.lang.String tool)
          Creates a new snapshot.
 
Method Summary
(package private)  int getNumberOfBucketsRetrieved()
          Gets the number of buckets that were retrieved to create the snapshot.
 java.lang.String getOwner()
          Returns the Owner responsible for the Snapshot data, or null if there is no Snapshot data.
 java.lang.String getTool()
          Returns the Tool responsible for the Snapshot data, or null if there is no Snapshot data.
 boolean isEmpty()
          Returns true if the Snapshot contains no data.
 java.util.Iterator<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData> iterator()
          Returns an iterator over the last SensorData snapshot.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SensorDataSnapshot

public SensorDataSnapshot(org.hackystat.sensorbase.client.SensorBaseClient client,
                          java.lang.String user,
                          java.lang.String project,
                          java.lang.String sdt,
                          org.hackystat.utilities.time.period.Day day)
                   throws org.hackystat.sensorbase.client.SensorBaseClientException
Creates a new snapshot.

Parameters:
client - The SensorBaseClient to be used for querying for SensorData.
user - The Hackystat user that owns the Project whose data is being retrieved.
project - The project to obtain data for.
sdt - The sensor data type to get data for.
day - The day to get the latest snapshot for.
Throws:
org.hackystat.sensorbase.client.SensorBaseClientException - Thrown if there is an error while communication with the sensorbase server.

SensorDataSnapshot

public SensorDataSnapshot(org.hackystat.sensorbase.client.SensorBaseClient client,
                          java.lang.String user,
                          java.lang.String project,
                          java.lang.String sdt,
                          org.hackystat.utilities.time.period.Day day,
                          int bucketSize)
                   throws org.hackystat.sensorbase.client.SensorBaseClientException
Creates a new snapshot.

Parameters:
client - The SensorBaseClient to be used for querying for SensorData.
user - The Hackystat user that owns the Project whose data is being retrieved.
project - The project to obtain data for.
sdt - The sensor data type to get data for.
day - The day to get the latest snapshot for.
bucketSize - The interval of time (in minutes) in which data should be retrieved from the server.
Throws:
org.hackystat.sensorbase.client.SensorBaseClientException - Thrown if there is an error while communication with the sensorbase server.

SensorDataSnapshot

public SensorDataSnapshot(org.hackystat.sensorbase.client.SensorBaseClient client,
                          java.lang.String user,
                          java.lang.String project,
                          java.lang.String sdt,
                          org.hackystat.utilities.time.period.Day day,
                          int bucketSize,
                          java.lang.String tool)
                   throws org.hackystat.sensorbase.client.SensorBaseClientException
Creates a new snapshot.

Parameters:
client - The SensorBaseClient to be used for querying for SensorData.
user - The Hackystat user that owns the Project whose data is being retrieved.
project - The project to obtain data for.
sdt - The sensor data type to get data for.
day - The day to get the latest snapshot for.
bucketSize - The interval of time (in minutes) in which data should be retrieved from the server.
tool - The tool that data should be retrieved for.
Throws:
org.hackystat.sensorbase.client.SensorBaseClientException - Thrown if there is an error while communication with the sensorbase server.
Method Detail

iterator

public java.util.Iterator<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData> iterator()
Returns an iterator over the last SensorData snapshot.

Specified by:
iterator in interface java.lang.Iterable<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData>
Returns:
Returns an iterator over the last SensorData snapshot.

getOwner

public java.lang.String getOwner()
Returns the Owner responsible for the Snapshot data, or null if there is no Snapshot data.

Returns:
The owner, or null.

getTool

public java.lang.String getTool()
Returns the Tool responsible for the Snapshot data, or null if there is no Snapshot data.

Returns:
The owner, or null.

isEmpty

public boolean isEmpty()
Returns true if the Snapshot contains no data.

Returns:
True if the Snapshot contains no data.

getNumberOfBucketsRetrieved

int getNumberOfBucketsRetrieved()
Gets the number of buckets that were retrieved to create the snapshot. This method is only meant for testing purposes.

Returns:
Returns the number of buckets retrieved during snapshot creation.