stop method

Permanently stop this study.

Note that will mark the study as stopped in the deployment service. Once stopped, a study cannot be restarted.

Implementation

@mustCallSuper
Future<void> stop(Study study) async {
  // Early out in case study has already been stopped.
  if (study.deploymentStatus?.status == StudyDeploymentStatusTypes.Stopped) {
    return;
  }

  try {
    final deploymentStatus = (await deploymentService.stop(
      study.studyDeploymentId,
    ));
    if (deploymentStatus != null) {
      study.deploymentStatusReceived(deploymentStatus);
    }
  } catch (error) {
    print(
      "$runtimeType - failed to stop study for study deployment '${study.studyDeploymentId}' "
      "at deployment service '$deploymentService'.\n"
      "Stopping the study locally only.\n"
      "Error: $error",
    );
  }
}