BUG 0000 "Added changes to solr" SOLVED

- Added changes to solr, according to:
    https://github.com/colosa/processmaker/pull/1045/files
- Solved problem with:
    php -f reindex_solr.php
* Available from version ProcessMaker-2.0.46
This commit is contained in:
Victor Saisa Lopez
2013-01-25 17:13:52 -04:00
parent cbcad06e31
commit 23a7051496
16 changed files with 503 additions and 153 deletions

View File

@@ -121,6 +121,10 @@ class Bootstrap
public static function registerSystemClasses()
{
self::registerClass("Propel", PATH_THIRDPARTY . "propel" . PATH_SEP . "Propel.php");
self::registerClass("Creole", PATH_THIRDPARTY . "creole" . PATH_SEP . "Creole.php");
self::registerClass("Criteria", PATH_THIRDPARTY . "propel" . PATH_SEP . "util" . PATH_SEP . "Criteria.php");
//DATABASE propel classes used in "Cases" Options
self::registerClass("Entity_Base", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "entities" . PATH_SEP . "Base.php");
@@ -191,6 +195,8 @@ class Bootstrap
self::registerClass("AppOwnerPeer", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppOwnerPeer.php");
self::registerClass("BaseAppSolrQueue", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "om" . PATH_SEP . "BaseAppSolrQueue.php");
self::registerClass("Entity_SolrRequestData", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "entities" . PATH_SEP . "SolrRequestData.php");
self::registerClass("Entity_SolrUpdateDocument", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "entities" . PATH_SEP . "SolrUpdateDocument.php");
self::registerClass("Entity_AppSolrQueue", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "entities" . PATH_SEP . "AppSolrQueue.php");
self::registerClass("AppSolrQueue", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppSolrQueue.php");
self::registerClass("AppSolrQueuePeer", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "AppSolrQueuePeer.php");
@@ -314,10 +320,6 @@ class Bootstrap
self::registerClass("StepTrigger", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "StepTrigger.php");
self::registerClass("StepTriggerPeer", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "StepTriggerPeer.php");
self::registerClass("SolrRequestData", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "entities" . PATH_SEP . "SolrRequestData.php");
self::registerClass("SolrUpdateDocument", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "entities" . PATH_SEP . "SolrUpdateDocument.php");
self::registerClass("BaseSwimlanesElements",PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "om" . PATH_SEP . "BaseSwimlanesElements.php");
self::registerClass("SwimlanesElements", PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "SwimlanesElements.php");
self::registerClass("BaseSwimlanesElementsPeer",PATH_HOME ."engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "om" . PATH_SEP . "BaseSwimlanesElementsPeer.php");

View File

@@ -129,10 +129,23 @@ if (! defined ('PATH_HOME')) {
require_once ("creole/Creole.php");
}
require_once 'classes/model/AppDelegation.php';
require_once 'classes/model/Event.php';
require_once 'classes/model/AppEvent.php';
require_once 'classes/model/CaseScheduler.php';
if (file_exists(PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php")) {
require_once (PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php");
}
require_once (PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths.php");
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.system.php");
require_once (PATH_GULLIVER . "class.bootstrap.php");
spl_autoload_register(array("Bootstrap", "autoloadClass"));
Bootstrap::registerSystemClasses();
//require_once 'classes/model/AppDelegation.php';
//require_once 'classes/model/Event.php';
//require_once 'classes/model/AppEvent.php';
//require_once 'classes/model/CaseScheduler.php';
// G::loadClass('pmScript');
// //default values
@@ -173,7 +186,7 @@ if (! defined ('SYS_SYS')) {
// ****************************************
// read initialize file
require_once PATH_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.system.php';
//require_once PATH_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'class.system.php';
$config = System::getSystemConfiguration ('', '', SYS_SYS);
define ('MEMCACHED_ENABLED', $config ['memcached']);
define ('MEMCACHED_SERVER', $config ['memcached_server']);
@@ -185,8 +198,8 @@ if (! defined ('SYS_SYS')) {
print "MEMCACHED_SERVER: " . MEMCACHED_SERVER . "\n";
// ****************************************
include_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths_installed.php');
include_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
//include_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths_installed.php');
//include_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
// ***************** PM Paths DATA **************************
define ('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
@@ -362,3 +375,4 @@ function setExecutionResultMessage($m, $t = '')
$c = 'yellow';
eprintln ("[$m]", $c);
}

View File

@@ -162,13 +162,20 @@ class AppSolr
}
/**
* Return if the Solr functionality is enabled.
* Return if the Solr server is currently working.
*
* @return boolean true:enabled functionality, false:disabled functionality
*/
public function isSolrEnabled ()
{
return $this->_solrIsEnabled;
G::LoadClass("searchIndex");
$searchIndex = new BpmnEngine_Services_SearchIndex($this->_solrIsEnabled, $this->_solrHost);
//Execute query
$solrStatusResult = $searchIndex->isEnabled($this->_solrInstance);
return $solrStatusResult;
}
/**
@@ -470,8 +477,18 @@ class AppSolr
}
// the array of data that must be returned with placeholders
$columsToInclude = array ('APP_CREATE_DATE','','','','APP_NUMBER','','APP_PRO_TITLE','APP_STATUS','','','APP_TITLE','APP_UID','DEL_LAST_UPDATE_DATE','','','','','','','','','DEL_MAX_PRIORITY','','','','','','PRO_UID','',''
$columsToInclude = array(
"APP_CREATE_DATE",
"APP_NUMBER",
"APP_PRO_TITLE",
"APP_STATUS",
"APP_TITLE",
"APP_UID",
"DEL_LAST_UPDATE_DATE",
"DEL_MAX_PRIORITY",
"PRO_UID"
);
// create pagination data
$solrSearchText = null;
$sortableCols = array ();
@@ -487,28 +504,28 @@ class AppSolr
switch ($sort) {
case 'APP_CACHE_VIEW.APP_NUMBER':
case 'APP_NUMBER':
$sortCols[0] = 4;
$sortCols[0] = 1; //4;
$sortableCols[0] = 'true';
$sortDir[0] = $dir;
break;
// multivalue field can't be ordered
case 'APP_TITLE':
$sortCols[0] = 10;
$sortCols[0] = 4; //10;
$sortableCols[0] = 'true';
$sortDir[0] = $dir;
break;
case 'APP_PRO_TITLE':
$sortCols[0] = 6;
$sortCols[0] = 2; //6;
$sortableCols[0] = 'true';
$sortDir[0] = $dir;
break;
case 'APP_UPDATE_DATE':
$sortCols[0] = 12;
$sortCols[0] = 6; //12;
$sortableCols[0] = 'true';
$sortDir[0] = $dir;
break;
default:
$sortCols[0] = 4;
$sortCols[0] = 1; //4;
$sortableCols[0] = 'true';
$sortDir[0] = 'desc';
break;
@@ -657,27 +674,39 @@ class AppSolr
$solrSearchText .= "(" . $search . ")";
}
}
// add del_index dynamic fields to list of resulting columns
// the fields begin in the 30th column and more
$columsToInclude = array_merge( $columsToInclude, $delegationIndexes );
$columsToIncludeFinal = array();
$columsToIncludeFinal = array_merge($columsToInclude, $delegationIndexes);
// if is a counter no records are returned
if ($doCount) {
$start = 0;
$limit = 0;
$numSortingCols = 0;
$columsToInclude = array ();
$columsToIncludeFinal = array();
}
$data = array ('workspace' => $this->_solrInstance, // solr instance
'startAfter' => intval( $start ),'pageSize' => intval( $limit ),'searchText' => $solrSearchText,'filterText' => '', // $filter, //ex:'field1:value1,field2:[value2.1
// TO value2.2],field3:value3'
'numSortingCols' => $numSortingCols,'sortableCols' => $sortableCols,'sortCols' => $sortCols,'sortDir' => $sortDir,'includeCols' => $columsToInclude,'resultFormat' => 'json'
$data = array(
"workspace" => $this->_solrInstance, // solr instance
"startAfter" => intval($start),
"pageSize" => intval($limit),
"searchText" => $solrSearchText,
"filterText" => "", // $filter, //ex:"field1:value1,field2:[value2.1
// TO value2.2],field3:value3"
"numSortingCols" => $numSortingCols,
"sortableCols" => $sortableCols,
"sortCols" => $sortCols,
"sortDir" => $sortDir,
"includeCols" => $columsToIncludeFinal,
"resultFormat" => "json"
);
$solrRequestData = Entity_SolrRequestData::createForRequestPagination( $data );
// use search index to return list of cases
$searchIndex = new BpmnEngine_Services_SearchIndex( $this->_solrIsEnabled, $this->_solrHost );
// execute query
$solrQueryResult = $searchIndex->getDataTablePaginatedList( $solrRequestData );
@@ -702,10 +731,10 @@ class AppSolr
// number of found records
$result['totalCount'] = $solrQueryResult->iTotalDisplayRecords;
//get all the data from database
// get the missing data from database
$appUids = array ();
foreach ($solrQueryResult->aaData as $i => $data) {
$appUids[] = $data[11];
$appUids[] = $data["APP_UID"]; //APP_UID
}
$aaappsDBData = $this->getListApplicationDelegationData($appUids, $action, $status);
@@ -713,18 +742,20 @@ class AppSolr
if ($this->debug) {
$this->afterDbQueryTime = microtime( true );
}
// complete the missing data to display it in the grid.
$delIndexes = array (); //store all the delegation indexes
foreach ($solrQueryResult->aaData as $i => $data) {
//initialize array
$delIndexes = array ();
// complete empty values
$appUID = $data[11];
$appUID = $data["APP_UID"]; //APP_UID
//get all the delindexes
for ($i = 30; $i < count( $data ); $i ++) {
if (is_array( $data[$i] )) {
foreach ($data[$i] as $delIndex) {
for ($i = count($columsToInclude); $i <= count($data) - 1; $i++) {
if (is_array($data[$columsToIncludeFinal[$i]])) {
foreach ($data[$columsToIncludeFinal[$i]] as $delIndex) {
$delIndexes[] = $delIndex;
}
}
@@ -756,7 +787,15 @@ class AppSolr
$arrayRowAux = array();
foreach ($resultColumns as $j => $columnName) {
$arrayRowAux[$columnName] = $data[$j];
if (isset($data[$columnName])) {
$arrayRowAux[$columnName] = $data[$columnName];
} else {
if ($columnName == "DEL_PRIORITY") {
$arrayRowAux[$columnName] = $data["DEL_MAX_PRIORITY"]; //different name
} else {
$arrayRowAux[$columnName] = ""; //placeholder
}
}
}
//Remove duplicated
@@ -773,11 +812,11 @@ class AppSolr
$aRow = $arrayRowAux;
// convert date from solr format UTC to local time in MySQL format
$solrdate = $data[0];
$solrdate = $data["APP_CREATE_DATE"];
$localDate = date( 'Y-m-d H:i:s', strtotime( $solrdate ) );
$aRow['APP_CREATE_DATE'] = $localDate;
$solrdate = $data[12];
$solrdate = $data["DEL_LAST_UPDATE_DATE"];
$localDate = date( 'Y-m-d H:i:s', strtotime( $solrdate ) );
$aRow['APP_UPDATE_DATE'] = $localDate;
@@ -940,11 +979,11 @@ class AppSolr
$c->addSelectColumn( AppDelegationPeer::DEL_THREAD_STATUS );
$c->addSelectColumn( AppDelegationPeer::TAS_UID );
$c->addAlias("u", "USERS");
$c->addAlias("uprev", "USERS");
$c->addAlias("adprev", "APP_DELEGATION");
$c->addAlias("ctastitle", "CONTENT");
$c->addAlias("at", "APP_THREAD");
$c->addAlias("u", UsersPeer::TABLE_NAME);
$c->addAlias("uprev", UsersPeer::TABLE_NAME);
$c->addAlias("adprev", AppDelegationPeer::TABLE_NAME);
$c->addAlias("ctastitle", ContentPeer::TABLE_NAME);
$c->addAlias("at", AppThreadPeer::TABLE_NAME);
$arrayCondition = array();
$arrayCondition[] = array(AppDelegationPeer::APP_UID, ApplicationPeer::APP_UID);
@@ -1106,11 +1145,11 @@ class AppSolr
$c->addSelectColumn( AppDelegationPeer::DEL_THREAD_STATUS );
$c->addSelectColumn( AppDelegationPeer::TAS_UID );
$c->addAlias( 'u', 'USERS' );
$c->addAlias( 'uprev', 'USERS' );
$c->addAlias( 'adprev', 'APP_DELEGATION' );
$c->addAlias( 'ctastitle', 'CONTENT' );
$c->addAlias( 'at', 'APP_THREAD' );
$c->addAlias("u", UsersPeer::TABLE_NAME);
$c->addAlias("uprev", UsersPeer::TABLE_NAME);
$c->addAlias("adprev", AppDelegationPeer::TABLE_NAME);
$c->addAlias("ctastitle", ContentPeer::TABLE_NAME);
$c->addAlias("at", AppThreadPeer::TABLE_NAME);
$aConditions = array ();
$aConditions[] = array (AppDelegationPeer::USR_UID,'u.USR_UID'
@@ -1379,7 +1418,7 @@ class AppSolr
* @param array $aaAPPUIDs Array of arrays of App_UID that must be updated,
* APP_UID is permitted also
*/
public function updateApplicationSearchIndex ($aaAPPUIDs)
public function updateApplicationSearchIndex($aaAPPUIDs, $saveDBRecord = true)
{
if (empty( $aaAPPUIDs )) {
return;
@@ -1392,20 +1431,29 @@ class AppSolr
$aaAPPUIDs[] = array ('APP_UID' => $APPUID
);
}
// check if index server is available
if (! $this->isSolrEnabled()) {
// store update in table and return
//Check if index server is available
if ($saveDBRecord) {
if ($this->isSolrEnabled()) {
//Store update in table but with status updated
foreach ($aaAPPUIDs as $aAPPUID) {
$this->applicationChangedUpdateSolrQueue( $aAPPUID['APP_UID'], true );
$this->applicationChangedUpdateSolrQueue($aAPPUID["APP_UID"], 0);
}
} else{
//Store update in table and return
foreach ($aaAPPUIDs as $aAPPUID) {
$this->applicationChangedUpdateSolrQueue($aAPPUID["APP_UID"], true);
}
return;
}
}
if ($this->debug) {
$this->getApplicationDataDBTime = 0;
$this->getPreparedApplicationDataDBTime = 0;
$this->getBuilXMLDocTime = 0;
$this->afterUpdateSolrXMLDocTime = 0;
$this->beforeCreateSolrXMLDocTime = microtime( true );
}
// create XML document
@@ -1476,17 +1524,18 @@ class AppSolr
*
* @param string $appUID Application identifier
*/
public function deleteApplicationSearchIndex ($appUID)
public function deleteApplicationSearchIndex($appUID, $saveDBRecord = true)
{
if (empty( $appUID )) {
return;
}
// check if index server is available
if (! $this->_solrIsEnabled) {
if ($saveDBRecord) {
// store update in table and return
$this->applicationChangedUpdateSolrQueue( $appUID['APP_UID'], 2 ); // delete
return;
//return;
}
$idQuery = "APP_UID:" . $appUID;
@@ -2487,10 +2536,10 @@ class AppSolr
$c->addSelectColumn( 'at.APP_THREAD_PARENT' );
$c->addSelectColumn( 'at.APP_THREAD_STATUS' );
$c->addAlias( 'capp', 'CONTENT' );
$c->addAlias( 'cpro', 'CONTENT' );
$c->addAlias( 'ad', 'APP_DELEGATION' );
$c->addAlias( 'at', 'APP_THREAD' );
$c->addAlias("capp", ContentPeer::TABLE_NAME);
$c->addAlias("cpro", ContentPeer::TABLE_NAME);
$c->addAlias("ad", AppDelegationPeer::TABLE_NAME);
$c->addAlias("at", AppThreadPeer::TABLE_NAME);
$aConditions = array ();
$aConditions[] = array (ApplicationPeer::APP_UID,'capp.CON_ID'
@@ -2589,12 +2638,12 @@ class AppSolr
$c->addAsColumn("PRO_CATEGORY_UID", "pro.PRO_CATEGORY");
$c->addAlias("capp", "CONTENT");
$c->addAlias("cpro", "CONTENT");
$c->addAlias("ad", "APP_DELEGATION");
$c->addAlias("at", "APP_THREAD");
$c->addAlias("appDely", "APP_DELAY");
$c->addAlias("pro", "PROCESS");
$c->addAlias("capp", ContentPeer::TABLE_NAME);
$c->addAlias("cpro", ContentPeer::TABLE_NAME);
$c->addAlias("ad", AppDelegationPeer::TABLE_NAME);
$c->addAlias("at", AppThreadPeer::TABLE_NAME);
$c->addAlias("appDely", AppDelayPeer::TABLE_NAME);
$c->addAlias("pro", ProcessPeer::TABLE_NAME);
$arrayCondition = array();
$arrayCondition[] = array(ApplicationPeer::APP_UID, "capp.CON_ID");
@@ -2720,9 +2769,25 @@ class AppSolr
*/
public function applicationChangedUpdateSolrQueue ($AppUid, $updated)
{
$traceData = $this->getCurrentTraceInfo();
$oAppSolrQueue = new AppSolrQueue();
$oAppSolrQueue->createUpdate( $AppUid, $updated );
$oAppSolrQueue->createUpdate($AppUid, $traceData, $updated);
}
private function getCurrentTraceInfo()
{
$traceData = debug_backtrace();
$resultTraceString = "";
foreach ($traceData as $key => $value) {
if ($value["function"] != "getCurrentTraceInfo" && $value["function"] != "require_once") {
$resultTraceString .= $value["file"] . " (" . $value["line"] . ") " . $value["function"] . "\n";
}
}
return $resultTraceString;
}
/**
@@ -2730,6 +2795,10 @@ class AppSolr
*/
public function synchronizePendingApplications ()
{
if (!$this->isSolrEnabled()) {
throw new Exception("Error connecting to solr server.");
}
// check table of pending updates
$oAppSolrQueue = new AppSolrQueue();
@@ -2738,10 +2807,10 @@ class AppSolr
foreach ($aAppSolrQueue as $oAppSolrQueueEntity) {
// call the syncronization function
if ($oAppSolrQueueEntity->appUpdated == 1) {
$this->updateApplicationSearchIndex( $oAppSolrQueueEntity->appUid );
$this->updateApplicationSearchIndex($oAppSolrQueueEntity->appUid, false);
}
if ($oAppSolrQueueEntity->appUpdated == 2) {
$this->deleteApplicationSearchIndex( $oAppSolrQueueEntity->appUid );
$this->deleteApplicationSearchIndex($oAppSolrQueueEntity->appUid, false);
}
$this->applicationChangedUpdateSolrQueue( $oAppSolrQueueEntity->appUid, 0 );
}
@@ -2831,7 +2900,12 @@ class AppSolr
*/
public function reindexAllApplications ($SkipRecords = 0, $indexTrunkSize = 1000)
{
if (!$this->isSolrEnabled()) {
throw new Exception("Error connecting to solr server.");
}
$trunk = $indexTrunkSize;
// delete all documents to begin reindex
// deleteAllDocuments();
// commitChanges();
@@ -2846,7 +2920,7 @@ class AppSolr
printf( "Indexing %d to %d \n", $skip, $skip + $trunk );
$initTimeDoc = microtime( true );
$this->updateApplicationSearchIndex( $aaAPPUIds );
$this->updateApplicationSearchIndex($aaAPPUIds, false);
$curTimeDoc = gmdate( 'H:i:s', (microtime( true ) - $initTimeDoc) );
printf( "Indexing document time: %s \n", $curTimeDoc );

View File

@@ -1,5 +1,4 @@
<?php
/**
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2012 Colosa Inc.23
@@ -60,13 +59,14 @@ class BpmnEngine_Services_SearchIndex
*
* @param [out] bool true if index service is enabled false in other case
*/
public function isEnabled ()
public function isEnabled($workspace)
{
// require_once (ROOT_PATH .
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
require_once ('class.solr.php');
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
return $solr->isEnabled();
return $solr->isEnabled($workspace);
}
/**
@@ -394,9 +394,9 @@ class BpmnEngine_Services_SearchIndex
$data['aaData'][$i][] = ''; // placeholder
} else {
if (isset( $doc->$columnName )) {
$data['aaData'][$i][] = $doc->$columnName;
$data["aaData"][$i][$columnName] = $doc->$columnName;
} else {
$data['aaData'][$i][] = '';
$data["aaData"][$i][$columnName] = "";
}
}
}
@@ -443,3 +443,4 @@ class BpmnEngine_Services_SearchIndex
}
}

View File

@@ -1,5 +1,4 @@
<?php
/**
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2012 Colosa Inc.23
@@ -48,12 +47,22 @@ class BpmnEngine_SearchIndexAccess_Solr
*
* @return bool
*/
public function isEnabled ()
public function isEnabled($workspace)
{
// verify solr server response
$resultServerStatus = false;
if ($this->_solrIsEnabled != true) {
return $resultServerStatus;
}
return $this->_solrIsEnabled;
//Verify solr server response
try{
$resultServerStatus = $this->ping($workspace);
} catch (Exception $e) {
$resultServerStatus = false;
}
return $resultServerStatus;
}
/**
@@ -435,6 +444,65 @@ class BpmnEngine_SearchIndexAccess_Solr
return $responseSolr;
}
/**
* Ping the Solr Server to check his health
*
* @param string $workspace
* Solr instance name
* @throws Exception
* @return void mixed of field names
*/
public function ping($workspace)
{
if (!$this->_solrIsEnabled) {
return;
}
$solrIntruct = "";
//Get configuration information in base to workspace parameter
$solrIntruct = (substr($this->_solrHost, -1) == "/")? $this->_solrHost : $this->_solrHost . "/";
$solrIntruct .= $workspace;
$solrIntruct .= "/admin/ping?wt=json";
$handler = curl_init($solrIntruct);
curl_setopt($handler, CURLOPT_RETURNTRANSFER, true);
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf["proxy_host"] != "") {
curl_setopt($handler, CURLOPT_PROXY, $sysConf["proxy_host"] . (($sysConf["proxy_port"] != "")? ":" . $sysConf["proxy_port"] : ""));
if ($sysConf["proxy_port"] != "") {
curl_setopt($handler, CURLOPT_PROXYPORT, $sysConf["proxy_port"]);
}
if ($sysConf["proxy_user"] != "") {
curl_setopt($handler, CURLOPT_PROXYUSERPWD, $sysConf["proxy_user"] . (($sysConf["proxy_pass"] != "")? ":" . $sysConf["proxy_pass"] : ""));
}
curl_setopt($handler, CURLOPT_HTTPHEADER, array("Expect:"));
}
$response = curl_exec($handler);
curl_close($handler);
//There's no response
if (!$response) {
return false;
}
//Decode
$responseSolr = G::json_decode ($response);
if ($responseSolr->responseHeader->status != "OK") {
throw new Exception("Error pinging Solr server." . $solrIntruct . " response error: " . $response . "\n");
}
return true;
}
/**
* Delete all documents from index
* @gearman = false
@@ -630,3 +698,4 @@ class BpmnEngine_SearchIndexAccess_Solr
return $responseSolr;
}
}

View File

@@ -6,7 +6,9 @@
*/
class Entity_AppSolrQueue extends Entity_Base
{
public $appUid = '';
public $appUid = "";
public $appChangeDate = "";
public $appChangeTrace = "";
public $appUpdated = 0;
private function __construct ()
@@ -26,7 +28,11 @@ class Entity_AppSolrQueue extends Entity_Base
$obj->initializeObject( $data );
$requiredFields = array ("appUid","appUpdated"
$requiredFields = array(
"appUid",
"appChangeDate",
"appChangeTrace",
"appUpdated"
);
$obj->validateRequiredFields( $requiredFields );

View File

@@ -1,5 +1,4 @@
<?php
//require_once 'classes/model/om/BaseAppSolrQueue.php';
//require_once 'classes/entities/AppSolrQueue.php';
@@ -31,7 +30,7 @@ class AppSolrQueue extends BaseAppSolrQueue
}
}
public function createUpdate ($sAppUid, $iUpdated)
public function createUpdate($sAppUid, $sAppChangeTrace, $iUpdated)
{
$con = Propel::getConnection( AppSolrQueuePeer::DATABASE_NAME );
try {
@@ -44,6 +43,8 @@ class AppSolrQueue extends BaseAppSolrQueue
$this->setNew( false );
//set field
$this->setAppUid($sAppUid);
$this->setAppChangeDate("now");
$this->setAppChangeTrace($sAppChangeTrace);
$this->setAppUpdated($iUpdated);
if ($this->validate()) {
$result = $this->save();
@@ -57,6 +58,8 @@ class AppSolrQueue extends BaseAppSolrQueue
//create record
//set values
$this->setAppUid($sAppUid);
$this->setAppChangeDate("now");
$this->setAppChangeTrace($sAppChangeTrace);
$this->setAppUpdated($iUpdated);
if ($this->validate()) {
$result = $this->save();
@@ -85,6 +88,8 @@ class AppSolrQueue extends BaseAppSolrQueue
$c = new Criteria();
$c->addSelectColumn(AppSolrQueuePeer::APP_UID);
$c->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_DATE);
$c->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_TRACE);
$c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
//"WHERE
@@ -98,8 +103,10 @@ class AppSolrQueue extends BaseAppSolrQueue
while (is_array( $row )) {
$appSolrQueue = Entity_AppSolrQueue::createEmpty();
$appSolrQueue->appUid = $row['APP_UID'];
$appSolrQueue->appUpdated = $row['APP_UPDATED'];
$appSolrQueue->appUid = $row["APP_UID"];
$appSolrQueue->appChangeDate = $row["APP_CHANGE_DATE"];
$appSolrQueue->appChangeTrace = $row["APP_CHANGE_TRACE"];
$appSolrQueue->appUpdated = $row["APP_UPDATED"];
$updatedApplications[] = $appSolrQueue;
$rs->next();
$row = $rs->getRow();

View File

@@ -67,6 +67,10 @@ class AppSolrQueueMapBuilder
$tMap->addPrimaryKey('APP_UID', 'AppUid', 'string', CreoleTypes::VARCHAR, true, 32);
$tMap->addColumn('APP_CHANGE_DATE', 'AppChangeDate', 'int', CreoleTypes::TIMESTAMP, true, null);
$tMap->addColumn('APP_CHANGE_TRACE', 'AppChangeTrace', 'string', CreoleTypes::VARCHAR, true, 500);
$tMap->addColumn('APP_UPDATED', 'AppUpdated', 'int', CreoleTypes::TINYINT, true, null);
} // doBuild()

View File

@@ -33,6 +33,18 @@ abstract class BaseAppSolrQueue extends BaseObject implements Persistent
*/
protected $app_uid = '';
/**
* The value for the app_change_date field.
* @var int
*/
protected $app_change_date;
/**
* The value for the app_change_trace field.
* @var string
*/
protected $app_change_trace;
/**
* The value for the app_updated field.
* @var int
@@ -64,6 +76,49 @@ abstract class BaseAppSolrQueue extends BaseObject implements Persistent
return $this->app_uid;
}
/**
* Get the [optionally formatted] [app_change_date] column value.
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the integer unix timestamp will be returned.
* @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL).
* @throws PropelException - if unable to convert the date/time to timestamp.
*/
public function getAppChangeDate($format = 'Y-m-d H:i:s')
{
if ($this->app_change_date === null || $this->app_change_date === '') {
return null;
} elseif (!is_int($this->app_change_date)) {
// a non-timestamp value was set externally, so we convert it
$ts = strtotime($this->app_change_date);
if ($ts === -1 || $ts === false) {
throw new PropelException("Unable to parse value of [app_change_date] as date/time value: " .
var_export($this->app_change_date, true));
}
} else {
$ts = $this->app_change_date;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
/**
* Get the [app_change_trace] column value.
*
* @return string
*/
public function getAppChangeTrace()
{
return $this->app_change_trace;
}
/**
* Get the [app_updated] column value.
*
@@ -97,6 +152,53 @@ abstract class BaseAppSolrQueue extends BaseObject implements Persistent
} // setAppUid()
/**
* Set the value of [app_change_date] column.
*
* @param int $v new value
* @return void
*/
public function setAppChangeDate($v)
{
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1 || $ts === false) {
throw new PropelException("Unable to parse date/time value for [app_change_date] from input: " .
var_export($v, true));
}
} else {
$ts = $v;
}
if ($this->app_change_date !== $ts) {
$this->app_change_date = $ts;
$this->modifiedColumns[] = AppSolrQueuePeer::APP_CHANGE_DATE;
}
} // setAppChangeDate()
/**
* Set the value of [app_change_trace] column.
*
* @param string $v new value
* @return void
*/
public function setAppChangeTrace($v)
{
// Since the native PHP type for this column is string,
// we will cast the input to a string (if it is not).
if ($v !== null && !is_string($v)) {
$v = (string) $v;
}
if ($this->app_change_trace !== $v) {
$this->app_change_trace = $v;
$this->modifiedColumns[] = AppSolrQueuePeer::APP_CHANGE_TRACE;
}
} // setAppChangeTrace()
/**
* Set the value of [app_updated] column.
*
@@ -138,14 +240,18 @@ abstract class BaseAppSolrQueue extends BaseObject implements Persistent
$this->app_uid = $rs->getString($startcol + 0);
$this->app_updated = $rs->getInt($startcol + 1);
$this->app_change_date = $rs->getTimestamp($startcol + 1, null);
$this->app_change_trace = $rs->getString($startcol + 2);
$this->app_updated = $rs->getInt($startcol + 3);
$this->resetModified();
$this->setNew(false);
// FIXME - using NUM_COLUMNS may be clearer.
return $startcol + 2; // 2 = AppSolrQueuePeer::NUM_COLUMNS - AppSolrQueuePeer::NUM_LAZY_LOAD_COLUMNS).
return $startcol + 4; // 4 = AppSolrQueuePeer::NUM_COLUMNS - AppSolrQueuePeer::NUM_LAZY_LOAD_COLUMNS).
} catch (Exception $e) {
throw new PropelException("Error populating AppSolrQueue object", $e);
@@ -353,6 +459,12 @@ abstract class BaseAppSolrQueue extends BaseObject implements Persistent
return $this->getAppUid();
break;
case 1:
return $this->getAppChangeDate();
break;
case 2:
return $this->getAppChangeTrace();
break;
case 3:
return $this->getAppUpdated();
break;
default:
@@ -376,7 +488,9 @@ abstract class BaseAppSolrQueue extends BaseObject implements Persistent
$keys = AppSolrQueuePeer::getFieldNames($keyType);
$result = array(
$keys[0] => $this->getAppUid(),
$keys[1] => $this->getAppUpdated(),
$keys[1] => $this->getAppChangeDate(),
$keys[2] => $this->getAppChangeTrace(),
$keys[3] => $this->getAppUpdated(),
);
return $result;
}
@@ -412,6 +526,12 @@ abstract class BaseAppSolrQueue extends BaseObject implements Persistent
$this->setAppUid($value);
break;
case 1:
$this->setAppChangeDate($value);
break;
case 2:
$this->setAppChangeTrace($value);
break;
case 3:
$this->setAppUpdated($value);
break;
} // switch()
@@ -442,7 +562,15 @@ abstract class BaseAppSolrQueue extends BaseObject implements Persistent
}
if (array_key_exists($keys[1], $arr)) {
$this->setAppUpdated($arr[$keys[1]]);
$this->setAppChangeDate($arr[$keys[1]]);
}
if (array_key_exists($keys[2], $arr)) {
$this->setAppChangeTrace($arr[$keys[2]]);
}
if (array_key_exists($keys[3], $arr)) {
$this->setAppUpdated($arr[$keys[3]]);
}
}
@@ -460,6 +588,14 @@ abstract class BaseAppSolrQueue extends BaseObject implements Persistent
$criteria->add(AppSolrQueuePeer::APP_UID, $this->app_uid);
}
if ($this->isColumnModified(AppSolrQueuePeer::APP_CHANGE_DATE)) {
$criteria->add(AppSolrQueuePeer::APP_CHANGE_DATE, $this->app_change_date);
}
if ($this->isColumnModified(AppSolrQueuePeer::APP_CHANGE_TRACE)) {
$criteria->add(AppSolrQueuePeer::APP_CHANGE_TRACE, $this->app_change_trace);
}
if ($this->isColumnModified(AppSolrQueuePeer::APP_UPDATED)) {
$criteria->add(AppSolrQueuePeer::APP_UPDATED, $this->app_updated);
}
@@ -518,6 +654,10 @@ abstract class BaseAppSolrQueue extends BaseObject implements Persistent
public function copyInto($copyObj, $deepCopy = false)
{
$copyObj->setAppChangeDate($this->app_change_date);
$copyObj->setAppChangeTrace($this->app_change_trace);
$copyObj->setAppUpdated($this->app_updated);

View File

@@ -25,7 +25,7 @@ abstract class BaseAppSolrQueuePeer
const CLASS_DEFAULT = 'classes.model.AppSolrQueue';
/** The total number of columns. */
const NUM_COLUMNS = 2;
const NUM_COLUMNS = 4;
/** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0;
@@ -34,6 +34,12 @@ abstract class BaseAppSolrQueuePeer
/** the column name for the APP_UID field */
const APP_UID = 'APP_SOLR_QUEUE.APP_UID';
/** the column name for the APP_CHANGE_DATE field */
const APP_CHANGE_DATE = 'APP_SOLR_QUEUE.APP_CHANGE_DATE';
/** the column name for the APP_CHANGE_TRACE field */
const APP_CHANGE_TRACE = 'APP_SOLR_QUEUE.APP_CHANGE_TRACE';
/** the column name for the APP_UPDATED field */
const APP_UPDATED = 'APP_SOLR_QUEUE.APP_UPDATED';
@@ -48,10 +54,10 @@ abstract class BaseAppSolrQueuePeer
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('AppUid', 'AppUpdated', ),
BasePeer::TYPE_COLNAME => array (AppSolrQueuePeer::APP_UID, AppSolrQueuePeer::APP_UPDATED, ),
BasePeer::TYPE_FIELDNAME => array ('APP_UID', 'APP_UPDATED', ),
BasePeer::TYPE_NUM => array (0, 1, )
BasePeer::TYPE_PHPNAME => array ('AppUid', 'AppChangeDate', 'AppChangeTrace', 'AppUpdated', ),
BasePeer::TYPE_COLNAME => array (AppSolrQueuePeer::APP_UID, AppSolrQueuePeer::APP_CHANGE_DATE, AppSolrQueuePeer::APP_CHANGE_TRACE, AppSolrQueuePeer::APP_UPDATED, ),
BasePeer::TYPE_FIELDNAME => array ('APP_UID', 'APP_CHANGE_DATE', 'APP_CHANGE_TRACE', 'APP_UPDATED', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
/**
@@ -61,10 +67,10 @@ abstract class BaseAppSolrQueuePeer
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/
private static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('AppUid' => 0, 'AppUpdated' => 1, ),
BasePeer::TYPE_COLNAME => array (AppSolrQueuePeer::APP_UID => 0, AppSolrQueuePeer::APP_UPDATED => 1, ),
BasePeer::TYPE_FIELDNAME => array ('APP_UID' => 0, 'APP_UPDATED' => 1, ),
BasePeer::TYPE_NUM => array (0, 1, )
BasePeer::TYPE_PHPNAME => array ('AppUid' => 0, 'AppChangeDate' => 1, 'AppChangeTrace' => 2, 'AppUpdated' => 3, ),
BasePeer::TYPE_COLNAME => array (AppSolrQueuePeer::APP_UID => 0, AppSolrQueuePeer::APP_CHANGE_DATE => 1, AppSolrQueuePeer::APP_CHANGE_TRACE => 2, AppSolrQueuePeer::APP_UPDATED => 3, ),
BasePeer::TYPE_FIELDNAME => array ('APP_UID' => 0, 'APP_CHANGE_DATE' => 1, 'APP_CHANGE_TRACE' => 2, 'APP_UPDATED' => 3, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, )
);
/**
@@ -167,6 +173,10 @@ abstract class BaseAppSolrQueuePeer
$criteria->addSelectColumn(AppSolrQueuePeer::APP_UID);
$criteria->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_DATE);
$criteria->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_TRACE);
$criteria->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
}

View File

@@ -2940,6 +2940,8 @@
<parameter name="Comment" value="APP_SOLR_QUEUE"/>
</vendor>
<column name="APP_UID" type="VARCHAR" size="32" required="true" primaryKey="true" default=""/>
<column name="APP_CHANGE_DATE" type="TIMESTAMP" required="true" />
<column name="APP_CHANGE_TRACE" type="VARCHAR" size="500" required="true" />
<column name="APP_UPDATED" type="TINYINT" required="true" default="1"/>
</table>
</database>

View File

@@ -3164,6 +3164,8 @@ END
CREATE TABLE [APP_SOLR_QUEUE]
(
[APP_UID] VARCHAR(32) default '' NOT NULL,
[APP_CHANGE_DATE] CHAR(19) NOT NULL,
[APP_CHANGE_TRACE] VARCHAR(500) NOT NULL,
[APP_UPDATED] TINYINT default 1 NOT NULL,
CONSTRAINT APP_SOLR_QUEUE_PK PRIMARY KEY ([APP_UID])
);

View File

@@ -1432,6 +1432,8 @@ DROP TABLE IF EXISTS `APP_SOLR_QUEUE`;
CREATE TABLE `APP_SOLR_QUEUE`
(
`APP_UID` VARCHAR(32) default '' NOT NULL,
`APP_CHANGE_DATE` DATETIME NOT NULL,
`APP_CHANGE_TRACE` VARCHAR(500) NOT NULL,
`APP_UPDATED` TINYINT default 1 NOT NULL,
PRIMARY KEY (`APP_UID`)
)ENGINE=MyISAM DEFAULT CHARSET='utf8' COMMENT='APP_SOLR_QUEUE';

View File

@@ -175,11 +175,20 @@ function getAllCounters ()
$aTypes['selfservice'] = 'CASES_SELFSERVICE';
//$aTypes['to_revise'] = 'CASES_TO_REVISE';
//$aTypes['to_reassign'] = 'CASES_TO_REASSIGN';
$solrEnabled = false;
if ((($solrConf = System::solrEnv()) !== false)) {
G::LoadClass( 'AppSolr' );
$ApplicationSolrIndex = new AppSolr( $solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance'] );
if ($ApplicationSolrIndex->isSolrEnabled()) {
$solrEnabled = true;
} else {
$solrEnabled = false;
}
}
if ($solrEnabled) {
$aCount = $ApplicationSolrIndex->getCasesCount( $userUid );
//get paused count

View File

@@ -19,6 +19,7 @@ $dateTo = isset( $_POST["dateTo"] ) ? substr( $_POST["dateTo"], 0, 10 ) : "";
try {
$userUid = (isset($_SESSION["USER_LOGGED"]) && $_SESSION["USER_LOGGED"] != "")? $_SESSION["USER_LOGGED"] : null;
$result = "";
$solrEnabled = false;
switch ($action) {
case "search":
@@ -44,6 +45,16 @@ try {
$solrConf["solr_instance"]
);
if ($ApplicationSolrIndex->isSolrEnabled()) {
//Check if there are missing records to reindex and reindex them
$ApplicationSolrIndex->synchronizePendingApplications();
$solrEnabled = true;
} else{
$solrEnabled = false;
}
}
if ($solrEnabled) {
$data = $ApplicationSolrIndex->getAppGridData(
$userUid,
$start,

View File

@@ -422,9 +422,6 @@ Bootstrap::registerClass('Controller', PATH_GULLIVER . "class.controlle
Bootstrap::registerClass('HttpProxyController', PATH_GULLIVER . "class.httpProxyController.php");
Bootstrap::registerClass('templatePower', PATH_GULLIVER . "class.templatePower.php");
Bootstrap::registerClass('XmlForm_Field_SimpleText', PATH_GULLIVER . "class.xmlformExtension.php");
Bootstrap::registerClass('Propel', PATH_THIRDPARTY . "propel/Propel.php");
Bootstrap::registerClass('Creole', PATH_THIRDPARTY . "creole/Creole.php");
Bootstrap::registerClass('Criteria', PATH_THIRDPARTY . "propel/util/Criteria.php");
Bootstrap::registerClass('Groups', PATH_HOME . "engine/classes/class.groups.php");
Bootstrap::registerClass('Tasks', PATH_HOME . "engine/classes/class.tasks.php");
Bootstrap::registerClass('Calendar', PATH_HOME . "engine/classes/class.calendar.php");