org.hackystat.tickertape.ticker.data
Class ProjectSensorDataLog

java.lang.Object
  extended by org.hackystat.tickertape.ticker.data.ProjectSensorDataLog

public class ProjectSensorDataLog
extends java.lang.Object

Provides a sliding window of recent project data, along with a record of the last time a tweet was generated from this data.

Author:
Philip Johnson

Field Summary
(package private)  java.util.Map<javax.xml.datatype.XMLGregorianCalendar,org.hackystat.sensorbase.resource.projects.jaxb.Project> timestamp2Project
           
(package private)  java.util.Map<javax.xml.datatype.XMLGregorianCalendar,java.util.List<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData>> timestamp2SensorDatas
          Maps the time when data was retrieved the list of data of interest.
 
Constructor Summary
ProjectSensorDataLog(org.hackystat.sensorbase.client.SensorBaseClient client, double maxLife, java.lang.String projectOwner, java.lang.String projectName, java.util.logging.Logger logger)
          Creates a new ProjectSensorDataLog that maintains a sliding window of data.
 
Method Summary
 int getBuildSuccessCount(java.lang.String user)
          Returns the number of successful builds.
 int getNumFilesWorkedOn(java.lang.String user)
          Returns a count of the number of distinct files for which DevEvent sensor data has been generated in the current sliding window of data.
 java.util.Set<java.lang.String> getOwners()
          Returns the set of all sensor data owners in this log.
 java.util.Set<java.lang.String> getOwners(javax.xml.datatype.XMLGregorianCalendar timestamp)
          Returns the (possibly empty) set of all sensor data owners in this log for the given time.
 java.lang.String getProjectName()
          Returns the name of the project monitored in this log.
 java.util.List<java.lang.String> getProjectParticipants()
          Returns the list consisting of the project owner and all members from the last update, or an empty list if problems occurred.
 java.util.List<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData> getRecentSensorData(java.lang.String user)
          Returns the (potentially empty) list of sensordatarefs received during the last update for the specified user.
 java.util.List<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData> getSensorData(java.lang.String user, java.lang.String sdt)
          Returns a list of all SensorData in our sliding window of data that was generated by the given user and is of the given SensorDataType.
 java.util.List<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData> getSensorData(java.lang.String user, java.lang.String sdt, javax.xml.datatype.XMLGregorianCalendar timestamp)
          Returns a list of all SensorData for the given timestamp that was generated by the given user and is of the given SensorDataType.
 int getSensorDataCount(java.lang.String user, java.lang.String sdt)
          Returns a count of the number of sensor data instances of the given type.
 int getSensorDataCount(java.lang.String user, java.lang.String sdt, javax.xml.datatype.XMLGregorianCalendar timestamp)
          Returns a count of the number of sensor data instances of the given type for the given tstamp.
 java.util.Set<java.lang.String> getSensorDataTypes(java.lang.String user)
          Returns the set of all SensorDataType names associated with data for this user anywhere in this log.
 java.util.Set<java.lang.String> getSensorDataTypes(java.lang.String user, javax.xml.datatype.XMLGregorianCalendar timestamp)
          Returns the set of all SensorDataType names associated with data for this user anywhere in this log.
 int getTestPassCount(java.lang.String user)
          Returns the number of passing tests.
 java.lang.String getToolString(java.lang.String user)
          Returns a string containing a list of comma separated tool names, or null if no tools.
 boolean hasRecentSensorData(java.lang.String user)
          Returns true if this user has data from the last update.
 boolean hasRecentTweet(java.lang.String user)
          Indicate if a tweet has been generated at least once based upon data received within the maxLife interval for the specified user.
 boolean hasSensorData()
          Returns true if there is any data in our sliding window.
 boolean hasSensorData(java.lang.String user, java.lang.String sdt)
          Returns true if there is at least one SensorDataRef in our sliding window of data that was generated by the given user and is of the given SensorDataType.
 java.lang.String mostWorkedOnFile(java.lang.String user)
          Returns the file that the user worked on the most during the sliding window of data.
 void setTweet(java.lang.String user)
          Indicate that a tweet was generated based upon the last received sensor data for the specified user.
 java.lang.String toString()
          Provides a formatted string indicating the contents of the this log for debugging purposes.
 void update()
          Retrieves project SensorDataRefs since the last time it was called.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

timestamp2SensorDatas

java.util.Map<javax.xml.datatype.XMLGregorianCalendar,java.util.List<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData>> timestamp2SensorDatas
Maps the time when data was retrieved the list of data of interest.


timestamp2Project

java.util.Map<javax.xml.datatype.XMLGregorianCalendar,org.hackystat.sensorbase.resource.projects.jaxb.Project> timestamp2Project
Constructor Detail

ProjectSensorDataLog

public ProjectSensorDataLog(org.hackystat.sensorbase.client.SensorBaseClient client,
                            double maxLife,
                            java.lang.String projectOwner,
                            java.lang.String projectName,
                            java.util.logging.Logger logger)
Creates a new ProjectSensorDataLog that maintains a sliding window of data.

Parameters:
client - The SensorBaseClient used to retrieve the data.
maxLife - The window size, in hours.
projectOwner - The project owner.
projectName - The project name.
logger - The logger to be used if problems occur.
Method Detail

update

public void update()
Retrieves project SensorDataRefs since the last time it was called. If this is the first invocation, then retrieves data for an interval corresponding to maxLife.


setTweet

public void setTweet(java.lang.String user)
Indicate that a tweet was generated based upon the last received sensor data for the specified user.

Parameters:
user - The user who had a tweet generated.

getProjectParticipants

public java.util.List<java.lang.String> getProjectParticipants()
Returns the list consisting of the project owner and all members from the last update, or an empty list if problems occurred.

Returns:
The (possibly empty) list of project members.

hasRecentTweet

public boolean hasRecentTweet(java.lang.String user)
Indicate if a tweet has been generated at least once based upon data received within the maxLife interval for the specified user.

Parameters:
user - The user of interest.
Returns:
True if a tweet has been generated recently.

getRecentSensorData

public java.util.List<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData> getRecentSensorData(java.lang.String user)
Returns the (potentially empty) list of sensordatarefs received during the last update for the specified user.

Parameters:
user - The user.
Returns:
The list of sensordatarefs, possibly empty.

hasRecentSensorData

public boolean hasRecentSensorData(java.lang.String user)
Returns true if this user has data from the last update.

Parameters:
user - The user.
Returns:
True if there is sensor data for this user.

getSensorData

public java.util.List<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData> getSensorData(java.lang.String user,
                                                                                                  java.lang.String sdt)
Returns a list of all SensorData in our sliding window of data that was generated by the given user and is of the given SensorDataType.

Parameters:
user - The user of interest.
sdt - The sensor data type of interest.
Returns:
A list of matching SensorData.

getSensorData

public java.util.List<org.hackystat.sensorbase.resource.sensordata.jaxb.SensorData> getSensorData(java.lang.String user,
                                                                                                  java.lang.String sdt,
                                                                                                  javax.xml.datatype.XMLGregorianCalendar timestamp)
Returns a list of all SensorData for the given timestamp that was generated by the given user and is of the given SensorDataType.

Parameters:
user - The user of interest.
sdt - The sensor data type of interest.
timestamp - The timestamp of interest.
Returns:
A list of matching SensorData.

getSensorDataTypes

public java.util.Set<java.lang.String> getSensorDataTypes(java.lang.String user)
Returns the set of all SensorDataType names associated with data for this user anywhere in this log.

Parameters:
user - The user of interest.
Returns:
A set of strings containing sensor data type names.

getSensorDataTypes

public java.util.Set<java.lang.String> getSensorDataTypes(java.lang.String user,
                                                          javax.xml.datatype.XMLGregorianCalendar timestamp)
Returns the set of all SensorDataType names associated with data for this user anywhere in this log.

Parameters:
user - The user of interest.
timestamp - The timestamp.
Returns:
A set of strings containing sensor data type names.

getOwners

public java.util.Set<java.lang.String> getOwners()
Returns the set of all sensor data owners in this log.

Returns:
A set of strings containing owner emails.

getOwners

public java.util.Set<java.lang.String> getOwners(javax.xml.datatype.XMLGregorianCalendar timestamp)
Returns the (possibly empty) set of all sensor data owners in this log for the given time. Note that no checking is done to see that the timestamp exists in the log.

Parameters:
timestamp - The timestamp.
Returns:
A set of strings containing owner emails.

hasSensorData

public boolean hasSensorData(java.lang.String user,
                             java.lang.String sdt)
Returns true if there is at least one SensorDataRef in our sliding window of data that was generated by the given user and is of the given SensorDataType.

Parameters:
user - The user of interest.
sdt - The sensor data type of interest.
Returns:
True if data of the specified type is present.

hasSensorData

public boolean hasSensorData()
Returns true if there is any data in our sliding window.

Returns:
True if data exists.

getNumFilesWorkedOn

public int getNumFilesWorkedOn(java.lang.String user)
Returns a count of the number of distinct files for which DevEvent sensor data has been generated in the current sliding window of data. Requires one HTTP call per DevEvent.

Parameters:
user - The user of interest.
Returns:
The number of files associated with DevEvents during this interval.

getSensorDataCount

public int getSensorDataCount(java.lang.String user,
                              java.lang.String sdt)
Returns a count of the number of sensor data instances of the given type.

Parameters:
user - The user of interest.
sdt - The sensor data type.
Returns:
The number of instances of this sensor data type.

getSensorDataCount

public int getSensorDataCount(java.lang.String user,
                              java.lang.String sdt,
                              javax.xml.datatype.XMLGregorianCalendar timestamp)
Returns a count of the number of sensor data instances of the given type for the given tstamp.

Parameters:
user - The user of interest.
sdt - The sensor data type.
timestamp - The timestamp.
Returns:
The number of instances of this sensor data type.

getBuildSuccessCount

public int getBuildSuccessCount(java.lang.String user)
Returns the number of successful builds.

Parameters:
user - The user.
Returns:
The numnber of builds that were successful.

getTestPassCount

public int getTestPassCount(java.lang.String user)
Returns the number of passing tests.

Parameters:
user - The user.
Returns:
The number of test invocations that passed.

getToolString

public java.lang.String getToolString(java.lang.String user)
Returns a string containing a list of comma separated tool names, or null if no tools.

Parameters:
user - The user of interest.
Returns:
The tool list, or null.

mostWorkedOnFile

public java.lang.String mostWorkedOnFile(java.lang.String user)
Returns the file that the user worked on the most during the sliding window of data. Requires one HTTP call per DevEvent.

Parameters:
user - The user.
Returns:
The file they worked on most, or null if no DevEvent data.

toString

public java.lang.String toString()
Provides a formatted string indicating the contents of the this log for debugging purposes.

Overrides:
toString in class java.lang.Object
Returns:
The log as a string.

getProjectName

public java.lang.String getProjectName()
Returns the name of the project monitored in this log.

Returns:
This project name.