/** * Clone the experiment with the given ID * @param $expId */ public static function clone_experiment($expId) { try { //create new experiment to receive the clone $experiment = Airavata::getExperiment(Session::get('authz-token'), $expId); $cloneId = Airavata::cloneExperiment(Session::get('authz-token'), $expId, 'Clone of ' . $experiment->experimentName); //updating the experiment inputs and output path $experiment = Airavata::getExperiment(Session::get('authz-token'), $cloneId); $experimentInputs = $experiment->experimentInputs; ExperimentUtilities::create_experiment_folder_path(); $hostName = $_SERVER['SERVER_NAME']; foreach ($experimentInputs as $experimentInput) { if ($experimentInput->type == DataType::URI) { $currentInputPath = $experimentInput->value; $hostPathConstant = 'file://' . Config::get('pga_config.airavata')['ssh-user'] . '@' . $hostName . ':'; $currentInputPath = str_replace($hostPathConstant, '', $currentInputPath); $parts = explode('/', rtrim($currentInputPath, '/')); $fileName = array_pop($parts); $newInputPath = ExperimentUtilities::$experimentPath . $fileName; copy($currentInputPath, $newInputPath); $experimentInput->value = $hostPathConstant . $newInputPath; } } Airavata::updateExperiment(Session::get('authz-token'), $cloneId, $experiment); return $cloneId; } catch (InvalidRequestException $ire) { CommonUtilities::print_error_message('<p>There was a problem cloning the experiment. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>'); } catch (ExperimentNotFoundException $enf) { CommonUtilities::print_error_message('<p>There was a problem cloning the experiment. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>ExperimentNotFoundException: ' . $enf->getMessage() . '</p>'); } catch (AiravataClientException $ace) { CommonUtilities::print_error_message('<p>There was a problem cloning the experiment. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>AiravataClientException: ' . $ace->getMessage() . '</p>'); } catch (AiravataSystemException $ase) { CommonUtilities::print_error_message('<p>There was a problem cloning the experiment. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>AiravataSystemException: ' . $ase->getMessage() . '</p>'); } catch (TTransportException $tte) { CommonUtilities::print_error_message('<p>There was a problem cloning the experiment. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>TTransportException: ' . $tte->getMessage() . '</p>'); } }
/** * Clone the experiment with the given ID * @param $expId */ public static function clone_experiment($expId) { try { //create new experiment to receive the clone $experiment = Airavata::getExperiment($expId); $cloneId = Airavata::cloneExperiment($expId, 'Clone of ' . $experiment->name); CommonUtilities::print_success_message("<p>Experiment cloned!</p>" . '<p>You will be redirected to the edit page shortly, or you can <a href="edit_experiment.php?expId=' . $cloneId . '">go directly</a> to the edit experiment page.</p>'); //redirect('edit_experiment.php?expId=' . $cloneId); return $cloneId; } catch (InvalidRequestException $ire) { CommonUtilities::print_error_message('<p>There was a problem cloning the experiment. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>'); } catch (ExperimentNotFoundException $enf) { CommonUtilities::print_error_message('<p>There was a problem cloning the experiment. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>ExperimentNotFoundException: ' . $enf->getMessage() . '</p>'); } catch (AiravataClientException $ace) { CommonUtilities::print_error_message('<p>There was a problem cloning the experiment. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>AiravataClientException: ' . $ace->getMessage() . '</p>'); } catch (AiravataSystemException $ase) { CommonUtilities::print_error_message('<p>There was a problem cloning the experiment. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>AiravataSystemException: ' . $ase->getMessage() . '</p>'); } catch (TTransportException $tte) { CommonUtilities::print_error_message('<p>There was a problem cloning the experiment. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>TTransportException: ' . $tte->getMessage() . '</p>'); } }