Пример #1
0
 /**
  * @covers AppSolr::getAppGridData
  *
  * @depends testReindexAllApplications
  */
 public function testGetAppGridData()
 {
     //$userUid, $start = null, $limit = null, $action = null, $filter = null, $search = null, $process = null, $user = null,
     //$status = null, $type = null, $dateFrom = null, $dateTo = null, $callback = null, $dir = null, $sort = 'APP_CACHE_VIEW.APP_NUMBER', $doCount = false
     $userUid = '00000000000000000000000000000001';
     //admin user
     $start = 0;
     $limit = 20;
     $action = 'todo';
     $sort = 'APP_NUMBER';
     $dir = 'ASC';
     $result = $this->object->getAppGridData($userUid, $start, $limit, $action, null, null, null, null, null, null, null, null, null, $dir, $sort, false);
     print_r($result);
     if (!$result['success']) {
         $this->assertEmpty($result['message'], 'The message is only display in not success');
     }
     if (!$result['result']) {
         $this->assertCount(0, $result['data'], 'Returned data when not success reported');
     }
     //verify the number of returned rows
     print 'count results: ' . count($result['data']);
     //$this->assertGreaterThan($result ['totalCount'], count($result ['data']), 'The returned records are less than the total');
     //test all the views
     $userUid = '00000000000000000000000000000001';
     //admin user
     $start = 0;
     $limit = 20;
     $action = 'participated';
     $sort = 'APP_NUMBER';
     $dir = 'ASC';
     $result = $this->object->getAppGridData($userUid, $start, $limit, $action, null, null, null, null, null, null, null, null, null, $dir, $sort, false);
     $userUid = '00000000000000000000000000000001';
     //admin user
     $start = 0;
     $limit = 20;
     $action = 'draft';
     $sort = 'APP_NUMBER';
     $dir = 'ASC';
     $result = $this->object->getAppGridData($userUid, $start, $limit, $action, null, null, null, null, null, null, null, null, null, $dir, $sort, false);
     $userUid = '00000000000000000000000000000001';
     //admin user
     $start = 0;
     $limit = 20;
     $action = 'unassigned';
     $sort = 'APP_NUMBER';
     $dir = 'ASC';
     $result = $this->object->getAppGridData($userUid, $start, $limit, $action, null, null, null, null, null, null, null, null, null, $dir, $sort, false);
     //test search functionality
 }
Пример #2
0
$type = isset($_GET["type"]) ? $_GET["type"] : (isset($_POST["type"]) ? $_POST["type"] : "extjs");
$dateFrom = isset($_POST["dateFrom"]) ? substr($_POST["dateFrom"], 0, 10) : "";
$dateTo = isset($_POST["dateTo"]) ? substr($_POST["dateTo"], 0, 10) : "";
try {
    $userUid = isset($_SESSION["USER_LOGGED"]) && $_SESSION["USER_LOGGED"] != "" ? $_SESSION["USER_LOGGED"] : null;
    $result = "";
    switch ($action) {
        case "search":
        case "to_reassign":
            $user = $user == "CURRENT_USER" ? $userUid : $user;
            $userUid = $user;
            break;
        default:
            break;
    }
    if (($action == "todo" || $action == "draft" || $action == "paused" || $action == "sent" || $action == "selfservice" || $action == "unassigned" || $action == "search") && ($solrConf = System::solrEnv()) !== false) {
        G::LoadClass("AppSolr");
        $ApplicationSolrIndex = new AppSolr($solrConf["solr_enabled"], $solrConf["solr_host"], $solrConf["solr_instance"]);
        $data = $ApplicationSolrIndex->getAppGridData($userUid, $start, $limit, $action, $filter, $search, $process, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort, $category);
        $result = G::json_encode($data);
    } else {
        G::LoadClass("applications");
        $apps = new Applications();
        $data = $apps->getAll($userUid, $start, $limit, $action, $filter, $search, $process, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort, $category);
        $result = G::json_encode($data);
    }
    echo $result;
} catch (Exception $e) {
    $msg = array("error" => $e->getMessage());
    echo G::json_encode($msg);
}
Пример #3
0
    public function getAppsData (
        $type,
        $start = null,
        $limit = null,
        $user = null,
        $filter = null,
        $search = null,
        $process = null,
        $status = null,
        $dateFrom = null,
        $dateTo = null,
        $callback = null,
        $dir = null,
        $sort = "APP_CACHE_VIEW.APP_NUMBER",
        $category = null)
    {
        require_once ("classes/model/AppNotes.php");

        $appNotes = new AppNotes();

        $start = empty( $start ) ? $this->appListStart : $start;
        $limit = empty( $limit ) ? $this->appListLimit : $limit;

        $notesStart = 0;
        $notesLimit = 4;
        switch ($user) {
            case 'CURRENT_USER':
                $user = $this->userID;
                break;
            case 'ALL':
                $user = null;
                break;
            case null:
                $user = $this->userID;
                break;
            default:
                //$user = $this->userID;
                break;
        }

        $solrEnabled = false;

        if ((
            $type == "todo" || $type == "draft" || $type == "paused" || $type == "sent" ||
            $type == "selfservice" || $type == "unassigned" || $type == "search"
        ) &&
        (($solrConf = System::solrEnv()) !== false)
        ) {
            G::LoadClass("AppSolr");

            $ApplicationSolrIndex = new AppSolr(
                $solrConf["solr_enabled"],
                $solrConf["solr_host"],
                $solrConf["solr_instance"]
            );

            if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
                //Check if there are missing records to reindex and reindex them
                $ApplicationSolrIndex->synchronizePendingApplications();
                $solrEnabled = true;
            } else{
                $solrEnabled = false;
            }
        }

        if ($solrEnabled) {
            $cases = $ApplicationSolrIndex->getAppGridData(
                $user,
                $start,
                $limit,
                $type,
                $filter,
                $search,
                $process,
                $status,
                '',
                $dateFrom,
                $dateTo,
                $callback,
                $dir,
                $sort,
                $category
            );
        } else {
            G::LoadClass( 'applications' );

            $apps = new Applications();

            $cases = $apps->getAll(
                $user,
                $start,
                $limit,
                $type,
                $filter,
                $search,
                $process,
                $status,
                '',
                $dateFrom,
                $dateTo,
                $callback,
                $dir,
                $sort,
                $category,
                false
            );
        }

        // formating & complitting apps data with 'Notes'
        foreach ($cases['data'] as $i => $row) {
            // Formatting
            $appTitle = str_replace( '#', '', $row['APP_TITLE'] );

            if (is_numeric( $appTitle )) {
                $cases['data'][$i]['APP_TITLE'] = G::LoadTranslation( 'ID_CASE' ) . ' ' . $appTitle;
            }

            if (isset( $row['DEL_DELEGATE_DATE'] )) {
                G::LoadClass( "configuration" );
                $conf = new Configurations();
                $generalConfCasesList = $conf->getConfiguration( 'ENVIRONMENT_SETTINGS', '' );
                $cases['data'][$i]['DEL_DELEGATE_DATE'] = '';
                if (defined('SYS_SYS')) {
                    if (isset( $generalConfCasesList['casesListDateFormat'] ) && ! empty( $generalConfCasesList['casesListDateFormat'] )) {
                        $cases['data'][$i]['DEL_DELEGATE_DATE'] = $conf->getSystemDate($row['DEL_DELEGATE_DATE'], 'casesListDateFormat');
                    }
                }
                if ($cases['data'][$i]['DEL_DELEGATE_DATE'] == '') {
                    $cases['data'][$i]['DEL_DELEGATE_DATE'] = $conf->getSystemDate($row['DEL_DELEGATE_DATE']);
                }
            }
            if (isset( $row['APP_DEL_PREVIOUS_USER'] )) {
                $cases['data'][$i]['APP_DEL_PREVIOUS_USER'] = ucwords( $row['APP_DEL_PREVIOUS_USER'] );
            }
            // Completting with Notes
            $notes = $appNotes->getNotesList( $row['APP_UID'], '', $notesStart, $notesLimit );
            $notes = $notes['array'];

            $cases['data'][$i]['NOTES_COUNT'] = $notes['totalCount'];
            $cases['data'][$i]['NOTES_LIST'] = $notes['notes'];
        }
        return $cases;
    }
Пример #4
0
    /**
     * Get list for Cases
     *
     * @access public
     * @param array $dataList, Data for list
     * @return array
     *
     * @author Brayan Pereyra (Cochalo) <*****@*****.**>
     * @copyright Colosa - Bolivia
     */
    public function getList($dataList = array())
    {
        Validator::isArray($dataList, '$dataList');
        if (!isset($dataList["userId"])) {
            throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId',''))));
        } else {
            Validator::usrUid($dataList["userId"], "userId");
        }

        $user = new \ProcessMaker\BusinessModel\User();

        if (!$user->checkPermission($dataList["userId"], "PM_ALLCASES")) {
            throw new \Exception(\G::LoadTranslation("ID_CASE_USER_NOT_HAVE_PERMISSION", array($dataList["userId"])));
        }

        G::LoadClass("applications");
        $solrEnabled = false;
        $userUid = $dataList["userId"];
        $callback = isset( $dataList["callback"] ) ? $dataList["callback"] : "stcCallback1001";
        $dir = isset( $dataList["dir"] ) ? $dataList["dir"] : "DESC";
        $sort = isset( $dataList["sort"] ) ? $dataList["sort"] : "APP_CACHE_VIEW.APP_NUMBER";
        $start = isset( $dataList["start"] ) ? $dataList["start"] : "0";
        $limit = isset( $dataList["limit"] ) ? $dataList["limit"] : "";
        $filter = isset( $dataList["filter"] ) ? $dataList["filter"] : "";
        $process = isset( $dataList["process"] ) ? $dataList["process"] : "";
        $category = isset( $dataList["category"] ) ? $dataList["category"] : "";
        $status = isset( $dataList["status"] ) ? strtoupper( $dataList["status"] ) : "";
        $user = isset( $dataList["user"] ) ? $dataList["user"] : "";
        $search = isset( $dataList["search"] ) ? $dataList["search"] : "";
        $action = isset( $dataList["action"] ) ? $dataList["action"] : "todo";
        $paged = isset( $dataList["paged"] ) ? $dataList["paged"] : true;
        $type = "extjs";
        $dateFrom = (!empty( $dataList["dateFrom"] )) ? substr( $dataList["dateFrom"], 0, 10 ) : "";
        $dateTo = (!empty( $dataList["dateTo"] )) ? substr( $dataList["dateTo"], 0, 10 ) : "";
        $first = isset( $dataList["first"] ) ? true :false;

        $valuesCorrect = array('todo', 'draft', 'paused', 'sent', 'selfservice', 'unassigned', 'search');
        if (!in_array($action, $valuesCorrect)) {
            throw (new \Exception(\G::LoadTranslation("ID_INCORRECT_VALUE_ACTION")));
        }

        $start = (int)$start;
        $start = abs($start);
        if ($start != 0) {
            $start--;
        }
        $limit = (int)$limit;
        $limit = abs($limit);
        if ($limit == 0) {
            G::LoadClass("configuration");
            $conf = new \Configurations();
            $generalConfCasesList = $conf->getConfiguration('ENVIRONMENT_SETTINGS', '');
            if (isset($generalConfCasesList['casesListRowNumber'])) {
                $limit = (int)$generalConfCasesList['casesListRowNumber'];
            } else {
                $limit = 25;
            }
        } else {
            $limit = (int)$limit;
        }
        if ($sort != 'APP_CACHE_VIEW.APP_NUMBER') {
            $sort = G::toUpper($sort);
            $columnsAppCacheView = \AppCacheViewPeer::getFieldNames(\BasePeer::TYPE_FIELDNAME);
            if (!(in_array($sort, $columnsAppCacheView))) {
                $sort = 'APP_CACHE_VIEW.APP_NUMBER';
            }
        }
        $dir = G::toUpper($dir);
        if (!($dir == 'DESC' || $dir == 'ASC')) {
            $dir = 'DESC';
        }
        if ($process != '') {
            Validator::proUid($process, '$pro_uid');
        }
        if ($category != '') {
            Validator::catUid($category, '$cat_uid');
        }
        $status = G::toUpper($status);
        $listStatus = array('TO_DO', 'DRAFT', 'COMPLETED', 'CANCEL', 'OPEN', 'CLOSE');
        if (!(in_array($status, $listStatus))) {
            $status = '';
        }
        if ($user != '') {
            Validator::usrUid($user, '$usr_uid');
        }
        if ($dateFrom != '') {
            Validator::isDate($dateFrom, 'Y-m-d', '$date_from');
        }
        if ($dateTo != '') {
            Validator::isDate($dateTo, 'Y-m-d', '$date_to');
        }

        if ($action == 'search' || $action == 'to_reassign') {
            $userUid = ($user == "CURRENT_USER") ? $userUid : $user;
            if ($first) {
                $result = array();
                $result['totalCount'] = 0;
                $result['data'] = array();
                return $result;
            }
        }

        if ((
                $action == "todo" || $action == "draft" || $action == "paused" || $action == "sent" ||
                $action == "selfservice" || $action == "unassigned" || $action == "search"
            ) &&
            (($solrConf = \System::solrEnv()) !== false)
        ) {
            G::LoadClass("AppSolr");

            $ApplicationSolrIndex = new \AppSolr(
                $solrConf["solr_enabled"],
                $solrConf["solr_host"],
                $solrConf["solr_instance"]
            );

            if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
                //Check if there are missing records to reindex and reindex them
                $ApplicationSolrIndex->synchronizePendingApplications();
                $solrEnabled = true;
            }
        }

        if ($solrEnabled) {
            $result = $ApplicationSolrIndex->getAppGridData(
                $userUid,
                $start,
                $limit,
                $action,
                $filter,
                $search,
                $process,
                $status,
                $type,
                $dateFrom,
                $dateTo,
                $callback,
                $dir,
                $sort,
                $category
            );
        } else {
            G::LoadClass("applications");
            $apps = new \Applications();
            $result = $apps->getAll(
                $userUid,
                $start,
                $limit,
                $action,
                $filter,
                $search,
                $process,
                $status,
                $type,
                $dateFrom,
                $dateTo,
                $callback,
                $dir,
                (strpos($sort, ".") !== false)? $sort : "APP_CACHE_VIEW." . $sort,
                $category,
                true,
                $paged
            );
        }
        if (!empty($result['data'])) {
            foreach ($result['data'] as &$value) {
                $value = array_change_key_case($value, CASE_LOWER);
            }
        }
        if ($paged == false) {
            $response = $result['data'];
        } else {
            $response['total'] = $result['totalCount'];
            $response['start'] = $start+1;
            $response['limit'] = $limit;
            $response['sort']  = G::toLower($sort);
            $response['dir']   = G::toLower($dir);
            $response['cat_uid']  = $category;
            $response['pro_uid']  = $process;
            $response['search']   = $search;
            if ($action == 'search') {
                $response['app_status'] = G::toLower($status);
                $response['usr_uid'] = $user;
                $response['date_from'] = $dateFrom;
                $response['date_to'] = $dateTo;
            }
            $response['data'] = $result['data'];
        }
        return $response;
    }
Пример #5
0
function getListUids($usrUid, $action)
{
    if (($solrConf = System::solrEnv(SYS_SYS)) !== false) {
        G::LoadClass('AppSolr');
        print "Solr Configuration file: " . PATH_DATA_SITE . "env.ini\n";
        print "solr_enabled: " . $solrConf['solr_enabled'] . "\n";
        print "solr_host: " . $solrConf['solr_host'] . "\n";
        print "solr_instance: " . $solrConf['solr_instance'] . "\n";
        $oAppSolr = new AppSolr($solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance']);
        G::LoadClass("applications");
        $apps = new Applications();
    } else {
        print "Incomplete Solr configuration. See configuration file: " . PATH_DATA_SITE . "env.ini";
        return;
    }
    //get the list of id's
    $userUid = $usrUid;
    $start = 0;
    $limit = 1;
    $action = $action;
    //todo,
    $filter = '';
    $search = '';
    $process = '';
    $user = '';
    $status = '';
    $type = 'extjs';
    $dateFrom = '';
    $dateTo = '';
    $callback = 'stcCallback1001';
    $dir = 'DESC';
    $sort = 'APP_NUMBER';
    $category = '';
    $dataSolr = $oAppSolr->getAppGridData($userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort);
    $dataDB = $apps->getAll($userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort, $category);
    $aAppUidsSolr = array();
    $aAppUidsDB = array();
    $trunkSize = 1000;
    //get DB uids
    print "Get DB Uids \n";
    $totalCasesDB = $dataDB["totalCount"];
    $loops = $totalCasesDB % $trunkSize > 0 ? $totalCasesDB / $trunkSize + 1 : $totalCasesDB / $trunkSize;
    for ($i = 0; $i < $loops; $i++) {
        $start = $i * $trunkSize;
        $limit = $trunkSize;
        //print "  Loop $start to " . (String)($start + $trunkSize) . " \n";
        $dataDB = $apps->getAll($userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort, $category);
        foreach ($dataDB["data"] as $caseDB) {
            $aAppUidsDB[] = $caseDB["APP_UID"];
        }
    }
    //get Solr uids
    print "Get Solr Uids \n";
    $totalCasesSolr = $dataSolr["totalCount"];
    $loops = $totalCasesSolr % $trunkSize > 0 ? $totalCasesSolr / $trunkSize + 1 : $totalCasesSolr / $trunkSize;
    for ($i = 0; $i < $loops; $i++) {
        $start = $i * $trunkSize;
        $limit = $trunkSize;
        //print "  Loop $start to " . (String)($start + $trunkSize) . " \n";
        $dataSolr = $oAppSolr->getAppGridData($userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort);
        foreach ($dataSolr["data"] as $caseSolr) {
            $aAppUidsSolr[] = $caseSolr["APP_UID"];
        }
    }
    $result = array();
    $result['total_cases_db'] = $totalCasesDB;
    $result['aDBAppUids'] = $aAppUidsDB;
    $result['total_cases_solr'] = $totalCasesSolr;
    $result['aSolrAppUids'] = $aAppUidsSolr;
    return $result;
}