DataPoint
A data point for the legacy CAWS data point endpoint, holding a header and the data.
The data point endpoint is deprecated in CAWS; new code uploads Measurements through CarpDataStreamService. Data points are uploaded with a DataPointReference.
CARP DataPoint definition accepted by the server, version 1.2 (example):
{
"id": 224038, # set by the server, not used in upload
"created_by_user_id": 1, # set by the server, not used in upload
"study_id": "c9d341ae", # set by the server, not used in upload
"carp_header": {
"study_id": "01cf04a7", # required - should be the study_deployment_id
"device_role_name": "phone", # optional
"trigger_id": "1", # optional
"user_id": "1e828ea0-78f7-11eb-a4c1", # required - use a UUID and avoid usernames like 'user@dtu.dk'
"upload_time": "2021-02-27T12:27:14.933672Z", # set by the server, not used in upload
"start_time": "2021-02-27T12:27:12.902614Z", # optional
"end_time": "2021-02-27T12:27:14.933672Z", # optional
"data_format": { # required
"namespace": "dk.cachet.carp",
"name": "light"
}
},
"carp_body": { # required
"id": "1e828ea0-78f7-11eb-a4c1-8518ece21966",
"timestamp": "2021-02-27T12:27:12.902614Z"
"max_lux": 12,
"mean_lux": 23,
"min_lux": 0.3,
"std_lux": 0.4,
}
}
- Annotations
-
- @JsonSerializable(fieldRename: FieldRename.snake, includeIfNull: false, explicitToJson: true)
Constructors
DataPoint.fromData
- Data data
Creates a DataPoint from a Data object, with the data type as DataPointHeader.dataFormat and the current UTC time as start time.
DataPoint.fromJson
Create a DataPoint from a JSON map.
DataPoint
- DataPointHeader carpHeader, [
- Data? data
Create a new DataPoint.
Properties
carpBody
The CARP data point body. Can be any JSON payload.
When this data point is created locally on the phone, the carpBody is a json serialization of data. If this data point is deserialized from json, the carpBody is the raw json.
Note that we do not support type/schema checking in this data pay load. CARP allow for any json formatted data to be uploaded and stored.
carpHeader
The data point header.
createdByUserId
The unique id of the user who created / uploaded this data point. null if this data point is not yet stored.
This user id is the server-side generated user id (an integer), and NOT the user id that this data point belongs to, which is stored in the DataPointHeader as the DataPointHeader.userId (a string, typically the email).
This createdByUserId id may, or may not, be identical to the id of the user who this data point belongs to. By being able to separate who uploads a data point and who the data point belongs to, allows for one user to upload data on behalf of another user. For example, a parent on behalf of a child.
data
The CARP data point body. Can be any payload modelled as a Data.
id
A unique, server-side generated ID for this data point. null if this data point is not yet stored.
studyId
The unique study deployment id that this data point belongs to / is uploaded as part of. Set by the server. null if this data point is not yet stored.
Methods
toJson
Serialize this DataPoint as a JSON map.