SmartphoneDeployment.fromPrimaryDeviceDeployment constructor

SmartphoneDeployment.fromPrimaryDeviceDeployment({
  1. String? studyId,
  2. String? studyDeploymentId,
  3. String? participantId,
  4. String? participantRoleName,
  5. required PrimaryDeviceDeployment deployment,
})

Create a SmartphoneDeployment based on a PrimaryDeviceDeployment.

Implementation

SmartphoneDeployment.fromPrimaryDeviceDeployment({
  this.studyId,
  String? studyDeploymentId,
  this.participantId,
  this.participantRoleName,
  required PrimaryDeviceDeployment deployment,
}) : super(
        deviceConfiguration: deployment.deviceConfiguration,
        registration: deployment.registration,
        connectedDevices: deployment.connectedDevices,
        connectedDeviceRegistrations: deployment.connectedDeviceRegistrations,
        tasks: deployment.tasks,
        triggers: deployment.triggers,
        taskControls: deployment.taskControls,
        expectedParticipantData: deployment.expectedParticipantData,
      ) {
  _studyDeploymentId = studyDeploymentId ?? const Uuid().v1;

  // check if this deployment has mapped study description in the application
  // data, i.e., a protocol generated from CAMS
  if (deployment.applicationData != null &&
      deployment.applicationData!.containsKey('studyDescription')) {
    var data =
        SmartphoneApplicationData.fromJson(deployment.applicationData!);
    _data.studyDescription = data.studyDescription;
    _data.dataEndPoint = data.dataEndPoint;
    _data.privacySchemaName = data.privacySchemaName;
    _data.applicationData = data.applicationData;
  } else {
    _data.applicationData = deployment.applicationData ?? {};
  }
}