SmartphoneStudy.fromMap constructor
Create a SmartphoneStudy from a SQL Result Map.
Implementation
factory SmartphoneStudy.fromMap(Map<String, Object?> map) {
final statusJson =
map[PersistenceService.DEPLOYMENT_STATUS_COLUMN] as String?;
final status = statusJson != null && statusJson != 'null'
? StudyDeploymentStatus.fromJson(
json.decode(statusJson) as Map<String, dynamic>,
)
: null;
final deploymentJson = map[PersistenceService.DEPLOYMENT_COLUMN] as String?;
final deployment = deploymentJson != null && deploymentJson != 'null'
? SmartphoneDeployment.fromJson(
json.decode(deploymentJson) as Map<String, dynamic>,
)
: null;
final samplingStateJson =
map[PersistenceService.SAMPLING_STATUS_COLUMN] as String?;
final samplingState =
samplingStateJson != null && samplingStateJson != 'null'
? SmartphoneDeploymentExecutorSamplingState.fromJson(
json.decode(samplingStateJson) as Map<String, dynamic>,
)
: null;
return SmartphoneStudy(
studyId: map[PersistenceService.STUDY_ID_COLUMN] as String?,
studyDeploymentId:
map[PersistenceService.STUDY_DEPLOYMENT_ID_COLUMN] as String,
deviceRoleName: map[PersistenceService.DEVICE_ROLE_NAME_COLUMN] as String,
participantId: map[PersistenceService.PARTICIPANT_ID_COLUMN] as String?,
participantRoleName:
map[PersistenceService.PARTICIPANT_ROLE_NAME_COLUMN] as String?,
createdOn: map[PersistenceService.CREATED_ON_COLUMN] != null
? DateTime.tryParse(
map[PersistenceService.CREATED_ON_COLUMN] as String,
)
: null,
deploymentStatus: status,
deployment: deployment,
)..samplingState = samplingState;
}