コード例 #1
0
    /**
     * Get results of the user's search of experiments with pagination
     * @return array|null
     */
    public static function get_expsearch_results_with_pagination( $inputs, $limit, $offset)
    {
        $experiments = array();

        try
        {
            switch ( $inputs["search-key"])
            {
                case 'experiment-name':
                    $experiments = Airavata::searchExperimentsByNameWithPagination(
                        Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset);
                    break;
                case 'experiment-description':
                    $experiments = Airavata::searchExperimentsByDescWithPagination(
                        Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset);
                    break;
                case 'application':
                    $experiments = Airavata::searchExperimentsByApplicationWithPagination(
                        Session::get('gateway_id'), Session::get('username'), $inputs["search-value"], $limit, $offset);
                    break;
                case 'creation-time':
                    $experiments = Airavata::searchExperimentsByCreationTimeWithPagination(
                        Session::get('gateway_id'), Session::get('username'), strtotime( $inputs["from-date"])*1000,
                        strtotime( $inputs["to-date"])*1000 , $limit, $offset);
                    break;
                case '':
            }
        }
        catch (InvalidRequestException $ire)
        {
            Utilities::print_error_message('InvalidRequestException!<br><br>' . $ire->getMessage());
        }
        catch (AiravataClientException $ace)
        {
            Utilities::print_error_message('AiravataClientException!<br><br>' . $ace->getMessage());
        }
        catch (AiravataSystemException $ase)
        {
            if ($ase->airavataErrorType == 2) // 2 = INTERNAL_ERROR
            {
                Utilities::print_info_message('<p>You have not created any experiments yet, so no results will be returned!</p>
                                <p>Click <a href="create_experiment.php">here</a> to create an experiment, or
                                <a href="create_project.php">here</a> to create a new project.</p>');
            }
            else
            {
                Utilities::print_error_message('There was a problem with Airavata. Please try again later or report a bug using the link in the Help menu.');
                //print_error_message('AiravataSystemException!<br><br>' . $ase->airavataErrorType . ': ' . $ase->getMessage());
            }
        }
        catch (TTransportException $tte)
        {
            Utilities::print_error_message('TTransportException!<br><br>' . $tte->getMessage());
        }

        //get values of all experiments
        $expContainer = array();
        $expNum = 0;
        foreach( $experiments as $experiment)
        {
            $expValue = Utilities::get_experiment_values( $experiment, Utilities::get_project($experiment->projectID), true );
            $expContainer[$expNum]['experiment'] = $experiment;
            if( $expValue["experimentStatusString"] == "FAILED")
                $expValue["editable"] = false;
            $expContainer[$expNum]['expValue'] = $expValue;
            $expNum++;
        }

        return $expContainer;
    }