SOLR IMPLEMENTATION FOR v4.0 UPDATES (First Part)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
||||||
*
|
*
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 5304 Ventura Drive,
|
* For more information, contact Colosa Inc, 5304 Ventura Drive,
|
||||||
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
|
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// check script parameters
|
// check script parameters
|
||||||
@@ -28,18 +28,18 @@
|
|||||||
//(count ($argv) == 4) || ((count ($argv) == 5) && ($argv [3] != '-skip'))
|
//(count ($argv) == 4) || ((count ($argv) == 5) && ($argv [3] != '-skip'))
|
||||||
$commandLineSyntaxMsg = "Invalid command line arguments: \n " .
|
$commandLineSyntaxMsg = "Invalid command line arguments: \n " .
|
||||||
"syntax: ".
|
"syntax: ".
|
||||||
"php reindex_solr.php [workspace_name] [reindexall|reindexmissing|optimizeindex|reindexone] [-skip {record_number}] [-reindextrunksize {trunk_size}] [-appuid {APP_UID}]\n" .
|
"php reindex_solr.php [workspace_name] [reindexall|reindexmissing|optimizeindex|reindexone] [-skip {record_number}] [-reindextrunksize {trunk_size}] [-appuid {APP_UID}]\n" .
|
||||||
" Where \n".
|
" Where \n".
|
||||||
" reindexall : reindex all the database. \n" .
|
" reindexall : reindex all the database. \n" .
|
||||||
" reindexmissing: reindex only the missing records stored in database. \n".
|
" reindexmissing: reindex only the missing records stored in database. \n".
|
||||||
" (records defined in APP_SOLR_QUEUE table are required)\n" .
|
" (records defined in APP_SOLR_QUEUE table are required)\n" .
|
||||||
" optimizeindex: optimize the changes in the search index. (used to get faster results) \n" .
|
" optimizeindex: optimize the changes in the search index. (used to get faster results) \n" .
|
||||||
" Optional Options: \n" .
|
" Optional Options: \n" .
|
||||||
" -skip {record_number}: used to skip a number of records. \n ex: -skip 10000 //skips the first 10000 records. \n" .
|
" -skip {record_number}: used to skip a number of records. \n ex: -skip 10000 //skips the first 10000 records. \n" .
|
||||||
" -reindextrunksize {trunk_size}: specify the number of records sent to index each time. \n ex: -reindextrunksize 100 //(default = 1000) \n Reduce the trunk if using big documents, and memory is not enough. \n";
|
" -reindextrunksize {trunk_size}: specify the number of records sent to index each time. \n ex: -reindextrunksize 100 //(default = 1000) \n Reduce the trunk if using big documents, and memory is not enough. \n";
|
||||||
|
|
||||||
if ( (count ($argv) < 3) || ((count ($argv) % 2) == 0) ||
|
if ( (count ($argv) < 3) || ((count ($argv) % 2) == 0) ||
|
||||||
($argv [2] != 'reindexall' && $argv [2] != 'reindexmissing' && $argv [2] != 'optimizeindex' && $argv [2] != 'reindexone')) {
|
($argv [2] != 'reindexall' && $argv [2] != 'reindexmissing' && $argv [2] != 'optimizeindex' && $argv [2] != 'reindexone')) {
|
||||||
print $commandLineSyntaxMsg;
|
print $commandLineSyntaxMsg;
|
||||||
die ();
|
die ();
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ if(count ($argv) > 3) {
|
|||||||
if($argv [$argNumber] == '-appuid') {
|
if($argv [$argNumber] == '-appuid') {
|
||||||
//use skip option
|
//use skip option
|
||||||
$appUid = $argv [$argNumber + 1];
|
$appUid = $argv [$argNumber + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print $commandLineSyntaxMsg;
|
print $commandLineSyntaxMsg;
|
||||||
@@ -73,11 +73,19 @@ if(count ($argv) > 3) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$debug = 1;
|
||||||
|
|
||||||
ini_set ('display_errors', 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
|
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')) {
|
if (! defined ('SYS_LANG')) {
|
||||||
define ('SYS_LANG', 'en');
|
define ('SYS_LANG', 'en');
|
||||||
}
|
}
|
||||||
@@ -98,13 +106,16 @@ if (! defined ('PATH_HOME')) {
|
|||||||
array_pop ($docuroot);
|
array_pop ($docuroot);
|
||||||
$pathOutTrunk = implode (PATH_SEP, $docuroot) . PATH_SEP;
|
$pathOutTrunk = implode (PATH_SEP, $docuroot) . PATH_SEP;
|
||||||
// to do: check previous algorith for Windows $pathTrunk = "c:/home/";
|
// to do: check previous algorith for Windows $pathTrunk = "c:/home/";
|
||||||
|
|
||||||
define ('PATH_HOME', $pathhome);
|
define ('PATH_HOME', $pathhome);
|
||||||
define ('PATH_TRUNK', $pathTrunk);
|
define ('PATH_TRUNK', $pathTrunk);
|
||||||
define ('PATH_OUTTRUNK', $pathOutTrunk);
|
define ('PATH_OUTTRUNK', $pathOutTrunk);
|
||||||
|
|
||||||
require_once (PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
|
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 ('pear/json', 'class.json');
|
||||||
G::LoadThirdParty ('smarty/libs', 'Smarty.class');
|
G::LoadThirdParty ('smarty/libs', 'Smarty.class');
|
||||||
G::LoadSystem ('error');
|
G::LoadSystem ('error');
|
||||||
@@ -129,23 +140,10 @@ if (! defined ('PATH_HOME')) {
|
|||||||
require_once ("creole/Creole.php");
|
require_once ("creole/Creole.php");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists(PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php")) {
|
require_once 'classes/model/AppDelegation.php';
|
||||||
require_once (PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php");
|
require_once 'classes/model/Event.php';
|
||||||
}
|
require_once 'classes/model/AppEvent.php';
|
||||||
|
require_once 'classes/model/CaseScheduler.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');
|
// G::loadClass('pmScript');
|
||||||
|
|
||||||
// //default values
|
// //default values
|
||||||
@@ -171,36 +169,36 @@ if (! defined ('SYS_SYS')) {
|
|||||||
$sObject = $workspaceName;
|
$sObject = $workspaceName;
|
||||||
$sNow = ''; // $argv[2];
|
$sNow = ''; // $argv[2];
|
||||||
$sFilter = '';
|
$sFilter = '';
|
||||||
|
|
||||||
for ($i = 3; $i < count ($argv); $i++) {
|
for ($i = 3; $i < count ($argv); $i++) {
|
||||||
$sFilter .= ' ' . $argv [$i];
|
$sFilter .= ' ' . $argv [$i];
|
||||||
}
|
}
|
||||||
|
|
||||||
$oDirectory = dir (PATH_DB);
|
$oDirectory = dir (PATH_DB);
|
||||||
|
|
||||||
if (is_dir (PATH_DB . $sObject)) {
|
if (is_dir (PATH_DB . $sObject)) {
|
||||||
saveLog ('main', 'action', "checking folder " . PATH_DB . $sObject);
|
saveLog ('main', 'action', "checking folder " . PATH_DB . $sObject);
|
||||||
if (file_exists (PATH_DB . $sObject . PATH_SEP . 'db.php')) {
|
if (file_exists (PATH_DB . $sObject . PATH_SEP . 'db.php')) {
|
||||||
|
|
||||||
define ('SYS_SYS', $sObject);
|
define ('SYS_SYS', $sObject);
|
||||||
|
|
||||||
// ****************************************
|
// ****************************************
|
||||||
// read initialize file
|
// 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);
|
$config = System::getSystemConfiguration ('', '', SYS_SYS);
|
||||||
define ('MEMCACHED_ENABLED', $config ['memcached']);
|
define ('MEMCACHED_ENABLED', $config ['memcached']);
|
||||||
define ('MEMCACHED_SERVER', $config ['memcached_server']);
|
define ('MEMCACHED_SERVER', $config ['memcached_server']);
|
||||||
define ('TIME_ZONE', $config ['time_zone']);
|
define ('TIME_ZONE', $config ['time_zone']);
|
||||||
|
|
||||||
date_default_timezone_set (TIME_ZONE);
|
date_default_timezone_set (TIME_ZONE);
|
||||||
print "TIME_ZONE: " . TIME_ZONE . "\n";
|
print "TIME_ZONE: " . TIME_ZONE . "\n";
|
||||||
print "MEMCACHED_ENABLED: " . MEMCACHED_ENABLED . "\n";
|
print "MEMCACHED_ENABLED: " . MEMCACHED_ENABLED . "\n";
|
||||||
print "MEMCACHED_SERVER: " . MEMCACHED_SERVER . "\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_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.php');
|
||||||
|
|
||||||
// ***************** PM Paths DATA **************************
|
// ***************** PM Paths DATA **************************
|
||||||
define ('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
|
define ('PATH_DATA_SITE', PATH_DATA . 'sites/' . SYS_SYS . '/');
|
||||||
define ('PATH_DOCUMENT', PATH_DATA_SITE . 'files/');
|
define ('PATH_DOCUMENT', PATH_DATA_SITE . 'files/');
|
||||||
@@ -210,7 +208,7 @@ if (! defined ('SYS_SYS')) {
|
|||||||
define ('PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/');
|
define ('PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/');
|
||||||
define ('PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles' . PATH_SEP);
|
define ('PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles' . PATH_SEP);
|
||||||
define ('PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies' . PATH_SEP);
|
define ('PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies' . PATH_SEP);
|
||||||
|
|
||||||
// server info file
|
// server info file
|
||||||
if (is_file (PATH_DATA_SITE . PATH_SEP . '.server_info')) {
|
if (is_file (PATH_DATA_SITE . PATH_SEP . '.server_info')) {
|
||||||
$SERVER_INFO = file_get_contents (PATH_DATA_SITE . PATH_SEP . '.server_info');
|
$SERVER_INFO = file_get_contents (PATH_DATA_SITE . PATH_SEP . '.server_info');
|
||||||
@@ -222,10 +220,10 @@ if (! defined ('SYS_SYS')) {
|
|||||||
else {
|
else {
|
||||||
eprintln ("WARNING! No server info found!", 'red');
|
eprintln ("WARNING! No server info found!", 'red');
|
||||||
}
|
}
|
||||||
|
|
||||||
// read db configuration
|
// read db configuration
|
||||||
$sContent = file_get_contents (PATH_DB . $sObject . PATH_SEP . 'db.php');
|
$sContent = file_get_contents (PATH_DB . $sObject . PATH_SEP . 'db.php');
|
||||||
|
|
||||||
$sContent = str_replace ('<?php', '', $sContent);
|
$sContent = str_replace ('<?php', '', $sContent);
|
||||||
$sContent = str_replace ('<?', '', $sContent);
|
$sContent = str_replace ('<?', '', $sContent);
|
||||||
$sContent = str_replace ('?>', '', $sContent);
|
$sContent = str_replace ('?>', '', $sContent);
|
||||||
@@ -233,7 +231,7 @@ if (! defined ('SYS_SYS')) {
|
|||||||
$sContent = str_replace ("('", "$", $sContent);
|
$sContent = str_replace ("('", "$", $sContent);
|
||||||
$sContent = str_replace ("',", '=', $sContent);
|
$sContent = str_replace ("',", '=', $sContent);
|
||||||
$sContent = str_replace (");", ';', $sContent);
|
$sContent = str_replace (");", ';', $sContent);
|
||||||
|
|
||||||
eval ($sContent);
|
eval ($sContent);
|
||||||
$dsn = $DB_ADAPTER . '://' . $DB_USER . ':' . $DB_PASS . '@' . $DB_HOST . '/' . $DB_NAME;
|
$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;
|
$dsnRbac = $DB_ADAPTER . '://' . $DB_RBAC_USER . ':' . $DB_RBAC_PASS . '@' . $DB_RBAC_HOST . '/' . $DB_RBAC_NAME;
|
||||||
@@ -265,7 +263,7 @@ if (! defined ('SYS_SYS')) {
|
|||||||
fclose ($oFile);
|
fclose ($oFile);
|
||||||
Propel::init (PATH_CORE . 'config/_databases_.php');
|
Propel::init (PATH_CORE . 'config/_databases_.php');
|
||||||
// Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
|
// Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
|
||||||
|
|
||||||
eprintln ("Processing workspace: " . $sObject, 'green');
|
eprintln ("Processing workspace: " . $sObject, 'green');
|
||||||
try {
|
try {
|
||||||
processWorkspace ();
|
processWorkspace ();
|
||||||
@@ -295,16 +293,16 @@ function processWorkspace()
|
|||||||
global $SkipRecords;
|
global $SkipRecords;
|
||||||
global $TrunkSize;
|
global $TrunkSize;
|
||||||
global $appUid;
|
global $appUid;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if (($solrConf = System::solrEnv (SYS_SYS)) !== false) {
|
if (($solrConf = System::solrEnv (SYS_SYS)) !== false) {
|
||||||
G::LoadClass ('AppSolr');
|
G::LoadClass ('AppSolr');
|
||||||
print "Solr Configuration file: " . PATH_DATA_SITE . "env.ini\n";
|
print "Solr Configuration file: " . PATH_DATA_SITE . "env.ini\n";
|
||||||
print "solr_enabled: " . $solrConf ['solr_enabled'] . "\n";
|
print "solr_enabled: " . $solrConf ['solr_enabled'] . "\n";
|
||||||
print "solr_host: " . $solrConf ['solr_host'] . "\n";
|
print "solr_host: " . $solrConf ['solr_host'] . "\n";
|
||||||
print "solr_instance: " . $solrConf ['solr_instance'] . "\n";
|
print "solr_instance: " . $solrConf ['solr_instance'] . "\n";
|
||||||
|
|
||||||
$oAppSolr = new AppSolr ($solrConf ['solr_enabled'], $solrConf ['solr_host'], $solrConf ['solr_instance']);
|
$oAppSolr = new AppSolr ($solrConf ['solr_enabled'], $solrConf ['solr_host'], $solrConf ['solr_instance']);
|
||||||
if ($ScriptAction == "reindexall") {
|
if ($ScriptAction == "reindexall") {
|
||||||
$oAppSolr->reindexAllApplications ($SkipRecords, $TrunkSize);
|
$oAppSolr->reindexAllApplications ($SkipRecords, $TrunkSize);
|
||||||
@@ -319,13 +317,13 @@ function processWorkspace()
|
|||||||
if($appUid == ""){
|
if($appUid == ""){
|
||||||
print "Missing -appuid parameter. please complete it with this option.\n";
|
print "Missing -appuid parameter. please complete it with this option.\n";
|
||||||
}
|
}
|
||||||
$oAppSolr->updateApplicationSearchIndex ($appUid);
|
$oAppSolr->updateApplicationSearchIndex ($appUid, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "Incomplete Solr configuration. See configuration file: " . PATH_DATA_SITE . "env.ini";
|
print "Incomplete Solr configuration. See configuration file: " . PATH_DATA_SITE . "env.ini";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception $oError) {
|
catch (Exception $oError) {
|
||||||
saveLog ("main", "error", "Error processing workspace : " . $oError->getMessage () . "\n");
|
saveLog ("main", "error", "Error processing workspace : " . $oError->getMessage () . "\n");
|
||||||
@@ -339,7 +337,7 @@ function saveLog($sSource, $sType, $sDescription)
|
|||||||
if ($isDebug)
|
if ($isDebug)
|
||||||
print date ('H:i:s') . " ($sSource) $sType $sDescription <br>\n";
|
print date ('H:i:s') . " ($sSource) $sType $sDescription <br>\n";
|
||||||
@fwrite ($oFile, date ('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
|
@fwrite ($oFile, date ('Y-m-d H:i:s') . '(' . $sSource . ') ' . $sDescription . "\n");
|
||||||
|
|
||||||
G::verifyPath (PATH_DATA . 'log' . PATH_SEP, true);
|
G::verifyPath (PATH_DATA . 'log' . PATH_SEP, true);
|
||||||
if ($sType == 'action') {
|
if ($sType == 'action') {
|
||||||
$oFile = @fopen (PATH_DATA . 'log' . PATH_SEP . 'cron.log', 'a+');
|
$oFile = @fopen (PATH_DATA . 'log' . PATH_SEP . 'cron.log', 'a+');
|
||||||
@@ -360,7 +358,7 @@ function setExecutionMessage($m)
|
|||||||
$len = strlen ($m);
|
$len = strlen ($m);
|
||||||
$linesize = 60;
|
$linesize = 60;
|
||||||
$rOffset = $linesize - $len;
|
$rOffset = $linesize - $len;
|
||||||
|
|
||||||
eprint ("* $m");
|
eprint ("* $m");
|
||||||
for ($i = 0; $i < $rOffset; $i++)
|
for ($i = 0; $i < $rOffset; $i++)
|
||||||
eprint ('.');
|
eprint ('.');
|
||||||
@@ -375,4 +373,3 @@ function setExecutionResultMessage($m, $t = '')
|
|||||||
$c = 'yellow';
|
$c = 'yellow';
|
||||||
eprintln ("[$m]", $c);
|
eprintln ("[$m]", $c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
554
workflow/engine/bin/verify_solr.php
Normal file
554
workflow/engine/bin/verify_solr.php
Normal 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
@@ -153,7 +153,7 @@ class PMmemcached
|
|||||||
|
|
||||||
public function delete($key)
|
public function delete($key)
|
||||||
{
|
{
|
||||||
if (!$this->connected) {
|
if (! $this->connected || $this->class == 'filecache') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ class PMmemcached
|
|||||||
|
|
||||||
public function flush()
|
public function flush()
|
||||||
{
|
{
|
||||||
if (!$this->connected) {
|
if (! $this->connected || $this->class == 'filecache') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ class PMmemcached
|
|||||||
|
|
||||||
public function getStats()
|
public function getStats()
|
||||||
{
|
{
|
||||||
if (!$this->connected) {
|
if (! $this->connected || $this->class == 'filecache') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,13 +180,13 @@ class PMmemcached
|
|||||||
|
|
||||||
public function printDetails()
|
public function printDetails()
|
||||||
{
|
{
|
||||||
if (!$this->connected) {
|
if (! $this->connected || $this->class == 'filecache') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$status = $this->mem->getStats();
|
$status = $this->mem->getStats();
|
||||||
|
|
||||||
if (!is_array($status)) {
|
if (! is_array($status)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* ProcessMaker Open Source Edition
|
* ProcessMaker Open Source Edition
|
||||||
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
* Copyright (C) 2004 - 2012 Colosa Inc.23
|
||||||
*
|
*
|
||||||
@@ -18,429 +19,437 @@
|
|||||||
*
|
*
|
||||||
* For more information, contact Colosa Inc, 5304 Ventura Drive,
|
* For more information, contact Colosa Inc, 5304 Ventura Drive,
|
||||||
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
|
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class used as interface to have access to the search index services
|
* Class used as interface to have access to the search index services
|
||||||
*
|
*
|
||||||
* @author Herbert Saal Gutierrez
|
* @author Herbert Saal Gutierrez
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class BpmnEngine_Services_SearchIndex
|
class BpmnEngine_Services_SearchIndex
|
||||||
{
|
{
|
||||||
private $_solrIsEnabled = false;
|
private $_solrIsEnabled = false;
|
||||||
private $_solrHost = "";
|
private $_solrHost = "";
|
||||||
|
|
||||||
public function __construct ($solrIsEnabled = false, $solrHost = "")
|
function __construct($solrIsEnabled = false, $solrHost = "")
|
||||||
{
|
{
|
||||||
// check if Zend Library is available
|
// check if Zend Library is available
|
||||||
// if(class_exists("Zend_Registry")){
|
// if(class_exists("Zend_Registry")){
|
||||||
// $registry = Zend_Registry::getInstance();
|
// $registry = Zend_Registry::getInstance();
|
||||||
// //check if configuration is enabled
|
// //check if configuration is enabled
|
||||||
// $this->solrIsEnabled = $registry->isRegistered('solrEnabled') &&
|
// $this->solrIsEnabled = $registry->isRegistered('solrEnabled') &&
|
||||||
// $registry->get('solrEnabled') == 1;
|
// $registry->get('solrEnabled') == 1;
|
||||||
// $this->solrHost =
|
// $this->solrHost =
|
||||||
// $registry->isRegistered('solrHost')?$registry->get('solrHost'):"";
|
// $registry->isRegistered('solrHost')?$registry->get('solrHost'):"";
|
||||||
// }
|
// }
|
||||||
// else{
|
// else{
|
||||||
// //use the parameters to initialize class
|
// //use the parameters to initialize class
|
||||||
$this->_solrIsEnabled = $solrIsEnabled;
|
$this->_solrIsEnabled = $solrIsEnabled;
|
||||||
$this->_solrHost = $solrHost;
|
$this->_solrHost = $solrHost;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* Verify if the Solr service is available
|
||||||
|
* @gearman = false
|
||||||
|
* @rest = false
|
||||||
|
* @background = false
|
||||||
|
*
|
||||||
|
* no input parameters @param[in]
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* [out] bool true if index service is enabled false in other case
|
||||||
|
*/
|
||||||
|
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 ($workspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
public function getFacetsList($facetRequestEntity)
|
||||||
|
{
|
||||||
|
require_once ('class.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');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verify if the Solr service is available
|
* ***************************************************************
|
||||||
* @gearman = false
|
|
||||||
* @rest = false
|
|
||||||
* @background = false
|
|
||||||
*
|
|
||||||
* no input parameters @param[in]
|
|
||||||
*
|
|
||||||
* @param [out] bool true if index service is enabled false in other case
|
|
||||||
*/
|
*/
|
||||||
public function isEnabled($workspace)
|
// get array of selected facet groups
|
||||||
{
|
$facetRequestEntity->selectedFacetsString = str_replace (',,', ',', $facetRequestEntity->selectedFacetsString);
|
||||||
// require_once (ROOT_PATH .
|
// remove descriptions of selected facet groups
|
||||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
|
||||||
require_once ('class.solr.php');
|
$aGroups = explode (',', $facetRequestEntity->selectedFacetsString);
|
||||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
|
||||||
|
$aGroups = array_filter ($aGroups); // remove empty items
|
||||||
return $solr->isEnabled($workspace);
|
|
||||||
|
$aSelectedFacetGroups = array ();
|
||||||
|
foreach ($aGroups as $i => $value) {
|
||||||
|
$gi = explode (':::', $value);
|
||||||
|
$gr = explode ('::', $gi [0]);
|
||||||
|
$it = explode ('::', $gi [1]);
|
||||||
|
|
||||||
|
// create string for remove condition
|
||||||
|
$count = 0;
|
||||||
|
$removeCondition = str_replace ($value . ',', '', $facetRequestEntity->selectedFacetsString, $count);
|
||||||
|
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
|
||||||
|
);
|
||||||
|
|
||||||
|
$aSelectedFacetGroups [] = Entity_SelectedFacetGroupItem::createForRequest ($selectedFacetGroupData);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
|
||||||
*/
|
*/
|
||||||
public function getFacetsList ($facetRequestEntity)
|
// convert request to index request
|
||||||
{
|
// create filters
|
||||||
require_once ('class.solr.php');
|
$filters = array ();
|
||||||
// require_once (ROOT_PATH .
|
if (! empty ($aSelectedFacetGroups)) {
|
||||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
// exclude facetFields and facetDates included in filter from the next
|
||||||
require_once ('entities/FacetGroup.php');
|
// list of facets
|
||||||
require_once ('entities/FacetItem.php');
|
foreach ($aSelectedFacetGroups as $value) {
|
||||||
require_once ('entities/SelectedFacetGroupItem.php');
|
$facetRequestEntity->facetFields = array_diff ($facetRequestEntity->facetFields, array (
|
||||||
require_once ('entities/FacetResult.php');
|
$value->selectedFacetGroupName
|
||||||
|
));
|
||||||
/**
|
$facetRequestEntity->facetDates = array_diff ($facetRequestEntity->facetDates, array (
|
||||||
* ***************************************************************
|
$value->selectedFacetGroupName
|
||||||
*/
|
));
|
||||||
// get array of selected facet groups
|
}
|
||||||
$facetRequestEntity->selectedFacetsString = str_replace( ',,', ',', $facetRequestEntity->selectedFacetsString );
|
|
||||||
// remove descriptions of selected facet groups
|
// $facetFields = array_diff($facetFields,
|
||||||
|
// $facetInterfaceRequestEntity->selectedFacetGroups);
|
||||||
|
// $facetDates = array_diff($facetDates,
|
||||||
$aGroups = explode( ',', $facetRequestEntity->selectedFacetsString );
|
// $facetInterfaceRequestEntity->selectedFacetGroups);
|
||||||
|
foreach ($aSelectedFacetGroups as $group) {
|
||||||
$aGroups = array_filter( $aGroups ); // remove empty items
|
$filters [] = $group->selectedFacetGroupName . ':' . urlencode ($group->selectedFacetItemName);
|
||||||
|
}
|
||||||
|
}
|
||||||
$aSelectedFacetGroups = array ();
|
$facetRequestEntity->filters = $filters;
|
||||||
foreach ($aGroups as $i => $value) {
|
|
||||||
$gi = explode( ':::', $value );
|
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||||
$gr = explode( '::', $gi[0] );
|
|
||||||
$it = explode( '::', $gi[1] );
|
// create list of facets
|
||||||
|
$facetsList = $solr->getFacetsList ($facetRequestEntity);
|
||||||
// create string for remove condition
|
|
||||||
$count = 0;
|
$numFound = $facetsList->response->numFound;
|
||||||
$removeCondition = str_replace( $value . ',', '', $facetRequestEntity->selectedFacetsString, $count );
|
|
||||||
if ($count == 0) {
|
$facetCounts = $facetsList->facet_counts;
|
||||||
$removeCondition = str_replace( $value, '', $facetRequestEntity->selectedFacetsString, $count );
|
|
||||||
}
|
$facetGroups = array ();
|
||||||
$selectedFacetGroupData = array ('selectedFacetGroupName' => $gr[0],'selectedFacetGroupPrintName' => $gr[1],'selectedFacetItemName' => $it[0],'selectedFacetItemPrintName' => $it[1],'selectedFacetRemoveCondition' => $removeCondition
|
// convert facet fields result to objects
|
||||||
);
|
/**
|
||||||
|
* *********************************************************************
|
||||||
$aSelectedFacetGroups[] = Entity_SelectedFacetGroupItem::createForRequest( $selectedFacetGroupData );
|
*/
|
||||||
|
// include facet field results
|
||||||
|
$facetFieldsResult = $facetsList->facet_counts->facet_fields;
|
||||||
|
if (! empty ($facetFieldsResult)) {
|
||||||
|
foreach ($facetFieldsResult as $facetGroup => $facetvalues) {
|
||||||
|
if (count ($facetvalues) > 0) // if the group have facets included
|
||||||
|
{
|
||||||
|
$data = array (
|
||||||
|
'facetGroupName' => $facetGroup
|
||||||
|
);
|
||||||
|
$data ['facetGroupPrintName'] = $facetGroup;
|
||||||
|
$data ['facetGroupType'] = 'field';
|
||||||
|
$facetItems = array ();
|
||||||
|
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);
|
||||||
|
$facetItems [] = $newFacetItem;
|
||||||
|
}
|
||||||
|
$data ['facetItems'] = $facetItems;
|
||||||
|
$newFacetGroup = Entity_FacetGroup::createForInsert ($data);
|
||||||
|
|
||||||
|
$facetGroups [] = $newFacetGroup;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* ***************************************************************
|
|
||||||
*/
|
|
||||||
// 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
|
|
||||||
foreach ($aSelectedFacetGroups as $value) {
|
|
||||||
$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);
|
|
||||||
foreach ($aSelectedFacetGroups as $group) {
|
|
||||||
$filters[] = $group->selectedFacetGroupName . ':' . urlencode( $group->selectedFacetItemName );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$facetRequestEntity->filters = $filters;
|
|
||||||
|
|
||||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
|
||||||
|
|
||||||
// create list of facets
|
|
||||||
$facetsList = $solr->getFacetsList( $facetRequestEntity );
|
|
||||||
|
|
||||||
$numFound = $facetsList->response->numFound;
|
|
||||||
|
|
||||||
$facetCounts = $facetsList->facet_counts;
|
|
||||||
|
|
||||||
$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 (count( $facetvalues ) > 0) // if the group have facets included
|
|
||||||
{
|
|
||||||
$data = array ('facetGroupName' => $facetGroup
|
|
||||||
);
|
|
||||||
$data['facetGroupPrintName'] = $facetGroup;
|
|
||||||
$data['facetGroupType'] = 'field';
|
|
||||||
$facetItems = array ();
|
|
||||||
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 );
|
|
||||||
$facetItems[] = $newFacetItem;
|
|
||||||
}
|
|
||||||
$data['facetItems'] = $facetItems;
|
|
||||||
$newFacetGroup = Entity_FacetGroup::createForInsert( $data );
|
|
||||||
|
|
||||||
$facetGroups[] = $newFacetGroup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* *********************************************************************
|
|
||||||
*/
|
|
||||||
// include facet date ranges results
|
|
||||||
$facetDatesResult = $facetsList->facet_counts->facet_dates;
|
|
||||||
if (! empty( $facetDatesResult )) {
|
|
||||||
foreach ($facetDatesResult as $facetGroup => $facetvalues) {
|
|
||||||
if (count( (array) $facetvalues ) > 3) // if the group have any facets included
|
|
||||||
// besides start, end and gap
|
|
||||||
{
|
|
||||||
$data = array ('facetGroupName' => $facetGroup
|
|
||||||
);
|
|
||||||
$data['facetGroupPrintName'] = $facetGroup;
|
|
||||||
$data['facetGroupType'] = 'daterange';
|
|
||||||
$facetItems = array ();
|
|
||||||
$facetvalueskeys = array_keys( (array) $facetvalues );
|
|
||||||
foreach ($facetvalueskeys as $i => $k) {
|
|
||||||
if ($k != 'gap' && $k != 'start' && $k != 'end') {
|
|
||||||
$dataItem = array ();
|
|
||||||
if ($i < count( $facetvalueskeys ) - 4) {
|
|
||||||
|
|
||||||
$dataItem['facetName'] = '[' . $k . '%20TO%20' . $facetvalueskeys[$i + 1] . ']';
|
|
||||||
$dataItem['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalueskeys[$i + 1] . ']';
|
|
||||||
} else {
|
|
||||||
// the last group
|
|
||||||
$dataItem['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
|
||||||
$dataItem['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
|
||||||
}
|
|
||||||
|
|
||||||
$dataItem['facetCount'] = $facetvalues->$k;
|
|
||||||
$dataItem['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty( $facetRequestEntity->selectedFacetsString ) ? '' : ',') . $data['facetGroupName'] . '::' . $data['facetGroupPrintName'] . ':::' . $dataItem['facetName'] . '::' . $dataItem['facetPrintName'];
|
|
||||||
$newFacetItem = Entity_FacetItem::createForInsert( $dataItem );
|
|
||||||
$facetItems[] = $newFacetItem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$data['facetItems'] = $facetItems;
|
|
||||||
$newFacetGroup = Entity_FacetGroup::createForInsert( $data );
|
|
||||||
|
|
||||||
$facetGroups[] = $newFacetGroup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 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 .= $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 );
|
|
||||||
|
|
||||||
return $facetResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the total number of documents in search server
|
* *********************************************************************
|
||||||
*
|
|
||||||
* @param string $workspace
|
|
||||||
* @return integer number of documents
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
public function getNumberDocuments ($workspace)
|
// include facet date ranges results
|
||||||
{
|
$facetDatesResult = $facetsList->facet_counts->facet_dates;
|
||||||
require_once ('class.solr.php');
|
if (! empty ($facetDatesResult)) {
|
||||||
// require_once (ROOT_PATH .
|
foreach ($facetDatesResult as $facetGroup => $facetvalues) {
|
||||||
// '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
if (count ((array)$facetvalues) > 3) // if the group have any facets included
|
||||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
// besides start, end and gap
|
||||||
|
{
|
||||||
// create list of facets
|
$data = array (
|
||||||
$numberDocuments = $solr->getNumberDocuments( $workspace );
|
'facetGroupName' => $facetGroup
|
||||||
|
);
|
||||||
return $numberDocuments;
|
$data ['facetGroupPrintName'] = $facetGroup;
|
||||||
}
|
$data ['facetGroupType'] = 'daterange';
|
||||||
|
$facetItems = array ();
|
||||||
/**
|
$facetvalueskeys = array_keys ((array)$facetvalues);
|
||||||
* Update document Index
|
foreach ($facetvalueskeys as $i => $k) {
|
||||||
*
|
if ($k != 'gap' && $k != 'start' && $k != 'end') {
|
||||||
* @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
|
$dataItem = array ();
|
||||||
*/
|
if ($i < count ($facetvalueskeys) - 4) {
|
||||||
public function updateIndexDocument ($solrUpdateDocumentEntity)
|
|
||||||
{
|
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
|
||||||
G::LoadClass( 'solr' );
|
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalueskeys [$i + 1] . ']';
|
||||||
|
}
|
||||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
else {
|
||||||
|
// the last group
|
||||||
// create list of facets
|
$dataItem ['facetName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||||
$solr->updateDocument( $solrUpdateDocumentEntity );
|
$dataItem ['facetPrintName'] = '[' . $k . '%20TO%20' . $facetvalues->end . ']';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
$dataItem ['facetCount'] = $facetvalues->$k;
|
||||||
* Delete document from index
|
$dataItem ['facetSelectCondition'] = $facetRequestEntity->selectedFacetsString . (empty ($facetRequestEntity->selectedFacetsString) ? '' : ',') . $data ['facetGroupName'] . '::' . $data ['facetGroupPrintName'] . ':::' . $dataItem ['facetName'] . '::' . $dataItem ['facetPrintName'];
|
||||||
*
|
$newFacetItem = Entity_FacetItem::createForInsert ($dataItem);
|
||||||
* @param string $workspace
|
$facetItems [] = $newFacetItem;
|
||||||
* @param string $idQuery
|
|
||||||
*/
|
|
||||||
public function deleteDocumentFromIndex ($workspace, $idQuery)
|
|
||||||
{
|
|
||||||
G::LoadClass( 'solr' );
|
|
||||||
|
|
||||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
|
||||||
|
|
||||||
// create list of facets
|
|
||||||
$solr->deleteDocument( $workspace, $idQuery );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Commit index changes
|
|
||||||
*
|
|
||||||
* @param string $workspace
|
|
||||||
*/
|
|
||||||
public function commitIndexChanges ($workspace)
|
|
||||||
{
|
|
||||||
G::LoadClass( 'solr' );
|
|
||||||
|
|
||||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
|
||||||
|
|
||||||
// commit
|
|
||||||
$solr->commitChanges( $workspace );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optimize index changes
|
|
||||||
*
|
|
||||||
* @param string $workspace
|
|
||||||
*/
|
|
||||||
public function optimizeIndexChanges ($workspace)
|
|
||||||
{
|
|
||||||
G::LoadClass( 'solr' );
|
|
||||||
|
|
||||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
|
||||||
|
|
||||||
// commit
|
|
||||||
$solr->optimizeChanges( $workspace );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 ('entities/SolrRequestData.php');
|
|
||||||
require_once ('entities/SolrQueryResult.php');
|
|
||||||
|
|
||||||
// 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 ++) {
|
|
||||||
// verify if column is sortable
|
|
||||||
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]];
|
|
||||||
// define the direction of the sorting columns
|
|
||||||
$solrRequestData->sortDir[$i] = $solrRequestData->sortDir[$i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$data ['facetItems'] = $facetItems;
|
||||||
|
$newFacetGroup = Entity_FacetGroup::createForInsert ($data);
|
||||||
|
|
||||||
|
$facetGroups [] = $newFacetGroup;
|
||||||
}
|
}
|
||||||
// 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 );
|
|
||||||
|
|
||||||
// get total number of documents in index
|
|
||||||
$numTotalDocs = $solr->getNumberDocuments( $solrRequestData->workspace );
|
|
||||||
|
|
||||||
// create the Datatable response of the query
|
|
||||||
$numFound = $solrPaginatedResult->response->numFound;
|
|
||||||
|
|
||||||
$docs = $solrPaginatedResult->response->docs;
|
|
||||||
// print_r($docs);
|
|
||||||
// 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
|
|
||||||
"iTotalDisplayRecords" => $numFound,"aaData" => array ()
|
|
||||||
);
|
|
||||||
// copy result document or add placeholders to result
|
|
||||||
foreach ($docs as $i => $doc) {
|
|
||||||
$data['aaData'][$i] = array ();
|
|
||||||
foreach ($solrRequestData->includeCols as $columnName) {
|
|
||||||
if ($columnName == '') {
|
|
||||||
$data['aaData'][$i][] = ''; // placeholder
|
|
||||||
} else {
|
|
||||||
if (isset( $doc->$columnName )) {
|
|
||||||
$data["aaData"][$i][$columnName] = $doc->$columnName;
|
|
||||||
} else {
|
|
||||||
$data["aaData"][$i][$columnName] = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$solrQueryResponse = Entity_SolrQueryResult::createForRequest( $data );
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
return $solrQueryResponse;
|
|
||||||
}
|
}
|
||||||
|
// TODO:convert facet queries
|
||||||
|
// -----
|
||||||
/**
|
/**
|
||||||
* Return the list of stored fields in the index.
|
* ***************************************************************
|
||||||
*
|
|
||||||
* @param string $workspace
|
|
||||||
* @return array of index fields
|
|
||||||
*/
|
*/
|
||||||
public function getIndexFields ($workspace)
|
// Create a filter string used in the filter of results of a datatable
|
||||||
{
|
$filterText = ''; // the list of selected filters used for filtering result,
|
||||||
require_once ('class.solr.php');
|
// send in ajax
|
||||||
|
foreach ($aSelectedFacetGroups as $selectedFacetGroup) {
|
||||||
$solr = new BpmnEngine_SearchIndexAccess_Solr( $this->_solrIsEnabled, $this->_solrHost );
|
$filterText .= $selectedFacetGroup->selectedFacetGroupName . ':' . urlencode ($selectedFacetGroup->selectedFacetItemName) . ',';
|
||||||
|
|
||||||
// print "SearchIndex!!!!";
|
|
||||||
// create list of facets
|
|
||||||
$solrFieldsData = $solr->getListIndexedStoredFields( $workspace );
|
|
||||||
// copy list of arrays
|
|
||||||
$listFields = array ();
|
|
||||||
foreach ($solrFieldsData->fields as $key => $fieldData) {
|
|
||||||
if (array_key_exists( 'dynamicBase', $fieldData )) {
|
|
||||||
$originalFieldName = substr( $key, 0, - strlen( $fieldData->dynamicBase ) + 1 );
|
|
||||||
// $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
|
|
||||||
// Maintain case sensitive variable names
|
|
||||||
$listFields[$originalFieldName] = $key;
|
|
||||||
} else {
|
|
||||||
// $listFields[strtolower($key)] = $key;
|
|
||||||
// Maintain case sensitive variable names
|
|
||||||
$listFields[$key] = $key;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $listFields;
|
|
||||||
}
|
}
|
||||||
|
$filterText = substr_replace ($filterText, '', - 1);
|
||||||
|
// $filterText = ($filterText == '')?'':'&filterText='.$filterText;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ***************************************************************
|
||||||
|
*/
|
||||||
|
// Create result
|
||||||
|
$dataFacetResult = array (
|
||||||
|
'aFacetGroups' => $facetGroups,
|
||||||
|
'aSelectedFacetGroups' => $aSelectedFacetGroups,
|
||||||
|
'sFilterText' => $filterText
|
||||||
|
);
|
||||||
|
$facetResult = Entity_FacetResult::createForRequest ($dataFacetResult);
|
||||||
|
|
||||||
|
return $facetResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
// create list of facets
|
||||||
|
$numberDocuments = $solr->getNumberDocuments ($workspace);
|
||||||
|
|
||||||
|
return $numberDocuments;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update document Index
|
||||||
|
* @param SolrUpdateDocumentEntity $solrUpdateDocumentEntity
|
||||||
|
*/
|
||||||
|
public function updateIndexDocument($solrUpdateDocumentEntity)
|
||||||
|
{
|
||||||
|
G::LoadClass ('solr');
|
||||||
|
|
||||||
|
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||||
|
|
||||||
|
// create list of facets
|
||||||
|
$solr->updateDocument ($solrUpdateDocumentEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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);
|
||||||
|
|
||||||
|
// create list of facets
|
||||||
|
$solr->deleteDocument ($workspace, $idQuery);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit index changes
|
||||||
|
* @param string $workspace
|
||||||
|
*/
|
||||||
|
public function commitIndexChanges($workspace)
|
||||||
|
{
|
||||||
|
G::LoadClass ('solr');
|
||||||
|
|
||||||
|
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||||
|
|
||||||
|
// commit
|
||||||
|
$solr->commitChanges ($workspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Optimize index changes
|
||||||
|
* @param string $workspace
|
||||||
|
*/
|
||||||
|
public function optimizeIndexChanges($workspace)
|
||||||
|
{
|
||||||
|
G::LoadClass ('solr');
|
||||||
|
|
||||||
|
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||||
|
|
||||||
|
// commit
|
||||||
|
$solr->optimizeChanges ($workspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ('entities/SolrRequestData.php');
|
||||||
|
require_once ('entities/SolrQueryResult.php');
|
||||||
|
|
||||||
|
// 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 ++) {
|
||||||
|
// verify if column is sortable
|
||||||
|
//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]];
|
||||||
|
// define the direction of the sorting columns
|
||||||
|
//$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);
|
||||||
|
|
||||||
|
// get total number of documents in index
|
||||||
|
$numTotalDocs = $solr->getNumberDocuments ($solrRequestData->workspace);
|
||||||
|
|
||||||
|
// create the Datatable response of the query
|
||||||
|
$numFound = $solrPaginatedResult->response->numFound;
|
||||||
|
|
||||||
|
$docs = $solrPaginatedResult->response->docs;
|
||||||
|
// print_r($docs);
|
||||||
|
// 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
|
||||||
|
"iTotalDisplayRecords" => $numFound,
|
||||||
|
"aaData" => array ()
|
||||||
|
);
|
||||||
|
// copy result document or add placeholders to result
|
||||||
|
foreach ($docs as $i => $doc) {
|
||||||
|
$data ['aaData'] [$i] = array ();
|
||||||
|
foreach ($solrRequestData->includeCols as $columnName) {
|
||||||
|
if ($columnName == '') {
|
||||||
|
$data ['aaData'] [$i] [] = ''; // placeholder
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (isset ($doc->$columnName)) {
|
||||||
|
$data ['aaData'] [$i] [$columnName] = $doc->$columnName;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$data ['aaData'] [$i] [$columnName] = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$solrQueryResponse = Entity_SolrQueryResult::createForRequest ($data);
|
||||||
|
//
|
||||||
|
|
||||||
|
return $solrQueryResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the list of stored fields in the index.
|
||||||
|
* @param string $workspace
|
||||||
|
* @return array of index fields
|
||||||
|
*/
|
||||||
|
public function getIndexFields($workspace)
|
||||||
|
{
|
||||||
|
require_once ('class.solr.php');
|
||||||
|
|
||||||
}
|
$solr = new BpmnEngine_SearchIndexAccess_Solr ($this->_solrIsEnabled, $this->_solrHost);
|
||||||
|
|
||||||
|
// print "SearchIndex!!!!";
|
||||||
|
// create list of facets
|
||||||
|
$solrFieldsData = $solr->getListIndexedStoredFields ($workspace);
|
||||||
|
// copy list of arrays
|
||||||
|
$listFields = array ();
|
||||||
|
foreach ($solrFieldsData->fields as $key => $fieldData) {
|
||||||
|
if (array_key_exists ('dynamicBase', $fieldData)) {
|
||||||
|
$originalFieldName = substr ($key, 0, - strlen ($fieldData->dynamicBase) + 1);
|
||||||
|
// $listFields[strtolower($originalFieldName)] = $key; //in case of case insentive strings
|
||||||
|
// Maintain case sensitive variable names
|
||||||
|
$listFields [$originalFieldName] = $key;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// $listFields[strtolower($key)] = $key;
|
||||||
|
// Maintain case sensitive variable names
|
||||||
|
$listFields [$key] = $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $listFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,43 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
//require_once ('Base.php');
|
require_once ('Base.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Application Solr Queue
|
* Application Solr Queue
|
||||||
*/
|
*/
|
||||||
class Entity_AppSolrQueue extends Entity_Base
|
class Entity_AppSolrQueue extends Entity_Base
|
||||||
{
|
{
|
||||||
public $appUid = "";
|
public $appUid = '';
|
||||||
public $appChangeDate = "";
|
public $appChangeDate = '';
|
||||||
public $appChangeTrace = "";
|
public $appChangeTrace = '';
|
||||||
public $appUpdated = 0;
|
public $appUpdated = 0;
|
||||||
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static function createEmpty()
|
||||||
|
{
|
||||||
|
$obj = new Entity_AppSolrQueue ();
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function createForRequest($data)
|
||||||
|
{
|
||||||
|
$obj = new Entity_AppSolrQueue ();
|
||||||
|
|
||||||
|
$obj->initializeObject ($data);
|
||||||
|
|
||||||
|
$requiredFields = array (
|
||||||
|
"appUid",
|
||||||
|
"appChangeDate",
|
||||||
|
"appChangeTrace",
|
||||||
|
"appUpdated"
|
||||||
|
);
|
||||||
|
|
||||||
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
private function __construct ()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
static function createEmpty ()
|
|
||||||
{
|
|
||||||
$obj = new Entity_AppSolrQueue();
|
|
||||||
return $obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
static function createForRequest ($data)
|
|
||||||
{
|
|
||||||
$obj = new Entity_AppSolrQueue();
|
|
||||||
|
|
||||||
$obj->initializeObject( $data );
|
|
||||||
|
|
||||||
$requiredFields = array(
|
|
||||||
"appUid",
|
|
||||||
"appChangeDate",
|
|
||||||
"appChangeTrace",
|
|
||||||
"appUpdated"
|
|
||||||
);
|
|
||||||
|
|
||||||
$obj->validateRequiredFields( $requiredFields );
|
|
||||||
|
|
||||||
return $obj;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,154 +2,156 @@
|
|||||||
|
|
||||||
class Entity_Base
|
class Entity_Base
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this function check if a field is in the data sent in the constructor
|
* 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
|
* 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;
|
$fieldIsEmpty = true;
|
||||||
|
|
||||||
// this is a trick, if $fields is a string, $fields will be an array with
|
// this is a trick, if $fields is a string, $fields will be an array with
|
||||||
// one element
|
// one element
|
||||||
if (is_array( $field )) {
|
if (is_array ($field)) {
|
||||||
$fields = $field;
|
$fields = $field;
|
||||||
} else {
|
}
|
||||||
$fields = array ();
|
else {
|
||||||
$fields[] = $field;
|
$fields = array ();
|
||||||
}
|
$fields [] = $field;
|
||||||
|
}
|
||||||
// if there are aliases for this field, evaluate all aliases and take the
|
|
||||||
// first occurence
|
// if there are aliases for this field, evaluate all aliases and take the
|
||||||
foreach ($fields as $k => $f) {
|
// first occurence
|
||||||
if (isset( $this->temp[$f] )) {
|
foreach ($fields as $k => $f) {
|
||||||
$fieldIsEmpty = false;
|
if (isset ($this->temp [$f])) {
|
||||||
return $this->temp[$f];
|
$fieldIsEmpty = false;
|
||||||
}
|
return $this->temp [$f];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// field empty means the user has not sent a value for this Field, so we are
|
|
||||||
// using the default value
|
// field empty means the user has not sent a value for this Field, so we are
|
||||||
if ($fieldIsEmpty) {
|
// using the default value
|
||||||
if ($default !== false) {
|
if ($fieldIsEmpty) {
|
||||||
return $default;
|
if ($default !== false) {
|
||||||
}
|
return $default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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)));
|
||||||
|
die ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* Copy the values of the Entity to the array of aliases
|
||||||
|
* The array of aliases must be defined.
|
||||||
|
*
|
||||||
|
* @return Array of alias with the Entity values
|
||||||
|
*/
|
||||||
|
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 = $className::GetAliases ();
|
||||||
|
foreach ($this as $field => $value)
|
||||||
|
if (isset ($aliases [$field])) {
|
||||||
|
// echo "Field exists in Aliases: " . $field . "\n";
|
||||||
|
// echo "Alias Name:" . $aliases[$field] . "\n";
|
||||||
|
// echo "Alias value:" . $value . "\n";
|
||||||
|
$aAlias [$aliases [$field]] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function validateRequiredFields ($requiredFields = array())
|
return $aAlias;
|
||||||
{
|
}
|
||||||
foreach ($requiredFields as $k => $field) {
|
|
||||||
if ($this->{$field} === null) {
|
/**
|
||||||
throw (new Exception( "Field $field is required in " . get_class( $this ) ));
|
*
|
||||||
die();
|
*
|
||||||
}
|
*
|
||||||
}
|
* Set the data from array of alias to Entity
|
||||||
|
*
|
||||||
|
* @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 = $className::GetAliases ();
|
||||||
|
foreach ($this as $field => $value)
|
||||||
|
if (isset ($aliases [$field]))
|
||||||
|
$this->{$field} = $aAliasData [$aliases [$field]];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
*
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Copy the values of the Entity to the array of aliases
|
* Initialize object with values from $data.
|
||||||
* The array of aliases must be defined.
|
* The values from data use properties or alias array.
|
||||||
*
|
*
|
||||||
* @return Array of alias with the Entity values
|
* @param
|
||||||
*/
|
* $data
|
||||||
public function getAliasDataArray ()
|
*/
|
||||||
{
|
protected function initializeObject($data)
|
||||||
$aAlias = array ();
|
{
|
||||||
// get aliases from class
|
// get aliases from class
|
||||||
$className = get_class( $this );
|
$className = get_class ($this);
|
||||||
if (method_exists( $className, 'GetAliases' )) {
|
$aliases = array ();
|
||||||
$aliases = call_user_func( array ($className,'GetAliases'
|
$swAliases = false;
|
||||||
) );
|
if (method_exists ($className, 'GetAliases')) {
|
||||||
// $aliases = $className::GetAliases ();
|
$aliases = call_user_func (array (
|
||||||
foreach ($this as $field => $value) {
|
$className,
|
||||||
if (isset( $aliases[$field] )) {
|
'GetAliases'
|
||||||
// echo "Field exists in Aliases: " . $field . "\n";
|
));
|
||||||
// echo "Alias Name:" . $aliases[$field] . "\n";
|
// $aliases = $className::GetAliases ();
|
||||||
// echo "Alias value:" . $value . "\n";
|
$swAliases = true;
|
||||||
$aAlias[$aliases[$field]] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $aAlias;
|
|
||||||
}
|
}
|
||||||
|
// use object properties or aliases to initialize
|
||||||
|
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]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function serialize()
|
||||||
|
{
|
||||||
|
if (isset ($this->temp))
|
||||||
|
unset ($this->temp);
|
||||||
|
return serialize ($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function unserialize($str)
|
||||||
|
{
|
||||||
|
$className = get_class ($this);
|
||||||
|
$data = unserialize ($str);
|
||||||
|
return new $className ($data);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
}
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Set the data from array of alias to Entity
|
|
||||||
*
|
|
||||||
* @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 = $className::GetAliases ();
|
|
||||||
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
|
|
||||||
*/
|
|
||||||
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 = $className::GetAliases ();
|
|
||||||
$swAliases = true;
|
|
||||||
}
|
|
||||||
// use object properties or aliases to initialize
|
|
||||||
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]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function serialize ()
|
|
||||||
{
|
|
||||||
if (isset( $this->temp )) {
|
|
||||||
unset( $this->temp );
|
|
||||||
}
|
|
||||||
return serialize( $this );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function unserialize ($str)
|
|
||||||
{
|
|
||||||
$className = get_class( $this );
|
|
||||||
$data = unserialize( $str );
|
|
||||||
return new $className( $data );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,49 +1,51 @@
|
|||||||
<?php
|
<?php
|
||||||
//require_once ('Base.php');
|
require_once ('Base.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Facet group entity that represent a facet group
|
* Facet group entity that represent a facet group
|
||||||
*
|
*
|
||||||
* @property $facetGroupName: The name of the facet (field name in solr index)
|
* @property $facetGroupName: The name of the facet (field name in solr index)
|
||||||
* @property $facetGroupPrintName: The print name of the facet (Human readable
|
* @property $facetGroupPrintName: The print name of the facet (Human readable
|
||||||
* description)
|
* description)
|
||||||
* @property $facetGroupType: The type of facet group, field, daterange, filter,
|
* @property $facetGroupType: The type of facet group, field, daterange, filter,
|
||||||
* range
|
* range
|
||||||
* @property $facetGroupId: An identifier to find group information
|
* @property $facetGroupId: An identifier to find group information
|
||||||
* @property $facetItems: array of facet items
|
* @property $facetItems: array of facet items
|
||||||
* @author dev-HebertSaak
|
* @author dev-HebertSaak
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Entity_FacetGroup extends Entity_Base
|
class Entity_FacetGroup extends Entity_Base
|
||||||
{
|
{
|
||||||
public $facetGroupName = '';
|
public $facetGroupName = '';
|
||||||
public $facetGroupPrintName = '';
|
public $facetGroupPrintName = '';
|
||||||
public $facetGroupType = ''; // field, daterange, query
|
public $facetGroupType = ''; // field, daterange, query
|
||||||
public $facetGroupId = '';
|
public $facetGroupId = '';
|
||||||
public $facetItems = array ();
|
public $facetItems = array ();
|
||||||
|
|
||||||
private function __construct ()
|
private function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createEmpty ()
|
static function createEmpty()
|
||||||
{
|
{
|
||||||
$obj = new Entity_FacetGroup();
|
$obj = new Entity_FacetGroup ();
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createForInsert ($data)
|
static function createForInsert($data)
|
||||||
{
|
{
|
||||||
$obj = new Entity_FacetGroup();
|
$obj = new Entity_FacetGroup ();
|
||||||
|
|
||||||
$obj->initializeObject( $data );
|
$obj->initializeObject ($data);
|
||||||
|
|
||||||
$requiredFields = array ("facetGroupName","facetItems"
|
$requiredFields = array (
|
||||||
);
|
"facetGroupName",
|
||||||
|
"facetItems"
|
||||||
$obj->validateRequiredFields( $requiredFields );
|
);
|
||||||
|
|
||||||
return $obj;
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
}
|
|
||||||
}
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,40 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
//require_once ('Base.php');
|
require_once ('Base.php');
|
||||||
|
|
||||||
class Entity_FacetInterfaceRequest extends Entity_Base
|
class Entity_FacetInterfaceRequest extends Entity_Base
|
||||||
{
|
{
|
||||||
public $searchText = '';
|
public $searchText = '';
|
||||||
public $selectedFacetsString = ''; // string of selected facet groups and
|
public $selectedFacetsString = ''; // string of selected facet groups and
|
||||||
|
// items in format:
|
||||||
// items in format:
|
// groupkey1::groupdesc1:::itemkey1::itemdesc1,groupkey2::groupdesc2:::itemkey2::itemdesc2,
|
||||||
// groupkey1::groupdesc1:::itemkey1::itemdesc1,groupkey2::groupdesc2:::itemkey2::itemdesc2,
|
// groupkey3::groupdesc3:::itemkey3::itemdesc3
|
||||||
// groupkey3::groupdesc3:::itemkey3::itemdesc3
|
// var $selectedFacetFields = array();
|
||||||
// var $selectedFacetFields = array();
|
// var $selectedFacetTypes = array();
|
||||||
// var $selectedFacetTypes = array();
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
private function __construct ()
|
}
|
||||||
{
|
|
||||||
}
|
static function createEmpty()
|
||||||
|
{
|
||||||
static function createEmpty ()
|
$obj = new Entity_FacetInterfaceRequest ();
|
||||||
{
|
return $obj;
|
||||||
$obj = new Entity_FacetInterfaceRequest();
|
}
|
||||||
return $obj;
|
|
||||||
}
|
static function createForRequest($data)
|
||||||
|
{
|
||||||
static function createForRequest ($data)
|
$obj = new Entity_FacetInterfaceRequest ();
|
||||||
{
|
|
||||||
$obj = new Entity_FacetInterfaceRequest();
|
$obj->initializeObject ($data);
|
||||||
|
|
||||||
$obj->initializeObject( $data );
|
$requiredFields = array (
|
||||||
|
"searchText",
|
||||||
$requiredFields = array ("searchText","selectedFacetsString"
|
"selectedFacetsString"
|
||||||
);
|
);
|
||||||
|
|
||||||
$obj->validateRequiredFields( $requiredFields );
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
|
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,37 +1,39 @@
|
|||||||
<?php
|
<?php
|
||||||
//require_once ('Base.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
|
// array of facetsgroups, array of Entity_SelectedFacetGroupItem, filter text
|
||||||
|
|
||||||
|
public $aFacetGroup = array ();
|
||||||
public $aFacetGroup = array ();
|
public $aSelectedFacetGroupItem = array ();
|
||||||
public $aSelectedFacetGroupItem = array ();
|
public $sFilterText = '';
|
||||||
public $sFilterText = '';
|
|
||||||
|
private function __construct()
|
||||||
private function __construct ()
|
{
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
static function createEmpty()
|
||||||
static function createEmpty ()
|
{
|
||||||
{
|
$obj = new Entity_FacetInterfaceResult ();
|
||||||
$obj = new Entity_FacetInterfaceResult();
|
return $obj;
|
||||||
return $obj;
|
}
|
||||||
}
|
|
||||||
|
static function createForRequest($data)
|
||||||
static function createForRequest ($data)
|
{
|
||||||
{
|
$obj = new Entity_FacetInterfaceResult ();
|
||||||
$obj = new Entity_FacetInterfaceResult();
|
|
||||||
|
$obj->initializeObject ($data);
|
||||||
$obj->initializeObject( $data );
|
|
||||||
|
$requiredFields = array (
|
||||||
$requiredFields = array ("aFacetGroup","aSelectedFacetGroupItem","sFilterText"
|
"aFacetGroup",
|
||||||
);
|
"aSelectedFacetGroupItem",
|
||||||
|
"sFilterText"
|
||||||
$obj->validateRequiredFields( $requiredFields );
|
);
|
||||||
|
|
||||||
return $obj;
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
}
|
|
||||||
}
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,48 +1,47 @@
|
|||||||
<?php
|
<?php
|
||||||
//require_once ('Base.php');
|
require_once ('Base.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* Entity Face item, represent an option in a facet group
|
* Entity Face item, represent an option in a facet group
|
||||||
*
|
*
|
||||||
* @author dev-HebertSaak
|
* @author dev-HebertSaak
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
class Entity_FacetItem extends Entity_Base
|
class Entity_FacetItem extends Entity_Base
|
||||||
{
|
{
|
||||||
public $facetName = '';
|
public $facetName = '';
|
||||||
public $facetPrintName = '';
|
public $facetPrintName = '';
|
||||||
public $facetCount = '';
|
public $facetCount = '';
|
||||||
public $facetSelectCondition = ''; // selected condition used to select
|
public $facetSelectCondition = ''; // selected condition used to select
|
||||||
|
// this facet
|
||||||
// this facet
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
private function __construct ()
|
}
|
||||||
{
|
|
||||||
}
|
static function createEmpty()
|
||||||
|
{
|
||||||
static function createEmpty ()
|
$obj = new Entity_FacetItem ();
|
||||||
{
|
return $obj;
|
||||||
$obj = new Entity_FacetItem();
|
}
|
||||||
return $obj;
|
|
||||||
}
|
static function createForInsert($data)
|
||||||
|
{
|
||||||
static function createForInsert ($data)
|
$obj = new Entity_FacetItem ();
|
||||||
{
|
|
||||||
$obj = new Entity_FacetItem();
|
$obj->initializeObject ($data);
|
||||||
|
|
||||||
$obj->initializeObject( $data );
|
$requiredFields = array (
|
||||||
|
"facetName",
|
||||||
$requiredFields = array ("facetName","facetCount"
|
"facetCount"
|
||||||
);
|
);
|
||||||
|
|
||||||
$obj->validateRequiredFields( $requiredFields );
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
|
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,45 +1,43 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once ('Base.php');
|
||||||
//require_once ('Base.php');
|
|
||||||
|
|
||||||
class Entity_FacetRequest extends Entity_Base
|
class Entity_FacetRequest extends Entity_Base
|
||||||
{
|
{
|
||||||
|
public $workspace = '';
|
||||||
|
public $searchText = '';
|
||||||
|
public $facetFields = array ();
|
||||||
|
public $facetQueries = array ();
|
||||||
|
public $facetDates = array ();
|
||||||
|
public $facetDatesStart = '';
|
||||||
|
public $facetDatesEnd = '';
|
||||||
|
public $facetDateGap = '';
|
||||||
|
public $facetRanges = array ();
|
||||||
|
public $filters = array ();
|
||||||
|
public $selectedFacetsString = '';
|
||||||
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static function createEmpty()
|
||||||
|
{
|
||||||
|
$obj = new Entity_FacetRequest ();
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function createForRequest($data)
|
||||||
|
{
|
||||||
|
$obj = new Entity_FacetRequest ();
|
||||||
|
|
||||||
|
$obj->initializeObject ($data);
|
||||||
|
|
||||||
|
$requiredFields = array (
|
||||||
|
"workspace"
|
||||||
|
);
|
||||||
|
|
||||||
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
public $workspace = '';
|
}
|
||||||
public $searchText = '';
|
|
||||||
public $facetFields = array();
|
|
||||||
public $facetQueries = array();
|
|
||||||
public $facetDates = array();
|
|
||||||
public $facetDatesStart = '';
|
|
||||||
public $facetDatesEnd = '';
|
|
||||||
public $facetDateGap = '';
|
|
||||||
public $facetRanges = array();
|
|
||||||
public $filters = array();
|
|
||||||
public $selectedFacetsString = '';
|
|
||||||
|
|
||||||
private function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function createEmpty()
|
|
||||||
{
|
|
||||||
$obj = new Entity_FacetRequest ();
|
|
||||||
return $obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function createForRequest($data)
|
|
||||||
{
|
|
||||||
$obj = new Entity_FacetRequest ();
|
|
||||||
|
|
||||||
$obj->initializeObject($data);
|
|
||||||
|
|
||||||
$requiredFields = array(
|
|
||||||
"workspace"
|
|
||||||
);
|
|
||||||
|
|
||||||
$obj->validateRequiredFields($requiredFields);
|
|
||||||
|
|
||||||
return $obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,34 +1,37 @@
|
|||||||
<?php
|
<?php
|
||||||
//require_once ('Base.php');
|
require_once ('Base.php');
|
||||||
|
|
||||||
class Entity_FacetResult extends Entity_Base
|
class Entity_FacetResult extends Entity_Base
|
||||||
{
|
{
|
||||||
public $aFacetGroups = array ();
|
public $aFacetGroups = array ();
|
||||||
public $aSelectedFacetGroups = array ();
|
public $aSelectedFacetGroups = array ();
|
||||||
public $sFilterText = '';
|
public $sFilterText = '';
|
||||||
|
|
||||||
private function __construct ()
|
private function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createEmpty ()
|
static function createEmpty()
|
||||||
{
|
{
|
||||||
$obj = new Entity_FacetResult();
|
$obj = new Entity_FacetResult ();
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createForRequest ($data)
|
static function createForRequest($data)
|
||||||
{
|
{
|
||||||
$obj = new Entity_FacetResult();
|
$obj = new Entity_FacetResult ();
|
||||||
|
|
||||||
$obj->initializeObject( $data );
|
$obj->initializeObject ($data);
|
||||||
|
|
||||||
$requiredFields = array ("aFacetGroups","aSelectedFacetGroups","sFilterText"
|
$requiredFields = array (
|
||||||
);
|
"aFacetGroups",
|
||||||
|
"aSelectedFacetGroups",
|
||||||
$obj->validateRequiredFields( $requiredFields );
|
"sFilterText"
|
||||||
|
);
|
||||||
return $obj;
|
|
||||||
}
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
}
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,40 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
//require_once ('Base.php');
|
require_once ('Base.php');
|
||||||
|
|
||||||
class Entity_SelectedFacetGroupItem extends Entity_Base
|
class Entity_SelectedFacetGroupItem extends Entity_Base
|
||||||
{
|
{
|
||||||
public $selectedFacetGroupName = '';
|
public $selectedFacetGroupName = '';
|
||||||
public $selectedFacetGroupPrintName = '';
|
public $selectedFacetGroupPrintName = '';
|
||||||
public $selectedFacetItemName = '';
|
public $selectedFacetItemName = '';
|
||||||
public $selectedFacetItemPrintName = '';
|
public $selectedFacetItemPrintName = '';
|
||||||
public $selectedFacetRemoveCondition = ''; // remove condition, string of
|
public $selectedFacetRemoveCondition = ''; // remove condition, string of
|
||||||
|
// selected facets without this
|
||||||
// selected facets without this
|
// facet
|
||||||
// facet
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
private function __construct ()
|
}
|
||||||
{
|
|
||||||
}
|
static function createEmpty()
|
||||||
|
{
|
||||||
static function createEmpty ()
|
$obj = new Entity_SelectedFacetGroupItem ();
|
||||||
{
|
return $obj;
|
||||||
$obj = new Entity_SelectedFacetGroupItem();
|
}
|
||||||
return $obj;
|
|
||||||
}
|
static function createForRequest($data)
|
||||||
|
{
|
||||||
static function createForRequest ($data)
|
$obj = new Entity_SelectedFacetGroupItem ();
|
||||||
{
|
|
||||||
$obj = new Entity_SelectedFacetGroupItem();
|
$obj->initializeObject ($data);
|
||||||
|
|
||||||
$obj->initializeObject( $data );
|
$requiredFields = array (
|
||||||
|
"selectedFacetGroupName",
|
||||||
$requiredFields = array ("selectedFacetGroupName","selectedFacetItemName"
|
"selectedFacetItemName"
|
||||||
);
|
);
|
||||||
|
|
||||||
$obj->validateRequiredFields( $requiredFields );
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
|
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,38 +1,40 @@
|
|||||||
<?php
|
<?php
|
||||||
//require_once ('Base.php');
|
require_once ('Base.php');
|
||||||
|
|
||||||
class Entity_SolrQueryResult extends Entity_Base
|
class Entity_SolrQueryResult extends Entity_Base
|
||||||
{
|
{
|
||||||
public $sEcho = '';
|
public $sEcho = '';
|
||||||
public $iTotalRecords = 0;
|
public $iTotalRecords = 0;
|
||||||
public $iTotalDisplayRecords = 10;
|
public $iTotalDisplayRecords = 10;
|
||||||
public $aaData = array (); // array of arrays of records to
|
public $aaData = array (); // array of arrays of records to
|
||||||
|
// display
|
||||||
// display
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
private function __construct ()
|
}
|
||||||
{
|
|
||||||
}
|
static function createEmpty()
|
||||||
|
{
|
||||||
static function createEmpty ()
|
$obj = new Entity_SolrQueryResult ();
|
||||||
{
|
return $obj;
|
||||||
$obj = new Entity_SolrQueryResult();
|
}
|
||||||
return $obj;
|
|
||||||
}
|
static function createForRequest($data)
|
||||||
|
{
|
||||||
static function createForRequest ($data)
|
$obj = new Entity_SolrQueryResult ();
|
||||||
{
|
|
||||||
$obj = new Entity_SolrQueryResult();
|
$obj->initializeObject ($data);
|
||||||
|
|
||||||
$obj->initializeObject( $data );
|
$requiredFields = array (
|
||||||
|
'sEcho',
|
||||||
$requiredFields = array ('sEcho','iTotalRecords','iTotalDisplayRecords','aaData'
|
'iTotalRecords',
|
||||||
);
|
'iTotalDisplayRecords',
|
||||||
|
'aaData'
|
||||||
$obj->validateRequiredFields( $requiredFields );
|
);
|
||||||
|
|
||||||
return $obj;
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
}
|
|
||||||
}
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,48 +1,46 @@
|
|||||||
<?php
|
<?php
|
||||||
|
require_once ('Base.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;
|
||||||
|
public $searchText = '*:*';
|
||||||
|
public $filterText = ''; // comma separated list of filters field:value
|
||||||
|
public $numSortingCols = 0; // number of columns that are sorted
|
||||||
|
public $sortableCols = array (); // array of booleans indicating if column is
|
||||||
|
// sortable (true, false)
|
||||||
|
public $sortCols = array (); // array of indices of sorted columns index
|
||||||
|
// based in the total number of sorting cols
|
||||||
|
public $sortDir = array (); // array of direction of sorting for each
|
||||||
|
// column (desc, asc)
|
||||||
|
public $includeCols = array ();
|
||||||
|
public $resultFormat = 'xml'; // json, xml, php
|
||||||
|
|
||||||
|
private function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static function createEmpty()
|
||||||
|
{
|
||||||
|
$obj = new Entity_SolrRequestData ();
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
static function createForRequestPagination($data)
|
||||||
|
{
|
||||||
|
$obj = new Entity_SolrRequestData ();
|
||||||
|
|
||||||
|
$obj->initializeObject ($data);
|
||||||
|
|
||||||
|
$requiredFields = array (
|
||||||
|
'workspace'
|
||||||
|
);
|
||||||
|
|
||||||
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
|
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
public $workspace = '';
|
}
|
||||||
public $startAfter = 0;
|
|
||||||
public $pageSize = 10;
|
|
||||||
public $searchText = '*:*';
|
|
||||||
public $filterText = ''; // comma separated list of filters field:value
|
|
||||||
public $numSortingCols = 0; // number of columns that are sorted
|
|
||||||
public $sortableCols = array(); // array of booleans indicating if column is
|
|
||||||
// sortable (true, false)
|
|
||||||
public $sortCols = array(); // array of indices of sorted columns index
|
|
||||||
// based in the total number of sorting cols
|
|
||||||
public $sortDir = array(); // array of direction of sorting for each
|
|
||||||
// column (desc, asc)
|
|
||||||
public $includeCols = array();
|
|
||||||
public $resultFormat = 'xml'; // json, xml, php
|
|
||||||
|
|
||||||
private function __construct()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function createEmpty()
|
|
||||||
{
|
|
||||||
$obj = new Entity_SolrRequestData ();
|
|
||||||
return $obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function createForRequestPagination($data)
|
|
||||||
{
|
|
||||||
$obj = new Entity_SolrRequestData ();
|
|
||||||
|
|
||||||
$obj->initializeObject($data);
|
|
||||||
|
|
||||||
$requiredFields = array(
|
|
||||||
'workspace'
|
|
||||||
);
|
|
||||||
|
|
||||||
$obj->validateRequiredFields($requiredFields);
|
|
||||||
|
|
||||||
return $obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,33 +1,35 @@
|
|||||||
<?php
|
<?php
|
||||||
//require_once ('Base.php');
|
require_once ('Base.php');
|
||||||
|
|
||||||
class Entity_SolrUpdateDocument extends Entity_Base
|
class Entity_SolrUpdateDocument extends Entity_Base
|
||||||
{
|
{
|
||||||
var $workspace = '';
|
var $workspace = '';
|
||||||
var $document = '';
|
var $document = '';
|
||||||
|
|
||||||
private function __construct ()
|
private function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createEmpty ()
|
static function createEmpty()
|
||||||
{
|
{
|
||||||
$obj = new Entity_SolrUpdateDocument();
|
$obj = new Entity_SolrUpdateDocument ();
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
static function createForRequest ($data)
|
static function createForRequest($data)
|
||||||
{
|
{
|
||||||
$obj = new Entity_SolrUpdateDocument();
|
$obj = new Entity_SolrUpdateDocument ();
|
||||||
|
|
||||||
$obj->initializeObject( $data );
|
$obj->initializeObject ($data);
|
||||||
|
|
||||||
$requiredFields = array ("workspace","document"
|
$requiredFields = array (
|
||||||
);
|
"workspace",
|
||||||
|
"document"
|
||||||
$obj->validateRequiredFields( $requiredFields );
|
);
|
||||||
|
|
||||||
return $obj;
|
$obj->validateRequiredFields ($requiredFields);
|
||||||
}
|
|
||||||
}
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -81,22 +81,30 @@ class AppSolrQueue extends BaseAppSolrQueue
|
|||||||
* Returns the list of updated applications
|
* Returns the list of updated applications
|
||||||
* array of Entity_AppSolrQueue
|
* array of Entity_AppSolrQueue
|
||||||
*/
|
*/
|
||||||
public function getListUpdatedApplications ()
|
public function getListUpdatedApplications($updated = true, $deleted = true)
|
||||||
{
|
{
|
||||||
$updatedApplications = array ();
|
$updatedApplications = array ();
|
||||||
try {
|
try {
|
||||||
$c = new Criteria();
|
$c = new Criteria();
|
||||||
|
|
||||||
$c->addSelectColumn(AppSolrQueuePeer::APP_UID);
|
$c->addSelectColumn(AppSolrQueuePeer::APP_UID);
|
||||||
$c->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_DATE);
|
$c->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_DATE);
|
||||||
$c->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_TRACE);
|
$c->addSelectColumn(AppSolrQueuePeer::APP_CHANGE_TRACE);
|
||||||
$c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
|
$c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
|
||||||
|
|
||||||
//"WHERE
|
//"WHERE
|
||||||
$c->add( AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL );
|
if($updated == true && $deleted == true){
|
||||||
|
$c->add(AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL);
|
||||||
$rs = AppSolrQueuePeer::doSelectRS( $c );
|
}
|
||||||
$rs->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
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);
|
||||||
//echo $c->toString();
|
//echo $c->toString();
|
||||||
$rs->next();
|
$rs->next();
|
||||||
$row = $rs->getRow();
|
$row = $rs->getRow();
|
||||||
@@ -111,11 +119,11 @@ class AppSolrQueue extends BaseAppSolrQueue
|
|||||||
$rs->next();
|
$rs->next();
|
||||||
$row = $rs->getRow();
|
$row = $rs->getRow();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $updatedApplications;
|
return $updatedApplications;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$con->rollback();
|
$con->rollback();
|
||||||
throw ($e);
|
throw ($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} // AppSolrQueue
|
||||||
|
|
||||||
|
|||||||
@@ -181,10 +181,8 @@ function getAllCounters ()
|
|||||||
G::LoadClass( 'AppSolr' );
|
G::LoadClass( 'AppSolr' );
|
||||||
$ApplicationSolrIndex = new AppSolr( $solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance'] );
|
$ApplicationSolrIndex = new AppSolr( $solrConf['solr_enabled'], $solrConf['solr_host'], $solrConf['solr_instance'] );
|
||||||
|
|
||||||
if ($ApplicationSolrIndex->isSolrEnabled()) {
|
if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
|
||||||
$solrEnabled = true;
|
$solrEnabled = true;
|
||||||
} else {
|
|
||||||
$solrEnabled = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ try {
|
|||||||
$solrConf["solr_instance"]
|
$solrConf["solr_instance"]
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($ApplicationSolrIndex->isSolrEnabled()) {
|
if ($ApplicationSolrIndex->isSolrEnabled() && $solrConf['solr_enabled'] == true) {
|
||||||
//Check if there are missing records to reindex and reindex them
|
//Check if there are missing records to reindex and reindex them
|
||||||
$ApplicationSolrIndex->synchronizePendingApplications();
|
$ApplicationSolrIndex->synchronizePendingApplications();
|
||||||
$solrEnabled = true;
|
$solrEnabled = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user