Path changes for experiment outputs
Project: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/commit/f1b3474d Tree: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/tree/f1b3474d Diff: http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/diff/f1b3474d Branch: refs/heads/master Commit: f1b3474d7a1c0cba1749f49156e6d18dbe56a1ab Parents: 20cf13c Author: Nipurn Doshi <[email protected]> Authored: Tue Mar 24 14:38:16 2015 -0400 Committer: Suresh Marru <[email protected]> Committed: Thu Apr 9 11:41:34 2015 -0400 ---------------------------------------------------------------------- app/controllers/ExperimentController.php | 43 +++++++++-------- app/libraries/utilities.php | 67 +++++++++++---------------- app/views/experiment/summary.blade.php | 20 ++++++-- 3 files changed, 67 insertions(+), 63 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f1b3474d/app/controllers/ExperimentController.php ---------------------------------------------------------------------- diff --git a/app/controllers/ExperimentController.php b/app/controllers/ExperimentController.php index 0743113..95caf97 100755 --- a/app/controllers/ExperimentController.php +++ b/app/controllers/ExperimentController.php @@ -67,28 +67,33 @@ class ExperimentController extends BaseController { public function summary() { $experiment = Utilities::get_experiment($_GET['expId']); - $project = Utilities::get_project($experiment->projectID); - $expVal = Utilities::get_experiment_values( $experiment, $project); - // User should not clone or edit a failed experiment. Only create clones of it. - if( $expVal["experimentStatusString"] == "FAILED") - $expVal["editable"] = false; - - if( Request::ajax() ) + if( $experiment != null) { - return json_encode( $experiment); + $project = Utilities::get_project($experiment->projectID); + $expVal = Utilities::get_experiment_values( $experiment, $project); + // User should not clone or edit a failed experiment. Only create clones of it. + if( $expVal["experimentStatusString"] == "FAILED") + $expVal["editable"] = false; + + if( Request::ajax() ) + { + return json_encode( $experiment); + } + else + { + return View::make( "experiment/summary", + array( + "expId" => Input::get("expId"), + "experiment" => $experiment, + "project" => $project, + "expVal" => $expVal + + ) + ); + } } else - { - return View::make( "experiment/summary", - array( - "expId" => Input::get("expId"), - "experiment" => $experiment, - "project" => $project, - "expVal" => $expVal - - ) - ); - } + return View::make( "experiment/summary", array("invalidExperimentId" => 1)); } public function expChange() http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f1b3474d/app/libraries/utilities.php ---------------------------------------------------------------------- diff --git a/app/libraries/utilities.php b/app/libraries/utilities.php index 1631bb5..e32da17 100644 --- a/app/libraries/utilities.php +++ b/app/libraries/utilities.php @@ -746,6 +746,7 @@ public static function assemble_experiment() { $utility = new Utilities(); $experimentInputs = array(); + $app_config = Utilities::read_config(); $scheduling = new ComputationalResourceScheduling(); $scheduling->totalCPUCount = $_POST['cpu-count']; @@ -763,31 +764,14 @@ public static function assemble_experiment() $experimentInputs = Utilities::process_inputs($applicationInputs, $experimentInputs); //var_dump($experimentInputs); - if( Utilities::$experimentPath != null){ - $advHandling = new AdvancedOutputDataHandling(); - - $advHandling->outputDataDir = str_replace( base_path() . Constant::EXPERIMENT_DATA_ROOT, Utilities::$pathConstant , Utilities::$experimentPath); - $userConfigData->advanceOutputDataHandling = $advHandling; + if( Utilities::$experimentPath == null){ + Utilities::create_experiment_folder_path(); } + $advHandling = new AdvancedOutputDataHandling(); - - - - /* - $applicationOutputs = get_application_outputs($_POST['application']); - $experimentOutputs = array(); - - foreach ($applicationOutputs as $applicationOutput) - { - $experimentOutput = new DataObjectType(); - $experimentOutput->key = $applicationOutput->name; - $experimentOutput->type = $applicationOutput->type; - $experimentOutput->value = ''; - - $experimentOutputs[] = $experimentOutput; - } - */ + $advHandling->outputDataDir = str_replace( base_path() . Constant::EXPERIMENT_DATA_ROOT, Utilities::$pathConstant , Utilities::$experimentPath); + $userConfigData->advanceOutputDataHandling = $advHandling; //TODO: replace constructor with a call to airvata to get a prepopulated experiment template $experiment = new Experiment(); @@ -836,20 +820,7 @@ public static function process_inputs($applicationInputs, $experimentInputs) if (Utilities::file_upload_successful()) { // construct unique path - do - { - Utilities::$experimentPath = base_path() . Constant::EXPERIMENT_DATA_ROOT . str_replace(' ', '', Session::get('username') ) . md5(rand() * time()) . '/'; - } - while (is_dir( Utilities::$experimentPath)); // if dir already exists, try again - - //var_dump( Utilities::$experimentPath ); exit; - // create upload directory - if (!mkdir( Utilities::$experimentPath)) - { - Utilities::print_error_message('<p>Error creating upload directory! - Please try again later or report a bug using the link in the Help menu.</p>'); - $experimentAssemblySuccessful = false; - } + Utilities::create_experiment_folder_path(); } else { @@ -1015,6 +986,22 @@ public static function process_inputs($applicationInputs, $experimentInputs) } +public static function create_experiment_folder_path() +{ + do + { + Utilities::$experimentPath = base_path() . Constant::EXPERIMENT_DATA_ROOT . str_replace(' ', '', Session::get('username') ) . md5(rand() * time()) . '/'; + } + while (is_dir( Utilities::$experimentPath)); // if dir already exists, try again + // create upload directory + if (!mkdir( Utilities::$experimentPath)) + { + Utilities::print_error_message('<p>Error creating upload directory! + Please try again later or report a bug using the link in the Help menu.</p>'); + $experimentAssemblySuccessful = false; + } +} + /** * Check the uploaded files for errors */ @@ -1830,17 +1817,19 @@ public static function list_output_files($experiment, $expStatus) { $utility = new Utilities(); $experimentOutputs = $experiment->experimentOutputs; + foreach ((array)$experimentOutputs as $output) - { + { if ($output->type == DataType::URI || $output->type == DataType::STDOUT || $output->type == DataType::STDERR ) { + $explode = explode('/', $output->value); //echo '<p>' . $output->key . ': <a href="' . $output->value . '">' . $output->value . '</a></p>'; $outputPath = str_replace(Utilities::$experimentDataPathAbsolute, Constant::EXPERIMENT_DATA_ROOT, $output->value); $outputPathArray = explode("/", $outputPath); echo '<p>' . $output->name . ' : ' . '<a target="_blank" - href="' . str_replace(Utilities::$experimentDataPathAbsolute, Constant::EXPERIMENT_DATA_ROOT, $output->value) . '">' . - $outputPathArray[ sizeof( $outputPathArray) - 1] . ' <span class="glyphicon glyphicon-new-window"></span></a></p>'; + href="' . URL::to("/") . "/.." . Constant::EXPERIMENT_DATA_ROOT . $explode[sizeof($explode)-2] . '/' . $explode[sizeof($explode)-1] . '">' . + $explode[sizeof($explode)-1] . ' <span class="glyphicon glyphicon-new-window"></span></a></p>'; } elseif ($output->type == DataType::STRING) { http://git-wip-us.apache.org/repos/asf/airavata-php-gateway/blob/f1b3474d/app/views/experiment/summary.blade.php ---------------------------------------------------------------------- diff --git a/app/views/experiment/summary.blade.php b/app/views/experiment/summary.blade.php index 4692f40..e94cf9c 100755 --- a/app/views/experiment/summary.blade.php +++ b/app/views/experiment/summary.blade.php @@ -7,12 +7,19 @@ @section('content') <div class="container" style="max-width: 750px;"> -<h1> - Experiment Summary - <small><a href="{{ URL::to('/') }}/experiment/summary?expId={{ $experiment->experimentID }}" - title="Refresh"><span class="glyphicon glyphicon-refresh refresh-exp"></span></a></small> -</h1> + @if(isset( $invalidExperimentId ) ) + <div class="alert alert-danger"> + The Experiment ID does not exist. Please go to correct experiment. + </div> + @else + <h1> + Experiment Summary + <small><a href="{{ URL::to('/') }}/experiment/summary?expId={{ $experiment->experimentID }}" + title="Refresh"><span class="glyphicon glyphicon-refresh refresh-exp"></span></a></small> + </h1> + + <table class="table"> <tr> <td><strong>Name</strong></td> @@ -100,6 +107,9 @@ </div> </form> <input type="hidden" id="expObj" value="{{ htmlentities( json_encode( $experiment)) }}"/> + + <!-- check of correct experiment Id ends here --> + @endif </div> @stop
