com.biocomfort.TO.data_consumer
Class RestDataConsumer

java.lang.Object
  extended by com.biocomfort.TO.data_consumer.DataConsumer
      extended by com.biocomfort.TO.data_consumer.RestDataConsumer
All Implemented Interfaces:
SDKDataListener

public class RestDataConsumer
extends DataConsumer

The class RestDataConsumer is a concrete implementation of the DataConsumer class that will send the received measurement data to a restful web service.

The received measurement data is transformed into XML and sent as POST data to the following URLs:

where <urlString> can be defined by a RestDataConsumer object.

The data of blood pressure monitors is transformed into the following XML format:
 
 <?xml version="1.0" encoding="UTF-8"?>
 <blood-pressure-measurement>
     <manually-entered type="boolean">false</manually-entered>
     <timestamp type="datetime">2008-05-13T12:00:00+00:00</timestamp>
     <user-id nil="true" type="integer"/>
     <systolic>
         <value type="decimal">121.0</value>
     </systolic>
     <diastolic>
         <value type="decimal">82.0</value>
     </diastolic>
     <pulse>
         <value type="integer">93</value>
     </pulse>
 </blood-pressure-measurement>
 
 
The data of blood glucose monitors is transformed into the following XML format:
 
 <?xml version="1.0" encoding="UTF-8"?>
 <blood-glucose-measurement>
     <manually-entered type="boolean">false</manually-entered>
     <timestamp type="datetime">2008-05-13T12:00:00+00:00</timestamp>
     <user-id nil="true" type="integer"/>
     <glucose>
         <value type="decimal">123.0</value>
     </glucose>
 </blood-glucose-measurement>
 
 
The data of body diagnostic scales is transformed into the following XML format:
 
 <?xml version="1.0" encoding="UTF-8"?>
 <body-weight-measurement>
     <manually-entered type="boolean">false</manually-entered>
     <timestamp type="datetime">2008-05-13T12:00:00+00:00</timestamp>
     <user-id nil="true" type="integer"/>
     <weight>
         <value type="decimal">80.0</value>
     </weight>
     <impedance>
         <value type="decimal">600.0</value>
     </impedance>
     <body-fat>
         <value type="decimal">20.0</value>
     </body-fat>
     <body-water>
         <value type="decimal">60.0</value>
     </body-water>
     <muscle-mass>
         <value type="decimal">22.0</value>
     </muscle-mass>
 </body-weight-measurement>
 
 
In order to process measurement data with an object of this data consumer register an instance with a SDK implementation by calling the method SDK.addSDKDataListener(SDKDataListener).

See Also:
SDK.addSDKDataListener(SDKDataListener)

Constructor Summary
RestDataConsumer(java.lang.String urlString)
          Constructs a RestDataConsumer object with specifying the URL string by the given parameter urlString.
 
Method Summary
 java.lang.String getUrlString()
          Returns the URL string thats represents the URL basis to which the transformed measurement data is sent.
 boolean isEnabledBloodGlucoseProcessing()
          Returns true if the processing of received blood glucose measurement data is enabled, false otherwise.
 boolean isEnabledBloodPressureProcessing()
          Returns true if the processing of received blood pressure measurement data is enabled, false otherwise.
 boolean isEnabledWeightProcessing()
          Returns true if the processing of received weight measurement data is enabled, false otherwise.
protected  void processData(MedicalDeviceTO medicalDevice, TO data)
          Sends the received measurement data to a restful web service in case that the processing for the corresponding measurement data type is enabled.
 void setEnabledBloodGlucoseProcessing(boolean enabled)
          Enables or disables the processing of received blood glucose measurement data.
 void setEnabledBloodPressureProcessing(boolean enabled)
          Enables or disables the processing of received blood pressure measurement data.
 void setEnabledWeightProcessing(boolean enabled)
          Enables or disables the processing of received weight measurement data.
 void setUrlString(java.lang.String urlString)
          Sets the URL string thats represents the URL basis to which the transformed measurement data is sent.
 
Methods inherited from class com.biocomfort.TO.data_consumer.DataConsumer
addDataConsumerListener, fireOnErrorEvent, fireOnSuccessEvent, isEnabled, onDataReceived, removeDataConsumerListener, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RestDataConsumer

public RestDataConsumer(java.lang.String urlString)
Constructs a RestDataConsumer object with specifying the URL string by the given parameter urlString.

In order to process measurement data with this object register it with a SDK implementation by calling the method SDK.addSDKDataListener(SDKDataListener).

Parameters:
urlString -
See Also:
SDK.addSDKDataListener(SDKDataListener)
Method Detail

getUrlString

public java.lang.String getUrlString()
Returns the URL string thats represents the URL basis to which the transformed measurement data is sent.

Returns:
the URL string basis

setUrlString

public void setUrlString(java.lang.String urlString)
Sets the URL string thats represents the URL basis to which the transformed measurement data is sent.

Parameters:
urlString - the new URL string basis

processData

protected void processData(MedicalDeviceTO medicalDevice,
                           TO data)
Sends the received measurement data to a restful web service in case that the processing for the corresponding measurement data type is enabled. The received measurement data is transformed into a special XML format and sent as POST data to the following URLs: "<urlString>/blood_pressure_measurements", "<urlString>/blood_glucose_measurements", or "<urlString>/body_weight_measurements", depending on the measurement type.

Specified by:
processData in class DataConsumer
Parameters:
medicalDevice - the medical device that sends the data
data - the received measurement data
See Also:
setEnabledBloodPressureProcessing(boolean), setEnabledBloodGlucoseProcessing(boolean), setEnabledWeightProcessing(boolean), setUrlString(String)

isEnabledBloodPressureProcessing

public boolean isEnabledBloodPressureProcessing()
Returns true if the processing of received blood pressure measurement data is enabled, false otherwise.

Returns:
true if processing of blood pressure measurements is enabled

setEnabledBloodPressureProcessing

public void setEnabledBloodPressureProcessing(boolean enabled)
Enables or disables the processing of received blood pressure measurement data. If the given parameter enabled is true the processing of blood pressure measurements is enabled.

Parameters:
enabled - true to enable the processing of blood pressure measurements

isEnabledBloodGlucoseProcessing

public boolean isEnabledBloodGlucoseProcessing()
Returns true if the processing of received blood glucose measurement data is enabled, false otherwise.

Returns:
true if processing of blood glucose measurements is enabled

setEnabledBloodGlucoseProcessing

public void setEnabledBloodGlucoseProcessing(boolean enabled)
Enables or disables the processing of received blood glucose measurement data. If the given parameter enabled is true the processing of blood glucose measurements is enabled.

Parameters:
enabled - true to enable the processing of blood glucose measurements

isEnabledWeightProcessing

public boolean isEnabledWeightProcessing()
Returns true if the processing of received weight measurement data is enabled, false otherwise.

Returns:
true if processing of weight measurements is enabled

setEnabledWeightProcessing

public void setEnabledWeightProcessing(boolean enabled)
Enables or disables the processing of received weight measurement data. If the given parameter enabled is true the processing of weight measurements is enabled.

Parameters:
enabled - true to enable the processing of weight measurements