/** * 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>'); } }
/** * @param $applicationInputs * @param $experimentInputs * @internal param $environmentPath * @return array */ public static function process_inputs($applicationInputs, $experimentInputs) { $experimentAssemblySuccessful = true; $newExperimentInputs = array(); //var_dump($_FILES); if (sizeof($_FILES) > 0) { if (ExperimentUtilities::file_upload_successful()) { // construct unique path ExperimentUtilities::create_experiment_folder_path(); } else { $experimentAssemblySuccessful = false; } } //sending application inputs in the order defined by the admins. $order = array(); foreach ($applicationInputs as $index => $input) { $order[$index] = $input->inputOrder; } array_multisort($order, SORT_ASC, $applicationInputs); foreach ($applicationInputs as $applicationInput) { $experimentInput = new InputDataObjectType(); $experimentInput = $applicationInput; //$experimentInput->name = $applicationInput->name; //$experimentInput->metaData = $applicationInput->metaData; //$experimentInput->type = $applicationInput->type; //$experimentInput->type = DataType::STRING; if (($applicationInput->type == DataType::STRING) || ($applicationInput->type == DataType::INTEGER) || ($applicationInput->type == DataType::FLOAT) ) { if (isset($_POST[$applicationInput->name]) && (trim($_POST[$applicationInput->name]) != '')) { $experimentInput->value = $_POST[$applicationInput->name]; $experimentInput->type = $applicationInput->type; } else // use previous value { $index = -1; for ($i = 0; $i < sizeof($experimentInputs); $i++) { if ($experimentInputs[$i]->name == $applicationInput->name) { $index = $i; } } if ($index >= 0) { $experimentInput->value = $experimentInputs[$index]->value; $experimentInput->type = $applicationInput->type; } } } elseif ($applicationInput->type == DataType::URI) { //var_dump($_FILES[$applicationInput->name]->name); if ($_FILES[$applicationInput->name]['name']) { $file = $_FILES[$applicationInput->name]; // // move file to experiment data directory // $filePath = ExperimentUtilities::$experimentPath . $file['name']; // check if file already exists if (is_file($filePath)) { unlink($filePath); CommonUtilities::print_warning_message('Uploaded file already exists! Overwriting...'); } $moveFile = move_uploaded_file($file['tmp_name'], $filePath); if ($moveFile) { CommonUtilities::print_success_message('Upload: ' . $file['name'] . '<br>' . 'Type: ' . $file['type'] . '<br>' . 'Size: ' . ($file['size'] / 1024) . ' kB'); //<br>' . //'Stored in: ' . $experimentPath . $file['name']); } else { CommonUtilities::print_error_message('<p>Error moving uploaded file ' . $file['name'] . '! Please try again later or report a bug using the link in the Help menu.</p>'); $experimentAssemblySuccessful = false; } $hostName = $_SERVER['SERVER_NAME']; $experimentInput->value = 'file://' . ExperimentUtilities::$sshUser . '@' . $hostName . ':' . $filePath; $experimentInput->type = $applicationInput->type; } else { $index = -1; for ($i = 0; $i < sizeof($experimentInputs); $i++) { if ($experimentInputs[$i]->name == $applicationInput->name) { $index = $i; } } if ($index >= 0) { $experimentInput->value = $experimentInputs[$index]->value; $experimentInput->type = $applicationInput->type; } } } else { CommonUtilities::print_error_message('I cannot accept this input type yet!'); } $newExperimentInputs[] = $experimentInput; } if ($experimentAssemblySuccessful) { return $newExperimentInputs; } else { return false; } }