DataManager
Stores or uploads the Measurements collected in a study deployment.
A data manager listens to the measurement stream of one deployment and saves each measurement, e.g. to a file, a database, or a server. Which one is used is set by the protocol's DataEndPoint: the SmartphoneStudyController asks the DataManagerRegistry for a data manager of DataEndPoint.type and calls configure with the deployment's measurements.
Key points:
- One instance per deployment. Several deployments can run at the same time, so implementations must not share resources like the same file or network socket.
- onMeasurement is called for each measurement; onError and onDone for errors and the end of the stream.
- Call close to flush buffered data. The data manager cannot be used after that.
See also AbstractDataManager to extend, the built-in SQLiteDataManager, FileDataManager, and ConsoleDataManager, and DataManagerFactory to register your own.
- Implementers
Constructors
DataManager
Properties
deployment
The deployment using this data manager.
events
Stream of data manager events, see DataManagerEventTypes.
studyDeploymentId
The ID of the study deployment that this manager is handling.
type
The type of this data manager as enumerated in DataEndPointTypes.
Methods
close
Flushes any buffered data and closes this data manager.
After calling close the data manager can no longer be used.
configure
- required DataEndPoint dataEndPoint,
- required SmartphoneDeployment deployment,
- required Stream<
Measurement> measurements,
Configures the data manager with the study deployment, the dataEndPoint, and the stream of measurements to handle.
Call this before any data is handled.
onDone
When the data stream closes, the onDone handler is called.
onError
When an error event is sent on the stream, the onError handler is called.
onMeasurement
- Measurement measurement
On each measurement collected, the onMeasurement handler is called.
Implementations of this interface should handle how to save or upload the measurement.