Merge remote branch 'upstream/master' into pmsql

This commit is contained in:
Brayan Osmar Pereyra Suxo
2013-01-28 16:56:06 -04:00
20 changed files with 599 additions and 160 deletions

View File

@@ -1,6 +1,6 @@
<?php
/**
*
*
* ProcessMaker Open Source Edition
* Copyright (C) 2004 - 2012 Colosa Inc.23
*
@@ -19,7 +19,7 @@
*
* For more information, contact Colosa Inc, 5304 Ventura Drive,
* Delray Beach, FL, 33484, USA, or email info@colosa.com.
*
*
*/
// check script parameters
@@ -28,18 +28,18 @@
//(count ($argv) == 4) || ((count ($argv) == 5) && ($argv [3] != '-skip'))
$commandLineSyntaxMsg = "Invalid command line arguments: \n " .
"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".
" reindexall : reindex all the database. \n" .
" reindexall : reindex all the database. \n" .
" reindexmissing: reindex only the missing records stored in database. \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" .
" Optional Options: \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) ||
($argv [2] != 'reindexall' && $argv [2] != 'reindexmissing' && $argv [2] != 'optimizeindex' && $argv [2] != 'reindexone')) {
if ( (count ($argv) < 3) || ((count ($argv) % 2) == 0) ||
($argv [2] != 'reindexall' && $argv [2] != 'reindexmissing' && $argv [2] != 'optimizeindex' && $argv [2] != 'reindexone')) {
print $commandLineSyntaxMsg;
die ();
}
@@ -64,7 +64,7 @@ if(count ($argv) > 3) {
if($argv [$argNumber] == '-appuid') {
//use skip option
$appUid = $argv [$argNumber + 1];
}
}
}
else {
print $commandLineSyntaxMsg;
@@ -98,13 +98,13 @@ if (! defined ('PATH_HOME')) {
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');
@@ -129,10 +129,23 @@ if (! defined ('PATH_HOME')) {
require_once ("creole/Creole.php");
}
require_once 'classes/model/AppDelegation.php';
require_once 'classes/model/Event.php';
require_once 'classes/model/AppEvent.php';
require_once 'classes/model/CaseScheduler.php';
if (file_exists(PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php")) {
require_once (PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths_installed.php");
}
require_once (PATH_HOME . "engine" . PATH_SEP . "config" . PATH_SEP . "paths.php");
require_once (PATH_HOME . "engine" . PATH_SEP . "classes" . PATH_SEP . "class.system.php");
require_once (PATH_GULLIVER . "class.bootstrap.php");
spl_autoload_register(array("Bootstrap", "autoloadClass"));
Bootstrap::registerSystemClasses();
//require_once 'classes/model/AppDelegation.php';
//require_once 'classes/model/Event.php';
//require_once 'classes/model/AppEvent.php';
//require_once 'classes/model/CaseScheduler.php';
// G::loadClass('pmScript');
// //default values
@@ -158,36 +171,36 @@ 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';
//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');
//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/');
@@ -197,7 +210,7 @@ if (! defined ('SYS_SYS')) {
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');
@@ -209,10 +222,10 @@ if (! defined ('SYS_SYS')) {
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);
@@ -220,7 +233,7 @@ if (! defined ('SYS_SYS')) {
$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;
@@ -252,7 +265,7 @@ if (! defined ('SYS_SYS')) {
fclose ($oFile);
Propel::init (PATH_CORE . 'config/_databases_.php');
// Creole::registerDriver('dbarray', 'creole.contrib.DBArrayConnection');
eprintln ("Processing workspace: " . $sObject, 'green');
try {
processWorkspace ();
@@ -282,16 +295,16 @@ function processWorkspace()
global $SkipRecords;
global $TrunkSize;
global $appUid;
try {
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']);
if ($ScriptAction == "reindexall") {
$oAppSolr->reindexAllApplications ($SkipRecords, $TrunkSize);
@@ -312,7 +325,7 @@ function processWorkspace()
else {
print "Incomplete Solr configuration. See configuration file: " . PATH_DATA_SITE . "env.ini";
}
}
catch (Exception $oError) {
saveLog ("main", "error", "Error processing workspace : " . $oError->getMessage () . "\n");
@@ -326,7 +339,7 @@ function saveLog($sSource, $sType, $sDescription)
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+');
@@ -347,7 +360,7 @@ function setExecutionMessage($m)
$len = strlen ($m);
$linesize = 60;
$rOffset = $linesize - $len;
eprint ("* $m");
for ($i = 0; $i < $rOffset; $i++)
eprint ('.');
@@ -362,3 +375,4 @@ function setExecutionResultMessage($m, $t = '')
$c = 'yellow';
eprintln ("[$m]", $c);
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -18,6 +18,40 @@ require_once 'classes/model/om/BaseAdditionalTables.php';
*
* @package workflow.engine.classes.model
*/
function validateType ($value, $type)
{
switch ($type) {
case 'INTEGER':
$value = str_replace(",", "", $value);
$value = str_replace(".", "", $value);
break;
case 'FLOAT':
case 'DOUBLE':
$pos = strrpos($value, ",");
$pos = ($pos === false) ? 0 : $pos;
$posPoint = strrpos($value, ".");
$posPoint = ($posPoint === false) ? 0 : $posPoint;
if ($pos > $posPoint) {
$value2 = substr($value, $pos+1);
$value1 = substr($value, 0, $pos);
$value1 = str_replace(".", "", $value1);
$value = $value1.".".$value2;
} else {
$value2 = substr($value, $posPoint+1);
$value1 = substr($value, 0, $posPoint);
$value1 = str_replace(",", "", $value1);
$value = $value1.".".$value2;
}
break;
default:
break;
}
return $value;
}
class AdditionalTables extends BaseAdditionalTables
{
public $fields = array();
@@ -669,8 +703,35 @@ class AdditionalTables extends BaseAdditionalTables
switch ($row['ADD_TAB_TYPE']) {
//switching by report table type
case 'NORMAL':
require_once 'classes/model/Fields.php';
$criteriaField = new Criteria('workflow');
$criteriaField->add(FieldsPeer::ADD_TAB_UID, $row['ADD_TAB_UID']);
$datasetField = FieldsPeer::doSelectRS($criteriaField);
$datasetField->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$fieldTypes = array();
while ($datasetField->next()) {
$rowfield = $datasetField->getRow();
switch ($rowfield['FLD_TYPE']) {
case 'FLOAT':
case 'DOUBLE':
case 'INTEGER':
$fieldTypes[] = array($rowfield['FLD_NAME']=>$rowfield['FLD_TYPE']);
break;
default:
break;
}
}
// parsing empty values to null
foreach ($caseData as $i => $v) {
foreach ($fieldTypes as $key => $fieldType) {
foreach ($fieldType as $name => $type) {
if ( strtoupper ( $i) == $name) {
$v = validateType ($v, $type);
unset($name);
}
}
}
$caseData[$i] = $v === '' ? null : $v;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -186,7 +186,6 @@ class pmTablesProxy extends HttpProxyController
}
}
}
return $fields;
}
@@ -1384,14 +1383,25 @@ class pmTablesProxy extends HttpProxyController
$arrayNode = $dynaformHandler->getArray( $node );
$fieldName = $arrayNode['__nodeName__'];
$fieldType = $arrayNode['type'];
$fieldValidate = ( isset($arrayNode['validate'])) ? $arrayNode['validate'] : '';
if (! in_array( $fieldType, $excludeFieldsList ) && ! in_array( $fieldName, $fieldsNames )) {
$fields[] = array ('FIELD_UID' => $fieldName . '-' . $fieldType,'FIELD_NAME' => $fieldName,'_index' => $index ++,'_isset' => true
if (! in_array( $fieldType, $excludeFieldsList ) && ! in_array( $fieldName, $fieldsNames ) ) {
$fields[] = array (
'FIELD_UID' => $fieldName . '-' . $fieldType,
'FIELD_NAME' => $fieldName,
'FIELD_VALIDATE'=>$fieldValidate,
'_index' => $index ++,
'_isset' => true
);
$fieldsNames[] = $fieldName;
if (in_array( $fieldType, $labelFieldsTypeList ) && ! in_array( $fieldName . '_label', $fieldsNames )) {
$fields[] = array ('FIELD_UID' => $fieldName . '_label' . '-' . $fieldType,'FIELD_NAME' => $fieldName . '_label','_index' => $index ++,'_isset' => true
$fields[] = array (
'FIELD_UID' => $fieldName . '_label' . '-' . $fieldType,
'FIELD_NAME' => $fieldName . '_label',
'FIELD_VALIDATE'=>$fieldValidate,
'_index' => $index ++,
'_isset' => true
);
$fieldsNames[] = $fieldName;
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -35,6 +35,7 @@ Ext.onReady(function(){
totalProperty: 'count',
fields : [
{name : 'FIELD_UID'},
{name : 'FIELD_VALIDATE'},
{name : 'FIELD_NAME'},
{name : '_index'},
{name : '_isset'}
@@ -69,6 +70,11 @@ Ext.onReady(function(){
hidden:true,
hideable:false
}, {
dataIndex:'FIELD_VALIDATE',
hidden:true,
hideable:false
}
, {
dataIndex:'_index',
hidden:true,
hideable:false
@@ -1175,6 +1181,15 @@ function setReportFields(records) {
}
var meta = mapPMFieldType(records[i].data['FIELD_UID']);
var typeField = meta.type;
var sizeField = meta.size;
if (records[i].data['FIELD_VALIDATE'].toUpperCase() == 'REAL') {
typeField = 'DOUBLE';
sizeField = '';
}
if (records[i].data['FIELD_VALIDATE'].toUpperCase() == 'INT') {
typeField = 'INTEGER';
}
var row = new PMRow({
uid : '',
_index : records[i].data['_index'] !== '' ? records[i].data['_index'] : records[i].data['FIELD_DYN'],
@@ -1182,8 +1197,8 @@ function setReportFields(records) {
field_dyn : records[i].data['FIELD_NAME'],
field_name : records[i].data['FIELD_NAME'].toUpperCase(),
field_label : records[i].data['FIELD_NAME'].toUpperCase(),
field_type : meta.type,
field_size : meta.size,
field_type : typeField,
field_size : sizeField,
field_key : 0,
field_null : 1,
field_filter: 0,

View File

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