SOLR IMPLEMENTATION FOR v4.0 UPDATES (First Part)

This commit is contained in:
Erik Amaru Ortiz
2013-06-05 12:28:48 -04:00
parent b140da984c
commit a7f7109468
21 changed files with 5055 additions and 4450 deletions

View File

@@ -73,11 +73,19 @@ if(count ($argv) > 3) {
}
}
$debug = 1;
ini_set ('display_errors', 1);
error_reporting (E_ALL);
//error_reporting (E_ALL);
ini_set ('memory_limit', '256M'); // set enough memory for the script
$e_all = defined( 'E_DEPRECATED' ) ? E_ALL & ~ E_DEPRECATED : E_ALL;
$e_all = defined( 'E_STRICT' ) ? $e_all & ~ E_STRICT : $e_all;
$e_all = $debug ? $e_all : $e_all & ~ E_NOTICE;
ini_set( 'error_reporting', $e_all );
if (! defined ('SYS_LANG')) {
define ('SYS_LANG', 'en');
}
@@ -104,6 +112,9 @@ if (! defined ('PATH_HOME')) {
define ('PATH_OUTTRUNK', $pathOutTrunk);
require_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
require_once (PATH_GULLIVER . "class.bootstrap.php");
Bootstrap::registerSystemClasses();
spl_autoload_register(array('Bootstrap', 'autoloadClass'));
G::LoadThirdParty ('pear/json', 'class.json');
G::LoadThirdParty ('smarty/libs', 'Smarty.class');
@@ -129,23 +140,10 @@ if (! defined ('PATH_HOME')) {
require_once ("creole/Creole.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';
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
@@ -186,7 +184,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']);
@@ -198,8 +196,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 . '/');
@@ -319,7 +317,7 @@ function processWorkspace()
if($appUid == ""){
print "Missing -appuid parameter. please complete it with this option.\n";
}
$oAppSolr->updateApplicationSearchIndex ($appUid);
$oAppSolr->updateApplicationSearchIndex ($appUid, false);
}
}
else {
@@ -375,4 +373,3 @@ function setExecutionResultMessage($m, $t = '')
$c = 'yellow';
eprintln ("[$m]", $c);
}

View File

@@ -0,0 +1,554 @@
<?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.
*
*/
// check script parameters
// php reindex_solr.php workspacename [reindexall|reindexmissing|optimizeindex] [-skip 1005] [-reindextrunksize 1000]
// var_dump($argv);
//(count ($argv) == 4) || ((count ($argv) == 5) && ($argv [3] != '-skip'))
$commandLineSyntaxMsg = "Invalid command line arguments: \n " .
"Verify the list of cases comparing db vs solr lists by user if usr_uid is specify only verify one user otherwhise all users ".
"syntax: ".
"php verify_solr.php [workspace_name] [-usruid {USR_UID}]\n" .
" Where \n".
" workspace_name : is the workspace that is being verified. \n" .
" Optional Options: \n" .
" -usruid {USR_UID}: verify only one user with the specified user uid. \n ";
if ( (count ($argv) < 2) || ((count ($argv) > 2) && ((count ($argv) % 2) != 0))) {
print $commandLineSyntaxMsg;
die ();
}
$workspaceName = $argv [1];
$usrUid = "";
if((count ($argv) > 2)){
$usrUid = $argv [3];
}
ini_set ('display_errors', 1);
error_reporting (E_ALL);
ini_set ('memory_limit', '256M'); // set enough memory for the script
if (! defined ('SYS_LANG')) {
define ('SYS_LANG', 'en');
}
if (! defined ('PATH_HOME')) {
if (! defined ('PATH_SEP')) {
define ('PATH_SEP', (substr (PHP_OS, 0, 3) == 'WIN') ? '\\' : '/');
}
$docuroot = explode (PATH_SEP, str_replace ('engine' . PATH_SEP . 'methods' . PATH_SEP . 'services', '', dirname (__FILE__)));
array_pop ($docuroot);
array_pop ($docuroot);
$pathhome = implode (PATH_SEP, $docuroot) . PATH_SEP;
// try to find automatically the trunk directory where are placed the RBAC and
// Gulliver directories
// in a normal installation you don't need to change it.
array_pop ($docuroot);
$pathTrunk = implode (PATH_SEP, $docuroot) . PATH_SEP;
array_pop ($docuroot);
$pathOutTrunk = implode (PATH_SEP, $docuroot) . PATH_SEP;
// to do: check previous algorith for Windows $pathTrunk = "c:/home/";
define ('PATH_HOME', $pathhome);
define ('PATH_TRUNK', $pathTrunk);
define ('PATH_OUTTRUNK', $pathOutTrunk);
require_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
G::LoadThirdParty ('pear/json', 'class.json');
G::LoadThirdParty ('smarty/libs', 'Smarty.class');
G::LoadSystem ('error');
G::LoadSystem ('dbconnection');
G::LoadSystem ('dbsession');
G::LoadSystem ('dbrecordset');
G::LoadSystem ('dbtable');
G::LoadSystem ('rbac');
G::LoadSystem ('publisher');
G::LoadSystem ('templatePower');
G::LoadSystem ('xmlDocument');
G::LoadSystem ('xmlform');
G::LoadSystem ('xmlformExtension');
G::LoadSystem ('form');
G::LoadSystem ('menu');
G::LoadSystem ("xmlMenu");
G::LoadSystem ('dvEditor');
G::LoadSystem ('table');
G::LoadSystem ('pagedTable');
G::LoadClass ('system');
require_once ("propel/Propel.php");
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';
// G::loadClass('pmScript');
// //default values
// $bCronIsRunning = false;
// $sLastExecution = '';
// if ( file_exists(PATH_DATA . 'cron') ) {
// $aAux = unserialize( trim( @file_get_contents(PATH_DATA . 'cron')) );
// $bCronIsRunning = (boolean)$aAux['bCronIsRunning'];
// $sLastExecution = $aAux['sLastExecution'];
// }
// else {
// //if not exists the file, just create a new one with current date
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
// '1', 'sLastExecution' => date('Y-m-d H:i:s'))));
// }
print "PATH_HOME: " . PATH_HOME . "\n";
print "PATH_DB: " . PATH_DB . "\n";
print "PATH_CORE: " . PATH_CORE . "\n";
// define the site name (instance name)
if (! defined ('SYS_SYS')) {
$sObject = $workspaceName;
$sNow = ''; // $argv[2];
/*
$sFilter = '';
for ($i = 3; $i < count ($argv); $i++) {
$sFilter .= ' ' . $argv [$i];
}*/
$oDirectory = dir (PATH_DB);
if (is_dir (PATH_DB . $sObject)) {
saveLog ('main', 'action', "checking folder " . PATH_DB . $sObject);
if (file_exists (PATH_DB . $sObject . PATH_SEP . 'db.php')) {
define ('SYS_SYS', $sObject);
// ****************************************
// read initialize file
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']);
define ('TIME_ZONE', $config ['time_zone']);
date_default_timezone_set (TIME_ZONE);
print "TIME_ZONE: " . TIME_ZONE . "\n";
print "MEMCACHED_ENABLED: " . MEMCACHED_ENABLED . "\n";
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');
// ***************** PM Paths DATA **************************
define ('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
define ('PATH_DOCUMENT', PATH_DATA_SITE . 'files/');
define ('PATH_DATA_MAILTEMPLATES', PATH_DATA_SITE . 'mailTemplates/');
define ('PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/');
define ('PATH_DATA_REPORTS', PATH_DATA_SITE . 'reports/');
define ('PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/');
define ('PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles' . PATH_SEP);
define ('PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies' . PATH_SEP);
// server info file
if (is_file (PATH_DATA_SITE . PATH_SEP . '.server_info')) {
$SERVER_INFO = file_get_contents (PATH_DATA_SITE . PATH_SEP . '.server_info');
$SERVER_INFO = unserialize ($SERVER_INFO);
// print_r($SERVER_INFO);
define ('SERVER_NAME', $SERVER_INFO ['SERVER_NAME']);
define ('SERVER_PORT', $SERVER_INFO ['SERVER_PORT']);
}
else {
eprintln ("WARNING! No server info found!", 'red');
}
// read db configuration
$sContent = file_get_contents (PATH_DB . $sObject . PATH_SEP . 'db.php');
$sContent = str_replace ('<?php', '', $sContent);
$sContent = str_replace ('<?', '', $sContent);
$sContent = str_replace ('?>', '', $sContent);
$sContent = str_replace ('define', '', $sContent);
$sContent = str_replace ("('", "$", $sContent);
$sContent = str_replace ("',", '=', $sContent);
$sContent = str_replace (");", ';', $sContent);
eval ($sContent);
$dsn = $DB_ADAPTER . '://' . $DB_USER . ':' . $DB_PASS . '@' . $DB_HOST . '/' . $DB_NAME;
$dsnRbac = $DB_ADAPTER . '://' . $DB_RBAC_USER . ':' . $DB_RBAC_PASS . '@' . $DB_RBAC_HOST . '/' . $DB_RBAC_NAME;
$dsnRp = $DB_ADAPTER . '://' . $DB_REPORT_USER . ':' . $DB_REPORT_PASS . '@' . $DB_REPORT_HOST . '/' . $DB_REPORT_NAME;
switch ($DB_ADAPTER) {
case 'mysql' :
$dsn .= '?encoding=utf8';
$dsnRbac .= '?encoding=utf8';
break;
case 'mssql' :
// $dsn .= '?sendStringAsUnicode=false';
// $dsnRbac .= '?sendStringAsUnicode=false';
break;
default :
break;
}
// initialize db
$pro ['datasources'] ['workflow'] ['connection'] = $dsn;
$pro ['datasources'] ['workflow'] ['adapter'] = $DB_ADAPTER;
$pro ['datasources'] ['rbac'] ['connection'] = $dsnRbac;
$pro ['datasources'] ['rbac'] ['adapter'] = $DB_ADAPTER;
$pro ['datasources'] ['rp'] ['connection'] = $dsnRp;
$pro ['datasources'] ['rp'] ['adapter'] = $DB_ADAPTER;
// $pro['datasources']['dbarray']['connection'] =
// 'dbarray://user:pass@localhost/pm_os';
// $pro['datasources']['dbarray']['adapter'] = 'dbarray';
$oFile = fopen (PATH_CORE . 'config/_databases_.php', 'w');
fwrite ($oFile, '<?php global $pro;return $pro; ?>');
fclose ($oFile);
Propel::init (PATH_CORE . 'config/_databases_.php');
// Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
eprintln ("Processing workspace: " . $sObject, 'green');
try {
processWorkspace ();
}
catch (Exception $e) {
echo $e->getMessage ();
eprintln ("Problem in workspace: " . $sObject . ' it was omitted.', 'red');
}
eprintln ();
unlink (PATH_CORE . 'config/_databases_.php');
}
}
}
else {
processWorkspace ();
}
// finally update the file
// @file_put_contents(PATH_DATA . 'cron', serialize(array('bCronIsRunning' =>
// '0', 'sLastExecution' => date('Y-m-d H:i:s'))));
function processWorkspace()
{
global $sLastExecution;
global $ScriptAction;
//global $SkipRecords;
//global $TrunkSize;
global $usrUid;
try {
//if $usrUid is not set get all the users
//verify inbox
verifyInboxList($usrUid);
//verify draft
verifyDraftList($usrUid);
//verify participated list
verifyParticipatedList($usrUid);
//verify unassigned list
verifyUnassignedList($usrUid);
}
catch (Exception $oError) {
saveLog ("main", "error", "Error processing workspace : " . $oError->getMessage () . "\n");
}
}
function verifyInboxList($usrUid)
{
print "***********************\n";
print "Verify Inbox list: \n";
print "***********************\n";
$result = getListUids($usrUid, 'todo');
$aAppUidsDB = $result['aDBAppUids'];
$aAppUidsSolr = $result['aSolrAppUids'];
displayMissingCases($aAppUidsDB, $aAppUidsSolr);
}
function verifyDraftList($usrUid)
{
print "***********************\n";
print "Verify Draft list: \n";
print "***********************\n";
$result = getListUids($usrUid, 'draft');
$aAppUidsDB = $result['aDBAppUids'];
$aAppUidsSolr = $result['aSolrAppUids'];
displayMissingCases($aAppUidsDB, $aAppUidsSolr);
}
function verifyParticipatedList($usrUid)
{
print "******************************\n";
print "Verify Participated list: \n";
print "******************************\n";
$result = getListUids($usrUid, 'sent');
$aAppUidsDB = $result['aDBAppUids'];
$aAppUidsSolr = $result['aSolrAppUids'];
displayMissingCases($aAppUidsDB, $aAppUidsSolr);
}
function verifyUnassignedList($usrUid)
{
print "******************************\n";
print "Verify Unassigned list: \n";
print "******************************\n";
$result = getListUids($usrUid, 'unassigned');
$aAppUidsDB = $result['aDBAppUids'];
$aAppUidsSolr = $result['aSolrAppUids'];
displayMissingCases($aAppUidsDB, $aAppUidsSolr);
}
function displayMissingCases($aAppUidsDB, $aAppUidsSolr)
{
//verify missing records
//verify size
print " Number of cases: DB:" . count($aAppUidsDB) . " Solr:" . count($aAppUidsSolr) . "\n";
//
if( count($aAppUidsDB) != count($aAppUidsSolr) ){
print " Different number of cases !!! \n";
}
$casesInDBNotSolr = array_diff($aAppUidsDB, $aAppUidsSolr);
$casesInSolrNotDB = array_diff($aAppUidsSolr, $aAppUidsDB);
print " Cases in DB but not in Solr: \n";
foreach($casesInDBNotSolr as $caseDB){
print " ". $caseDB . " \n";
}
print " Cases in Solr but not in DB: \n";
foreach($casesInSolrNotDB as $caseSolr){
print " ". $caseSolr . " \n";
}
}
function getListUids($usrUid, $action)
{
if (($solrConf = System::solrEnv (SYS_SYS)) !== false) {
G::LoadClass ('AppSolr');
print "Solr Configuration file: " . PATH_DATA_SITE . "env.ini\n";
print "solr_enabled: " . $solrConf ['solr_enabled'] . "\n";
print "solr_host: " . $solrConf ['solr_host'] . "\n";
print "solr_instance: " . $solrConf ['solr_instance'] . "\n";
$oAppSolr = new AppSolr ($solrConf ['solr_enabled'], $solrConf ['solr_host'], $solrConf ['solr_instance']);
G::LoadClass("applications");
$apps = new Applications();
}
else {
print "Incomplete Solr configuration. See configuration file: " . PATH_DATA_SITE . "env.ini";
return;
}
//get the list of id's
$userUid = $usrUid;
$start = 0;
$limit = 1;
$action = $action; //todo,
$filter = '';
$search = '';
$process = '';
$user = '';
$status = '';
$type = 'extjs';
$dateFrom = '';
$dateTo = '';
$callback = 'stcCallback1001';
$dir = 'DESC';
$sort = 'APP_NUMBER';
$category = '';
$dataSolr = $oAppSolr->getAppGridData(
$userUid,
$start,
$limit,
$action,
$filter,
$search,
$process,
$user,
$status,
$type,
$dateFrom,
$dateTo,
$callback,
$dir,
$sort
);
$dataDB = $apps->getAll(
$userUid,
$start,
$limit,
$action,
$filter,
$search,
$process,
$user,
$status,
$type,
$dateFrom,
$dateTo,
$callback,
$dir,
$sort,
$category
);
$aAppUidsSolr = array();
$aAppUidsDB = array();
$trunkSize = 1000;
//get DB uids
print "Get DB Uids \n";
$totalCasesDB = $dataDB["totalCount"];
$loops = ((($totalCasesDB % $trunkSize) > 0 )? ($totalCasesDB / $trunkSize)+1: ($totalCasesDB / $trunkSize));
for ($i = 0; $i < $loops; $i++) {
$start = $i * $trunkSize;
$limit = $trunkSize;
//print " Loop $start to " . (String)($start + $trunkSize) . " \n";
$dataDB = $apps->getAll(
$userUid,
$start,
$limit,
$action,
$filter,
$search,
$process,
$user,
$status,
$type,
$dateFrom,
$dateTo,
$callback,
$dir,
$sort,
$category
);
foreach($dataDB["data"] as $caseDB){
$aAppUidsDB[] = $caseDB["APP_UID"];
}
}
//get Solr uids
print "Get Solr Uids \n";
$totalCasesSolr = $dataSolr["totalCount"];
$loops = ((($totalCasesSolr % $trunkSize) > 0 )? ($totalCasesSolr / $trunkSize)+1: ($totalCasesSolr / $trunkSize));
for ($i = 0; $i < $loops; $i++) {
$start = $i * $trunkSize;
$limit = $trunkSize;
//print " Loop $start to " . (String)($start + $trunkSize) . " \n";
$dataSolr = $oAppSolr->getAppGridData(
$userUid,
$start,
$limit,
$action,
$filter,
$search,
$process,
$user,
$status,
$type,
$dateFrom,
$dateTo,
$callback,
$dir,
$sort
);
foreach($dataSolr["data"] as $caseSolr){
$aAppUidsSolr[] = $caseSolr["APP_UID"];
}
}
$result = array();
$result['total_cases_db'] = $totalCasesDB;
$result['aDBAppUids'] = $aAppUidsDB;
$result['total_cases_solr'] = $totalCasesSolr;
$result['aSolrAppUids'] = $aAppUidsSolr;
return $result;
}
function saveLog($sSource, $sType, $sDescription)
{
try {
global $isDebug;
if ($isDebug)
print date ('H:i:s') . " ($sSource) $sType $sDescription <br>\n";
@fwrite ($oFile, date ('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
G::verifyPath (PATH_DATA . 'log' . PATH_SEP, true);
if ($sType == 'action') {
$oFile = @fopen (PATH_DATA . 'log' . PATH_SEP . 'cron.log', 'a+');
}
else {
$oFile = @fopen (PATH_DATA . 'log' . PATH_SEP . 'cronError.log', 'a+');
}
@fwrite ($oFile, date ('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
@fclose ($oFile);
}
catch (Exception $oError) {
// CONTINUE
}
}
function setExecutionMessage($m)
{
$len = strlen ($m);
$linesize = 60;
$rOffset = $linesize - $len;
eprint ("* $m");
for ($i = 0; $i < $rOffset; $i++)
eprint ('.');
}
function setExecutionResultMessage($m, $t = '')
{
$c = 'green';
if ($t == 'error')
$c = 'red';
if ($t == 'info')
$c = 'yellow';
eprintln ("[$m]", $c);
}

File diff suppressed because it is too large Load Diff

View File

@@ -153,7 +153,7 @@ class PMmemcached
public function delete($key)
{
if (!$this->connected) {
if (! $this->connected || $this->class == 'filecache') {
return false;
}
@@ -162,7 +162,7 @@ class PMmemcached
public function flush()
{
if (!$this->connected) {
if (! $this->connected || $this->class == 'filecache') {
return false;
}
@@ -171,7 +171,7 @@ class PMmemcached
public function getStats()
{
if (!$this->connected) {
if (! $this->connected || $this->class == 'filecache') {
return false;
}
@@ -180,7 +180,7 @@ class PMmemcached
public function printDetails()
{
if (!$this->connected) {
if (! $this->connected || $this->class == 'filecache') {
return false;
}

View File

@@ -1,5 +1,6 @@
<?php
/**
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2012 Colosa Inc.23
*
@@ -18,8 +19,10 @@
*
* For more information, contact Colosa Inc, 5304 Ventura Drive,
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
*
*/
/**
* Class used as interface to have access to the search index services
*
@@ -31,7 +34,7 @@ class BpmnEngine_Services_SearchIndex
private $_solrIsEnabled = false;
private $_solrHost = "";
public function __construct ($solrIsEnabled = false, $solrHost = "")
function __construct($solrIsEnabled = false, $solrHost = "")
{
// check if Zend Library is available
// if(class_exists("Zend_Registry")){
@@ -48,7 +51,6 @@ class BpmnEngine_Services_SearchIndex
$this->_solrHost = $solrHost;
// }
}
/**
* Verify if the Solr service is available
* @gearman = false
@@ -57,7 +59,8 @@ class BpmnEngine_Services_SearchIndex
*
* 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($workspace)
{
@@ -65,7 +68,6 @@ class BpmnEngine_Services_SearchIndex
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
require_once ('class.solr.php');
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
return $solr->isEnabled ($workspace);
}
@@ -75,8 +77,10 @@ class BpmnEngine_Services_SearchIndex
* @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
*/
public function getFacetsList($facetRequestEntity)
{
@@ -95,12 +99,10 @@ class BpmnEngine_Services_SearchIndex
$facetRequestEntity->selectedFacetsString = str_replace (',,', ',', $facetRequestEntity->selectedFacetsString);
// remove descriptions of selected facet groups
$aGroups = explode (',', $facetRequestEntity->selectedFacetsString);
$aGroups = array_filter ($aGroups); // remove empty items
$aSelectedFacetGroups = array ();
foreach ($aGroups as $i => $value) {
$gi = explode (':::', $value);
@@ -113,7 +115,12 @@ class BpmnEngine_Services_SearchIndex
if ($count == 0) {
$removeCondition = str_replace ($value, '', $facetRequestEntity->selectedFacetsString, $count);
}
$selectedFacetGroupData = array ('selectedFacetGroupName' => $gr[0],'selectedFacetGroupPrintName' => $gr[1],'selectedFacetItemName' => $it[0],'selectedFacetItemPrintName' => $it[1],'selectedFacetRemoveCondition' => $removeCondition
$selectedFacetGroupData = array (
'selectedFacetGroupName' => $gr [0],
'selectedFacetGroupPrintName' => $gr [1],
'selectedFacetItemName' => $it [0],
'selectedFacetItemPrintName' => $it [1],
'selectedFacetRemoveCondition' => $removeCondition
);
$aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest ($selectedFacetGroupData);
@@ -129,9 +136,11 @@ class BpmnEngine_Services_SearchIndex
// 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->facetFields = array_diff ($facetRequestEntity->facetFields, array (
$value->selectedFacetGroupName
));
$facetRequestEntity->facetDates = array_diff( $facetRequestEntity->facetDates, array ($value->selectedFacetGroupName
$facetRequestEntity->facetDates = array_diff ($facetRequestEntity->facetDates, array (
$value->selectedFacetGroupName
));
}
@@ -165,7 +174,8 @@ class BpmnEngine_Services_SearchIndex
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';
@@ -196,7 +206,8 @@ class BpmnEngine_Services_SearchIndex
if (count ((array)$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';
@@ -209,7 +220,8 @@ class BpmnEngine_Services_SearchIndex
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
} else {
}
else {
// the last group
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
@@ -243,12 +255,14 @@ class BpmnEngine_Services_SearchIndex
$filterText = substr_replace ($filterText, '', - 1);
// $filterText = ($filterText == '')?'':'&filterText='.$filterText;
/**
* ***************************************************************
*/
// Create result
$dataFacetResult = array ('aFacetGroups' => $facetGroups,'aSelectedFacetGroups' => $aSelectedFacetGroups,'sFilterText' => $filterText
$dataFacetResult = array (
'aFacetGroups' => $facetGroups,
'aSelectedFacetGroups' => $aSelectedFacetGroups,
'sFilterText' => $filterText
);
$facetResult = Entity_FacetResult::createForRequest ($dataFacetResult);
@@ -257,7 +271,6 @@ class BpmnEngine_Services_SearchIndex
/**
* Get the total number of documents in search server
*
* @param string $workspace
* @return integer number of documents
*
@@ -277,7 +290,6 @@ class BpmnEngine_Services_SearchIndex
/**
* Update document Index
*
* @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
*/
public function updateIndexDocument($solrUpdateDocumentEntity)
@@ -292,7 +304,6 @@ class BpmnEngine_Services_SearchIndex
/**
* Delete document from index
*
* @param string $workspace
* @param string $idQuery
*/
@@ -308,7 +319,6 @@ class BpmnEngine_Services_SearchIndex
/**
* Commit index changes
*
* @param string $workspace
*/
public function commitIndexChanges($workspace)
@@ -323,7 +333,6 @@ class BpmnEngine_Services_SearchIndex
/**
* Optimize index changes
*
* @param string $workspace
*/
public function optimizeIndexChanges($workspace)
@@ -338,7 +347,6 @@ class BpmnEngine_Services_SearchIndex
/**
* Call Solr server to return the list of paginated pages.
*
* @param FacetRequest $solrRequestData
* @return Entity_SolrQueryResult
*/
@@ -350,23 +358,22 @@ class BpmnEngine_Services_SearchIndex
// prepare the list of sorted columns
// verify if the data of sorting is available
if (isset( $solrRequestData->sortCols[0] )) {
for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
//if (isset ($solrRequestData->sortCols [0])) {
// for ($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
// verify if column is sortable
if ($solrRequestData->includeCols[$solrRequestData->sortCols[$i]] != '' && $solrRequestData->sortableCols[$i] == "true") {
//if ($solrRequestData->includeCols [$solrRequestData->sortCols [$i]] != '' && $solrRequestData->sortableCols [$i] == "true") {
// change sorting column index to column names
$solrRequestData->sortCols[$i] = $solrRequestData->includeCols[$solrRequestData->sortCols[$i]];
//$solrRequestData->sortCols [$i] = $solrRequestData->includeCols [$solrRequestData->sortCols [$i]];
// define the direction of the sorting columns
$solrRequestData->sortDir[$i] = $solrRequestData->sortDir[$i];
}
}
}
//$solrRequestData->sortDir [$i] = $solrRequestData->sortDir [$i];
//}
// }
//}
// remove placeholder fields
// the placeholder doesn't affect the the solr's response
// $solrRequestData->includeCols = array_diff($solrRequestData->includeCols,
// array(''));
// execute query
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
$solrPaginatedResult = $solr->executeQuery ($solrRequestData);
@@ -380,11 +387,13 @@ class BpmnEngine_Services_SearchIndex
$docs = $solrPaginatedResult->response->docs;
// print_r($docs);
// insert list of names in docs result
$data = array ("sEcho" => '', // must be completed in response
$data = array (
"sEcho" => '', // must be completed in response
"iTotalRecords" => intval ($numTotalDocs), // we must get the
// total number of
// documents
"iTotalDisplayRecords" => $numFound,"aaData" => array ()
"iTotalDisplayRecords" => $numFound,
"aaData" => array ()
);
// copy result document or add placeholders to result
foreach ($docs as $i => $doc) {
@@ -392,11 +401,13 @@ class BpmnEngine_Services_SearchIndex
foreach ($solrRequestData->includeCols as $columnName) {
if ($columnName == '') {
$data ['aaData'] [$i] [] = ''; // placeholder
} else {
}
else {
if (isset ($doc->$columnName)) {
$data["aaData"][$i][$columnName] = $doc->$columnName;
} else {
$data["aaData"][$i][$columnName] = "";
$data ['aaData'] [$i] [$columnName] = $doc->$columnName;
}
else {
$data ['aaData'] [$i] [$columnName] = '';
}
}
}
@@ -405,13 +416,11 @@ class BpmnEngine_Services_SearchIndex
$solrQueryResponse = Entity_SolrQueryResult::createForRequest ($data);
//
return $solrQueryResponse;
}
/**
* Return the list of stored fields in the index.
*
* @param string $workspace
* @return array of index fields
*/
@@ -432,7 +441,8 @@ class BpmnEngine_Services_SearchIndex
// $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
// Maintain case sensitive variable names
$listFields [$originalFieldName] = $key;
} else {
}
else {
// $listFields[strtolower($key)] = $key;
// Maintain case sensitive variable names
$listFields [$key] = $key;
@@ -443,4 +453,3 @@ class BpmnEngine_Services_SearchIndex
}
}

View File

@@ -1,6 +1,6 @@
<?php
/**
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2012 Colosa Inc.23
*
@@ -19,19 +19,18 @@
*
* 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
{
const SOLR_VERSION = '&version=2.2';
private $_solrIsEnabled = false;
private $_solrHost = "";
@@ -54,14 +53,13 @@ class BpmnEngine_SearchIndexAccess_Solr
{
$resultServerStatus = false;
if ($this->_solrIsEnabled != true) {
return $resultServerStatus;
}
//if($this->_solrIsEnabled != true)
//return $resultServerStatus;
//Verify solr server response
// verify solr server response
try{
$resultServerStatus = $this->ping($workspace);
} catch (Exception $e) {
}catch(Exception $ex){
$resultServerStatus = false;
}
@@ -74,15 +72,16 @@ class BpmnEngine_SearchIndexAccess_Solr
* @rest = false
* @background = false
*
* @param workspace: workspace name
* @param
* workspace: workspace name
* @return total
*/
public function getNumberDocuments($workspace)
{
if (!$this->_solrIsEnabled) {
return;
}
//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 .= $workspace;
@@ -112,7 +111,7 @@ class BpmnEngine_SearchIndexAccess_Solr
// verify the result of solr
$responseSolrTotal = G::json_decode ($responseTotal);
if ($responseSolrTotal->responseHeader->status != 0) {
throw new Exception("Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error returning the total number of documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
}
$numTotalDocs = $responseSolrTotal->response->numFound;
return $numTotalDocs;
@@ -128,9 +127,8 @@ class BpmnEngine_SearchIndexAccess_Solr
*/
public function executeQuery($solrRequestData)
{
if (!$this->_solrIsEnabled) {
return;
}
//if (! $this->_solrIsEnabled)
//return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
$workspace = $solrRequestData->workspace;
@@ -196,7 +194,7 @@ class BpmnEngine_SearchIndexAccess_Solr
// decode
$responseSolr = G::json_decode ($response);
if ($responseSolr->responseHeader->status != 0) {
throw new Exception("Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error executing query to Solr." . $solrIntruct . " response error: " . $response . "\n");
}
return $responseSolr;
@@ -212,9 +210,8 @@ class BpmnEngine_SearchIndexAccess_Solr
*/
public function updateDocument($solrUpdateDocument)
{
if (!$this->_solrIsEnabled) {
return;
}
//if (! $this->_solrIsEnabled)
//return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
@@ -223,10 +220,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init ($solrIntruct);
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml'
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
'Content-type:application/xml'
)); // -H
curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
curl_setopt ($handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document); // data
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
@@ -245,7 +244,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) {
throw new Exception("Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error updating document in Solr." . $solrIntruct . " response error: " . $response . "\n");
}
}
@@ -259,9 +258,8 @@ class BpmnEngine_SearchIndexAccess_Solr
*/
public function commitChanges($workspace)
{
if (!$this->_solrIsEnabled) {
return;
}
//if (! $this->_solrIsEnabled)
//return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
@@ -270,9 +268,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init ($solrIntruct);
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H
curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
'Content-type:application/xml'
)); // -H
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
curl_setopt ($handler, CURLOPT_POSTFIELDS, "<commit/>"); // data
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
@@ -291,7 +292,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) {
throw new Exception("Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error commiting changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
}
}
@@ -305,9 +306,8 @@ class BpmnEngine_SearchIndexAccess_Solr
*/
public function rollbackChanges($workspace)
{
if (!$this->_solrIsEnabled) {
return;
}
//if (! $this->_solrIsEnabled)
//return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
@@ -317,9 +317,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init ($solrIntruct);
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H
curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
'Content-type:application/xml'
)); // -H
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
curl_setopt ($handler, CURLOPT_POSTFIELDS, "<rollback/>"); // data
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
@@ -338,7 +341,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) {
throw new Exception("Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error rolling back changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
}
}
@@ -352,9 +355,8 @@ class BpmnEngine_SearchIndexAccess_Solr
*/
public function optimizeChanges($workspace)
{
if (!$this->_solrIsEnabled) {
return;
}
//if (! $this->_solrIsEnabled)
//return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
@@ -364,9 +366,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init ($solrIntruct);
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H
curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
'Content-type:application/xml'
)); // -H
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
curl_setopt ($handler, CURLOPT_POSTFIELDS, "<optimize/>"); // data
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
@@ -385,22 +390,22 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) {
throw new Exception("Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error optimizing changes in Solr." . $solrIntruct . " response error: " . $response . "\n");
}
}
/**
* 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 of field names
*/
public function getListIndexedStoredFields($workspace)
{
if (!$this->_solrIsEnabled) {
return;
}
//if (! $this->_solrIsEnabled)
//return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
@@ -429,7 +434,7 @@ class BpmnEngine_SearchIndexAccess_Solr
// decode
$responseSolr = G::json_decode ($response);
if ($responseSolr->responseHeader->status != 0) {
throw new Exception("Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error getting index fields in Solr." . $solrIntruct . " response error: " . $response . "\n");
}
return $responseSolr;
}
@@ -444,52 +449,29 @@ class BpmnEngine_SearchIndexAccess_Solr
*/
public function ping($workspace)
{
if (!$this->_solrIsEnabled) {
return;
}
//if (! $this->_solrIsEnabled)
//return;
$solrIntruct = "";
//Get configuration information in base to workspace parameter
$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) {
//there's no response
if(!$response)
return false;
}
//Decode
// decode
$responseSolr = G::json_decode ($response);
if ($responseSolr->responseHeader->status != "OK") {
throw new Exception("Error pinging Solr server." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error pinging Solr server." . $solrIntruct . " response error: " . $response . "\n");
}
return true;
}
@@ -503,12 +485,10 @@ class BpmnEngine_SearchIndexAccess_Solr
*/
public function deleteAllDocuments($workspace)
{
if (!$this->_solrIsEnabled) {
return;
}
//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 . "/";
@@ -517,9 +497,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init ($solrIntruct);
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H
curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
'Content-type:application/xml'
)); // -H
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
curl_setopt ($handler, CURLOPT_POSTFIELDS, "<delete><query>*:*</query></delete>"); // data
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
@@ -539,7 +522,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) {
throw new Exception("Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error deleting all documents in Solr." . $solrIntruct . " response error: " . $response . "\n");
}
}
@@ -553,12 +536,10 @@ class BpmnEngine_SearchIndexAccess_Solr
*/
public function deleteDocument($workspace, $idQuery)
{
if (!$this->_solrIsEnabled) {
return;
}
//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 . "/";
@@ -567,9 +548,12 @@ class BpmnEngine_SearchIndexAccess_Solr
$handler = curl_init ($solrIntruct);
curl_setopt ($handler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handler, CURLOPT_HTTPHEADER, array('Content-type:application/xml')); // -H
curl_setopt($handler, CURLOPT_BINARYTRANSFER, true); // --data-binary
curl_setopt ($handler, CURLOPT_HTTPHEADER, array (
'Content-type:application/xml'
)); // -H
curl_setopt ($handler, CURLOPT_BINARYTRANSFER, TRUE); // --data-binary
curl_setopt ($handler, CURLOPT_POSTFIELDS, "<delete><query>" . $idQuery . "</query></delete>"); // data
//Apply proxy settings
$sysConf = System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
@@ -589,7 +573,7 @@ class BpmnEngine_SearchIndexAccess_Solr
$swOk = strpos ($response, '<int name="status">0</int>');
if (! $swOk) {
throw new Exception("Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error deleting document in Solr." . $solrIntruct . " response error: " . $response . "\n");
}
}
@@ -601,9 +585,8 @@ class BpmnEngine_SearchIndexAccess_Solr
*/
public function getFacetsList($facetRequest)
{
if (!$this->_solrIsEnabled) {
return;
}
//if (! $this->_solrIsEnabled)
//return;
$solrIntruct = '';
// get configuration information in base to workspace parameter
@@ -638,7 +621,6 @@ class BpmnEngine_SearchIndexAccess_Solr
}
// echo "<pre>";
$resultFormat = '&wt=json';
$solrIntruct = (substr ($this->_solrHost, - 1) == "/") ? $this->_solrHost : $this->_solrHost . "/";
@@ -676,10 +658,9 @@ class BpmnEngine_SearchIndexAccess_Solr
// decode
$responseSolr = G::json_decode ($response);
if ($responseSolr->responseHeader->status != 0) {
throw new Exception("Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n");
throw new Exception (date('Y-m-d H:i:s:u') . " Error getting faceted list from Solr." . $solrIntruct . " response error: " . $response . "\n");
}
return $responseSolr;
}
}

View File

@@ -1,14 +1,14 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
/**
* Application Solr Queue
*/
class Entity_AppSolrQueue extends Entity_Base
{
public $appUid = "";
public $appChangeDate = "";
public $appChangeTrace = "";
public $appUid = '';
public $appChangeDate = '';
public $appChangeTrace = '';
public $appUpdated = 0;
private function __construct()
@@ -39,5 +39,5 @@ class Entity_AppSolrQueue extends Entity_Base
return $obj;
}
}
}

View File

@@ -15,7 +15,8 @@ class Entity_Base
// one element
if (is_array ($field)) {
$fields = $field;
} else {
}
else {
$fields = array ();
$fields [] = $field;
}
@@ -41,7 +42,7 @@ class Entity_Base
protected function validateRequiredFields($requiredFields = array())
{
foreach ($requiredFields as $k => $field) {
if ($this->{$field} === null) {
if ($this->{$field} === NULL) {
throw (new Exception ("Field $field is required in " . get_class ($this)));
die ();
}
@@ -52,7 +53,6 @@ class Entity_Base
*
*
*
*
* Copy the values of the Entity to the array of aliases
* The array of aliases must be defined.
*
@@ -64,10 +64,12 @@ class Entity_Base
// 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) {
foreach ($this as $field => $value)
if (isset ($aliases [$field])) {
// echo "Field exists in Aliases: " . $field . "\n";
// echo "Alias Name:" . $aliases[$field] . "\n";
@@ -75,7 +77,6 @@ class Entity_Base
$aAlias [$aliases [$field]] = $value;
}
}
}
return $aAlias;
}
@@ -84,36 +85,36 @@ class Entity_Base
*
*
*
*
* Set the data from array of alias to Entity
*
* @param $aAliasData array of data of aliases
* @param $aAliasData array
* of data of aliases
*/
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] )) {
foreach ($this as $field => $value)
if (isset ($aliases [$field]))
$this->{$field} = $aAliasData [$aliases [$field]];
}
}
}
}
/**
*
*
*
*
* Initialize object with values from $data.
* The values from data use properties or alias array.
*
* @param $data
* @param
* $data
*/
protected function initializeObject($data)
{
@@ -122,26 +123,27 @@ class Entity_Base
$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;
}
// use object properties or aliases to initialize
foreach ($this as $field => $value) {
foreach ($this as $field => $value)
if (isset ($data [$field])) {
$this->$field = $data [$field];
} elseif ($swAliases && isset( $aliases[$field] ) && isset( $data[$aliases[$field]] )) {
$this->$field = $data[$aliases[$field]];
}
elseif ($swAliases && isset ($aliases [$field]) && isset ($data [$aliases [$field]])) {
$this->$field = $data [$aliases [$field]];
}
}
public function serialize()
{
if (isset( $this->temp )) {
if (isset ($this->temp))
unset ($this->temp);
}
return serialize ($this);
}
@@ -151,5 +153,5 @@ class Entity_Base
$data = unserialize ($str);
return new $className ($data);
}
}
}

View File

@@ -1,5 +1,5 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
/**
* Facet group entity that represent a facet group
@@ -38,12 +38,14 @@ class Entity_FacetGroup extends Entity_Base
$obj->initializeObject ($data);
$requiredFields = array ("facetGroupName","facetItems"
$requiredFields = array (
"facetGroupName",
"facetItems"
);
$obj->validateRequiredFields ($requiredFields);
return $obj;
}
}
}

View File

@@ -1,18 +1,16 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
class Entity_FacetInterfaceRequest extends Entity_Base
{
public $searchText = '';
public $selectedFacetsString = ''; // string of selected facet groups and
// items in format:
// groupkey1::groupdesc1:::itemkey1::itemdesc1,groupkey2::groupdesc2:::itemkey2::itemdesc2,
// groupkey3::groupdesc3:::itemkey3::itemdesc3
// var $selectedFacetFields = array();
// var $selectedFacetTypes = array();
private function __construct()
{
}
@@ -29,12 +27,14 @@ class Entity_FacetInterfaceRequest extends Entity_Base
$obj->initializeObject ($data);
$requiredFields = array ("searchText","selectedFacetsString"
$requiredFields = array (
"searchText",
"selectedFacetsString"
);
$obj->validateRequiredFields ($requiredFields);
return $obj;
}
}
}

View File

@@ -1,11 +1,10 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
class Entity_FacetInterfaceResult extends Entity_Base
{
// array of facetsgroups, array of Entity_SelectedFacetGroupItem, filter text
public $aFacetGroup = array ();
public $aSelectedFacetGroupItem = array ();
public $sFilterText = '';
@@ -26,12 +25,15 @@ class Entity_FacetInterfaceResult extends Entity_Base
$obj->initializeObject ($data);
$requiredFields = array ("aFacetGroup","aSelectedFacetGroupItem","sFilterText"
$requiredFields = array (
"aFacetGroup",
"aSelectedFacetGroupItem",
"sFilterText"
);
$obj->validateRequiredFields ($requiredFields);
return $obj;
}
}
}

View File

@@ -1,11 +1,10 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
/**
*
*
*
*
* Entity Face item, represent an option in a facet group
*
* @author dev-HebertSaak
@@ -17,10 +16,8 @@ class Entity_FacetItem extends Entity_Base
public $facetPrintName = '';
public $facetCount = '';
public $facetSelectCondition = ''; // selected condition used to select
// this facet
private function __construct()
{
}
@@ -37,12 +34,14 @@ class Entity_FacetItem extends Entity_Base
$obj->initializeObject ($data);
$requiredFields = array ("facetName","facetCount"
$requiredFields = array (
"facetName",
"facetCount"
);
$obj->validateRequiredFields ($requiredFields);
return $obj;
}
}
}

View File

@@ -1,10 +1,8 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
class Entity_FacetRequest extends Entity_Base
{
public $workspace = '';
public $searchText = '';
public $facetFields = array ();
@@ -21,13 +19,13 @@ class Entity_FacetRequest extends Entity_Base
{
}
public static function createEmpty()
static function createEmpty()
{
$obj = new Entity_FacetRequest ();
return $obj;
}
public static function createForRequest($data)
static function createForRequest($data)
{
$obj = new Entity_FacetRequest ();
@@ -41,5 +39,5 @@ class Entity_FacetRequest extends Entity_Base
return $obj;
}
}
}

View File

@@ -1,5 +1,5 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
class Entity_FacetResult extends Entity_Base
{
@@ -23,12 +23,15 @@ class Entity_FacetResult extends Entity_Base
$obj->initializeObject ($data);
$requiredFields = array ("aFacetGroups","aSelectedFacetGroups","sFilterText"
$requiredFields = array (
"aFacetGroups",
"aSelectedFacetGroups",
"sFilterText"
);
$obj->validateRequiredFields ($requiredFields);
return $obj;
}
}
}

View File

@@ -1,5 +1,5 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
class Entity_SelectedFacetGroupItem extends Entity_Base
{
@@ -8,11 +8,9 @@ class Entity_SelectedFacetGroupItem extends Entity_Base
public $selectedFacetItemName = '';
public $selectedFacetItemPrintName = '';
public $selectedFacetRemoveCondition = ''; // remove condition, string of
// selected facets without this
// facet
private function __construct()
{
}
@@ -29,12 +27,14 @@ class Entity_SelectedFacetGroupItem extends Entity_Base
$obj->initializeObject ($data);
$requiredFields = array ("selectedFacetGroupName","selectedFacetItemName"
$requiredFields = array (
"selectedFacetGroupName",
"selectedFacetItemName"
);
$obj->validateRequiredFields ($requiredFields);
return $obj;
}
}
}

View File

@@ -1,5 +1,5 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
class Entity_SolrQueryResult extends Entity_Base
{
@@ -7,10 +7,8 @@ class Entity_SolrQueryResult extends Entity_Base
public $iTotalRecords = 0;
public $iTotalDisplayRecords = 10;
public $aaData = array (); // array of arrays of records to
// display
private function __construct()
{
}
@@ -27,12 +25,16 @@ class Entity_SolrQueryResult extends Entity_Base
$obj->initializeObject ($data);
$requiredFields = array ('sEcho','iTotalRecords','iTotalDisplayRecords','aaData'
$requiredFields = array (
'sEcho',
'iTotalRecords',
'iTotalDisplayRecords',
'aaData'
);
$obj->validateRequiredFields ($requiredFields);
return $obj;
}
}
}

View File

@@ -1,10 +1,8 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
class Entity_SolrRequestData extends Entity_Base
{
public $workspace = '';
public $startAfter = 0;
public $pageSize = 10;
@@ -24,13 +22,13 @@ class Entity_SolrRequestData extends Entity_Base
{
}
public static function createEmpty()
static function createEmpty()
{
$obj = new Entity_SolrRequestData ();
return $obj;
}
public static function createForRequestPagination($data)
static function createForRequestPagination($data)
{
$obj = new Entity_SolrRequestData ();
@@ -44,5 +42,5 @@ class Entity_SolrRequestData extends Entity_Base
return $obj;
}
}
}

View File

@@ -1,5 +1,5 @@
<?php
//require_once ('Base.php');
require_once ('Base.php');
class Entity_SolrUpdateDocument extends Entity_Base
{
@@ -22,12 +22,14 @@ class Entity_SolrUpdateDocument extends Entity_Base
$obj->initializeObject ($data);
$requiredFields = array ("workspace","document"
$requiredFields = array (
"workspace",
"document"
);
$obj->validateRequiredFields ($requiredFields);
return $obj;
}
}
}

View File

@@ -81,7 +81,7 @@ class AppSolrQueue extends BaseAppSolrQueue
* Returns the list of updated applications
* array of Entity_AppSolrQueue
*/
public function getListUpdatedApplications ()
public function getListUpdatedApplications($updated = true, $deleted = true)
{
$updatedApplications = array ();
try {
@@ -93,7 +93,15 @@ class AppSolrQueue extends BaseAppSolrQueue
$c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
//"WHERE
if($updated == true && $deleted == true){
$c->add(AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL);
}
if($updated == true && $deleted == false){
$c->add(AppSolrQueuePeer::APP_UPDATED, 1, Criteria::EQUAL);
}
if($updated == false && $deleted == true){
$c->add(AppSolrQueuePeer::APP_UPDATED, 2, Criteria::EQUAL);
}
$rs = AppSolrQueuePeer::doSelectRS($c);
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
@@ -111,11 +119,11 @@ class AppSolrQueue extends BaseAppSolrQueue
$rs->next();
$row = $rs->getRow();
}
return $updatedApplications;
} catch (Exception $e) {
$con->rollback();
throw ($e);
}
}
}
} // AppSolrQueue

View File

@@ -181,10 +181,8 @@ function getAllCounters ()
G::LoadClass( 'AppSolr' );
$ApplicationSolrIndex = new AppSolr( $solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance'] );
if ($ApplicationSolrIndex->isSolrEnabled()) {
if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
$solrEnabled = true;
} else {
$solrEnabled = false;
}
}

View File

@@ -62,7 +62,7 @@ try {
$solrConf["solr_instance"]
);
if ($ApplicationSolrIndex->isSolrEnabled()) {
if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
//Check if there are missing records to reindex and reindex them
$ApplicationSolrIndex->synchronizePendingApplications();
$solrEnabled = true;