org.hackystat.dailyprojectdata.client
Class DailyProjectDataClient

java.lang.Object
  extended by org.hackystat.dailyprojectdata.client.DailyProjectDataClient

public class DailyProjectDataClient
extends java.lang.Object

Provides a client to support access to the DailyProjectData service.

Author:
Philip Johnson

Field Summary
static java.lang.String DAILYPROJECTDATACLIENT_TIMEOUT_KEY
          The System property key used to retrieve the default timeout value in milliseconds.
 
Constructor Summary
DailyProjectDataClient(java.lang.String host, java.lang.String email, java.lang.String password)
          Initializes a new DailyProjectDataClient, given the host, userEmail, and password.
 
Method Summary
 DailyProjectDataClient authenticate()
          Authenticates this user and password with this DailyProjectData service, throwing a DailyProjectDataException if the user and password associated with this instance are not valid credentials.
 void clearLocalCache()
          Delete all entries from the local cache of DailyProjectData instances associated with this DailyProjectDataClient instance.
 void clearLocalCache(java.lang.String user, java.lang.String project)
          Delete all cache entries associated with the specified project and its owner.
 boolean clearServerCache()
          Clears the (front side) DPD cache associated with this user on the DailyProjectData server to which this DailyProjectDataClient instance is connected.
 boolean clearServerCache(java.lang.String owner, java.lang.String project)
          Clears the (front side) DPD cache entries associated with the specified project and its owner on the DailyProjectData server to which this DailyProjectDataClient instance is connected.
 void enableCaching(java.lang.String cacheName, java.lang.String subDir, java.lang.Double maxLife, java.lang.Long capacity)
          Enables caching in this client.
 BuildDailyProjectData getBuild(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp)
          Returns a BuildDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 BuildDailyProjectData getBuild(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp, java.lang.String type)
          Returns a BuildDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 CodeIssueDailyProjectData getCodeIssue(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp, java.lang.String tool, java.lang.String type)
          Returns a CodeIssueDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 CommitDailyProjectData getCommit(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp)
          Returns a CommitDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 ComplexityDailyProjectData getComplexity(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp, java.lang.String type, java.lang.String tool)
          Returns a ComplexityDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 CouplingDailyProjectData getCoupling(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp, java.lang.String type, java.lang.String tool)
          Returns a CouplingDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 CoverageDailyProjectData getCoverage(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp, java.lang.String granularity)
          Returns a CoverageDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 DevTimeDailyProjectData getDevTime(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp)
          Returns a DevTimeDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 FileMetricDailyProjectData getFileMetric(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp, java.lang.String sizeMetric)
          Returns a FileMetricDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 FileMetricDailyProjectData getFileMetric(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp, java.lang.String sizeMetric, java.lang.String tool)
          Returns a FileMetricDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 IssueDailyProjectData getIssue(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp)
          Returns a IssueDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 IssueDailyProjectData getIssue(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp, java.lang.String status)
          Returns a IssueDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 IssueChangeDailyProjectData getIssueChange(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp)
          Returns a IssueDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
 UnitTestDailyProjectData getUnitTest(java.lang.String user, java.lang.String project, javax.xml.datatype.XMLGregorianCalendar timestamp)
          Returns a UnitTestDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.
static boolean isHost(java.lang.String host)
          Returns true if the passed host is a DailyProjectData host.
 int localCacheSize(java.lang.String user, java.lang.String project)
          Returns the number of cached entries for the given project and its owner.
 void setTimeout(int milliseconds)
          Sets the timeout value for this client.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DAILYPROJECTDATACLIENT_TIMEOUT_KEY

public static final java.lang.String DAILYPROJECTDATACLIENT_TIMEOUT_KEY
The System property key used to retrieve the default timeout value in milliseconds.

See Also:
Constant Field Values
Constructor Detail

DailyProjectDataClient

public DailyProjectDataClient(java.lang.String host,
                              java.lang.String email,
                              java.lang.String password)
Initializes a new DailyProjectDataClient, given the host, userEmail, and password. Note that the userEmail and password refer to the underlying SensorBase client associated with this DailyProjectData service. This service does not keep its own independent set of userEmails and passwords. Authentication is not actually performed in this constructor. Use the authenticate() method to explicitly check the authentication credentials.

Parameters:
host - The host, such as 'http://localhost:9877/dailyprojectdata'.
email - The user's email used for authentication.
password - The password used for authentication.
Method Detail

setTimeout

public final void setTimeout(int milliseconds)
Sets the timeout value for this client.

Parameters:
milliseconds - The number of milliseconds to wait before timing out.

authenticate

public DailyProjectDataClient authenticate()
                                    throws DailyProjectDataClientException
Authenticates this user and password with this DailyProjectData service, throwing a DailyProjectDataException if the user and password associated with this instance are not valid credentials. Note that authentication is performed by checking these credentials with the SensorBase; this service does not keep its own independent set of usernames and passwords.

Returns:
This DailyProjectDataClient instance.
Throws:
DailyProjectDataClientException - If authentication is not successful.

getDevTime

public DevTimeDailyProjectData getDevTime(java.lang.String user,
                                          java.lang.String project,
                                          javax.xml.datatype.XMLGregorianCalendar timestamp)
                                   throws DailyProjectDataClientException
Returns a DevTimeDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of DevTime.
Returns:
A DevTimeDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getUnitTest

public UnitTestDailyProjectData getUnitTest(java.lang.String user,
                                            java.lang.String project,
                                            javax.xml.datatype.XMLGregorianCalendar timestamp)
                                     throws DailyProjectDataClientException
Returns a UnitTestDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of DevTime.
Returns:
A DevTimeDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

isHost

public static boolean isHost(java.lang.String host)
Returns true if the passed host is a DailyProjectData host.

Parameters:
host - The URL of a DailyProjectData host, "http://localhost:9876/dailyprojectdata".
Returns:
True if this URL responds as a DailyProjectData host.

getFileMetric

public FileMetricDailyProjectData getFileMetric(java.lang.String user,
                                                java.lang.String project,
                                                javax.xml.datatype.XMLGregorianCalendar timestamp,
                                                java.lang.String sizeMetric)
                                         throws DailyProjectDataClientException
Returns a FileMetricDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of DevTime.
sizeMetric - The size metric to be retrieved.
Returns:
A FileMetricDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getFileMetric

public FileMetricDailyProjectData getFileMetric(java.lang.String user,
                                                java.lang.String project,
                                                javax.xml.datatype.XMLGregorianCalendar timestamp,
                                                java.lang.String sizeMetric,
                                                java.lang.String tool)
                                         throws DailyProjectDataClientException
Returns a FileMetricDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of DevTime.
sizeMetric - The size metric to be retrieved.
tool - The tool whose data is to be retrieved, or null for no tool.
Returns:
A FileMetricDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getComplexity

public ComplexityDailyProjectData getComplexity(java.lang.String user,
                                                java.lang.String project,
                                                javax.xml.datatype.XMLGregorianCalendar timestamp,
                                                java.lang.String type,
                                                java.lang.String tool)
                                         throws DailyProjectDataClientException
Returns a ComplexityDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of DevTime.
type - The type of complexity, such as "Cyclometric".
tool - The tool that provided the complexity data, such as "JavaNCSS".
Returns:
A ComplexityDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getCoupling

public CouplingDailyProjectData getCoupling(java.lang.String user,
                                            java.lang.String project,
                                            javax.xml.datatype.XMLGregorianCalendar timestamp,
                                            java.lang.String type,
                                            java.lang.String tool)
                                     throws DailyProjectDataClientException
Returns a CouplingDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of DevTime.
type - The type of coupling, such as "class".
tool - The tool that provided the coupling data, such as "DependencyFinder".
Returns:
A CouplingDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getCodeIssue

public CodeIssueDailyProjectData getCodeIssue(java.lang.String user,
                                              java.lang.String project,
                                              javax.xml.datatype.XMLGregorianCalendar timestamp,
                                              java.lang.String tool,
                                              java.lang.String type)
                                       throws DailyProjectDataClientException
Returns a CodeIssueDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of CodeIssue data.
tool - An optional tool for matching CodeIssue data.
type - An optional type for matching CodeIssue types.
Returns:
A CodeIssueDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getCoverage

public CoverageDailyProjectData getCoverage(java.lang.String user,
                                            java.lang.String project,
                                            javax.xml.datatype.XMLGregorianCalendar timestamp,
                                            java.lang.String granularity)
                                     throws DailyProjectDataClientException
Returns a CoverageDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of CodeIssue data.
granularity - the granularity of the coverage data.
Returns:
A CoverageDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getCommit

public CommitDailyProjectData getCommit(java.lang.String user,
                                        java.lang.String project,
                                        javax.xml.datatype.XMLGregorianCalendar timestamp)
                                 throws DailyProjectDataClientException
Returns a CommitDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of CodeIssue data.
Returns:
A CommitDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getBuild

public BuildDailyProjectData getBuild(java.lang.String user,
                                      java.lang.String project,
                                      javax.xml.datatype.XMLGregorianCalendar timestamp,
                                      java.lang.String type)
                               throws DailyProjectDataClientException
Returns a BuildDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of build data.
type - The type of build to retrieve data for.
Returns:
A BuildDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getBuild

public BuildDailyProjectData getBuild(java.lang.String user,
                                      java.lang.String project,
                                      javax.xml.datatype.XMLGregorianCalendar timestamp)
                               throws DailyProjectDataClientException
Returns a BuildDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of build data.
Returns:
A BuildDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getIssue

public IssueDailyProjectData getIssue(java.lang.String user,
                                      java.lang.String project,
                                      javax.xml.datatype.XMLGregorianCalendar timestamp,
                                      java.lang.String status)
                               throws DailyProjectDataClientException
Returns a IssueDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of build data.
status - The status of the issue, open or closed, or a specified status such as "Accepted" or "Fixed"
Returns:
A IssueDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getIssue

public IssueDailyProjectData getIssue(java.lang.String user,
                                      java.lang.String project,
                                      javax.xml.datatype.XMLGregorianCalendar timestamp)
                               throws DailyProjectDataClientException
Returns a IssueDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of build data.
Returns:
A IssueDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

getIssueChange

public IssueChangeDailyProjectData getIssueChange(java.lang.String user,
                                                  java.lang.String project,
                                                  javax.xml.datatype.XMLGregorianCalendar timestamp)
                                           throws DailyProjectDataClientException
Returns a IssueDailyProjectData instance from this server, or throws a DailyProjectData exception if problems occurred.

Parameters:
user - The user that owns the project.
project - The project owned by user.
timestamp - The Timestamp indicating the start of the 24 hour period of build data.
Returns:
A IssueDailyProjectData instance.
Throws:
DailyProjectDataClientException - If the credentials associated with this instance are not valid, or if the underlying SensorBase service cannot be reached, or if one or more of the supplied user, password, or timestamp is not valid.

enableCaching

public void enableCaching(java.lang.String cacheName,
                          java.lang.String subDir,
                          java.lang.Double maxLife,
                          java.lang.Long capacity)
Enables caching in this client. We do not cache DPDs for the current day, since not all data might be have been sent yet.

Parameters:
cacheName - The name of the cache.
subDir - The subdirectory in which the cache backend store is saved.
maxLife - The default expiration time for cached objects in days.
capacity - The maximum number of instances to be held in-memory.

clearLocalCache

public void clearLocalCache()
Delete all entries from the local cache of DailyProjectData instances associated with this DailyProjectDataClient instance. All DPD-specific caches are cleared. If this DPDClient instance does not have caching enabled, then this method has no effect.


clearLocalCache

public void clearLocalCache(java.lang.String user,
                            java.lang.String project)
Delete all cache entries associated with the specified project and its owner. If this DPDClient does not have caching enabled, then this has no effect.

Parameters:
user - The user.
project - The project.

localCacheSize

public int localCacheSize(java.lang.String user,
                          java.lang.String project)
Returns the number of cached entries for the given project and its owner. If this DPDClient does not have caching enabled, then returns 0.

Parameters:
user - The owner of this project.
project - The project.
Returns:
The number of entries in the cache for that project.

clearServerCache

public boolean clearServerCache()
                         throws DailyProjectDataClientException
Clears the (front side) DPD cache associated with this user on the DailyProjectData server to which this DailyProjectDataClient instance is connected.

Returns:
True if the command succeeded.
Throws:
DailyProjectDataClientException - If problems occur.

clearServerCache

public boolean clearServerCache(java.lang.String owner,
                                java.lang.String project)
                         throws DailyProjectDataClientException
Clears the (front side) DPD cache entries associated with the specified project and its owner on the DailyProjectData server to which this DailyProjectDataClient instance is connected.

Parameters:
owner - The owner of the project whose entries are to be cleared.
project - The project DPDs to be cleared on the server.
Returns:
True if the command succeeded.
Throws:
DailyProjectDataClientException - If problems occur.