restoreDeployment method
Restore the SmartphoneDeployment with the deploymentId
from local cache.
Returns a SmartphoneDeployment if successful, null otherwise.
Implementation
Future<SmartphoneDeployment?> restoreDeployment(String deploymentId) async {
info("$runtimeType - Restoring deployment, deploymentId: $deploymentId");
SmartphoneDeployment? deployment;
try {
final List<Map<String, Object?>> maps = await database?.query(
DEPLOYMENT_TABLE_NAME,
columns: [DEPLOYMENT_COLUMN],
where: '$STUDY_DEPLOYMENT_ID_COLUMN = ?',
whereArgs: [deploymentId],
) ??
[];
if (maps.isNotEmpty) {
final jsonString = maps[0][DEPLOYMENT_COLUMN] as String;
deployment = SmartphoneDeployment.fromJson(
json.decode(jsonString) as Map<String, dynamic>);
}
} catch (exception) {
warning('$runtimeType - Failed to restore deployment - $exception');
}
return deployment;
}