BUG 9180 Correct coding convention

Correct coding convention and replace json_encode to G::json_encode and
json_decode to G::json_decode
This commit is contained in:
Herbert Saal Gutierrez
2012-05-30 17:47:28 -04:00
parent 1b2747987e
commit 01d65b3ff1
17 changed files with 1677 additions and 1355 deletions

View File

@@ -8,10 +8,8 @@
// php reindex_solr.php workspacename [reindexall|reindexmissing]
// var_dump($argv);
if (count ($argv) != 3) {
print "Invalid command line arguments: \n syntax: php reindex_solr.php [workspace_name] [reindexall|reindexmissing] \n".
" Where reindexall : reindex all the database \n".
" reindexmissing: reindex only the missing records stored in database.\n";
die;
print "Invalid command line arguments: \n syntax: php reindex_solr.php [workspace_name] [reindexall|reindexmissing] \n" . " Where reindexall : reindex all the database \n" . " reindexmissing: reindex only the missing records stored in database.\n";
die ();
}
$workspaceName = $argv [1];
$ScriptAction = $argv [2];
@@ -217,7 +215,8 @@ else {
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
// '0', 'sLastExecution' => date('Y-m-d H:i:s'))));
function processWorkspace() {
function processWorkspace()
{
global $sLastExecution;
global $ScriptAction;
@@ -248,7 +247,8 @@ function processWorkspace() {
}
}
function saveLog($sSource, $sType, $sDescription) {
function saveLog($sSource, $sType, $sDescription)
{
try {
global $isDebug;
if ($isDebug)
@@ -270,7 +270,8 @@ function saveLog($sSource, $sType, $sDescription) {
}
}
function setExecutionMessage($m) {
function setExecutionMessage($m)
{
$len = strlen ($m);
$linesize = 60;
$rOffset = $linesize - $len;
@@ -280,7 +281,8 @@ function setExecutionMessage($m) {
eprint ('.');
}
function setExecutionResultMessage($m, $t = '') {
function setExecutionResultMessage($m, $t = '')
{
$c = 'green';
if ($t == 'error')
$c = 'red';

View File

@@ -1,4 +1,27 @@
<?php
/**
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2012 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 5304 Ventura Drive,
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
*
*/
require_once "classes/model/Application.php";
require_once "classes/model/AppDelegation.php";
require_once "classes/model/AppThread.php";
@@ -13,93 +36,132 @@ require_once "entities/SolrUpdateDocument.php";
require_once "entities/AppSolrQueue.php";
require_once "classes/model/AppSolrQueue.php";
/**
* Invalid search text for Solr exception
*
* @author Herbert Saal Gutierrez
*
*/
class InvalidIndexSearchTextException extends Exception {
class InvalidIndexSearchTextException extends Exception
{
// Redefine the exception so message isn't optional
public function __construct($message, $code = 0) {
public function __construct($message, $code = 0)
{
// some code
// make sure everything is assigned properly
parent::__construct ($message, $code);
}
// custom string representation of object
public function __toString() {
public function __toString()
{
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
}
/**
* Application without Delegations exception
*
* @author Herbert Saal Gutierrez
*
* @category Colosa
* @copyright Copyright (c) 2005-2011 Colosa Inc. (http://www.colosa.com)
*/
class ApplicationWithoutDelegationRecordsException extends Exception {
class ApplicationWithoutDelegationRecordsException extends Exception
{
// Redefine the exception so message isn't optional
public function __construct($message, $code = 0) {
public function __construct($message, $code = 0)
{
// some code
// make sure everything is assigned properly
parent::__construct ($message, $code);
}
// custom string representation of object
public function __toString() {
public function __toString()
{
return __CLASS__ . ": [{$this->code}]: {$this->message}\n";
}
}
/**
* Implementation to display application data in the PMOS2 grids using Solr search service
* Implementation to display application data in the PMOS2 grids using Solr
* search service
*
* @author Herbert Saal Gutierrez
* @category Colosa
* @copyright Copyright (c) 2005-2011 Colosa Inc. (http://www.colosa.com)
*
*/
class AppSolr {
private $solrIsEnabled = false;
private $solrHost = "";
private $solrInstance = "";
class AppSolr
{
private $_solrIsEnabled = false;
private $_solrHost = "";
private $_solrInstance = "";
function __construct($SolrEnabled, $SolrHost, $SolrInstance) {
public function __construct($SolrEnabled, $SolrHost, $SolrInstance)
{
// define solr availability
$this->solrIsEnabled = $SolrEnabled;
$this->solrHost = $SolrHost;
$this->solrInstance = $SolrInstance;
$this->_solrIsEnabled = $SolrEnabled;
$this->_solrHost = $SolrHost;
$this->_solrInstance = $SolrInstance;
}
public function isSolrEnabled() {
return $this->solrIsEnabled;
/**
* Return if the Solr functionality is enabled.
* @return boolean true:enabled functionality, false:disabled functionality
*/
public function isSolrEnabled()
{
return $this->_solrIsEnabled;
}
/**
* Gets the information of Grids using Solr server.
*
* Returns the list of records for the grid depending of the function conditions
* Returns the list of records for the grid depending of the function
* conditions
* If doCount is true only the count of records is returned.
*
* @param string $userUid current logged user.
* @param int $start the offset to return the group of records. Used for pagination.
* @param int $limit The number of records to return in the set.
* @param string $action the action: todo, participated, draft, unassigned
* @param string $filter filter the results posible values ('read', 'unread', 'started', 'completed')
* @param string $search search string
* @param string $process PRO_UID to filter results by specified process.
* @param string $user USR_UID to filter results by specified user.
* @param string $status filter by an application Status : TO_DO, COMPLETED, DRAFT
* @param string $type default extjs
* @param string $dateFrom filter by DEL_DELEGATE_DATE, not used
* @param string $dateTo filter by DEL_DELEGATE_DATE, not used
* @param string $callback default stcCallback1001 not used
* @param string $dir sort direction ASC, DESC
* @param string $sort sort field
* @param boolean $doCount default=false, if true only the count of records is returned.
* @param string $userUid
* current logged user.
* @param int $start
* the offset to return the group of records. Used for pagination.
* @param int $limit
* The number of records to return in the set.
* @param string $action
* the action: todo, participated, draft, unassigned
* @param string $filter
* filter the results posible values ('read', 'unread', 'started',
* 'completed')
* @param string $search
* search string
* @param string $process
* PRO_UID to filter results by specified process.
* @param string $user
* USR_UID to filter results by specified user.
* @param string $status
* filter by an application Status : TO_DO, COMPLETED, DRAFT
* @param string $type
* default extjs
* @param string $dateFrom
* filter by DEL_DELEGATE_DATE, not used
* @param string $dateTo
* filter by DEL_DELEGATE_DATE, not used
* @param string $callback
* default stcCallback1001 not used
* @param string $dir
* sort direction ASC, DESC
* @param string $sort
* sort field
* @param boolean $doCount
* default=false, if true only the count of records is returned.
* @return array return the list of cases
*/
public function getAppGridData($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) {
public function getAppGridData($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)
{
$callback = isset ($callback) ? $callback : 'stcCallback1001';
$dir = isset ($dir) ? $dir : 'DESC'; // direction of sort column
@@ -319,7 +381,7 @@ class AppSolr {
}
$data = array (
'workspace' => $this->solrInstance, // solr instance
'workspace' => $this->_solrInstance, // solr instance
'startAfter' => intval ($start),
'pageSize' => intval ($limit),
'searchText' => $solrSearchText,
@@ -333,9 +395,9 @@ class AppSolr {
'resultFormat' => 'json'
);
$solrRequestData = Entity_SolrRequestData::CreateForRequestPagination ( $data );
$solrRequestData = Entity_SolrRequestData::createForRequestPagination ($data);
// use search index to return list of cases
$searchIndex = new BpmnEngine_Services_SearchIndex ( $this->solrIsEnabled, $this->solrHost );
$searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
// execute query
$solrQueryResult = $searchIndex->getDataTablePaginatedList ($solrRequestData);
@@ -457,32 +519,41 @@ class AppSolr {
/**
* Get the array of counters of cases
* @param string $userUid the current logged user uid identifier
*
* @param string $userUid
* the current logged user uid identifier
*/
function getCasesCount($userUid){
public function getCasesCount($userUid)
{
$casesCount = array ();
// get number of records in todo list
$data = $this->getAppGridData($userUid, 0, 0, 'todo', null, null, null, null, null, null,
null, null, null, null, null, true);
$data = $this->getAppGridData ($userUid, 0, 0, 'todo', null, null, null, null, null,
null, null, null, null, null, null, true);
$casesCount ['to_do'] = $data ['totalCount'];
// get number of records in participated list
$data = $this->getAppGridData($userUid, 0, 0, 'sent', null, null, null, null, null, null,
null, null, null, null, null, true);
$data = $this->getAppGridData ($userUid, 0, 0, 'sent', null, null, null, null, null,
null, null, null, null, null, null, true);
$casesCount ['sent'] = $data ['totalCount'];
// get number of records in draft list
$data = $this->getAppGridData($userUid, 0, 0, 'draft', null, null, null, null, null, null,
null, null, null, null, null, true);
$data = $this->getAppGridData ($userUid, 0, 0, 'draft', null, null, null, null, null,
null, null, null, null, null, null, true);
$casesCount ['draft'] = $data ['totalCount'];
// get number of records in unassigned list
$data = $this->getAppGridData($userUid, 0, 0, 'unassigned', null, null, null, null, null, null,
null, null, null, null, null, true);
$data = $this->getAppGridData ($userUid, 0, 0, 'unassigned', null, null, null, null,
null, null, null, null, null, null, null, true);
$casesCount ['selfservice'] = $data ['totalCount'];
return $casesCount;
}
function getUserGroups($usrUID) {
/**
* Get the user groups
* @param string $usrUID the user identifier
* @return array of user groups
*/
public function getUserGroups($usrUID)
{
$gu = new GroupUser ();
$rows = $gu->getAllUserGroups ($usrUID);
return $rows;
@@ -490,11 +561,15 @@ class AppSolr {
/**
* Get the application delegation record from database
* @param string $appUID Application identifier
* @param string $delIndex delegation index
*
* @param string $appUID
* Application identifier
* @param string $delIndex
* delegation index
* @return array with delegation record.
*/
function getAppDelegationData($appUID, $delIndex) {
public function getAppDelegationData($appUID, $delIndex)
{
$c = new Criteria ();
@@ -595,7 +670,8 @@ class AppSolr {
* @param string $plainSearchText
* @return string formated Solr search string.
*/
function getSearchText($plainSearchText) {
public function getSearchText($plainSearchText)
{
$formattedSearchText = "";
// if an error is found in string null is returned
$includeToken = true;
@@ -628,14 +704,14 @@ class AppSolr {
// cache the index fields
G::LoadClass ('PMmemcached');
$oMemcache = PMmemcached::getSingleton ( $this->solrInstance );
$oMemcache = PMmemcached::getSingleton ($this->_solrInstance);
$ListFieldsInfo = $oMemcache->get ('Solr_Index_Fields');
if (! $ListFieldsInfo) {
G::LoadClass ('searchIndex');
$searchIndex = new BpmnEngine_Services_SearchIndex ( $this->solrIsEnabled, $this->solrHost );
$searchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
// execute query
$ListFieldsInfo = $searchIndex->getIndexFields ( $this->solrInstance );
$ListFieldsInfo = $searchIndex->getIndexFields ($this->_solrInstance);
// cache
$oMemcache->set ('Solr_Index_Fields', $ListFieldsInfo);
@@ -645,7 +721,9 @@ class AppSolr {
$tok = strtok ($plainSearchText, " ");
while ($tok !== false) {
$fieldName = substr($tok, 0, strpos($tok, ":")); //strstr ( $tok, ":", true ); php 5.3
$fieldName = substr ($tok, 0, strpos ($tok, ":")); // strstr ( $tok,
// ":",
// true ); php 5.3
$searchText = strstr ($tok, ":");
// verify if there's a field definition
@@ -750,16 +828,20 @@ class AppSolr {
if ($fromDateOriginal != '*') {
// TODO complete date creation
//list($year, $month, $day) = sscanf($fromDateOriginal, '%04d/%02d/%02d');
// list($year, $month, $day) = sscanf($fromDateOriginal,
// '%04d/%02d/%02d');
// $fromDateDatetime = new DateTime($fromDateOriginal);
//$fromDateDatetime = date_create_from_format ( 'Y-m-d', $fromDateOriginal );
// $fromDateDatetime = date_create_from_format ( 'Y-m-d',
// $fromDateOriginal );
// $fromDateDatetime->getTimestamp ()
$fromDate = gmdate ("Y-m-d\T00:00:00\Z", strtotime ($fromDateOriginal));
}
if ($toDateOriginal != '*') {
//list($year, $month, $day) = sscanf($fromDateOriginal, '%04d/%02d/%02d');
// list($year, $month, $day) = sscanf($fromDateOriginal,
// '%04d/%02d/%02d');
// $toDateDatetime = new DateTime($toDateOriginal);
//$toDateDatetime = date_create_from_format ( 'Y-m-d', $toDateOriginal );
// $toDateDatetime = date_create_from_format ( 'Y-m-d',
// $toDateOriginal );
$toDate = gmdate ("Y-m-d\T00:00:00\Z", strtotime ($fromDateOriginal));
}
$searchText = ":[" . $fromDate . " TO " . $toDate . "]";
@@ -786,10 +868,13 @@ class AppSolr {
/**
* Get all the application delegation records from database
* @param string $appUID Application identifier
*
* @param string $appUID
* Application identifier
* @return array delegation records
*/
function getApplicationDelegationsIndex($appUID) {
public function getApplicationDelegationsIndex($appUID)
{
$delIndexes = array ();
$c = new Criteria ();
@@ -815,10 +900,13 @@ class AppSolr {
/**
* Update the information of the specified applications in Solr
* @param array $aaAPPUIDs Array of arrays of App_UID that must be updated,
*
* @param array $aaAPPUIDs
* Array of arrays of App_UID that must be updated,
* APP_UID is permitted also
*/
function updateApplicationSearchIndex($aaAPPUIDs) {
public function updateApplicationSearchIndex($aaAPPUIDs)
{
if (empty ($aaAPPUIDs))
return;
@@ -842,28 +930,30 @@ class AppSolr {
// update document
$data = array (
'workspace' => $this->solrInstance,
'workspace' => $this->_solrInstance,
'document' => $xmlDoc
);
$oSolrUpdateDocument = Entity_SolrUpdateDocument::CreateForRequest ( $data );
$oSolrUpdateDocument = Entity_SolrUpdateDocument::createForRequest ($data);
G::LoadClass ('searchIndex');
$oSearchIndex = new BpmnEngine_Services_SearchIndex ( $this->solrIsEnabled, $this->solrHost );
$oSearchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
$oSearchIndex->updateIndexDocument ($oSolrUpdateDocument);
// commit changes
$oSearchIndex->commitIndexChanges ( $this->solrInstance );
$oSearchIndex->commitIndexChanges ($this->_solrInstance);
}
/**
* Delete the specified application record from Solr
*
* @param string $appUID Application identifier
* @param string $appUID
* Application identifier
*/
function deleteApplicationSearchIndex($appUID) {
public function deleteApplicationSearchIndex($appUID)
{
if (empty ($appUID))
return;
@@ -877,21 +967,25 @@ class AppSolr {
G::LoadClass ('searchIndex');
$oSearchIndex = new BpmnEngine_Services_SearchIndex ( $this->solrIsEnabled, $this->solrHost );
$oSearchIndex = new BpmnEngine_Services_SearchIndex ($this->_solrIsEnabled, $this->_solrHost);
$oSearchIndex->deleteDocumentFromIndex ( $this->solrInstance, $idQuery );
$oSearchIndex->deleteDocumentFromIndex ($this->_solrInstance, $idQuery);
// commit changes
$oSearchIndex->commitIndexChanges ( $this->solrInstance );
$oSearchIndex->commitIndexChanges ($this->_solrInstance);
}
/**
* Create XML data in Solr format of the specified applications
* this function uses the buildSearchIndexDocumentPMOS2 function to create each record
* @param array $aaAPPUIDs array of arrays of application identifiers
* this function uses the buildSearchIndexDocumentPMOS2 function to create
* each record
*
* @param array $aaAPPUIDs
* array of arrays of application identifiers
* @return string The resulting XML document in Solr format
*/
function createSolrXMLDocument($aaAPPUIDs) {
public function createSolrXMLDocument($aaAPPUIDs)
{
// search data from DB
$xmlDoc = "<?xml version='1.0' encoding='UTF-8'?>\n";
$xmlDoc .= "<add>\n";
@@ -920,7 +1014,10 @@ class AppSolr {
$unassignedGroups = $result [12];
// create document
$xmlDoc .= $this->buildSearchIndexDocumentPMOS2 ( $documentInformation, $dynaformFieldTypes, $lastUpdateDate, $maxPriority, $assignedUsers, $assignedUsersRead, $assignedUsersUnread, $draftUser, $participatedUsers, $participatedUsersStartedByUser, $participatedUsersCompletedByUser, $unassignedUsers, $unassignedGroups );
$xmlDoc .= $this->buildSearchIndexDocumentPMOS2 ($documentInformation, $dynaformFieldTypes,
$lastUpdateDate, $maxPriority, $assignedUsers, $assignedUsersRead, $assignedUsersUnread,
$draftUser, $participatedUsers, $participatedUsersStartedByUser, $participatedUsersCompletedByUser,
$unassignedUsers, $unassignedGroups);
}
@@ -972,10 +1069,11 @@ class AppSolr {
* $participatedUsersCompletedByUser,
* $unassignedUsers, $unassignedGroups);*
*/
function buildSearchIndexDocumentPMOS2($documentData, $dynaformFieldTypes, $lastUpdateDate,
public function buildSearchIndexDocumentPMOS2($documentData, $dynaformFieldTypes, $lastUpdateDate,
$maxPriority, $assignedUsers, $assignedUsersRead, $assignedUsersUnread, $draftUser,
$participatedUsers, $participatedUsersStartedByUser, $participatedUsersCompletedByUser,
$unassignedUsers, $unassignedGroups) {
$unassignedUsers, $unassignedGroups)
{
// build xml document
$writer = new XMLWriter ();
@@ -1215,19 +1313,13 @@ class AppSolr {
// try to convert string to date
// TODO convert to php 5.2 format
/*
$newdate = date_create_from_format ( 'Y-m-d H:i:s', $value );
if (! $newdate) {
$newdate = date_create_from_format ( 'Y-m-d', $value );
$withHour = false;
}
if (! $newdate) {
$newdate = date_create_from_format ( 'd/m/Y', $value );
$withHour = false;
}
if (! $newdate) {
$newdate = date_create_from_format ( 'j/m/Y', $value );
$withHour = false;
}
* $newdate = date_create_from_format ( 'Y-m-d H:i:s', $value
* ); if (! $newdate) { $newdate = date_create_from_format (
* 'Y-m-d', $value ); $withHour = false; } if (! $newdate) {
* $newdate = date_create_from_format ( 'd/m/Y', $value );
* $withHour = false; } if (! $newdate) { $newdate =
* date_create_from_format ( 'j/m/Y', $value ); $withHour =
* false; }
*/
$newdate = strtotime ($value);
if (! $newdate) {
@@ -1236,12 +1328,11 @@ class AppSolr {
else {
$typeSufix = '_tdt';
/*
if ($withHour)
//$value = gmdate ( "Y-m-d\TH:i:s\Z", $newdate->getTimestamp () );
$value = gmdate ( "Y-m-d\TH:i:s\Z", $newdate );
else {
$value = gmdate ( "Y-m-d\T00:00:00\Z", $newdate );
}*/
* if ($withHour) //$value = gmdate ( "Y-m-d\TH:i:s\Z",
* $newdate->getTimestamp () ); $value = gmdate (
* "Y-m-d\TH:i:s\Z", $newdate ); else { $value = gmdate (
* "Y-m-d\T00:00:00\Z", $newdate ); }
*/
$value = gmdate ("Y-m-d\T00:00:00\Z", $newdate);
}
break;
@@ -1307,24 +1398,27 @@ class AppSolr {
/**
* Search records in specified application delegation data
* @param string $AppUID application identifier
*
* @param string $AppUID
* application identifier
* @throws ApplicationWithoutDelegationRecordsException
* @return array array of arrays with the following information(
$documentInformation,
$dynaformFieldTypes,
$lastUpdateDate,
$maxPriority,
$assignedUsers,
$assignedUsersRead,
$assignedUsersUnread,
$draftUser,
$participatedUsers,
$participatedUsersStartedByUser,
$participatedUsersCompletedByUser,
$unassignedUsers,
$unassignedGroups
* $documentInformation,
* $dynaformFieldTypes,
* $lastUpdateDate,
* $maxPriority,
* $assignedUsers,
* $assignedUsersRead,
* $assignedUsersUnread,
* $draftUser,
* $participatedUsers,
* $participatedUsersStartedByUser,
* $participatedUsersCompletedByUser,
* $unassignedUsers,
* $unassignedGroups
*/
function getApplicationIndexData($AppUID) {
public function getApplicationIndexData($AppUID)
{
G::LoadClass ('memcached');
// get all the application data
@@ -1448,7 +1542,7 @@ class AppSolr {
foreach ($allAppDbData as $row) {
$unassignedUsersGroups = array ();
// use cache
$oMemcache = PMmemcached::getSingleton ( $this->solrInstance );
$oMemcache = PMmemcached::getSingleton ($this->_solrInstance);
$unassignedUsersGroups = $oMemcache->get ($row ['PRO_UID'] . "_" . $row ['TAS_UID']);
if (! $unassignedUsersGroups) {
@@ -1488,7 +1582,7 @@ class AppSolr {
// process
$dynaformFieldTypes = array ();
// get cache instance
$oMemcache = PMmemcached::getSingleton ( $this->solrInstance );
$oMemcache = PMmemcached::getSingleton ($this->_solrInstance);
$dynaformFieldTypes = $oMemcache->get ($documentInformation ['PRO_UID']);
if (! $dynaformFieldTypes) {
G::LoadClass ('dynaformhandler');
@@ -1542,14 +1636,22 @@ class AppSolr {
/**
* Find the maximun value of the specified column in the array and return the
* row index
* @param array $arr array of arrays with the data
* @param string $column column name to search in
* @param string $columnType column type STRING, NUMBER, DATE
* @param string $columnCondition column condition
* @param string $condition the condition
*
* @param array $arr
* array of arrays with the data
* @param string $column
* column name to search in
* @param string $columnType
* column type STRING, NUMBER, DATE
* @param string $columnCondition
* column condition
* @param string $condition
* the condition
* @return integer The index of the maximun record in array
*/
function aaGetMaximun($arr, $column, $columnType = 'STRING', $columnCondition = "", $condition = "") {
public function aaGetMaximun($arr, $column, $columnType = 'STRING',
$columnCondition = "", $condition = "")
{
// get first value
$auxValue = $arr [0] [$column];
$index = null;
@@ -1581,14 +1683,21 @@ class AppSolr {
/**
* Get minimum of array of arrays
*
* @param array $arr array of arrays with the data
* @param string $column the name of the column to search in
* @param string $columnType the column type STRING, NUMBER, DATE
* @param string $columnCondition the column condition
* @param string $condition the condition
* @param array $arr
* array of arrays with the data
* @param string $column
* the name of the column to search in
* @param string $columnType
* the column type STRING, NUMBER, DATE
* @param string $columnCondition
* the column condition
* @param string $condition
* the condition
* @return Ambigous <NULL, unknown> Index of the minimun value found
*/
function aaGetMinimun($arr, $column, $columnType = 'STRING', $columnCondition = "", $condition = "") {
public function aaGetMinimun($arr, $column, $columnType = 'STRING',
$columnCondition = "", $condition = "")
{
// get first value
$auxValue = $arr [0] [$column];
$index = null;
@@ -1627,7 +1736,8 @@ class AppSolr {
* contain the conditions that must fullfill 'Column'=>'Condition'
* @return array array of indexes with the found records
*/
function aaSearchRecords($arr, $andColumnsConditions) {
public function aaSearchRecords($arr, $andColumnsConditions)
{
$indexes = array ();
$isEqual = true;
foreach ($arr as $i => $row) {
@@ -1673,10 +1783,13 @@ class AppSolr {
/**
* Get application and delegation data from database
* @param string $AppUID the application identifier
*
* @param string $AppUID
* the application identifier
* @return array of records from database
*/
function getApplicationDelegationData($AppUID) {
public function getApplicationDelegationData($AppUID)
{
$allAppDbData = array ();
@@ -1783,12 +1896,17 @@ class AppSolr {
}
/**
* Get the list of groups of unassigned users of the specified task from database
* @param string $ProUID Process identifier
* @param string $TaskUID task identifier
* Get the list of groups of unassigned users of the specified task from
* database
*
* @param string $ProUID
* Process identifier
* @param string $TaskUID
* task identifier
* @return array of unassigned user groups
*/
function getTaskUnassignedUsersGroupsData($ProUID, $TaskUID) {
public function getTaskUnassignedUsersGroupsData($ProUID, $TaskUID)
{
$unassignedUsersGroups = array ();
$c = new Criteria ();
@@ -1828,10 +1946,13 @@ class AppSolr {
/**
* Get the list of dynaform file names associated with the specified process
* from database
* @param string $ProUID process identifier
*
* @param string $ProUID
* process identifier
* @return array of dynaform file names
*/
function getProcessDynaformFileNames($ProUID) {
public function getProcessDynaformFileNames($ProUID)
{
$dynaformFileNames = array ();
$c = new Criteria ();
@@ -1858,11 +1979,13 @@ class AppSolr {
* Store a flag indicating if the application was updated in database
* table APP_SOLR_QUEUE
*
* @param string $AppUid applicatiom identifier
* @param string $AppUid
* applicatiom identifier
* @param integer $updated
* 0:false, not updated, 1: updated, 2:deleted
*/
function applicationChangedUpdateSolrQueue($AppUid, $updated) {
public function applicationChangedUpdateSolrQueue($AppUid, $updated)
{
$oAppSolrQueue = new AppSolrQueue ();
$oAppSolrQueue->createUpdate ($AppUid, $updated);
@@ -1871,7 +1994,8 @@ class AppSolr {
/**
* Update application records in Solr that are stored in APP_SOLR_QUEUE table
*/
function synchronizePendingApplications() {
public function synchronizePendingApplications()
{
// check table of pending updates
$oAppSolrQueue = new AppSolrQueue ();
@@ -1886,9 +2010,11 @@ class AppSolr {
/**
* Get the total number of application records in database
*
* @return application counter
*/
function getCountApplicationsPMOS2() {
public function getCountApplicationsPMOS2()
{
$c = new Criteria ();
$c->addSelectColumn (ApplicationPeer::APP_UID);
@@ -1900,11 +2026,15 @@ class AppSolr {
/**
* Get a paginated list of application uids from database.
* @param integer $skip the offset from where to return the application records
* @param integer $pagesize the size of the page
*
* @param integer $skip
* the offset from where to return the application records
* @param integer $pagesize
* the size of the page
* @return array of application id's in the specified page.
*/
function getPagedApplicationUids($skip, $pagesize) {
public function getPagedApplicationUids($skip, $pagesize)
{
$c = new Criteria ();
@@ -1930,7 +2060,8 @@ class AppSolr {
* Reindex all the application records in Solr server
* update applications in groups of 1000
*/
function reindexAllApplications() {
public function reindexAllApplications()
{
$trunk = 1000;
// delete all documents to begin reindex
// deleteAllDocuments();

View File

@@ -1,4 +1,26 @@
<?php
/**
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2012 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 5304 Ventura Drive,
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
*
*/
/**
@@ -7,23 +29,26 @@
* @author Herbert Saal Gutierrez
*
*/
Class BpmnEngine_Services_SearchIndex
class BpmnEngine_Services_SearchIndex
{
private $solrIsEnabled = false;
private $solrHost = "";
private $_solrIsEnabled = false;
private $_solrHost = "";
function __construct($solrIsEnabled = false, $solrHost = ""){
function __construct($solrIsEnabled = false, $solrHost = "")
{
// check if Zend Library is available
// if(class_exists("Zend_Registry")){
// $registry = Zend_Registry::getInstance();
// //check if configuration is enabled
// $this->solrIsEnabled = $registry->isRegistered('solrEnabled') && $registry->get('solrEnabled') == 1;
// $this->solrHost = $registry->isRegistered('solrHost')?$registry->get('solrHost'):"";
// $this->solrIsEnabled = $registry->isRegistered('solrEnabled') &&
// $registry->get('solrEnabled') == 1;
// $this->solrHost =
// $registry->isRegistered('solrHost')?$registry->get('solrHost'):"";
// }
// else{
// //use the parameters to initialize class
$this->solrIsEnabled = $solrIsEnabled;
$this->solrHost = $solrHost;
$this->_solrIsEnabled = $solrIsEnabled;
$this->_solrHost = $solrHost;
// }
}
/**
@@ -33,36 +58,43 @@ Class BpmnEngine_Services_SearchIndex
* @background = false
*
* no input parameters @param[in]
* @param[out] bool true if index service is enabled false in other case
*
* @param
* [out] bool true if index service is enabled false in other case
*/
public function isEnabled()
{
//require_once (ROOT_PATH . '/businessLogic/modules/SearchIndexAccess/Solr.php');
// require_once (ROOT_PATH .
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
require_once ('class.solr.php');
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
return $solr->isEnabled ();
}
/**
* Get the list of facets in base to the specified query and filter
* @gearman = true
* @rest = false
* @background = false
*
* @param[in] Entity_FacetRequest facetRequestEntity Facet request entity
* @param[out] array FacetGroup
* @param
* [in] Entity_FacetRequest facetRequestEntity Facet request entity
* @param
* [out] array FacetGroup
*/
function getFacetsList($facetRequestEntity)
public function getFacetsList($facetRequestEntity)
{
require_once ('class.solr.php');
//require_once (ROOT_PATH . '/businessLogic/modules/SearchIndexAccess/Solr.php');
// require_once (ROOT_PATH .
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
require_once ('entities/FacetGroup.php');
require_once ('entities/FacetItem.php');
require_once ('entities/SelectedFacetGroupItem.php');
require_once ('entities/FacetResult.php');
/******************************************************************/
/**
* ***************************************************************
*/
// get array of selected facet groups
$facetRequestEntity->selectedFacetsString = str_replace (',,', ',', $facetRequestEntity->selectedFacetsString);
// remove descriptions of selected facet groups
@@ -72,8 +104,7 @@ Class BpmnEngine_Services_SearchIndex
$aGroups = array_filter ($aGroups); // remove empty items
$aSelectedFacetGroups = array ();
foreach($aGroups as $i => $value)
{
foreach ($aGroups as $i => $value) {
$gi = explode (':::', $value);
$gr = explode ('::', $gi [0]);
$it = explode ('::', $gi [1]);
@@ -81,8 +112,7 @@ Class BpmnEngine_Services_SearchIndex
// create string for remove condition
$count = 0;
$removeCondition = str_replace ($value . ',', '', $facetRequestEntity->selectedFacetsString, $count);
if($count == 0)
{
if ($count == 0) {
$removeCondition = str_replace ($value, '', $facetRequestEntity->selectedFacetsString, $count);
}
$selectedFacetGroupData = array (
@@ -93,29 +123,38 @@ Class BpmnEngine_Services_SearchIndex
'selectedFacetRemoveCondition' => $removeCondition
);
$aSelectedFacetGroups[] = Entity_SelectedFacetGroupItem::CreateForRequest($selectedFacetGroupData);
$aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest ($selectedFacetGroupData);
}
/******************************************************************/
/**
* ***************************************************************
*/
// convert request to index request
// create filters
$filters = array ();
if (! empty ($aSelectedFacetGroups)) {
//exclude facetFields and facetDates included in filter from the next list of facets
// exclude facetFields and facetDates included in filter from the next
// list of facets
foreach ($aSelectedFacetGroups as $value) {
$facetRequestEntity->facetFields = array_diff($facetRequestEntity->facetFields, array($value->selectedFacetGroupName));
$facetRequestEntity->facetDates = array_diff($facetRequestEntity->facetDates, array($value->selectedFacetGroupName));
$facetRequestEntity->facetFields = array_diff ($facetRequestEntity->facetFields, array (
$value->selectedFacetGroupName
));
$facetRequestEntity->facetDates = array_diff ($facetRequestEntity->facetDates, array (
$value->selectedFacetGroupName
));
}
//$facetFields = array_diff($facetFields, $facetInterfaceRequestEntity->selectedFacetGroups);
//$facetDates = array_diff($facetDates, $facetInterfaceRequestEntity->selectedFacetGroups);
// $facetFields = array_diff($facetFields,
// $facetInterfaceRequestEntity->selectedFacetGroups);
// $facetDates = array_diff($facetDates,
// $facetInterfaceRequestEntity->selectedFacetGroups);
foreach ($aSelectedFacetGroups as $group) {
$filters [] = $group->selectedFacetGroupName . ':' . urlencode ($group->selectedFacetItemName);
}
}
$facetRequestEntity->filters = $filters;
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
// create list of facets
$facetsList = $solr->getFacetsList ($facetRequestEntity);
@@ -126,54 +165,56 @@ Class BpmnEngine_Services_SearchIndex
$facetGroups = array ();
// convert facet fields result to objects
/************************************************************************/
/**
* *********************************************************************
*/
// include facet field results
$facetFieldsResult = $facetsList ['facet_counts'] ['facet_fields'];
if(!empty($facetFieldsResult))
{
foreach($facetFieldsResult as $facetGroup => $facetvalues)
{
if (! empty ($facetFieldsResult)) {
foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
if (count ($facetvalues) > 0) // if the group have facets included
{
$data = array('facetGroupName' => $facetGroup);
$data = array (
'facetGroupName' => $facetGroup
);
$data ['facetGroupPrintName'] = $facetGroup;
$data ['facetGroupType'] = 'field';
$facetItems = array ();
for($i = 0; $i < count($facetvalues) ; $i+=2)
{
for ($i = 0; $i < count ($facetvalues); $i += 2) {
$dataItem = array ();
$dataItem ['facetName'] = $facetvalues [$i];
$dataItem ['facetPrintName'] = $facetvalues [$i];
$dataItem ['facetCount'] = $facetvalues [$i + 1];
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
$newFacetItem = Entity_FacetItem::CreateForInsert($dataItem);
$newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
$facetItems [] = $newFacetItem;
}
$data ['facetItems'] = $facetItems;
$newFacetGroup = Entity_FacetGroup::CreateForInsert($data);
$newFacetGroup = Entity_FacetGroup::createForInsert ($data);
$facetGroups [] = $newFacetGroup;
}
}
}
/************************************************************************/
/**
* *********************************************************************
*/
// include facet date ranges results
$facetDatesResult = $facetsList ['facet_counts'] ['facet_dates'];
if(!empty($facetDatesResult))
if (! empty ($facetDatesResult)) {
foreach ($facetDatesResult as $facetGroup => $facetvalues) {
if (count ($facetvalues) > 3) // if the group have any facets included
// besides start, end and gap
{
foreach($facetDatesResult as $facetGroup => $facetvalues)
{
if(count($facetvalues) > 3) //if the group have any facets included besides start, end and gap
{
$data = array('facetGroupName' => $facetGroup);
$data = array (
'facetGroupName' => $facetGroup
);
$data ['facetGroupPrintName'] = $facetGroup;
$data ['facetGroupType'] = 'daterange';
$facetItems = array ();
$facetvalueskeys = array_keys ($facetvalues);
foreach ($facetvalueskeys as $i => $k)
{
if($k != 'gap' && $k != 'start' && $k != 'end')
{
foreach ($facetvalueskeys as $i => $k) {
if ($k != 'gap' && $k != 'start' && $k != 'end') {
$dataItem = array ();
if ($i < count ($facetvalueskeys) - 4) {
@@ -188,13 +229,13 @@ Class BpmnEngine_Services_SearchIndex
$dataItem ['facetCount'] = $facetvalues [$k];
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
$newFacetItem = Entity_FacetItem::CreateForInsert($dataItem);
$newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
$facetItems [] = $newFacetItem;
}
}
$data ['facetItems'] = $facetItems;
$newFacetGroup = Entity_FacetGroup::CreateForInsert($data);
$newFacetGroup = Entity_FacetGroup::createForInsert ($data);
$facetGroups [] = $newFacetGroup;
}
@@ -202,32 +243,44 @@ Class BpmnEngine_Services_SearchIndex
}
// TODO:convert facet queries
// -----
/******************************************************************/
/**
* ***************************************************************
*/
// Create a filter string used in the filter of results of a datatable
$filterText = ''; //the list of selected filters used for filtering result, send in ajax
foreach($aSelectedFacetGroups as $selectedFacetGroup)
{
$filterText = ''; // the list of selected filters used for filtering result,
// send in ajax
foreach ($aSelectedFacetGroups as $selectedFacetGroup) {
$filterText .= $selectedFacetGroup->selectedFacetGroupName . ':' . urlencode ($selectedFacetGroup->selectedFacetItemName) . ',';
}
$filterText = substr_replace ($filterText, '', - 1);
// $filterText = ($filterText == '')?'':'&filterText='.$filterText;
/******************************************************************/
/**
* ***************************************************************
*/
// Create result
$dataFacetResult = array (
'aFacetGroups' => $facetGroups,
'aSelectedFacetGroups' => $aSelectedFacetGroups,
'sFilterText' => $filterText
);
$facetResult = Entity_FacetResult::CreateForRequest($dataFacetResult);
$facetResult = Entity_FacetResult::createForRequest ($dataFacetResult);
return $facetResult;
}
function getNumberDocuments($workspace){
/**
* Get the total number of documents in search server
* @param string $workspace
* @return integer number of documents
*
*/
public function getNumberDocuments($workspace)
{
require_once ('class.solr.php');
//require_once (ROOT_PATH . '/businessLogic/modules/SearchIndexAccess/Solr.php');
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
// require_once (ROOT_PATH .
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
// create list of facets
$numberDocuments = $solr->getNumberDocuments ($workspace);
@@ -235,36 +288,59 @@ Class BpmnEngine_Services_SearchIndex
return $numberDocuments;
}
function updateIndexDocument($solrUpdateDocumentEntity){
/**
* Update document Index
* @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
*/
public function updateIndexDocument($solrUpdateDocumentEntity)
{
G::LoadClass ('solr');
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
// create list of facets
$solr->updateDocument ($solrUpdateDocumentEntity);
}
function deleteDocumentFromIndex($workspace, $idQuery){
/**
* Delete document from index
* @param string $workspace
* @param string $idQuery
*/
public function deleteDocumentFromIndex($workspace, $idQuery)
{
G::LoadClass ('solr');
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
// create list of facets
$solr->deleteDocument ($workspace, $idQuery);
}
function commitIndexChanges($workspace){
/**
* Commit index changes
* @param string $workspace
*/
public function commitIndexChanges($workspace)
{
G::LoadClass ('solr');
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
// commit
$solr->commitChanges ($workspace);
}
function getDataTablePaginatedList($solrRequestData){
/**
* Call Solr server to return the list of paginated pages.
* @param FacetRequest $solrRequestData
* @return Entity_SolrQueryResult
*/
public function getDataTablePaginatedList($solrRequestData)
{
require_once ('class.solr.php');
//require_once (ROOT_PATH . '/businessLogic/modules/SearchIndexAccess/Solr.php');
// require_once (ROOT_PATH .
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
require_once ('entities/SolrRequestData.php');
require_once ('entities/SolrQueryResult.php');
@@ -284,11 +360,12 @@ Class BpmnEngine_Services_SearchIndex
}
// remove placeholder fields
// the placeholder doesn't affect the the solr's response
//$solrRequestData->includeCols = array_diff($solrRequestData->includeCols, array(''));
// $solrRequestData->includeCols = array_diff($solrRequestData->includeCols,
// array(''));
// print_r($solrRequestData);
// execute query
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
$solrPaginatedResult = $solr->executeQuery ($solrRequestData);
// get total number of documents in index
@@ -302,7 +379,9 @@ Class BpmnEngine_Services_SearchIndex
// insert list of names in docs result
$data = array (
"sEcho" => '', // must be completed in response
"iTotalRecords" => intval($numTotalDocs), //we must get the total number of documents
"iTotalRecords" => intval ($numTotalDocs), // we must get the
// total number of
// documents
"iTotalDisplayRecords" => $numFound,
"aaData" => array ()
);
@@ -312,32 +391,40 @@ Class BpmnEngine_Services_SearchIndex
foreach ($solrRequestData->includeCols as $columnName) {
if ($columnName == '') {
$data ['aaData'] [$i] [] = ''; // placeholder
}else{
}
else {
if (isset ($doc [$columnName])) {
$data ['aaData'] [$i] [] = $doc [$columnName];
}else{
}
else {
$data ['aaData'] [$i] [] = '';
}
}
}
}
$solrQueryResponse = Entity_SolrQueryResult::CreateForRequest($data);
$solrQueryResponse = Entity_SolrQueryResult::createForRequest ($data);
//
return $solrQueryResponse;
}
function getIndexFields($workspace){
/**
* Return the list of stored fields in the index.
* @param string $workspace
* @return array of index fields
*/
public function getIndexFields($workspace)
{
// global $indexFields;
// cache
// if(!empty($indexFields))
// return $indexFields;
require_once ('class.solr.php');
//require_once (ROOT_PATH . '/businessLogic/modules/SearchIndexAccess/Solr.php');
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
// require_once (ROOT_PATH .
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
// print "SearchIndex!!!!";
// create list of facets
@@ -352,7 +439,8 @@ Class BpmnEngine_Services_SearchIndex
// $listFields[strtolower($originalFieldName)] = $key;
// Maintain case sensitive variable names
$listFields [$originalFieldName] = $key;
}else{
}
else {
// $listFields[strtolower($key)] = $key;
// Maintain case sensitive variable names
$listFields [$key] = $key;

View File

@@ -1,19 +1,44 @@
<?php
/**
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2012 Colosa Inc.23
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* For more information, contact Colosa Inc, 5304 Ventura Drive,
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
*
*/
/**
* Interface to the Solr Search server
* @author Herbert Saal Gutierrez
*
*/
class BpmnEngine_SearchIndexAccess_Solr {
class BpmnEngine_SearchIndexAccess_Solr
{
const SOLR_VERSION = '&version=2.2';
private $solrIsEnabled = false;
private $solrHost = "";
private $_solrIsEnabled = false;
private $_solrHost = "";
function __construct($solrIsEnabled = false, $solrHost = "") {
public function __construct($solrIsEnabled = false, $solrHost = "")
{
// use the parameters to initialize class
$this->solrIsEnabled = $solrIsEnabled;
$this->solrHost = $solrHost;
$this->_solrIsEnabled = $solrIsEnabled;
$this->_solrHost = $solrHost;
}
/**
@@ -24,10 +49,11 @@ class BpmnEngine_SearchIndexAccess_Solr {
*
* @return bool
*/
function isEnabled() {
public function isEnabled()
{
// verify solr server response
return $this->solrIsEnabled;
return $this->_solrIsEnabled;
}
/**
@@ -40,13 +66,14 @@ class BpmnEngine_SearchIndexAccess_Solr {
* workspace: workspace name
* @return total
*/
function getNumberDocuments($workspace) {
if (! $this->solrIsEnabled)
public function getNumberDocuments($workspace)
{
if (! $this->_solrIsEnabled)
return;
// get configuration information in base to workspace parameter
// get total number of documents in registry
$solrIntruct = (substr($this->solrHost, -1) == "/")?$this->solrHost:$this->solrHost . "/";
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace;
$solrIntruct .= "/select/?q=*:*";
$solrIntruct .= self::SOLR_VERSION;
@@ -58,7 +85,7 @@ class BpmnEngine_SearchIndexAccess_Solr {
curl_close ($handlerTotal);
// verify the result of solr
$responseSolrTotal = json_decode ( $responseTotal, true );
$responseSolrTotal = G::json_decode ($responseTotal, true);
if ($responseSolrTotal ['responseHeader'] ['status'] != 0) {
throw new Exception ("Error returning the total number of documents in Solr." . $solrIntruct);
}
@@ -74,8 +101,9 @@ class BpmnEngine_SearchIndexAccess_Solr {
*
* @return solr response
*/
function executeQuery($solrRequestData) {
if (! $this->solrIsEnabled)
public function executeQuery($solrRequestData)
{
if (! $this->_solrIsEnabled)
return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
@@ -107,7 +135,7 @@ class BpmnEngine_SearchIndexAccess_Solr {
$filters .= '&fq=' . urlencode ($value);
}
$solrIntruct = (substr($this->solrHost, -1) == "/")?$this->solrHost:$this->solrHost . "/";
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace;
$solrIntruct .= "/select/?q=$query";
$solrIntruct .= "&echoParams=none";
@@ -126,7 +154,7 @@ class BpmnEngine_SearchIndexAccess_Solr {
curl_close ($handler);
// decode
$responseSolr = json_decode ( $response, true );
$responseSolr = G::json_decode ($response, true);
if ($responseSolr ['responseHeader'] ['status'] != 0) {
throw new Exception ("Error executing query to Solr." . $solrIntruct);
}
@@ -142,12 +170,13 @@ class BpmnEngine_SearchIndexAccess_Solr {
*
* @return solr response
*/
function updateDocument($solrUpdateDocument) {
if (! $this->solrIsEnabled)
public function updateDocument($solrUpdateDocument)
{
if (! $this->_solrIsEnabled)
return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
$solrIntruct = (substr($this->solrHost, -1) == "/")?$this->solrHost:$this->solrHost . "/";
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $solrUpdateDocument->workspace;
$solrIntruct .= "/update";
@@ -175,12 +204,13 @@ class BpmnEngine_SearchIndexAccess_Solr {
*
* @return solr response
*/
function commitChanges($workspace) {
if (! $this->solrIsEnabled)
public function commitChanges($workspace)
{
if (! $this->_solrIsEnabled)
return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
$solrIntruct = (substr($this->solrHost, -1) == "/")?$this->solrHost:$this->solrHost . "/";
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace;
$solrIntruct .= "/update";
@@ -208,13 +238,14 @@ class BpmnEngine_SearchIndexAccess_Solr {
*
* @return solr response
*/
function rollbackChanges($workspace) {
if (! $this->solrIsEnabled)
public function rollbackChanges($workspace)
{
if (! $this->_solrIsEnabled)
return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
$solrIntruct = (substr($this->solrHost, -1) == "/")?$this->solrHost:$this->solrHost . "/";
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace;
$solrIntruct .= "/update";
@@ -242,13 +273,14 @@ class BpmnEngine_SearchIndexAccess_Solr {
*
* @return solr response
*/
function optimizeChanges($workspace) {
if (! $this->solrIsEnabled)
public function optimizeChanges($workspace)
{
if (! $this->_solrIsEnabled)
return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
$solrIntruct = (substr($this->solrHost, -1) == "/")?$this->solrHost:$this->solrHost . "/";
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace;
$solrIntruct .= "/update";
@@ -270,17 +302,20 @@ class BpmnEngine_SearchIndexAccess_Solr {
/**
* Return the list of the stored fields in Solr
* @param string $workspace Solr instance name
*
* @param string $workspace
* Solr instance name
* @throws Exception
* @return void|mixed array of field names
* @return void mixed of field names
*/
function getListIndexedStoredFields($workspace) {
if (! $this->solrIsEnabled)
public function getListIndexedStoredFields($workspace)
{
if (! $this->_solrIsEnabled)
return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
$solrIntruct = (substr($this->solrHost, -1) == "/")?$this->solrHost:$this->solrHost . "/";
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace;
$solrIntruct .= "/admin/luke?numTerms=0&wt=json";
@@ -289,7 +324,7 @@ class BpmnEngine_SearchIndexAccess_Solr {
$response = curl_exec ($handler);
curl_close ($handler);
// decode
$responseSolr = json_decode ( $response, true );
$responseSolr = G::json_decode ($response, true);
if ($responseSolr ['responseHeader'] ['status'] != 0) {
throw new Exception ("Error getting index fields in Solr." . $solrIntruct);
}
@@ -304,14 +339,15 @@ class BpmnEngine_SearchIndexAccess_Solr {
*
* @return solr response
*/
function deleteAllDocuments($workspace) {
if (! $this->solrIsEnabled)
public function deleteAllDocuments($workspace)
{
if (! $this->_solrIsEnabled)
return;
// $registry = Zend_Registry::getInstance();
$solrIntruct = '';
// get configuration information in base to workspace parameter
$solrIntruct = (substr($this->solrHost, -1) == "/")?$this->solrHost:$this->solrHost . "/";
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace;
$solrIntruct .= "/update";
@@ -340,14 +376,15 @@ class BpmnEngine_SearchIndexAccess_Solr {
*
* @return solr response
*/
function deleteDocument($workspace, $idQuery) {
if (! $this->solrIsEnabled)
public function deleteDocument($workspace, $idQuery)
{
if (! $this->_solrIsEnabled)
return;
// $registry = Zend_Registry::getInstance();
$solrIntruct = '';
// get configuration information in base to workspace parameter
$solrIntruct = (substr($this->solrHost, -1) == "/")?$this->solrHost:$this->solrHost . "/";
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace;
$solrIntruct .= "/update";
@@ -374,8 +411,9 @@ class BpmnEngine_SearchIndexAccess_Solr {
* @param Entity_FacetRequest $facetRequestEntity
* @return solr response: list of facets array
*/
function getFacetsList($facetRequest) {
if (! $this->solrIsEnabled)
public function getFacetsList($facetRequest)
{
if (! $this->_solrIsEnabled)
return;
$solrIntruct = '';
@@ -413,7 +451,7 @@ class BpmnEngine_SearchIndexAccess_Solr {
$resultFormat = '&wt=json';
$solrIntruct = (substr($this->solrHost, -1) == "/")?$this->solrHost:$this->solrHost . "/";
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace;
$solrIntruct .= "/select/?q=$query";
$solrIntruct .= "&echoParams=none";
@@ -432,7 +470,7 @@ class BpmnEngine_SearchIndexAccess_Solr {
curl_close ($handler);
// decode
$responseSolr = json_decode ( $response, true );
$responseSolr = G::json_decode ($response, true);
if ($responseSolr ['responseHeader'] ['status'] != 0) {
throw new Exception ("Error getting faceted list from Solr." . $solrIntruct);
}

View File

@@ -4,20 +4,24 @@ require_once ('Base.php');
/**
* Application Solr Queue
*/
class Entity_AppSolrQueue extends Entity_Base {
class Entity_AppSolrQueue extends Entity_Base
{
public $appUid = '';
public $appUpdated = 0;
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_AppSolrQueue ();
return $obj;
}
static function CreateForRequest($data) {
static function createForRequest($data)
{
$obj = new Entity_AppSolrQueue ();
$obj->initializeObject ($data);

View File

@@ -1,12 +1,14 @@
<?php
class Entity_Base {
class Entity_Base
{
/**
* this function check if a field is in the data sent in the constructor
* you can specify an array, and this function will use like alias
*/
protected function validateField($field, $default = false) {
protected function validateField($field, $default = false)
{
$fieldIsEmpty = true;
// this is a trick, if $fields is a string, $fields will be an array with
@@ -37,7 +39,8 @@ class Entity_Base {
}
}
protected function validateRequiredFields($requiredFields = array()) {
protected function validateRequiredFields($requiredFields = array())
{
foreach ($requiredFields as $k => $field) {
if ($this->{$field} === NULL) {
throw (new Exception ("Field $field is required in " . get_class ($this)));
@@ -47,6 +50,7 @@ class Entity_Base {
}
/**
*
*
*
* Copy the values of the Entity to the array of aliases
@@ -54,12 +58,16 @@ class Entity_Base {
*
* @return Array of alias with the Entity values
*/
public function getAliasDataArray() {
public function getAliasDataArray()
{
$aAlias = array ();
// get aliases from class
$className = get_class ($this);
if (method_exists ($className, 'GetAliases')) {
$aliases = call_user_func(array($className, 'GetAliases'));
$aliases = call_user_func (array (
$className,
'GetAliases'
));
// $aliases = $className::GetAliases ();
foreach ($this as $field => $value)
if (isset ($aliases [$field])) {
@@ -74,6 +82,7 @@ class Entity_Base {
}
/**
*
*
*
* Set the data from array of alias to Entity
@@ -81,11 +90,15 @@ class Entity_Base {
* @param $aAliasData array
* of data of aliases
*/
public function setAliasDataArray($aAliasData) {
public function setAliasDataArray($aAliasData)
{
// get aliases from class
$className = get_class ($this);
if (method_exists ($className, 'GetAliases')) {
$aliases = call_user_func(array($className, 'GetAliases'));
$aliases = call_user_func (array (
$className,
'GetAliases'
));
// $aliases = $className::GetAliases ();
foreach ($this as $field => $value)
if (isset ($aliases [$field]))
@@ -94,6 +107,7 @@ class Entity_Base {
}
/**
*
*
*
* Initialize object with values from $data.
@@ -102,13 +116,17 @@ class Entity_Base {
* @param
* $data
*/
protected function initializeObject($data) {
protected function initializeObject($data)
{
// get aliases from class
$className = get_class ($this);
$aliases = array ();
$swAliases = false;
if (method_exists ($className, 'GetAliases')) {
$aliases = call_user_func(array($className, 'GetAliases'));
$aliases = call_user_func (array (
$className,
'GetAliases'
));
// $aliases = $className::GetAliases ();
$swAliases = true;
}
@@ -122,13 +140,15 @@ class Entity_Base {
}
}
public function serialize() {
public function serialize()
{
if (isset ($this->temp))
unset ($this->temp);
return serialize ($this);
}
public function unserialize($str) {
public function unserialize($str)
{
$className = get_class ($this);
$data = unserialize ($str);
return new $className ($data);

View File

@@ -2,8 +2,6 @@
require_once ('Base.php');
/**
*
*
* Facet group entity that represent a facet group
*
* @property $facetGroupName: The name of the facet (field name in solr index)
@@ -16,22 +14,26 @@ require_once ('Base.php');
* @author dev-HebertSaak
*
*/
class Entity_FacetGroup extends Entity_Base {
class Entity_FacetGroup extends Entity_Base
{
public $facetGroupName = '';
public $facetGroupPrintName = '';
public $facetGroupType = ''; // field, daterange, query
public $facetGroupId = '';
public $facetItems = array ();
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_FacetGroup ();
return $obj;
}
static function CreateForInsert($data) {
static function createForInsert($data)
{
$obj = new Entity_FacetGroup ();
$obj->initializeObject ($data);

View File

@@ -1,7 +1,8 @@
<?php
require_once ('Base.php');
class Entity_FacetInterfaceRequest extends Entity_Base {
class Entity_FacetInterfaceRequest extends Entity_Base
{
public $searchText = '';
public $selectedFacetsString = ''; // string of selected facet groups and
// items in format:
@@ -10,15 +11,18 @@ class Entity_FacetInterfaceRequest extends Entity_Base {
// var $selectedFacetFields = array();
// var $selectedFacetTypes = array();
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_FacetInterfaceRequest ();
return $obj;
}
static function CreateForRequest($data) {
static function createForRequest($data)
{
$obj = new Entity_FacetInterfaceRequest ();
$obj->initializeObject ($data);

View File

@@ -1,22 +1,26 @@
<?php
require_once ('Base.php');
class Entity_FacetInterfaceResult extends Entity_Base {
class Entity_FacetInterfaceResult extends Entity_Base
{
// array of facetsgroups, array of Entity_SelectedFacetGroupItem, filter text
public $aFacetGroup = array ();
public $aSelectedFacetGroupItem = array ();
public $sFilterText = '';
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_FacetInterfaceResult ();
return $obj;
}
static function CreateForRequest($data) {
static function createForRequest($data)
{
$obj = new Entity_FacetInterfaceResult ();
$obj->initializeObject ($data);

View File

@@ -2,6 +2,7 @@
require_once ('Base.php');
/**
*
*
*
* Entity Face item, represent an option in a facet group
@@ -9,22 +10,26 @@ require_once ('Base.php');
* @author dev-HebertSaak
*
*/
class Entity_FacetItem extends Entity_Base {
class Entity_FacetItem extends Entity_Base
{
public $facetName = '';
public $facetPrintName = '';
public $facetCount = '';
public $facetSelectCondition = ''; // selected condition used to select
// this facet
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_FacetItem ();
return $obj;
}
static function CreateForInsert($data) {
static function createForInsert($data)
{
$obj = new Entity_FacetItem ();
$obj->initializeObject ($data);

View File

@@ -1,7 +1,8 @@
<?php
require_once ('Base.php');
class Entity_FacetRequest extends Entity_Base {
class Entity_FacetRequest extends Entity_Base
{
public $workspace = '';
public $searchText = '';
public $facetFields = array ();
@@ -14,15 +15,18 @@ class Entity_FacetRequest extends Entity_Base {
public $filters = array ();
public $selectedFacetsString = '';
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_FacetRequest ();
return $obj;
}
static function CreateForRequest($data) {
static function createForRequest($data)
{
$obj = new Entity_FacetRequest ();
$obj->initializeObject ($data);

View File

@@ -1,20 +1,24 @@
<?php
require_once ('Base.php');
class Entity_FacetResult extends Entity_Base {
class Entity_FacetResult extends Entity_Base
{
public $aFacetGroups = array ();
public $aSelectedFacetGroups = array ();
public $sFilterText = '';
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_FacetResult ();
return $obj;
}
static function CreateForRequest($data) {
static function createForRequest($data)
{
$obj = new Entity_FacetResult ();
$obj->initializeObject ($data);

View File

@@ -1,7 +1,8 @@
<?php
require_once ('Base.php');
class Entity_SelectedFacetGroupItem extends Entity_Base {
class Entity_SelectedFacetGroupItem extends Entity_Base
{
public $selectedFacetGroupName = '';
public $selectedFacetGroupPrintName = '';
public $selectedFacetItemName = '';
@@ -10,15 +11,18 @@ class Entity_SelectedFacetGroupItem extends Entity_Base {
// selected facets without this
// facet
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_SelectedFacetGroupItem ();
return $obj;
}
static function CreateForRequest($data) {
static function createForRequest($data)
{
$obj = new Entity_SelectedFacetGroupItem ();
$obj->initializeObject ($data);

View File

@@ -1,22 +1,26 @@
<?php
require_once ('Base.php');
class Entity_SolrQueryResult extends Entity_Base {
class Entity_SolrQueryResult extends Entity_Base
{
public $sEcho = '';
public $iTotalRecords = 0;
public $iTotalDisplayRecords = 10;
public $aaData = array (); // array of arrays of records to
// display
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_SolrQueryResult ();
return $obj;
}
static function CreateForRequest($data) {
static function createForRequest($data)
{
$obj = new Entity_SolrQueryResult ();
$obj->initializeObject ($data);

View File

@@ -1,7 +1,8 @@
<?php
require_once ('Base.php');
class Entity_SolrRequestData extends Entity_Base {
class Entity_SolrRequestData extends Entity_Base
{
public $workspace = '';
public $startAfter = 0;
public $pageSize = 10;
@@ -17,15 +18,18 @@ class Entity_SolrRequestData extends Entity_Base {
public $includeCols = array ();
public $resultFormat = 'xml'; // json, xml, php
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_SolrRequestData ();
return $obj;
}
static function CreateForRequestPagination($data) {
static function createForRequestPagination($data)
{
$obj = new Entity_SolrRequestData ();
$obj->initializeObject ($data);

View File

@@ -1,19 +1,23 @@
<?php
require_once ('Base.php');
class Entity_SolrUpdateDocument extends Entity_Base {
class Entity_SolrUpdateDocument extends Entity_Base
{
var $workspace = '';
var $document = '';
private function __construct() {
private function __construct()
{
}
static function CreateEmpty() {
static function createEmpty()
{
$obj = new Entity_SolrUpdateDocument ();
return $obj;
}
static function CreateForRequest($data) {
static function createForRequest($data)
{
$obj = new Entity_SolrUpdateDocument ();
$obj->initializeObject ($data);

View File

@@ -109,7 +109,7 @@ class AppSolrQueue extends BaseAppSolrQueue {
$row = $rs->getRow();
while (is_array($row)) {
$appSolrQueue = Entity_AppSolrQueue::CreateEmpty();
$appSolrQueue = Entity_AppSolrQueue::createEmpty();
$appSolrQueue->appUid = $row['APP_UID'];
$appSolrQueue->appUpdated = $row['APP_UPDATED'];
$updatedApplications[] = $appSolrQueue;