/** * Get all projects owned by the given user * @param $username * @return null */ public static function get_all_user_projects($gatewayId, $username) { $userProjects = null; try { $userProjects = Airavata::getUserProjects(Session::get('authz-token'), $gatewayId, $username, -1, 0); //var_dump( $userProjects); exit; } catch (InvalidRequestException $ire) { CommonUtilities::print_error_message('<p>There was a problem getting the user\'s projects. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>'); } catch (AiravataClientException $ace) { CommonUtilities::print_error_message('<p>There was a problem getting the user\'s projects. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>Airavata Client Exception: ' . $ace->getMessage() . '</p>'); } catch (AiravataSystemException $ase) { if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR { CommonUtilities::print_warning_message('<p>You must create a project before you can create an experiment. Click <a href="' . URL::to('/') . '/project/create">here</a> to create a project.</p>'); } else { CommonUtilities::print_error_message('<p>There was a problem getting the user\'s projects. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>AiravataSystemException: ' . $ase->getMessage() . '</p>'); } } return $userProjects; }
/** * Create a select input and populate it with project options from the database */ public static function create_project_select($projectId = null, $editable = true) { $editable ? $disabled = '' : ($disabled = 'disabled'); $userProjects = ProjectUtilities::get_all_user_projects(Session::get("gateway_id"), Session::get('username')); echo '<select class="form-control" name="project" id="project" required ' . $disabled . '>'; if (sizeof($userProjects) > 0) { foreach ($userProjects as $project) { if ($project->projectID == $projectId) { $selected = 'selected'; } else { $selected = ''; } echo '<option value="' . $project->projectID . '" ' . $selected . '>' . $project->name . '</option>'; } } echo '</select>'; if (sizeof($userProjects) == 0) { CommonUtilities::print_warning_message('<p>You must create a project before you can create an experiment. Click <a href="' . URL::to('/') . '/project/create">here</a> to create a project.</p>'); } }
<?php if (isset($expContainer)) { if (sizeof($expContainer) == 0) { if (isset($pageNo) && $pageNo == 1) { CommonUtilities::print_warning_message('No results found. Please try again.'); } else { CommonUtilities::print_warning_message('No more results found.'); } } else { ?> <div id="re" class="table-responsive"> <table class="table"> <tr> <th>Name</th> <th>Application</th> <th>Description</th> <!--<th>Resource</th>--> <th>Creation Time</th> <th>Status</th> <!-- <select class="form-control select-status">--> <!-- <option value="ALL">Status</option>--> <!-- @foreach( $expStates as $index => $state)--> <!-- <option value="{{ $state }}">{{ $state }}</option>--> <!-- @endforeach--> <!-- </select>-->
/** * @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 || $applicationInput->type == DataType::URI && !empty($applicationInput->metaData) && json_decode($applicationInput->metaData)->location == "remote") { if (isset($_POST[$applicationInput->name]) && trim($_POST[$applicationInput->name]) != '') { $experimentInput->value = $_POST[$applicationInput->name]; $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; } } } 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 // if (!empty($applicationInput->value)) { $filePath = ExperimentUtilities::$experimentPath . $applicationInput->value; } else { $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://' . Config::get('pga_config.airavata')['ssh-user'] . '@' . $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; } }
/** * Get all available applications * @return null */ public static function get_all_applications() { $applications = null; try { $applications = Airavata::getAllApplicationInterfaceNames(Session::get('authz-token'), Session::get("gateway_id")); } catch (InvalidRequestException $ire) { CommonUtilities::print_error_message('<p>There was a problem getting all applications. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>InvalidRequestException: ' . $ire->getMessage() . '</p>'); } catch (AiravataClientException $ace) { CommonUtilities::print_error_message('<p>There was a problem getting all applications. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>Airavata Client Exception: ' . $ace->getMessage() . '</p>'); } catch (AiravataSystemException $ase) { CommonUtilities::print_warning_message('<p>You must create an application module, interface and deployment space before you can create an experiment. Click <a href="' . URL::to('/') . '/app/module">here</a> to create an application.</p>'); /* CommonUtilities::print_error_message('<p>There was a problem getting all applications. Please try again later or submit a bug report using the link in the Help menu.</p>' . '<p>Airavata System Exception: ' . $ase->getMessage() . '</p>'); */ } if (count($applications) == 0) { CommonUtilities::print_warning_message('<p>You must create an application module, interface and deployment space before you can create an experiment. Click <a href="' . URL::to('/') . '/app/module">here</a> to create an application.</p>'); } return $applications; }