|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.hackystat.sensorbase.client.SensorBaseClient
public class SensorBaseClient
Provides a high-level interface for Clients wishing to communicate with a SensorBase.
Nested Class Summary | |
---|---|
static class |
SensorBaseClient.InvitationReply
The possible responses to a Project invitation. |
Field Summary | |
---|---|
static java.lang.String |
SENSORBASECLIENT_TIMEOUT_KEY
The System property key used to retrieve the default timeout value in milliseconds. |
Constructor Summary | |
---|---|
SensorBaseClient(java.lang.String host,
java.lang.String email,
java.lang.String password)
Initializes a new SensorBaseClient, given the host, userEmail, and password. |
Method Summary | |
---|---|
SensorBaseClient |
authenticate()
Authenticates this user and password with the server. |
void |
clearCache()
Delete all entries from this cache. |
void |
compressTables()
Compresses the server database tables. |
void |
deleteProject(java.lang.String email,
java.lang.String projectName)
Deletes the Project given its owner and projectName. |
void |
deleteSensorData(java.lang.String email)
Deletes all sensor data associated with the specified user. |
void |
deleteSensorData(java.lang.String email,
javax.xml.datatype.XMLGregorianCalendar timestamp)
Ensures that the SensorData instance with the specified user and tstamp is not on the server. |
void |
deleteSensorDataType(java.lang.String sdtName)
Deletes the SDT given its name. |
void |
deleteUser(java.lang.String email)
Deletes the User given their email. |
void |
enableCaching(java.lang.String cacheName,
java.lang.String subDir,
java.lang.Double maxLife,
java.lang.Long capacity)
Enables caching in this client. |
void |
enableHttpTracing(boolean enable)
When passed true, future HTTP calls using this client instance will print out information on the request and response. |
MultiDayProjectSummary |
getMonthProjectSummary(java.lang.String owner,
java.lang.String projectName,
int year,
int month)
Returns a MultiDayProjectSummary for the specified project, year, and month (zero based). |
MultiDayProjectSummary |
getMultiDayProjectSummary(java.lang.String owner,
java.lang.String projectName,
javax.xml.datatype.XMLGregorianCalendar startTime,
int numDays)
Returns a MultiDayProjectSummary for the specified interval of days. |
Project |
getProject(ProjectRef ref)
Returns the named Project associated with the ProjectRef. |
Project |
getProject(java.lang.String email,
java.lang.String projectName)
Returns the Project from this server. |
ProjectIndex |
getProjectIndex()
Returns the index of all Projects from this server. |
ProjectIndex |
getProjectIndex(java.lang.String email)
Returns the index of all Projects from this server associated with this user. |
SensorDataIndex |
getProjectSensorData(java.lang.String owner,
java.lang.String projectName)
Returns a SensorDataIndex representing all the SensorData for this Project. |
SensorDataIndex |
getProjectSensorData(java.lang.String owner,
java.lang.String projectName,
javax.xml.datatype.XMLGregorianCalendar startTime,
javax.xml.datatype.XMLGregorianCalendar endTime)
Returns a SensorDataIndex representing the SensorData for the Project during the time interval. |
SensorDataIndex |
getProjectSensorData(java.lang.String owner,
java.lang.String projectName,
javax.xml.datatype.XMLGregorianCalendar startTime,
javax.xml.datatype.XMLGregorianCalendar endTime,
int startIndex,
int maxInstances)
Returns a SensorDataIndex representing the SensorData with the startIndex and maxInstances for the Project during the time interval. |
SensorDataIndex |
getProjectSensorData(java.lang.String owner,
java.lang.String projectName,
javax.xml.datatype.XMLGregorianCalendar startTime,
javax.xml.datatype.XMLGregorianCalendar endTime,
java.lang.String sdt)
Returns a SensorDataIndex representing the SensorData with the given SDT for the Project during the time interval. |
SensorDataIndex |
getProjectSensorData(java.lang.String owner,
java.lang.String projectName,
javax.xml.datatype.XMLGregorianCalendar startTime,
javax.xml.datatype.XMLGregorianCalendar endTime,
java.lang.String sdt,
java.lang.String tool)
Returns a SensorDataIndex representing the SensorData with the given SDT for the Project during the time interval. |
SensorDataIndex |
getProjectSensorDataSnapshot(java.lang.String owner,
java.lang.String projectName,
javax.xml.datatype.XMLGregorianCalendar startTime,
javax.xml.datatype.XMLGregorianCalendar endTime,
java.lang.String sdt)
Returns a SensorDataIndex containing a snapshot of the sensor data for the given project and sdt during the specified time interval. |
SensorDataIndex |
getProjectSensorDataSnapshot(java.lang.String owner,
java.lang.String projectName,
javax.xml.datatype.XMLGregorianCalendar startTime,
javax.xml.datatype.XMLGregorianCalendar endTime,
java.lang.String sdt,
java.lang.String tool)
Returns a SensorDataIndex containing a snapshot of the sensor data for the given project, sdt and tool during the specified time interval. |
ProjectSummary |
getProjectSummary(java.lang.String owner,
java.lang.String projectName,
javax.xml.datatype.XMLGregorianCalendar startTime,
javax.xml.datatype.XMLGregorianCalendar endTime)
Returns a ProjectSummary representing a summary of the number of sensor data instances of each type for the given interval. |
SensorData |
getSensorData(SensorDataRef ref)
Returns the named SensorData associated with the SensorDataRef. |
SensorData |
getSensorData(java.lang.String uriString)
Returns the SensorData for this user from this server given the passed uriString suffix. |
SensorData |
getSensorData(java.lang.String email,
javax.xml.datatype.XMLGregorianCalendar timestamp)
Returns the SensorData for this user from this server with the specified timestamp. |
SensorDataIndex |
getSensorDataIndex()
Returns the index of SensorData from this server. |
SensorDataIndex |
getSensorDataIndex(java.lang.String email)
Returns the index of SensorData for this user from this server. |
SensorDataIndex |
getSensorDataIndex(java.lang.String email,
java.lang.String sdtName)
Returns the index of SensorData for this user from this server with the specified SDT. |
SensorDataIndex |
getSensorDataIndexLastMod(java.lang.String email,
javax.xml.datatype.XMLGregorianCalendar lastModStartTime,
javax.xml.datatype.XMLGregorianCalendar lastModEndTime)
Returns an index to SensorData for the specified user of all sensor data that have arrived at the server since the specified start and end times. |
SensorDataType |
getSensorDataType(SensorDataTypeRef ref)
Returns the named SensorDataType associated with the SensorDataTypeRef. |
SensorDataType |
getSensorDataType(java.lang.String sdtName)
Returns the named SensorDataType from this server. |
SensorDataTypeIndex |
getSensorDataTypeIndex()
Returns the index of SensorDataTypes from this server. |
org.restlet.data.Response |
getUri(java.lang.String uriString)
GETs the URI string and returns the Restlet Response if the server indicates success. |
User |
getUser()
Returns the User instance associated with this SensorBaseClient instance. |
User |
getUser(java.lang.String email)
Returns the named User from this server. |
User |
getUser(UserRef ref)
Returns the named User associated with the UserRef. |
UserIndex |
getUserIndex()
Returns the index of Users from this server. |
void |
indexTables()
Indexes the server database tables. |
boolean |
inProject(java.lang.String email,
java.lang.String projectName)
True if the current user is the owner, member, or spectator of the specified project. |
Project |
invite(java.lang.String email,
java.lang.String projectName)
Invites the user indicated via their email address to the named project owned by this user. |
static boolean |
isHost(java.lang.String host)
Returns true if the passed host is a SensorBase host. |
static boolean |
isRegistered(java.lang.String host,
java.lang.String email,
java.lang.String password)
Returns true if the user and password is registered as a user with this host. |
SensorData |
makeSensorData(java.util.Map<java.lang.String,java.lang.String> keyValMap)
Provides an easy way to construct SensorData instances. |
void |
putProject(Project project)
Creates the passed Project on the server. |
void |
putSensorData(SensorData data)
Creates the passed SensorData on the server. |
void |
putSensorDataBatch(SensorDatas data)
Creates the passed batch of SensorData on the server. |
void |
putSensorDataType(SensorDataType sdt)
Creates the passed SDT on the server. |
static void |
registerUser(java.lang.String host,
java.lang.String email)
Registers the given user email with the given SensorBase. |
void |
renameProject(java.lang.String owner,
java.lang.String projectName,
java.lang.String newProjectName)
Renames the project. |
void |
reply(java.lang.String owner,
java.lang.String projectName,
SensorBaseClient.InvitationReply reply)
Accepts the invitation to be a member of the project owned by owner. |
int |
rowCount(java.lang.String table)
Gets the rowcount for the specified table. |
void |
setTimeout(int milliseconds)
Attempts to provide a timeout value for this SensorBaseClient. |
void |
updateUserProperties(java.lang.String email,
Properties properties)
Updates the specified user's properties. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String SENSORBASECLIENT_TIMEOUT_KEY
Constructor Detail |
---|
public SensorBaseClient(java.lang.String host, java.lang.String email, java.lang.String password)
host
- The host, such as 'http://localhost:9876/sensorbase'.email
- The user's email that we will use for authentication.password
- The password we will use for authentication.Method Detail |
---|
public final void setTimeout(int milliseconds)
milliseconds
- The number of milliseconds to wait before timing out.public void enableHttpTracing(boolean enable)
enable
- If true, trace output will be generated.public SensorBaseClient authenticate() throws SensorBaseClientException
SensorBaseClientException
- If authentication is not successful.public SensorData makeSensorData(java.util.Map<java.lang.String,java.lang.String> keyValMap) throws SensorBaseClientException
keyValMap
- The map of key-value pairs corresponding to SensorData fields and properties.
SensorBaseClientException
- If errors occur parsing the contents of the keyValMap.public SensorDataTypeIndex getSensorDataTypeIndex() throws SensorBaseClientException
SensorBaseClientException
- If the server does not return the Index or returns an index
that cannot be marshalled into Java SensorDataTypeIndex instance.public SensorDataType getSensorDataType(java.lang.String sdtName) throws SensorBaseClientException
sdtName
- The SDT name.
SensorBaseClientException
- If the server does not return the SDT or returns something
that cannot be marshalled into Java SensorDataType instance.public SensorDataType getSensorDataType(SensorDataTypeRef ref) throws SensorBaseClientException
ref
- The SensorDataTypeRef instance
SensorBaseClientException
- If the server does not return the SDT or returns something
that cannot be marshalled into Java SensorDataType instance.public void putSensorDataType(SensorDataType sdt) throws SensorBaseClientException
sdt
- The SDT to create.
SensorBaseClientException
- If the user is not the admin or if there is some problem with
the SDT instance.public void deleteSensorDataType(java.lang.String sdtName) throws SensorBaseClientException
sdtName
- The name of the SDT to delete.
SensorBaseClientException
- If the server does not indicate success.public UserIndex getUserIndex() throws SensorBaseClientException
SensorBaseClientException
- If the server does not return the Index or returns an index
that cannot be marshalled into Java UserIndex instance.public User getUser() throws SensorBaseClientException
SensorBaseClientException
- If problems occur.public User getUser(java.lang.String email) throws SensorBaseClientException
email
- The user email.
SensorBaseClientException
- If the server does not return the SDT or returns something
that cannot be marshalled into Java User instance.public User getUser(UserRef ref) throws SensorBaseClientException
ref
- The UserRef instance
SensorBaseClientException
- If the server does not return the user or returns something
that cannot be marshalled into Java User instance.public void deleteUser(java.lang.String email) throws SensorBaseClientException
email
- The email of the User to delete.
SensorBaseClientException
- If the server does not indicate success.public void updateUserProperties(java.lang.String email, Properties properties) throws SensorBaseClientException
email
- The email of the User whose properties are to be deleted.properties
- The properties to post.
SensorBaseClientException
- If the server does not indicate success.public org.restlet.data.Response getUri(java.lang.String uriString) throws SensorBaseClientException
uriString
- The URI String, such as "http://localhost:9876/sensorbase/sensordatatypes".
SensorBaseClientException
- If the server indicates that a problem occurred.public SensorDataIndex getSensorDataIndex() throws SensorBaseClientException
SensorBaseClientException
- If the server does not return the Index or returns an index
that cannot be marshalled into Java SensorDataIndex instance.public SensorDataIndex getSensorDataIndex(java.lang.String email) throws SensorBaseClientException
email
- The user email.
SensorBaseClientException
- If the server does not return the Index or returns an index
that cannot be marshalled into Java SensorDataIndex instance.public SensorDataIndex getSensorDataIndex(java.lang.String email, java.lang.String sdtName) throws SensorBaseClientException
email
- The user email.sdtName
- The name of the SDT whose SensorData is to be returned.
SensorBaseClientException
- If the server does not return the Index or returns an index
that cannot be marshalled into Java SensorDataIndex instance.public SensorDataIndex getSensorDataIndexLastMod(java.lang.String email, javax.xml.datatype.XMLGregorianCalendar lastModStartTime, javax.xml.datatype.XMLGregorianCalendar lastModEndTime) throws SensorBaseClientException
Note that data could be sent recently with a Timestamp (as opposed to LastMod field) from far back in the past, and the index will include references to such data. This method thus differs from all other SensorDataIndex-returning methods, because the others compare passed timestamp values to the Timestamp associated with the moment at which a sensor data instance is created, not the moment it ends up being received by the server.
This method is intended for use by user interface facilities such as the SensorDataViewer that wish to monitor the arrival of data at the SensorBase.
email
- The user email.lastModStartTime
- A timestamp used to determine the start time of data to get.lastModEndTime
- A timestamp used to determine the end time of data to get.
SensorBaseClientException
- If the server does not return the Index or returns an index
that cannot be marshalled into Java SensorDataIndex instance.public SensorData getSensorData(java.lang.String email, javax.xml.datatype.XMLGregorianCalendar timestamp) throws SensorBaseClientException
email
- The user email.timestamp
- The timestamp.
SensorBaseClientException
- If the server does not return the success code or returns a
String that cannot be marshalled into Java SensorData instance.public SensorData getSensorData(java.lang.String uriString) throws SensorBaseClientException
uriString
- A string that when prefixed with the sensorbase host should return
a SensorData instance in XML format. A string such as "http://localhost:9876/sensorbase"
will be prefixed to the uriString.
SensorBaseClientException
- If the server does not return the success code or returns a
String that cannot be marshalled into Java SensorData instance.public SensorData getSensorData(SensorDataRef ref) throws SensorBaseClientException
ref
- The SensorDataRef instance
SensorBaseClientException
- If the server does not return the data or returns something
that cannot be marshalled into Java SensorData instance.public void putSensorData(SensorData data) throws SensorBaseClientException
data
- The sensor data to create.
SensorBaseClientException
- If problems occur posting this data.public void putSensorDataBatch(SensorDatas data) throws SensorBaseClientException
data
- The sensor data batch to create, represented as a SensorDatas instance.
SensorBaseClientException
- If problems occur posting this data.public void deleteSensorData(java.lang.String email, javax.xml.datatype.XMLGregorianCalendar timestamp) throws SensorBaseClientException
email
- The email of the User.timestamp
- The timestamp of the sensor data.
SensorBaseClientException
- If the server does not indicate success.public void deleteSensorData(java.lang.String email) throws SensorBaseClientException
email
- The email of the User.
SensorBaseClientException
- If the server does not indicate success.public ProjectIndex getProjectIndex() throws SensorBaseClientException
SensorBaseClientException
- If the server does not return the Index or returns an index
that cannot be marshalled into Java ProjectIndex instance.public ProjectIndex getProjectIndex(java.lang.String email) throws SensorBaseClientException
email
- The user email.
SensorBaseClientException
- If the server does not return the Index or returns an index
that cannot be marshalled into Java ProjectIndex instance.public Project getProject(java.lang.String email, java.lang.String projectName) throws SensorBaseClientException
email
- The user email.projectName
- The project name.
SensorBaseClientException
- If the server does not return success or returns something
that cannot be marshalled into Java Project instance.public boolean inProject(java.lang.String email, java.lang.String projectName)
email
- The email address of the project owner.projectName
- The name of the project.
public Project invite(java.lang.String email, java.lang.String projectName) throws SensorBaseClientException
email
- The user to be invited to this project.projectName
- The project name.
SensorBaseClientException
- If the server does not return success.public void reply(java.lang.String owner, java.lang.String projectName, SensorBaseClient.InvitationReply reply) throws SensorBaseClientException
owner
- The owner of the project that this user has been invited intoprojectName
- the name of the project.reply
- The reply, either ACCEPT or DECLINE.
SensorBaseClientException
- If the server returns an error from this acceptance, for
example if the user has not actually been invited.public void renameProject(java.lang.String owner, java.lang.String projectName, java.lang.String newProjectName) throws SensorBaseClientException
owner
- The owner of the project to be renamed.projectName
- The current name of the project.newProjectName
- The new name of the project.
SensorBaseClientException
- If the server returns an error from this acceptance, for
example if the new project name is not unique.public Project getProject(ProjectRef ref) throws SensorBaseClientException
ref
- The ProjectRef instance
SensorBaseClientException
- If the server does not return the user or returns something
that cannot be marshalled into Java Project instance.public SensorDataIndex getProjectSensorData(java.lang.String owner, java.lang.String projectName) throws SensorBaseClientException
owner
- The project owner's email.projectName
- The project name.
SensorBaseClientException
- If the server does not return success or returns something
that cannot be marshalled into Java SensorDataIndex instance.public SensorDataIndex getProjectSensorData(java.lang.String owner, java.lang.String projectName, javax.xml.datatype.XMLGregorianCalendar startTime, javax.xml.datatype.XMLGregorianCalendar endTime) throws SensorBaseClientException
owner
- The project owner's email.projectName
- The project name.startTime
- The start time.endTime
- The end time.
SensorBaseClientException
- If the server does not return success or returns something
that cannot be marshalled into Java SensorDataIndex instance.public SensorDataIndex getProjectSensorData(java.lang.String owner, java.lang.String projectName, javax.xml.datatype.XMLGregorianCalendar startTime, javax.xml.datatype.XMLGregorianCalendar endTime, java.lang.String sdt) throws SensorBaseClientException
owner
- The project owner's email.projectName
- The project name.startTime
- The start time.endTime
- The end time.sdt
- The SensorDataType.
SensorBaseClientException
- If the server does not return success or returns something
that cannot be marshalled into Java SensorDataIndex instance.public SensorDataIndex getProjectSensorData(java.lang.String owner, java.lang.String projectName, javax.xml.datatype.XMLGregorianCalendar startTime, javax.xml.datatype.XMLGregorianCalendar endTime, java.lang.String sdt, java.lang.String tool) throws SensorBaseClientException
owner
- The project owner's email.projectName
- The project name.startTime
- The start time.endTime
- The end time.sdt
- The SensorDataType.tool
- The tool that generated this sensor data of the given type.
SensorBaseClientException
- If the server does not return success or returns something
that cannot be marshalled into Java SensorDataIndex instance.public SensorDataIndex getProjectSensorData(java.lang.String owner, java.lang.String projectName, javax.xml.datatype.XMLGregorianCalendar startTime, javax.xml.datatype.XMLGregorianCalendar endTime, int startIndex, int maxInstances) throws SensorBaseClientException
owner
- The project owner's email.projectName
- The project name.startTime
- The start time.endTime
- The end time.startIndex
- The zero-based index to the first Sensor Data instance to be returned in
the time interval, when the instances are all ordered by timestamp.maxInstances
- The maximum number of instances to return.
SensorBaseClientException
- If the server does not return success or returns something
that cannot be marshalled into Java SensorDataIndex instance.public SensorDataIndex getProjectSensorDataSnapshot(java.lang.String owner, java.lang.String projectName, javax.xml.datatype.XMLGregorianCalendar startTime, javax.xml.datatype.XMLGregorianCalendar endTime, java.lang.String sdt) throws SensorBaseClientException
owner
- The owner of the project.projectName
- The project name.startTime
- The start time.endTime
- The end time.sdt
- The sdt of interest for the sensor data.
SensorBaseClientException
- If problems occur.public SensorDataIndex getProjectSensorDataSnapshot(java.lang.String owner, java.lang.String projectName, javax.xml.datatype.XMLGregorianCalendar startTime, javax.xml.datatype.XMLGregorianCalendar endTime, java.lang.String sdt, java.lang.String tool) throws SensorBaseClientException
owner
- The owner of the project.projectName
- The project name.startTime
- The start time.endTime
- The end time.sdt
- The sdt of interest for the sensor data.tool
- The tool of interest for the sensor data.
SensorBaseClientException
- If problems occur.public ProjectSummary getProjectSummary(java.lang.String owner, java.lang.String projectName, javax.xml.datatype.XMLGregorianCalendar startTime, javax.xml.datatype.XMLGregorianCalendar endTime) throws SensorBaseClientException
owner
- The project owner.projectName
- The project name.startTime
- The start time.endTime
- The end time.
SensorBaseClientException
- If problems occur.public MultiDayProjectSummary getMultiDayProjectSummary(java.lang.String owner, java.lang.String projectName, javax.xml.datatype.XMLGregorianCalendar startTime, int numDays) throws SensorBaseClientException
owner
- The project owner.projectName
- The project name.startTime
- The start day.numDays
- The number of days, each one getting a ProjectSummary instance.
SensorBaseClientException
- If problems occur.public MultiDayProjectSummary getMonthProjectSummary(java.lang.String owner, java.lang.String projectName, int year, int month) throws SensorBaseClientException
owner
- The project owner.projectName
- The project name.year
- The year.month
- The month (zero based).
SensorBaseClientException
- If problems occur.public void putProject(Project project) throws SensorBaseClientException
project
- The project to create.
SensorBaseClientException
- If problems occur posting this data.public void deleteProject(java.lang.String email, java.lang.String projectName) throws SensorBaseClientException
email
- The email of the project owner.projectName
- The project name.
SensorBaseClientException
- If the server does not indicate success.public static void registerUser(java.lang.String host, java.lang.String email) throws SensorBaseClientException
host
- The host name, such as "http://localhost:9876/sensorbase".email
- The user email.
SensorBaseClientException
- If problems occur during registration.public static boolean isHost(java.lang.String host)
host
- The URL of a sensorbase host, such as "http://localhost:9876/sensorbase".
public static boolean isRegistered(java.lang.String host, java.lang.String email, java.lang.String password)
host
- The URL of a sensorbase host, such as "http://localhost:9876/sensorbase".email
- The user email.password
- The user password.
public void enableCaching(java.lang.String cacheName, java.lang.String subDir, java.lang.Double maxLife, java.lang.Long capacity)
cacheName
- The name of the cache.subDir
- The subdirectory in which the cache backend store is saved.maxLife
- The default expiration time for objects, in days.capacity
- The maximum number of instances to be held in-memory.public void clearCache()
public void compressTables() throws SensorBaseClientException
SensorBaseClientException
- If problems occur posting this data.public void indexTables() throws SensorBaseClientException
SensorBaseClientException
- If problems occur posting this data.public int rowCount(java.lang.String table) throws SensorBaseClientException
table
- The name of the table whose rowcount is to be retrieved.
SensorBaseClientException
- If problems occur posting this data.
This can happen if the user is not the admin user, or if the table name is invalid.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |