BUG 0000 herbert> SOLR implementation in PMOS2
Solr support in PMOS2 includes:
Functionality:
- Implementation of Home views (Inbox, Draft, Participated, Unassigned). The views return fast results.
- Include read, unread, all, and process filter in inbox View.
- Include process filter in draft view.
- Include started by me, completed by me, all, process, and status filter in participated view.
- Include process filter in unassigned view.
- Improved search functionality (search in user defined variables): Use the following syntax to search in process (user defined) variables. {variable_name}:{search_word} ex1:"causal:20*" where causal is the variable defined by the user.
+ Use of wildcards in search: Use * as wildcard at the begin or end of word
+ Multiple conditions in search: Separate multiple conditions by space ex2:"Materiales causal:20*" means that we are searching for the word Materiales and the causal that begin with 20.
+ Search in dates (interval ): Format=> {variable_date}:[yyyy-mm-dd TO yyyy-mm-dd]
Local date not UTC date required
ex: FechaRegistro:[2011-04-15 TO 2011-04-30] //registros con fecha entre el 2011-04-15 y el 2011-04-30.
+ we can use the wildcard *:
ex: FechaRegistro:[* TO 2011-04-30] //registros con fecha menor o igual a 2011-04-30.
FechaRegistro:[2011-04-15 TO *] //registros con fecha mayor o igual a 2011-04-15.
+ Search of exact phrases. format: {variable}:"frase a buscar"
ex: Cliente:"Jesus Marin"
- Application update function.
+ The function is called every time a change is detected in the application's data including the related delegations.
- Use of cache to improve performance
Not included:
- Order of task, sent by, and due date columns.
Pending:
- Advanced search view using faceted lists.
This commit is contained in:
255
workflow/engine/bin/reindex_solr.php
Normal file
255
workflow/engine/bin/reindex_solr.php
Normal file
@@ -0,0 +1,255 @@
|
||||
<?php
|
||||
/**
|
||||
* cron_single.php
|
||||
* @package workflow-engine-bin
|
||||
*/
|
||||
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');
|
||||
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 = $argv[1];
|
||||
$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(PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'env.ini');
|
||||
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("Probelm 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;
|
||||
G::LoadClass('AppSolr');
|
||||
|
||||
try {
|
||||
$oAppSolr = new AppSolr();
|
||||
if ($oAppSolr->isSolrEnabled()) {
|
||||
$oAppSolr->reindexAllApplications();
|
||||
//$data = $ApplicationSolrIndex->getAppGridData($start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort);
|
||||
//$result = G::json_encode($data);
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
saveLog ("main", "error", "Error processing workspace : " . $oError->getMessage() . "\n" );
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
1757
workflow/engine/classes/class.AppSolr.php
Normal file
1757
workflow/engine/classes/class.AppSolr.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -833,6 +833,9 @@ class Cases {
|
||||
*/
|
||||
|
||||
function updateCase($sAppUid, $Fields = array()) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
try {
|
||||
$aApplicationFields = $Fields['APP_DATA'];
|
||||
$Fields['APP_UID'] = $sAppUid;
|
||||
@@ -920,6 +923,8 @@ class Cases {
|
||||
}
|
||||
}
|
||||
}
|
||||
//Update Solr Index
|
||||
$appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
|
||||
return $Fields;
|
||||
}
|
||||
@@ -937,6 +942,9 @@ class Cases {
|
||||
*/
|
||||
|
||||
function removeCase($sAppUid) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
try {
|
||||
$oApplication = new Application();
|
||||
$oAppDelegation = new AppDelegation();
|
||||
@@ -990,7 +998,12 @@ class Cases {
|
||||
$oCriteria2->add(SubApplicationPeer::APP_PARENT, $sAppUid);
|
||||
SubApplicationPeer::doDelete($oCriteria2);
|
||||
$oApp = new Application;
|
||||
return $oApp->remove($sAppUid);
|
||||
$result = $oApp->remove($sAppUid);
|
||||
|
||||
//delete application from index
|
||||
$appSolr->deleteApplicationSearchIndex($sAppUid);
|
||||
|
||||
return $result;
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
@@ -1006,10 +1019,15 @@ class Cases {
|
||||
*/
|
||||
|
||||
function setDelInitDate($sAppUid, $iDelIndex) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
try {
|
||||
$oAppDel = AppDelegationPeer::retrieveByPk($sAppUid, $iDelIndex);
|
||||
$oAppDel->setDelInitDate("now");
|
||||
$oAppDel->save();
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
@@ -1026,11 +1044,17 @@ class Cases {
|
||||
*/
|
||||
|
||||
function setCatchUser($sAppUid, $iDelIndex, $usrId) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
try {
|
||||
$oAppDel = AppDelegationPeer::retrieveByPk($sAppUid, $iDelIndex);
|
||||
$oAppDel->setDelInitDate("now");
|
||||
$oAppDel->setUsrUid($usrId);
|
||||
$oAppDel->save();
|
||||
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
@@ -1436,9 +1460,15 @@ class Cases {
|
||||
*/
|
||||
|
||||
function newAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $sPrevious, $iPriority, $sDelType, $iAppThreadIndex = 1, $nextDel=null) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
try {
|
||||
$appDel = new AppDelegation();
|
||||
return $appDel->createAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iPriority, false, $sPrevious, $nextDel);
|
||||
$result = $appDel->createAppDelegation($sProUid, $sAppUid, $sTasUid, $sUsrUid, $iAppThreadIndex, $iPriority, false, $sPrevious, $nextDel);
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
return $result;
|
||||
}
|
||||
catch (exception $e) {
|
||||
throw ($e);
|
||||
@@ -1457,6 +1487,9 @@ class Cases {
|
||||
*/
|
||||
|
||||
function updateAppDelegation($sAppUid, $iDelIndex, $iAppThreadIndex) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
try {
|
||||
$appDelegation = new AppDelegation();
|
||||
$aData = array();
|
||||
@@ -1465,6 +1498,9 @@ class Cases {
|
||||
$aData['DEL_THREAD'] = $iAppThreadIndex;
|
||||
|
||||
$appDelegation->update($aData);
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
|
||||
return true;
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
@@ -1540,6 +1576,9 @@ class Cases {
|
||||
*/
|
||||
|
||||
function updateAppThread($sAppUid, $iAppThreadIndex, $iNewDelIndex) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
try {
|
||||
/// updating the DEL_INDEX value in the APP_THREAD
|
||||
$con = Propel::getConnection('workflow');
|
||||
@@ -1559,6 +1598,9 @@ class Cases {
|
||||
$aData['DEL_INDEX'] = $iNewDelIndex;
|
||||
$appThread->update($aData);
|
||||
*/
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
|
||||
return $iNewDelIndex;
|
||||
}
|
||||
catch (exception $e) {
|
||||
@@ -1576,6 +1618,9 @@ class Cases {
|
||||
*/
|
||||
|
||||
function closeAppThread($sAppUid, $iAppThreadIndex) {
|
||||
// //initialize solrindex object called from other functions
|
||||
// G::LoadClass('AppSolr');
|
||||
// $appSolr = new AppSolr();
|
||||
try {
|
||||
$appThread = new AppThread();
|
||||
$aData = array();
|
||||
@@ -1584,6 +1629,8 @@ class Cases {
|
||||
$aData['APP_THREAD_STATUS'] = 'CLOSED';
|
||||
|
||||
$appThread->update($aData);
|
||||
// //update searchindex
|
||||
// $appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
return true;
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
@@ -1599,6 +1646,9 @@ class Cases {
|
||||
*/
|
||||
|
||||
function closeAllThreads($sAppUid) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
try {
|
||||
//Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"');
|
||||
$c = new Criteria();
|
||||
@@ -1616,6 +1666,8 @@ class Cases {
|
||||
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
|
||||
}
|
||||
}
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
@@ -1633,9 +1685,15 @@ class Cases {
|
||||
*/
|
||||
|
||||
function newAppThread($sAppUid, $iNewDelIndex, $iAppParent) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
try {
|
||||
$appThread = new AppThread();
|
||||
return $appThread->createAppThread($sAppUid, $iNewDelIndex, $iAppParent);
|
||||
$result = $appThread->createAppThread($sAppUid, $iNewDelIndex, $iAppParent);
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
return $result;
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
@@ -1650,6 +1708,9 @@ class Cases {
|
||||
*/
|
||||
|
||||
function closeAllDelegations($sAppUid) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
try {
|
||||
//Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"');
|
||||
$c = new Criteria();
|
||||
@@ -1667,6 +1728,8 @@ class Cases {
|
||||
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
|
||||
}
|
||||
}
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
@@ -1682,6 +1745,10 @@ class Cases {
|
||||
*/
|
||||
|
||||
function CloseCurrentDelegation($sAppUid, $iDelIndex) {
|
||||
//called from other functions
|
||||
// //initialize solrindex object
|
||||
// G::LoadClass('AppSolr');
|
||||
// $appSolr = new AppSolr();
|
||||
try {
|
||||
//Execute('UPDATE APP_DELEGATION SET DEL_THREAD_STATUS="CLOSED" WHERE APP_UID="$sAppUid" AND DEL_THREAD_STATUS="OPEN"');
|
||||
$c = new Criteria();
|
||||
@@ -1703,6 +1770,9 @@ class Cases {
|
||||
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
|
||||
}
|
||||
}
|
||||
// //update searchindex
|
||||
// $appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
@@ -1719,6 +1789,9 @@ class Cases {
|
||||
*/
|
||||
|
||||
function ReactivateCurrentDelegation($sAppUid, $iDelegation) {
|
||||
// //initialize solrindex object called from other function
|
||||
// G::LoadClass('AppSolr');
|
||||
// $appSolr = new AppSolr();
|
||||
try {
|
||||
$c = new Criteria();
|
||||
$c->add(AppDelegationPeer::APP_UID, $sAppUid);
|
||||
@@ -1737,6 +1810,8 @@ class Cases {
|
||||
throw (new PropelException('The row cannot be created!', new PropelException($msg)));
|
||||
}
|
||||
}
|
||||
// //update searchindex
|
||||
// $appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
@@ -1754,7 +1829,11 @@ class Cases {
|
||||
|
||||
function startCase($sTasUid, $sUsrUid, $isSubprocess=false) {
|
||||
if ($sTasUid != '') {
|
||||
try {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
|
||||
try {
|
||||
$this->Task = new Task;
|
||||
$Fields = $this->Task->Load($sTasUid);
|
||||
|
||||
@@ -1795,6 +1874,8 @@ class Cases {
|
||||
G::LoadClass('derivation');
|
||||
$oDerivation = new Derivation();
|
||||
$oDerivation->setTasLastAssigned($sTasUid, $sUsrUid);
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sAppUid);
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
@@ -3341,6 +3422,10 @@ class Cases {
|
||||
*/
|
||||
|
||||
function pauseCase($sApplicationUID, $iDelegation, $sUserUID, $sUnpauseDate = null) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
|
||||
$this->CloseCurrentDelegation($sApplicationUID, $iDelegation);
|
||||
$oApplication = new Application();
|
||||
$aFields = $oApplication->Load($sApplicationUID);
|
||||
@@ -3368,6 +3453,9 @@ class Cases {
|
||||
$aData['APP_DISABLE_ACTION_DATE'] = $sUnpauseDate;
|
||||
$oAppDelay = new AppDelay();
|
||||
$oAppDelay->create($aData);
|
||||
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sApplicationUID);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3427,6 +3515,9 @@ class Cases {
|
||||
$aData['APP_DISABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
|
||||
$oAppDelay = new AppDelay();
|
||||
$aFieldsDelay = $oAppDelay->update($aData);
|
||||
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sApplicationUID);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3440,6 +3531,10 @@ class Cases {
|
||||
*/
|
||||
|
||||
function cancelCase($sApplicationUID, $iIndex, $user_logged) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
|
||||
$oApplication = new Application();
|
||||
$aFields = $oApplication->load($sApplicationUID);
|
||||
$oCriteria = new Criteria('workflow');
|
||||
@@ -3496,6 +3591,9 @@ class Cases {
|
||||
$oDerivation = new Derivation();
|
||||
$oDerivation->verifyIsCaseChild($sApplicationUID);
|
||||
}
|
||||
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sApplicationUID);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3509,6 +3607,10 @@ class Cases {
|
||||
*/
|
||||
|
||||
function reactivateCase($sApplicationUID, $iIndex, $user_logged) {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
|
||||
$oApplication = new Application();
|
||||
$aFields = $oApplication->load((isset($_POST['sApplicationUID']) ? $_POST['sApplicationUID'] : $_SESSION['APPLICATION']));
|
||||
$aFields['APP_STATUS'] = 'TO_DO';
|
||||
@@ -3542,6 +3644,9 @@ class Cases {
|
||||
$sql = "UPDATE APP_THREAD SET APP_THREAD_STATUS = 'OPEN' WHERE APP_UID = '$sApplicationUID' AND DEL_INDEX ='$iIndex' ";
|
||||
$stmt = $con->createStatement();
|
||||
$rs = $stmt->executeQuery($sql, ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sApplicationUID);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -3557,6 +3662,10 @@ class Cases {
|
||||
*/
|
||||
|
||||
function reassignCase($sApplicationUID, $iDelegation, $sUserUID, $newUserUID, $sType = 'REASSIGN') {
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
|
||||
$this->CloseCurrentDelegation($sApplicationUID, $iDelegation);
|
||||
$oAppDelegation = new AppDelegation();
|
||||
$aFieldsDel = $oAppDelegation->Load($sApplicationUID, $iDelegation);
|
||||
@@ -3589,6 +3698,10 @@ class Cases {
|
||||
$aData['APP_ENABLE_ACTION_DATE'] = date('Y-m-d H:i:s');
|
||||
$oAppDelay = new AppDelay();
|
||||
$oAppDelay->create($aData);
|
||||
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($sApplicationUID);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5040,6 +5153,10 @@ class Cases {
|
||||
*/
|
||||
|
||||
function executeTriggersAfterExternal($sProcess, $sTask, $sApplication, $iIndex, $iStepPosition, $aNewData = array()) {
|
||||
// //initialize solrindex object UpdateCase añready calls the update
|
||||
// G::LoadClass('AppSolr');
|
||||
// $appSolr = new AppSolr();
|
||||
|
||||
//load the variables
|
||||
$Fields = $this->loadCase($sApplication);
|
||||
$Fields['APP_DATA'] = array_merge($Fields['APP_DATA'], G::getSystemConstants());
|
||||
@@ -5056,6 +5173,9 @@ class Cases {
|
||||
$aData['DEL_INDEX'] = $iIndex;
|
||||
$aData['TAS_UID'] = $sTask;
|
||||
$this->updateCase($sApplication, $aData);
|
||||
|
||||
// //update searchindex
|
||||
// $appSolr->updateApplicationSearchIndex($sApplication);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5408,11 +5528,18 @@ class Cases {
|
||||
}
|
||||
|
||||
function discriminateCases($aData){
|
||||
//initialize solrindex object
|
||||
G::LoadClass('AppSolr');
|
||||
$appSolr = new AppSolr();
|
||||
|
||||
$siblingThreadData = $this->GetAllOpenDelegation($aData);
|
||||
foreach($siblingThreadData as $thread => $threadData)
|
||||
{
|
||||
$this->closeAppThread ( $aData['APP_UID'], $threadData['DEL_INDEX']); //Close Sibling AppThreads
|
||||
$this->CloseCurrentDelegation ($aData['APP_UID'], $threadData['DEL_INDEX']); //Close Sibling AppDelegations
|
||||
|
||||
//update searchindex
|
||||
$appSolr->updateApplicationSearchIndex($aData['APP_UID']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
110
workflow/engine/classes/class.fileCache.php
Normal file
110
workflow/engine/classes/class.fileCache.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
/**
|
||||
* class.memcached.php
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
* Copyright (C) 2004 - 2011 Colosa Inc.
|
||||
*
|
||||
* 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, 2566 Le Jeune Rd.,
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
class FileCache {
|
||||
|
||||
function __construct($dir) {
|
||||
$this->dir = $dir;
|
||||
}
|
||||
|
||||
private function _name($key) {
|
||||
return sprintf ( "%s/%s", $this->dir, sha1 ( $key ) );
|
||||
}
|
||||
|
||||
public function get($key, $expiration = 3600) {
|
||||
|
||||
if (! is_dir ( $this->dir ) or ! is_writable ( $this->dir )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$cache_path = $this->_name ( $key );
|
||||
|
||||
if (! @file_exists ( $cache_path )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (filemtime ( $cache_path ) < (time () - $expiration)) {
|
||||
// $this->clear($key);
|
||||
// different users can have different timeout requests
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (! $fp = @fopen ( $cache_path, 'rb' )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
flock ( $fp, LOCK_SH );
|
||||
|
||||
$cache = '';
|
||||
|
||||
if (filesize ( $cache_path ) > 0) {
|
||||
$cache = unserialize ( fread ( $fp, filesize ( $cache_path ) ) );
|
||||
}
|
||||
else {
|
||||
$cache = NULL;
|
||||
}
|
||||
|
||||
flock ( $fp, LOCK_UN );
|
||||
fclose ( $fp );
|
||||
|
||||
return $cache;
|
||||
}
|
||||
|
||||
public function set($key, $data) {
|
||||
|
||||
if (! is_dir ( $this->dir ) or ! is_writable ( $this->dir )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$cache_path = $this->_name ( $key );
|
||||
|
||||
if (! $fp = fopen ( $cache_path, 'wb' )) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (flock ( $fp, LOCK_EX )) {
|
||||
fwrite ( $fp, serialize ( $data ) );
|
||||
flock ( $fp, LOCK_UN );
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
}
|
||||
fclose ( $fp );
|
||||
@chmod ( $cache_path, 0777 );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
public function clear($key) {
|
||||
$cache_path = $this->_name ( $key );
|
||||
|
||||
if (file_exists ( $cache_path )) {
|
||||
unlink ( $cache_path );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -24,131 +24,164 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* The ProcessMaker memcached class
|
||||
*
|
||||
* @package workflow.engine.ProcessMaker
|
||||
*/
|
||||
|
||||
class PMmemcached {
|
||||
const ONE_MINUTE = 60;
|
||||
const ONE_HOUR = 3600;
|
||||
const TWO_HOURS = 7200;
|
||||
const EIGHT_HOURS = 28800;
|
||||
class PMmemcached {
|
||||
const ONE_MINUTE = 60;
|
||||
const ONE_HOUR = 3600;
|
||||
const TWO_HOURS = 7200;
|
||||
const EIGHT_HOURS = 28800;
|
||||
|
||||
var $version;
|
||||
var $mem;
|
||||
var $connected = false;
|
||||
var $enabled = false;
|
||||
var $supported = false;
|
||||
var $version;
|
||||
var $mem;
|
||||
var $connected = false;
|
||||
var $enabled = false;
|
||||
var $supported = false;
|
||||
|
||||
static private $instance = NULL;
|
||||
private static $instance = NULL;
|
||||
|
||||
private function __construct( $workspace ) {
|
||||
$this->enabled = MEMCACHED_ENABLED;
|
||||
$this->connected = false;
|
||||
$this->workspace = $workspace;
|
||||
if (class_exists('Memcached')) {
|
||||
$this->mem = new Memcached();
|
||||
$this->class = 'Memcached';
|
||||
}
|
||||
else {
|
||||
if (class_exists('Memcache')) {
|
||||
$this->mem = new Memcache();
|
||||
$this->class = 'Memcache';
|
||||
$this->supported = true;
|
||||
$this->connected = @$this->mem->connect( MEMCACHED_SERVER , 11211);
|
||||
if ( $this->connected ) {
|
||||
$this->version = $this->mem->getVersion();
|
||||
}
|
||||
private function __construct($workspace) {
|
||||
$this->enabled = MEMCACHED_ENABLED;
|
||||
$this->connected = false;
|
||||
$this->workspace = $workspace;
|
||||
if (class_exists ( 'Memcached' )) {
|
||||
$this->mem = new Memcached ();
|
||||
$this->class = 'Memcached';
|
||||
$this->connected = true;
|
||||
}
|
||||
else {
|
||||
if (class_exists ( 'Memcache' )) {
|
||||
$this->mem = new Memcache ();
|
||||
$this->class = 'Memcache';
|
||||
$this->supported = true;
|
||||
$this->connected = @$this->mem->connect ( MEMCACHED_SERVER, 11211 );
|
||||
if ($this->connected) {
|
||||
$this->version = $this->mem->getVersion ();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! MEMCACHED_ENABLED ) {
|
||||
$this->connected = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* to get singleton instance
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
function &getSingleton( $workspace ) {
|
||||
if (self::$instance == NULL) {
|
||||
self::$instance = new PMmemcached( $workspace );
|
||||
else {
|
||||
G::Loadclass ( 'fileCache' );
|
||||
// create cache folder
|
||||
$cacheFolder = PATH_DATA . "sites/" . $workspace . "/cachefiles/";
|
||||
if (! file_exists ( $cacheFolder )) {
|
||||
if (! mkdir ( $cacheFolder )) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->class = 'fileCache';
|
||||
$this->connected = true;
|
||||
$this->mem = new FileCache ( $cacheFolder );
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
function set($key, $object, $timeout=0) {
|
||||
if (! $this->connected ) return false;
|
||||
$this->mem->set( $this->workspace . '_' . $key, $object, false, $timeout) ;
|
||||
}
|
||||
|
||||
function get($key) {
|
||||
if (! $this->connected ) return false;
|
||||
return $this->mem->get( $this->workspace . '_' . $key) ;
|
||||
}
|
||||
|
||||
function add($key, $value ) {
|
||||
if (! $this->connected ) return false;
|
||||
return $this->mem->add( $this->workspace . '_' . $key, $value ) ;
|
||||
}
|
||||
|
||||
function increment($key, $value ) {
|
||||
if (! $this->connected ) return false;
|
||||
return $this->mem->increment( $this->workspace . '_' . $key, $value ) ;
|
||||
}
|
||||
|
||||
function delete($key) {
|
||||
if (! $this->connected ) return false;
|
||||
return $this->mem->delete( $this->workspace . '_' . $key) ;
|
||||
}
|
||||
|
||||
function flush() {
|
||||
if (! $this->connected ) return false;
|
||||
return $this->mem->flush();
|
||||
}
|
||||
|
||||
function getStats() {
|
||||
if (! $this->connected ) return false;
|
||||
return $status = $this->mem->getStats();
|
||||
}
|
||||
|
||||
function printDetails() {
|
||||
if (! $this->connected ) return false;
|
||||
$status = $this->mem->getStats();
|
||||
echo "<table border='1'>";
|
||||
echo "<tr><td>Memcache Server version:</td><td> ".$status ["version"]."</td></tr>";
|
||||
echo "<tr><td>Number of hours this server has been running </td><td>" . ($status ["uptime"] /3660) ."</td></tr>";
|
||||
echo "<tr><td>Total number of items stored by this server ever since it started </td><td>".$status ["total_items"]."</td></tr>";
|
||||
echo "<tr><td>Number of open connections </td><td>".$status ["curr_connections"]."</td></tr>";
|
||||
echo "<tr><td>Total number of connections opened since the server started running </td><td>".$status ["total_connections"]."</td></tr>";
|
||||
echo "<tr><td>Number of connection structures allocated by the server </td><td>".$status ["connection_structures"]."</td></tr>";
|
||||
echo "<tr><td>Cumulative number of retrieval requests </td><td>".$status ["cmd_get"]."</td></tr>";
|
||||
echo "<tr><td> Cumulative number of storage requests </td><td>".$status ["cmd_set"]."</td></tr>";
|
||||
|
||||
$percCacheHit=((real)$status ["get_hits"]/ (real)$status ["cmd_get"] *100);
|
||||
$percCacheHit=round($percCacheHit,3);
|
||||
$percCacheMiss=100-$percCacheHit;
|
||||
|
||||
echo "<tr><td>Number of keys that have been requested and found present </td><td>".$status ["get_hits"]." ($percCacheHit%)</td></tr>";
|
||||
echo "<tr><td>Number of items that have been requested and not found </td><td>".$status ["get_misses"]."($percCacheMiss%)</td></tr>";
|
||||
|
||||
$MBRead= (real)$status["bytes_read"]/(1024*1024);
|
||||
|
||||
echo "<tr><td>Total number of bytes read by this server from network </td><td>".$MBRead." Mega Bytes</td></tr>";
|
||||
$MBWrite=(real) $status["bytes_written"]/(1024*1024) ;
|
||||
echo "<tr><td>Total number of bytes sent by this server to network </td><td>".$MBWrite." Mega Bytes</td></tr>";
|
||||
$MBSize=(real) $status["limit_maxbytes"]/(1024*1024) ;
|
||||
echo "<tr><td>Number of bytes this server is allowed to use for storage.</td><td>".$MBSize." Mega Bytes</td></tr>";
|
||||
echo "<tr><td>Number of valid items removed from cache to free memory for new items.</td><td>".$status ["evictions"]."</td></tr>";
|
||||
echo "</table>";
|
||||
if (! MEMCACHED_ENABLED) {
|
||||
$this->connected = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* to get singleton instance
|
||||
*
|
||||
* @access public
|
||||
* @return object
|
||||
*/
|
||||
public static function getSingleton($workspace) {
|
||||
if (! self::$instance instanceof self) {
|
||||
self::$instance = new PMmemcached ( $workspace );
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function __clone() {
|
||||
throw new Exception ( "Clone is not allowed." );
|
||||
}
|
||||
|
||||
public function __wakeup() {
|
||||
throw new Exception ( "Deserializing is not allowed." );
|
||||
}
|
||||
|
||||
function set($key, $object, $timeout = 0) {
|
||||
if (! $this->connected)
|
||||
return false;
|
||||
if ($this->class != 'filecache')
|
||||
$this->mem->set ( $this->workspace . '_' . $key, $object, false, $timeout );
|
||||
else
|
||||
$this->mem->set ( $this->workspace . '_' . $key, $object );
|
||||
}
|
||||
|
||||
function get($key) {
|
||||
if (! $this->connected)
|
||||
return false;
|
||||
return $this->mem->get ( $this->workspace . '_' . $key );
|
||||
}
|
||||
|
||||
function add($key, $value) {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->add ( $this->workspace . '_' . $key, $value );
|
||||
}
|
||||
|
||||
function increment($key, $value) {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->increment ( $this->workspace . '_' . $key, $value );
|
||||
}
|
||||
|
||||
function delete($key) {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->delete ( $this->workspace . '_' . $key );
|
||||
}
|
||||
|
||||
function flush() {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $this->mem->flush ();
|
||||
}
|
||||
|
||||
function getStats() {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
return $status = $this->mem->getStats ();
|
||||
}
|
||||
|
||||
function printDetails() {
|
||||
if ((! $this->connected) || ($this->class == 'filecache'))
|
||||
return false;
|
||||
$status = $this->mem->getStats ();
|
||||
echo "<table border='1'>";
|
||||
echo "<tr><td>Memcache Server version:</td><td> " . $status ["version"] . "</td></tr>";
|
||||
echo "<tr><td>Number of hours this server has been running </td><td>" . ($status ["uptime"] / 3660) . "</td></tr>";
|
||||
echo "<tr><td>Total number of items stored by this server ever since it started </td><td>" . $status ["total_items"] . "</td></tr>";
|
||||
echo "<tr><td>Number of open connections </td><td>" . $status ["curr_connections"] . "</td></tr>";
|
||||
echo "<tr><td>Total number of connections opened since the server started running </td><td>" . $status ["total_connections"] . "</td></tr>";
|
||||
echo "<tr><td>Number of connection structures allocated by the server </td><td>" . $status ["connection_structures"] . "</td></tr>";
|
||||
echo "<tr><td>Cumulative number of retrieval requests </td><td>" . $status ["cmd_get"] . "</td></tr>";
|
||||
echo "<tr><td> Cumulative number of storage requests </td><td>" . $status ["cmd_set"] . "</td></tr>";
|
||||
|
||||
$percCacheHit = (( real ) $status ["get_hits"] / ( real ) $status ["cmd_get"] * 100);
|
||||
$percCacheHit = round ( $percCacheHit, 3 );
|
||||
$percCacheMiss = 100 - $percCacheHit;
|
||||
|
||||
echo "<tr><td>Number of keys that have been requested and found present </td><td>" . $status ["get_hits"] . " ($percCacheHit%)</td></tr>";
|
||||
echo "<tr><td>Number of items that have been requested and not found </td><td>" . $status ["get_misses"] . "($percCacheMiss%)</td></tr>";
|
||||
|
||||
$MBRead = ( real ) $status ["bytes_read"] / (1024 * 1024);
|
||||
|
||||
echo "<tr><td>Total number of bytes read by this server from network </td><td>" . $MBRead . " Mega Bytes</td></tr>";
|
||||
$MBWrite = ( real ) $status ["bytes_written"] / (1024 * 1024);
|
||||
echo "<tr><td>Total number of bytes sent by this server to network </td><td>" . $MBWrite . " Mega Bytes</td></tr>";
|
||||
$MBSize = ( real ) $status ["limit_maxbytes"] / (1024 * 1024);
|
||||
echo "<tr><td>Number of bytes this server is allowed to use for storage.</td><td>" . $MBSize . " Mega Bytes</td></tr>";
|
||||
echo "<tr><td>Number of valid items removed from cache to free memory for new items.</td><td>" . $status ["evictions"] . "</td></tr>";
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
364
workflow/engine/classes/class.searchIndex.php
Normal file
364
workflow/engine/classes/class.searchIndex.php
Normal file
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
|
||||
//$indexFields = array();
|
||||
|
||||
|
||||
Class BpmnEngine_Services_SearchIndex
|
||||
{
|
||||
private $solrIsEnabled = false;
|
||||
private $solrHost = "";
|
||||
|
||||
function __construct($solrIsEnabled = false, $solrHost = ""){
|
||||
//check if Zend Library is available
|
||||
// if(class_exists("Zend_Registry")){
|
||||
// $registry = Zend_Registry::getInstance();
|
||||
// //check if configuration is enabled
|
||||
// $this->solrIsEnabled = $registry->isRegistered('solrEnabled') && $registry->get('solrEnabled') == 1;
|
||||
// $this->solrHost = $registry->isRegistered('solrHost')?$registry->get('solrHost'):"";
|
||||
// }
|
||||
// else{
|
||||
// //use the parameters to initialize class
|
||||
$this->solrIsEnabled = $solrIsEnabled;
|
||||
$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()
|
||||
{
|
||||
//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();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
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');
|
||||
|
||||
/******************************************************************/
|
||||
//get array of selected facet groups
|
||||
$facetRequestEntity->selectedFacetsString = str_replace(',,', ',', $facetRequestEntity->selectedFacetsString);
|
||||
//remove descriptions of selected facet groups
|
||||
|
||||
$aGroups = explode(',', $facetRequestEntity->selectedFacetsString);
|
||||
|
||||
$aGroups = array_filter($aGroups);//remove empty items
|
||||
|
||||
$aSelectedFacetGroups = array();
|
||||
foreach($aGroups as $i => $value)
|
||||
{
|
||||
$gi = explode(':::', $value);
|
||||
$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);
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
//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($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($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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
function updateIndexDocument($solrUpdateDocumentEntity){
|
||||
G::LoadClass('solr');
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
|
||||
|
||||
//create list of facets
|
||||
$solr->updateDocument($solrUpdateDocumentEntity);
|
||||
}
|
||||
|
||||
function deleteDocumentFromIndex($workspace, $idQuery){
|
||||
G::LoadClass('solr');
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
|
||||
|
||||
//create list of facets
|
||||
$solr->deleteDocument($workspace, $idQuery);
|
||||
}
|
||||
|
||||
function commitIndexChanges($workspace){
|
||||
G::LoadClass('solr');
|
||||
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
|
||||
|
||||
//commit
|
||||
$solr->commitChanges($workspace);
|
||||
}
|
||||
|
||||
function getDataTablePaginatedList($solrRequestData){
|
||||
require_once ('class.solr.php');
|
||||
//require_once (ROOT_PATH . '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
require_once ('entities/SolrRequestData.php');
|
||||
require_once ('entities/SolrQueryResult.php');
|
||||
|
||||
//print_r($solrRequestData);
|
||||
//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(''));
|
||||
|
||||
//print_r($solrRequestData);
|
||||
//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][] = $doc[$columnName];
|
||||
}else{
|
||||
$data['aaData'][$i][] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$solrQueryResponse = Entity_SolrQueryResult::CreateForRequest($data);
|
||||
//
|
||||
|
||||
return $solrQueryResponse;
|
||||
}
|
||||
|
||||
function getIndexFields($workspace){
|
||||
//global $indexFields;
|
||||
//cache
|
||||
// if(!empty($indexFields))
|
||||
// return $indexFields;
|
||||
|
||||
require_once ('class.solr.php');
|
||||
//require_once (ROOT_PATH . '/businessLogic/modules/SearchIndexAccess/Solr.php');
|
||||
$solr = new BpmnEngine_SearchIndexAccess_Solr($this->solrIsEnabled, $this->solrHost);
|
||||
|
||||
|
||||
//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)){
|
||||
//remove *
|
||||
$originalFieldName = substr($key, 0, -strlen($fieldData['dynamicBase'])+1);
|
||||
//$listFields[strtolower($originalFieldName)] = $key;
|
||||
//Maintain case sensitive variable names
|
||||
$listFields[$originalFieldName] = $key;
|
||||
}else{
|
||||
//$listFields[strtolower($key)] = $key;
|
||||
//Maintain case sensitive variable names
|
||||
$listFields[$key] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
//print_r($listFields);
|
||||
//$indexFields = $listFields;
|
||||
|
||||
return $listFields;
|
||||
}
|
||||
|
||||
}
|
||||
432
workflow/engine/classes/class.solr.php
Normal file
432
workflow/engine/classes/class.solr.php
Normal file
@@ -0,0 +1,432 @@
|
||||
<?php
|
||||
class BpmnEngine_SearchIndexAccess_Solr {
|
||||
const SOLR_VERSION = '&version=2.2';
|
||||
private $solrIsEnabled = false;
|
||||
private $solrHost = "";
|
||||
|
||||
function __construct($solrIsEnabled = false, $solrHost = "") {
|
||||
// use the parameters to initialize class
|
||||
$this->solrIsEnabled = $solrIsEnabled;
|
||||
$this->solrHost = $solrHost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the Solr service is available
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function isEnabled() {
|
||||
// verify solr server response
|
||||
|
||||
return $this->solrIsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the total number of indexed documents
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @param
|
||||
* workspace: workspace name
|
||||
* @return total
|
||||
*/
|
||||
function getNumberDocuments($workspace) {
|
||||
if (! $this->solrIsEnabled)
|
||||
return;
|
||||
// get configuration information in base to workspace parameter
|
||||
|
||||
// get total number of documents in registry
|
||||
$solrIntruct = $this->solrHost;
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/select/?q=*:*";
|
||||
$solrIntruct .= self::SOLR_VERSION;
|
||||
$solrIntruct .= "&start=0&rows=0&echoParams=none&wt=json";
|
||||
|
||||
$handlerTotal = curl_init ( $solrIntruct );
|
||||
curl_setopt ( $handlerTotal, CURLOPT_RETURNTRANSFER, true );
|
||||
$responseTotal = curl_exec ( $handlerTotal );
|
||||
curl_close ( $handlerTotal );
|
||||
|
||||
// verify the result of solr
|
||||
$responseSolrTotal = json_decode ( $responseTotal, true );
|
||||
if ($responseSolrTotal['responseHeader']['status'] != 0) {
|
||||
throw new Exception ( "Error returning the total number of documents in Solr." );
|
||||
}
|
||||
$numTotalDocs = $responseSolrTotal ['response'] ['numFound'];
|
||||
return $numTotalDocs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a query in base to Request data
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
function executeQuery($solrRequestData) {
|
||||
if (! $this->solrIsEnabled)
|
||||
return;
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$workspace = $solrRequestData->workspace;
|
||||
|
||||
// format request
|
||||
$query = empty ( $solrRequestData->searchText ) ? '*:*' : $solrRequestData->searchText;
|
||||
$query = rawurlencode ( $query );
|
||||
$start = '&start=' . $solrRequestData->startAfter;
|
||||
$rows = '&rows=' . $solrRequestData->pageSize;
|
||||
$fieldList = '';
|
||||
$cols = $solrRequestData->includeCols;
|
||||
if (! empty ( $cols )) {
|
||||
$fieldList = "&fl=" . implode ( ",", $cols );
|
||||
}
|
||||
$sort = '';
|
||||
if ($solrRequestData->numSortingCols > 0) {
|
||||
$sort = '&sort=';
|
||||
for($i = 0; $i < $solrRequestData->numSortingCols; $i ++) {
|
||||
$sort .= $solrRequestData->sortCols [$i] . "%20" . $solrRequestData->sortDir [$i] . ",";
|
||||
}
|
||||
|
||||
$sort = substr_replace ( $sort, "", - 1 );
|
||||
}
|
||||
$resultFormat = empty ( $solrRequestData->resultFormat ) ? '' : '&wt=' . $solrRequestData->resultFormat;
|
||||
$filters = '';
|
||||
$aFilters = explode ( ',', $solrRequestData->filterText );
|
||||
foreach ( $aFilters as $value ) {
|
||||
$filters .= '&fq=' . urlencode ( $value );
|
||||
}
|
||||
|
||||
$solrIntruct = $this->solrHost;
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/select/?q=$query";
|
||||
$solrIntruct .= "&echoParams=none";
|
||||
$solrIntruct .= self::SOLR_VERSION;
|
||||
$solrIntruct .= $start;
|
||||
$solrIntruct .= $rows;
|
||||
$solrIntruct .= $fieldList;
|
||||
$solrIntruct .= $sort;
|
||||
$solrIntruct .= $filters;
|
||||
$solrIntruct .= $resultFormat;
|
||||
|
||||
// send query
|
||||
// search the cases in base to datatable parameters
|
||||
$handler = curl_init ( $solrIntruct );
|
||||
curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
|
||||
$response = curl_exec ( $handler );
|
||||
curl_close ( $handler );
|
||||
|
||||
// decode
|
||||
$responseSolr = json_decode ( $response, true );
|
||||
if ($responseSolr['responseHeader']['status'] != 0) {
|
||||
throw new Exception ( "Error executing query to Solr." );
|
||||
}
|
||||
|
||||
return $responseSolr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert or Update document index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
function updateDocument($solrUpdateDocument) {
|
||||
if (! $this->solrIsEnabled)
|
||||
return;
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = $this->solrHost;
|
||||
$solrIntruct .= $solrUpdateDocument->workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ( $solrIntruct );
|
||||
curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt ( $handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
) ); // -H
|
||||
curl_setopt ( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
|
||||
curl_setopt ( $handler, CURLOPT_POSTFIELDS, $solrUpdateDocument->document ); // data
|
||||
$response = curl_exec ( $handler );
|
||||
|
||||
curl_close ( $handler );
|
||||
|
||||
$swOk = strpos ( $response, '<int name="status">0</int>' );
|
||||
if (! $swOk) {
|
||||
throw new Exception ( "Error updating document in Solr." );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit the changes since the last commit
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
function commitChanges($workspace) {
|
||||
if (! $this->solrIsEnabled)
|
||||
return;
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = $this->solrHost;
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ( $solrIntruct );
|
||||
curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt ( $handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
) ); // -H
|
||||
curl_setopt ( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
|
||||
curl_setopt ( $handler, CURLOPT_POSTFIELDS, "<commit/>" ); // data
|
||||
$response = curl_exec ( $handler );
|
||||
curl_close ( $handler );
|
||||
|
||||
$swOk = strpos ( $response, '<int name="status">0</int>' );
|
||||
if (! $swOk) {
|
||||
throw new Exception ( "Error commiting changes in Solr." );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Commit the changes since the last commit
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
function rollbackChanges($workspace) {
|
||||
if (! $this->solrIsEnabled)
|
||||
return;
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = $this->solrHost;
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ( $solrIntruct );
|
||||
curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt ( $handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
) ); // -H
|
||||
curl_setopt ( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
|
||||
curl_setopt ( $handler, CURLOPT_POSTFIELDS, "<rollback/>" ); // data
|
||||
$response = curl_exec ( $handler );
|
||||
curl_close ( $handler );
|
||||
|
||||
$swOk = strpos ( $response, '<int name="status">0</int>' );
|
||||
if (! $swOk) {
|
||||
throw new Exception ( "Error rolling back changes in Solr." );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert or Update document index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
function optimizeChanges($workspace) {
|
||||
if (! $this->solrIsEnabled)
|
||||
return;
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = $this->solrHost;
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ( $solrIntruct );
|
||||
curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt ( $handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
) ); // -H
|
||||
curl_setopt ( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
|
||||
curl_setopt ( $handler, CURLOPT_POSTFIELDS, "<optimize/>" ); // data
|
||||
$response = curl_exec ( $handler );
|
||||
curl_close ( $handler );
|
||||
|
||||
$swOk = strpos ( $response, '<int name="status">0</int>' );
|
||||
if (! $swOk) {
|
||||
throw new Exception ( "Error optimizing changes in Solr." );
|
||||
}
|
||||
}
|
||||
|
||||
function getListIndexedStoredFields($workspace) {
|
||||
if (! $this->solrIsEnabled)
|
||||
return;
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = $this->solrHost;
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/admin/luke?numTerms=0&wt=json";
|
||||
|
||||
$handler = curl_init ( $solrIntruct );
|
||||
curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
|
||||
$response = curl_exec ( $handler );
|
||||
curl_close ( $handler );
|
||||
// decode
|
||||
$responseSolr = json_decode ( $response, true );
|
||||
if ($responseSolr['responseHeader']['status'] != 0) {
|
||||
throw new Exception ( "Error getting index fields in Solr." );
|
||||
}
|
||||
return $responseSolr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all documents from index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
function deleteAllDocuments($workspace) {
|
||||
if (! $this->solrIsEnabled)
|
||||
return;
|
||||
// $registry = Zend_Registry::getInstance();
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = $this->solrHost;
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ( $solrIntruct );
|
||||
curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt ( $handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
) ); // -H
|
||||
curl_setopt ( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
|
||||
curl_setopt ( $handler, CURLOPT_POSTFIELDS, "<delete><query>*:*</query></delete>" ); // data
|
||||
$response = curl_exec ( $handler );
|
||||
|
||||
curl_close ( $handler );
|
||||
|
||||
$swOk = strpos ( $response, '<int name="status">0</int>' );
|
||||
if (! $swOk) {
|
||||
throw new Exception ( "Error deleting all documents in Solr." );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete specified documents from index
|
||||
* @gearman = false
|
||||
* @rest = false
|
||||
* @background = false
|
||||
*
|
||||
* @return solr response
|
||||
*/
|
||||
function deleteDocument($workspace, $idQuery) {
|
||||
if (! $this->solrIsEnabled)
|
||||
return;
|
||||
// $registry = Zend_Registry::getInstance();
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$solrIntruct = $this->solrHost;
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/update";
|
||||
|
||||
$handler = curl_init ( $solrIntruct );
|
||||
curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt ( $handler, CURLOPT_HTTPHEADER, array (
|
||||
'Content-type:application/xml'
|
||||
) ); // -H
|
||||
curl_setopt ( $handler, CURLOPT_BINARYTRANSFER, TRUE ); // --data-binary
|
||||
curl_setopt ( $handler, CURLOPT_POSTFIELDS, "<delete><query>" . $idQuery . "</query></delete>" ); // data
|
||||
$response = curl_exec ( $handler );
|
||||
|
||||
curl_close ( $handler );
|
||||
|
||||
$swOk = strpos ( $response, '<int name="status">0</int>' );
|
||||
if (! $swOk) {
|
||||
throw new Exception ( "Error deleting document in Solr." );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a query in base to Request data
|
||||
*
|
||||
* @param Entity_FacetRequest $facetRequestEntity
|
||||
* @return solr response: list of facets array
|
||||
*/
|
||||
function getFacetsList($facetRequest) {
|
||||
if (! $this->solrIsEnabled)
|
||||
return;
|
||||
|
||||
$solrIntruct = '';
|
||||
// get configuration information in base to workspace parameter
|
||||
$workspace = $facetRequest->workspace;
|
||||
|
||||
// format request
|
||||
$query = empty ( $facetRequest->searchText ) ? '*:*' : $facetRequest->searchText;
|
||||
$query = rawurlencode ( $query );
|
||||
$start = '&start=0';
|
||||
$rows = '&rows=0';
|
||||
$facets = '&facet=on&facet.mincount=1&facet.limit=20'; // enable facet and
|
||||
// only return facets
|
||||
// with minimun one
|
||||
// instance
|
||||
foreach ( $facetRequest->facetFields as $value ) {
|
||||
$facets .= '&facet.field=' . $value;
|
||||
}
|
||||
foreach ( $facetRequest->facetQueries as $value ) {
|
||||
$facets .= '&facet.query=' . $value;
|
||||
}
|
||||
if (! empty ( $facetRequest->facetDates )) {
|
||||
foreach ( $facetRequest->facetDates as $value ) {
|
||||
$facets .= '&facet.date=' . $value;
|
||||
}
|
||||
$facets .= '&facet.date.start=' . $facetRequest->facetDatesStart;
|
||||
$facets .= '&facet.date.end=' . $facetRequest->facetDatesEnd;
|
||||
$facets .= '&facet.date.gap=' . $facetRequest->facetDateGap;
|
||||
}
|
||||
$filters = '';
|
||||
foreach ( $facetRequest->filters as $value ) {
|
||||
$filters .= '&fq=' . $value;
|
||||
}
|
||||
// echo "<pre>";
|
||||
|
||||
$resultFormat = '&wt=json';
|
||||
|
||||
$solrIntruct = $this->solrHost;
|
||||
$solrIntruct .= $workspace;
|
||||
$solrIntruct .= "/select/?q=$query";
|
||||
$solrIntruct .= "&echoParams=none";
|
||||
$solrIntruct .= self::SOLR_VERSION;
|
||||
$solrIntruct .= $start;
|
||||
$solrIntruct .= $rows;
|
||||
$solrIntruct .= $facets;
|
||||
$solrIntruct .= $filters;
|
||||
$solrIntruct .= $resultFormat;
|
||||
|
||||
// send query
|
||||
// search the cases in base to datatable parameters
|
||||
$handler = curl_init ( $solrIntruct );
|
||||
curl_setopt ( $handler, CURLOPT_RETURNTRANSFER, true );
|
||||
$response = curl_exec ( $handler );
|
||||
curl_close ( $handler );
|
||||
|
||||
// decode
|
||||
$responseSolr = json_decode ( $response, true );
|
||||
if ($responseSolr['responseHeader']['status'] != 0) {
|
||||
throw new Exception ( "Error getting faceted list from Solr." );
|
||||
}
|
||||
|
||||
return $responseSolr;
|
||||
}
|
||||
}
|
||||
35
workflow/engine/classes/entities/AppSolrQueue.php
Normal file
35
workflow/engine/classes/entities/AppSolrQueue.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
/**
|
||||
* Application Solr Queue
|
||||
*/
|
||||
class Entity_AppSolrQueue extends Entity_Base {
|
||||
public $appUid = '';
|
||||
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",
|
||||
"appUpdated"
|
||||
);
|
||||
|
||||
$obj->validateRequiredFields ( $requiredFields );
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
135
workflow/engine/classes/entities/Base.php
Normal file
135
workflow/engine/classes/entities/Base.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
class Entity_Base {
|
||||
|
||||
/**
|
||||
* this function check if a field is in the data sent in the constructor
|
||||
* you can specify an array, and this function will use like alias
|
||||
*/
|
||||
protected function validateField($field, $default = false) {
|
||||
$fieldIsEmpty = true;
|
||||
|
||||
// this is a trick, if $fields is a string, $fields will be an array with
|
||||
// one element
|
||||
if (is_array ( $field )) {
|
||||
$fields = $field;
|
||||
}
|
||||
else {
|
||||
$fields = array ();
|
||||
$fields [] = $field;
|
||||
}
|
||||
|
||||
// if there are aliases for this field, evaluate all aliases and take the
|
||||
// first occurence
|
||||
foreach ( $fields as $k => $f ) {
|
||||
if (isset ( $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
|
||||
if ($fieldIsEmpty) {
|
||||
if ($default !== false) {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function validateRequiredFields($requiredFields = array()) {
|
||||
foreach ( $requiredFields as $k => $field ) {
|
||||
if ($this->{$field} === NULL) {
|
||||
throw (new Zend_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 = $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;
|
||||
}
|
||||
}
|
||||
|
||||
return $aAlias;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* 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 = $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 = $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 );
|
||||
}
|
||||
|
||||
}
|
||||
49
workflow/engine/classes/entities/FacetGroup.php
Normal file
49
workflow/engine/classes/entities/FacetGroup.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Facet group entity that represent a facet group
|
||||
*
|
||||
* @property $facetGroupName: The name of the facet (field name in solr index)
|
||||
* @property $facetGroupPrintName: The print name of the facet (Human readable
|
||||
* description)
|
||||
* @property $facetGroupType: The type of facet group, field, daterange, filter,
|
||||
* range
|
||||
* @property $facetGroupId: An identifier to find group information
|
||||
* @property $facetItems: array of facet items
|
||||
* @author dev-HebertSaak
|
||||
*
|
||||
*/
|
||||
class Entity_FacetGroup extends Entity_Base {
|
||||
public $facetGroupName = '';
|
||||
public $facetGroupPrintName = '';
|
||||
public $facetGroupType = ''; // field, daterange, query
|
||||
public $facetGroupId = '';
|
||||
public $facetItems = array ();
|
||||
|
||||
private function __construct() {
|
||||
}
|
||||
|
||||
static function CreateEmpty() {
|
||||
$obj = new Entity_FacetGroup ();
|
||||
return $obj;
|
||||
}
|
||||
|
||||
static function CreateForInsert($data) {
|
||||
$obj = new Entity_FacetGroup ();
|
||||
|
||||
$obj->initializeObject ( $data );
|
||||
|
||||
$requiredFields = array (
|
||||
"facetGroupName",
|
||||
"facetItems"
|
||||
);
|
||||
|
||||
$obj->validateRequiredFields ( $requiredFields );
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
36
workflow/engine/classes/entities/FacetInterfaceRequest.php
Normal file
36
workflow/engine/classes/entities/FacetInterfaceRequest.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
class Entity_FacetInterfaceRequest extends Entity_Base {
|
||||
public $searchText = '';
|
||||
public $selectedFacetsString = ''; // string of selected facet groups and
|
||||
// items in format:
|
||||
// groupkey1::groupdesc1:::itemkey1::itemdesc1,groupkey2::groupdesc2:::itemkey2::itemdesc2,
|
||||
// groupkey3::groupdesc3:::itemkey3::itemdesc3
|
||||
// var $selectedFacetFields = array();
|
||||
// var $selectedFacetTypes = array();
|
||||
|
||||
private function __construct() {
|
||||
}
|
||||
|
||||
static function CreateEmpty() {
|
||||
$obj = new Entity_FacetInterfaceRequest ();
|
||||
return $obj;
|
||||
}
|
||||
|
||||
static function CreateForRequest($data) {
|
||||
$obj = new Entity_FacetInterfaceRequest ();
|
||||
|
||||
$obj->initializeObject ( $data );
|
||||
|
||||
$requiredFields = array (
|
||||
"searchText",
|
||||
"selectedFacetsString"
|
||||
);
|
||||
|
||||
$obj->validateRequiredFields ( $requiredFields );
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
35
workflow/engine/classes/entities/FacetInterfaceResult.php
Normal file
35
workflow/engine/classes/entities/FacetInterfaceResult.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
class Entity_FacetInterfaceResult extends Entity_Base {
|
||||
// array of facetsgroups, array of Entity_SelectedFacetGroupItem, filter text
|
||||
|
||||
public $aFacetGroup = array ();
|
||||
public $aSelectedFacetGroupItem = array ();
|
||||
public $sFilterText = '';
|
||||
|
||||
private function __construct() {
|
||||
}
|
||||
|
||||
static function CreateEmpty() {
|
||||
$obj = new Entity_FacetInterfaceResult ();
|
||||
return $obj;
|
||||
}
|
||||
|
||||
static function CreateForRequest($data) {
|
||||
$obj = new Entity_FacetInterfaceResult ();
|
||||
|
||||
$obj->initializeObject ( $data );
|
||||
|
||||
$requiredFields = array (
|
||||
"aFacetGroup",
|
||||
"aSelectedFacetGroupItem",
|
||||
"sFilterText"
|
||||
);
|
||||
|
||||
$obj->validateRequiredFields ( $requiredFields );
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
42
workflow/engine/classes/entities/FacetItem.php
Normal file
42
workflow/engine/classes/entities/FacetItem.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Entity Face item, represent an option in a facet group
|
||||
*
|
||||
* @author dev-HebertSaak
|
||||
*
|
||||
*/
|
||||
class Entity_FacetItem extends Entity_Base {
|
||||
public $facetName = '';
|
||||
public $facetPrintName = '';
|
||||
public $facetCount = '';
|
||||
public $facetSelectCondition = ''; // selected condition used to select
|
||||
// this facet
|
||||
|
||||
private function __construct() {
|
||||
}
|
||||
|
||||
static function CreateEmpty() {
|
||||
$obj = new Entity_FacetItem ();
|
||||
return $obj;
|
||||
}
|
||||
|
||||
static function CreateForInsert($data) {
|
||||
$obj = new Entity_FacetItem ();
|
||||
|
||||
$obj->initializeObject ( $data );
|
||||
|
||||
$requiredFields = array (
|
||||
"facetName",
|
||||
"facetCount"
|
||||
);
|
||||
|
||||
$obj->validateRequiredFields ( $requiredFields );
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
39
workflow/engine/classes/entities/FacetRequest.php
Normal file
39
workflow/engine/classes/entities/FacetRequest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
33
workflow/engine/classes/entities/FacetResult.php
Normal file
33
workflow/engine/classes/entities/FacetResult.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
class Entity_FacetResult extends Entity_Base {
|
||||
public $aFacetGroups = array ();
|
||||
public $aSelectedFacetGroups = array ();
|
||||
public $sFilterText = '';
|
||||
|
||||
private function __construct() {
|
||||
}
|
||||
|
||||
static function CreateEmpty() {
|
||||
$obj = new Entity_FacetResult ();
|
||||
return $obj;
|
||||
}
|
||||
|
||||
static function CreateForRequest($data) {
|
||||
$obj = new Entity_FacetResult ();
|
||||
|
||||
$obj->initializeObject ( $data );
|
||||
|
||||
$requiredFields = array (
|
||||
"aFacetGroups",
|
||||
"aSelectedFacetGroups",
|
||||
"sFilterText"
|
||||
);
|
||||
|
||||
$obj->validateRequiredFields ( $requiredFields );
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
36
workflow/engine/classes/entities/SelectedFacetGroupItem.php
Normal file
36
workflow/engine/classes/entities/SelectedFacetGroupItem.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
class Entity_SelectedFacetGroupItem extends Entity_Base {
|
||||
public $selectedFacetGroupName = '';
|
||||
public $selectedFacetGroupPrintName = '';
|
||||
public $selectedFacetItemName = '';
|
||||
public $selectedFacetItemPrintName = '';
|
||||
public $selectedFacetRemoveCondition = ''; // remove condition, string of
|
||||
// selected facets without this
|
||||
// facet
|
||||
|
||||
private function __construct() {
|
||||
}
|
||||
|
||||
static function CreateEmpty() {
|
||||
$obj = new Entity_SelectedFacetGroupItem ();
|
||||
return $obj;
|
||||
}
|
||||
|
||||
static function CreateForRequest($data) {
|
||||
$obj = new Entity_SelectedFacetGroupItem ();
|
||||
|
||||
$obj->initializeObject ( $data );
|
||||
|
||||
$requiredFields = array (
|
||||
"selectedFacetGroupName",
|
||||
"selectedFacetItemName"
|
||||
);
|
||||
|
||||
$obj->validateRequiredFields ( $requiredFields );
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
36
workflow/engine/classes/entities/SolrQueryResult.php
Normal file
36
workflow/engine/classes/entities/SolrQueryResult.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
class Entity_SolrQueryResult extends Entity_Base {
|
||||
public $sEcho = '';
|
||||
public $iTotalRecords = 0;
|
||||
public $iTotalDisplayRecords = 10;
|
||||
public $aaData = array (); // array of arrays of records to
|
||||
// display
|
||||
|
||||
private function __construct() {
|
||||
}
|
||||
|
||||
static function CreateEmpty() {
|
||||
$obj = new Entity_SolrQueryResult ();
|
||||
return $obj;
|
||||
}
|
||||
|
||||
static function CreateForRequest($data) {
|
||||
$obj = new Entity_SolrQueryResult ();
|
||||
|
||||
$obj->initializeObject ( $data );
|
||||
|
||||
$requiredFields = array (
|
||||
'sEcho',
|
||||
'iTotalRecords',
|
||||
'iTotalDisplayRecords',
|
||||
'aaData'
|
||||
);
|
||||
|
||||
$obj->validateRequiredFields ( $requiredFields );
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
42
workflow/engine/classes/entities/SolrRequestData.php
Normal file
42
workflow/engine/classes/entities/SolrRequestData.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
31
workflow/engine/classes/entities/SolrUpdateDocument.php
Normal file
31
workflow/engine/classes/entities/SolrUpdateDocument.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
require_once ('Base.php');
|
||||
|
||||
class Entity_SolrUpdateDocument extends Entity_Base {
|
||||
var $workspace = '';
|
||||
var $document = '';
|
||||
|
||||
private function __construct() {
|
||||
}
|
||||
|
||||
static function CreateEmpty() {
|
||||
$obj = new Entity_SolrUpdateDocument ();
|
||||
return $obj;
|
||||
}
|
||||
|
||||
static function CreateForRequest($data) {
|
||||
$obj = new Entity_SolrUpdateDocument ();
|
||||
|
||||
$obj->initializeObject ( $data );
|
||||
|
||||
$requiredFields = array (
|
||||
"workspace",
|
||||
"document"
|
||||
);
|
||||
|
||||
$obj->validateRequiredFields ( $requiredFields );
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
}
|
||||
126
workflow/engine/classes/model/AppSolrQueue.php
Normal file
126
workflow/engine/classes/model/AppSolrQueue.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
require_once 'classes/model/om/BaseAppSolrQueue.php';
|
||||
require_once 'classes/entities/AppSolrQueue.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'APP_SOLR_QUEUE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppSolrQueue extends BaseAppSolrQueue {
|
||||
|
||||
public function exists($sAppUid)
|
||||
{
|
||||
try {
|
||||
$oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid );
|
||||
if (!is_null($oRow))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function createUpdate($sAppUid, $iUpdated)
|
||||
{
|
||||
$con = Propel::getConnection(AppSolrQueuePeer::DATABASE_NAME);
|
||||
try
|
||||
{
|
||||
if($this->exists($sAppUid)){
|
||||
$con->begin();
|
||||
//update record
|
||||
//$oRow = AppSolrQueuePeer::retrieveByPK( $sAppUid );
|
||||
//$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
//$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
|
||||
$this->setNew(false);
|
||||
//set field
|
||||
$this->setAppUid($sAppUid);
|
||||
$this->setAppUpdated($iUpdated);
|
||||
if($this->validate())
|
||||
{
|
||||
$result=$this->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
$con->rollback();
|
||||
throw(new Exception("Failed Validation in class ".get_class($this)."."));
|
||||
}
|
||||
$con->commit();
|
||||
return $result;
|
||||
}else{
|
||||
//create record
|
||||
//set values
|
||||
$this->setAppUid($sAppUid);
|
||||
$this->setAppUpdated($iUpdated);
|
||||
if($this->validate())
|
||||
{
|
||||
$result=$this->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
$e=new Exception("Failed Validation in class ".get_class($this).".");
|
||||
//$e->aValidationFailures=$this->getValidationFailures();
|
||||
throw($e);
|
||||
}
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of updated applications
|
||||
* array of Entity_AppSolrQueue
|
||||
*/
|
||||
public function getListUpdatedApplications(){
|
||||
$updatedApplications = array();
|
||||
try
|
||||
{
|
||||
$c = new Criteria();
|
||||
|
||||
$c->addSelectColumn(AppSolrQueuePeer::APP_UID);
|
||||
$c->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
|
||||
|
||||
//"WHERE
|
||||
$c->add(AppSolrQueuePeer::APP_UPDATED, 0, Criteria::NOT_EQUAL);
|
||||
|
||||
$rs = AppSolrQueuePeer::doSelectRS($c);
|
||||
$rs->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
//echo $c->toString();
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
|
||||
while (is_array($row)) {
|
||||
$appSolrQueue = Entity_AppSolrQueue::CreateEmpty();
|
||||
$appSolrQueue->appUid = $row['APP_UID'];
|
||||
$appSolrQueue->appUpdated = $row['APP_UPDATED'];
|
||||
$updatedApplications[] = $appSolrQueue;
|
||||
$rs->next();
|
||||
$row = $rs->getRow();
|
||||
}
|
||||
|
||||
return $updatedApplications;
|
||||
}catch(Exception $e){
|
||||
$con->rollback();
|
||||
throw($e);
|
||||
}
|
||||
}
|
||||
} // AppSolrQueue
|
||||
23
workflow/engine/classes/model/AppSolrQueuePeer.php
Normal file
23
workflow/engine/classes/model/AppSolrQueuePeer.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
// include base peer class
|
||||
require_once 'classes/model/om/BaseAppSolrQueuePeer.php';
|
||||
|
||||
// include object class
|
||||
include_once 'classes/model/AppSolrQueue.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for performing query and update operations on the 'APP_SOLR_QUEUE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* You should add additional methods to this class to meet the
|
||||
* application requirements. This class will only be generated as
|
||||
* long as it does not already exist in the output directory.
|
||||
*
|
||||
* @package classes.model
|
||||
*/
|
||||
class AppSolrQueuePeer extends BaseAppSolrQueuePeer {
|
||||
|
||||
} // AppSolrQueuePeer
|
||||
73
workflow/engine/classes/model/map/AppSolrQueueMapBuilder.php
Normal file
73
workflow/engine/classes/model/map/AppSolrQueueMapBuilder.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
require_once 'propel/map/MapBuilder.php';
|
||||
include_once 'creole/CreoleTypes.php';
|
||||
|
||||
|
||||
/**
|
||||
* This class adds structure of 'APP_SOLR_QUEUE' table to 'workflow' DatabaseMap object.
|
||||
*
|
||||
*
|
||||
*
|
||||
* These statically-built map classes are used by Propel to do runtime db structure discovery.
|
||||
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||
* (i.e. if it's a text column type).
|
||||
*
|
||||
* @package workflow.classes.model.map
|
||||
*/
|
||||
class AppSolrQueueMapBuilder {
|
||||
|
||||
/**
|
||||
* The (dot-path) name of this class
|
||||
*/
|
||||
const CLASS_NAME = 'classes.model.map.AppSolrQueueMapBuilder';
|
||||
|
||||
/**
|
||||
* The database map.
|
||||
*/
|
||||
private $dbMap;
|
||||
|
||||
/**
|
||||
* Tells us if this DatabaseMapBuilder is built so that we
|
||||
* don't have to re-build it every time.
|
||||
*
|
||||
* @return boolean true if this DatabaseMapBuilder is built, false otherwise.
|
||||
*/
|
||||
public function isBuilt()
|
||||
{
|
||||
return ($this->dbMap !== null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the databasemap this map builder built.
|
||||
*
|
||||
* @return the databasemap
|
||||
*/
|
||||
public function getDatabaseMap()
|
||||
{
|
||||
return $this->dbMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* The doBuild() method builds the DatabaseMap
|
||||
*
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function doBuild()
|
||||
{
|
||||
$this->dbMap = Propel::getDatabaseMap('workflow');
|
||||
|
||||
$tMap = $this->dbMap->addTable('APP_SOLR_QUEUE');
|
||||
$tMap->setPhpName('AppSolrQueue');
|
||||
|
||||
$tMap->setUseIdGenerator(false);
|
||||
|
||||
$tMap->addPrimaryKey('APP_UID', 'AppUid', 'string', CreoleTypes::VARCHAR, true, 32);
|
||||
|
||||
$tMap->addColumn('APP_UPDATED', 'AppUpdated', 'int', CreoleTypes::TINYINT, true, null);
|
||||
|
||||
} // doBuild()
|
||||
|
||||
} // AppSolrQueueMapBuilder
|
||||
557
workflow/engine/classes/model/om/BaseAppSolrQueue.php
Normal file
557
workflow/engine/classes/model/om/BaseAppSolrQueue.php
Normal file
@@ -0,0 +1,557 @@
|
||||
<?php
|
||||
|
||||
require_once 'propel/om/BaseObject.php';
|
||||
|
||||
require_once 'propel/om/Persistent.php';
|
||||
|
||||
|
||||
include_once 'propel/util/Criteria.php';
|
||||
|
||||
include_once 'classes/model/AppSolrQueuePeer.php';
|
||||
|
||||
/**
|
||||
* Base class that represents a row from the 'APP_SOLR_QUEUE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package workflow.classes.model.om
|
||||
*/
|
||||
abstract class BaseAppSolrQueue extends BaseObject implements Persistent {
|
||||
|
||||
|
||||
/**
|
||||
* The Peer class.
|
||||
* Instance provides a convenient way of calling static methods on a class
|
||||
* that calling code may not be able to identify.
|
||||
* @var AppSolrQueuePeer
|
||||
*/
|
||||
protected static $peer;
|
||||
|
||||
|
||||
/**
|
||||
* The value for the app_uid field.
|
||||
* @var string
|
||||
*/
|
||||
protected $app_uid = '';
|
||||
|
||||
|
||||
/**
|
||||
* The value for the app_updated field.
|
||||
* @var int
|
||||
*/
|
||||
protected $app_updated = 1;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless save loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInSave = false;
|
||||
|
||||
/**
|
||||
* Flag to prevent endless validation loop, if this object is referenced
|
||||
* by another object which falls in this transaction.
|
||||
* @var boolean
|
||||
*/
|
||||
protected $alreadyInValidation = false;
|
||||
|
||||
/**
|
||||
* Get the [app_uid] column value.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getAppUid()
|
||||
{
|
||||
|
||||
return $this->app_uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [app_updated] column value.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAppUpdated()
|
||||
{
|
||||
|
||||
return $this->app_updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of [app_uid] column.
|
||||
*
|
||||
* @param string $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAppUid($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_uid !== $v || $v === '') {
|
||||
$this->app_uid = $v;
|
||||
$this->modifiedColumns[] = AppSolrQueuePeer::APP_UID;
|
||||
}
|
||||
|
||||
} // setAppUid()
|
||||
|
||||
/**
|
||||
* Set the value of [app_updated] column.
|
||||
*
|
||||
* @param int $v new value
|
||||
* @return void
|
||||
*/
|
||||
public function setAppUpdated($v)
|
||||
{
|
||||
|
||||
// Since the native PHP type for this column is integer,
|
||||
// we will cast the input value to an int (if it is not).
|
||||
if ($v !== null && !is_int($v) && is_numeric($v)) {
|
||||
$v = (int) $v;
|
||||
}
|
||||
|
||||
if ($this->app_updated !== $v || $v === 1) {
|
||||
$this->app_updated = $v;
|
||||
$this->modifiedColumns[] = AppSolrQueuePeer::APP_UPDATED;
|
||||
}
|
||||
|
||||
} // setAppUpdated()
|
||||
|
||||
/**
|
||||
* Hydrates (populates) the object variables with values from the database resultset.
|
||||
*
|
||||
* An offset (1-based "start column") is specified so that objects can be hydrated
|
||||
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||
* for results of JOIN queries where the resultset row includes columns from two or
|
||||
* more tables.
|
||||
*
|
||||
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
|
||||
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
|
||||
* @return int next starting column
|
||||
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||
*/
|
||||
public function hydrate(ResultSet $rs, $startcol = 1)
|
||||
{
|
||||
try {
|
||||
|
||||
$this->app_uid = $rs->getString($startcol + 0);
|
||||
|
||||
$this->app_updated = $rs->getInt($startcol + 1);
|
||||
|
||||
$this->resetModified();
|
||||
|
||||
$this->setNew(false);
|
||||
|
||||
// FIXME - using NUM_COLUMNS may be clearer.
|
||||
return $startcol + 2; // 2 = AppSolrQueuePeer::NUM_COLUMNS - AppSolrQueuePeer::NUM_LAZY_LOAD_COLUMNS).
|
||||
|
||||
} catch (Exception $e) {
|
||||
throw new PropelException("Error populating AppSolrQueue object", $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes this object from datastore and sets delete attribute.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return void
|
||||
* @throws PropelException
|
||||
* @see BaseObject::setDeleted()
|
||||
* @see BaseObject::isDeleted()
|
||||
*/
|
||||
public function delete($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("This object has already been deleted.");
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(AppSolrQueuePeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
AppSolrQueuePeer::doDelete($this, $con);
|
||||
$this->setDeleted(true);
|
||||
$con->commit();
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database. If the object is new,
|
||||
* it inserts it; otherwise an update is performed. This method
|
||||
* wraps the doSave() worker method in a transaction.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see doSave()
|
||||
*/
|
||||
public function save($con = null)
|
||||
{
|
||||
if ($this->isDeleted()) {
|
||||
throw new PropelException("You cannot save an object that has been deleted.");
|
||||
}
|
||||
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(AppSolrQueuePeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
try {
|
||||
$con->begin();
|
||||
$affectedRows = $this->doSave($con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores the object in the database.
|
||||
*
|
||||
* If the object is new, it inserts it; otherwise an update is performed.
|
||||
* All related objects are also updated in this method.
|
||||
*
|
||||
* @param Connection $con
|
||||
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||
* @throws PropelException
|
||||
* @see save()
|
||||
*/
|
||||
protected function doSave($con)
|
||||
{
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
if (!$this->alreadyInSave) {
|
||||
$this->alreadyInSave = true;
|
||||
|
||||
|
||||
// If this object has been modified, then save it to the database.
|
||||
if ($this->isModified()) {
|
||||
if ($this->isNew()) {
|
||||
$pk = AppSolrQueuePeer::doInsert($this, $con);
|
||||
$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
|
||||
// should always be true here (even though technically
|
||||
// BasePeer::doInsert() can insert multiple rows).
|
||||
|
||||
$this->setNew(false);
|
||||
} else {
|
||||
$affectedRows += AppSolrQueuePeer::doUpdate($this, $con);
|
||||
}
|
||||
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||
}
|
||||
|
||||
$this->alreadyInSave = false;
|
||||
}
|
||||
return $affectedRows;
|
||||
} // doSave()
|
||||
|
||||
/**
|
||||
* Array of ValidationFailed objects.
|
||||
* @var array ValidationFailed[]
|
||||
*/
|
||||
protected $validationFailures = array();
|
||||
|
||||
/**
|
||||
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||
*
|
||||
*
|
||||
* @return array ValidationFailed[]
|
||||
* @see validate()
|
||||
*/
|
||||
public function getValidationFailures()
|
||||
{
|
||||
return $this->validationFailures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the objects modified field values and all objects related to this table.
|
||||
*
|
||||
* If $columns is either a column name or an array of column names
|
||||
* only those columns are validated.
|
||||
*
|
||||
* @param mixed $columns Column name or an array of column names.
|
||||
* @return boolean Whether all columns pass validation.
|
||||
* @see doValidate()
|
||||
* @see getValidationFailures()
|
||||
*/
|
||||
public function validate($columns = null)
|
||||
{
|
||||
$res = $this->doValidate($columns);
|
||||
if ($res === true) {
|
||||
$this->validationFailures = array();
|
||||
return true;
|
||||
} else {
|
||||
$this->validationFailures = $res;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function performs the validation work for complex object models.
|
||||
*
|
||||
* In addition to checking the current object, all related objects will
|
||||
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||
* an aggreagated array of ValidationFailed objects will be returned.
|
||||
*
|
||||
* @param array $columns Array of column names to validate.
|
||||
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||
*/
|
||||
protected function doValidate($columns = null)
|
||||
{
|
||||
if (!$this->alreadyInValidation) {
|
||||
$this->alreadyInValidation = true;
|
||||
$retval = null;
|
||||
|
||||
$failureMap = array();
|
||||
|
||||
|
||||
if (($retval = AppSolrQueuePeer::doValidate($this, $columns)) !== true) {
|
||||
$failureMap = array_merge($failureMap, $retval);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->alreadyInValidation = false;
|
||||
}
|
||||
|
||||
return (!empty($failureMap) ? $failureMap : true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name name
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return mixed Value of field.
|
||||
*/
|
||||
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = AppSolrQueuePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->getByPosition($pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @return mixed Value of field at $pos
|
||||
*/
|
||||
public function getByPosition($pos)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
return $this->getAppUid();
|
||||
break;
|
||||
case 1:
|
||||
return $this->getAppUpdated();
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Exports the object as an array.
|
||||
*
|
||||
* You can specify the key type of the array by passing one of the class
|
||||
* type constants.
|
||||
*
|
||||
* @param string $keyType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return an associative array containing the field names (as keys) and field values
|
||||
*/
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = AppSolrQueuePeer::getFieldNames($keyType);
|
||||
$result = array(
|
||||
$keys[0] => $this->getAppUid(),
|
||||
$keys[1] => $this->getAppUpdated(),
|
||||
);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by name passed in as a string.
|
||||
*
|
||||
* @param string $name peer name
|
||||
* @param mixed $value field value
|
||||
* @param string $type The type of fieldname the $name is of:
|
||||
* one of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return void
|
||||
*/
|
||||
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$pos = AppSolrQueuePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||
return $this->setByPosition($pos, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a field from the object by Position as specified in the xml schema.
|
||||
* Zero-based.
|
||||
*
|
||||
* @param int $pos position in xml schema
|
||||
* @param mixed $value field value
|
||||
* @return void
|
||||
*/
|
||||
public function setByPosition($pos, $value)
|
||||
{
|
||||
switch($pos) {
|
||||
case 0:
|
||||
$this->setAppUid($value);
|
||||
break;
|
||||
case 1:
|
||||
$this->setAppUpdated($value);
|
||||
break;
|
||||
} // switch()
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the object using an array.
|
||||
*
|
||||
* This is particularly useful when populating an object from one of the
|
||||
* request arrays (e.g. $_POST). This method goes through the column
|
||||
* names, checking to see whether a matching key exists in populated
|
||||
* array. If so the setByName() method is called for that column.
|
||||
*
|
||||
* You can specify the key type of the array by additionally passing one
|
||||
* of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
|
||||
* TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
|
||||
*
|
||||
* @param array $arr An array to populate the object from.
|
||||
* @param string $keyType The type of keys the array uses.
|
||||
* @return void
|
||||
*/
|
||||
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
$keys = AppSolrQueuePeer::getFieldNames($keyType);
|
||||
|
||||
if (array_key_exists($keys[0], $arr)) $this->setAppUid($arr[$keys[0]]);
|
||||
if (array_key_exists($keys[1], $arr)) $this->setAppUpdated($arr[$keys[1]]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Criteria object containing the values of all modified columns in this object.
|
||||
*
|
||||
* @return Criteria The Criteria object containing all modified values.
|
||||
*/
|
||||
public function buildCriteria()
|
||||
{
|
||||
$criteria = new Criteria(AppSolrQueuePeer::DATABASE_NAME);
|
||||
|
||||
if ($this->isColumnModified(AppSolrQueuePeer::APP_UID)) $criteria->add(AppSolrQueuePeer::APP_UID, $this->app_uid);
|
||||
if ($this->isColumnModified(AppSolrQueuePeer::APP_UPDATED)) $criteria->add(AppSolrQueuePeer::APP_UPDATED, $this->app_updated);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a Criteria object containing the primary key for this object.
|
||||
*
|
||||
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||
* of whether or not they have been modified.
|
||||
*
|
||||
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||
*/
|
||||
public function buildPkeyCriteria()
|
||||
{
|
||||
$criteria = new Criteria(AppSolrQueuePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(AppSolrQueuePeer::APP_UID, $this->app_uid);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return string
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getAppUid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (app_uid column).
|
||||
*
|
||||
* @param string $key Primary key.
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
{
|
||||
$this->setAppUid($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets contents of passed object to values from current object.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param object $copyObj An object of AppSolrQueue (or compatible) type.
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setAppUpdated($this->app_updated);
|
||||
|
||||
|
||||
$copyObj->setNew(true);
|
||||
|
||||
$copyObj->setAppUid(''); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||
* keys that are defined for the table.
|
||||
*
|
||||
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||
* objects.
|
||||
*
|
||||
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||
* @return AppSolrQueue Clone of current object.
|
||||
* @throws PropelException
|
||||
*/
|
||||
public function copy($deepCopy = false)
|
||||
{
|
||||
// we use get_class(), because this might be a subclass
|
||||
$clazz = get_class($this);
|
||||
$copyObj = new $clazz();
|
||||
$this->copyInto($copyObj, $deepCopy);
|
||||
return $copyObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a peer instance associated with this om.
|
||||
*
|
||||
* Since Peer classes are not to have any instance attributes, this method returns the
|
||||
* same instance for all member of this class. The method could therefore
|
||||
* be static, but this would prevent one from overriding the behavior.
|
||||
*
|
||||
* @return AppSolrQueuePeer
|
||||
*/
|
||||
public function getPeer()
|
||||
{
|
||||
if (self::$peer === null) {
|
||||
self::$peer = new AppSolrQueuePeer();
|
||||
}
|
||||
return self::$peer;
|
||||
}
|
||||
|
||||
} // BaseAppSolrQueue
|
||||
570
workflow/engine/classes/model/om/BaseAppSolrQueuePeer.php
Normal file
570
workflow/engine/classes/model/om/BaseAppSolrQueuePeer.php
Normal file
@@ -0,0 +1,570 @@
|
||||
<?php
|
||||
|
||||
require_once 'propel/util/BasePeer.php';
|
||||
// The object class -- needed for instanceof checks in this class.
|
||||
// actual class may be a subclass -- as returned by AppSolrQueuePeer::getOMClass()
|
||||
include_once 'classes/model/AppSolrQueue.php';
|
||||
|
||||
/**
|
||||
* Base static class for performing query and update operations on the 'APP_SOLR_QUEUE' table.
|
||||
*
|
||||
*
|
||||
*
|
||||
* @package workflow.classes.model.om
|
||||
*/
|
||||
abstract class BaseAppSolrQueuePeer {
|
||||
|
||||
/** the default database name for this class */
|
||||
const DATABASE_NAME = 'workflow';
|
||||
|
||||
/** the table name for this class */
|
||||
const TABLE_NAME = 'APP_SOLR_QUEUE';
|
||||
|
||||
/** A class that can be returned by this peer. */
|
||||
const CLASS_DEFAULT = 'classes.model.AppSolrQueue';
|
||||
|
||||
/** The total number of columns. */
|
||||
const NUM_COLUMNS = 2;
|
||||
|
||||
/** The number of lazy-loaded columns. */
|
||||
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||
|
||||
|
||||
/** the column name for the APP_UID field */
|
||||
const APP_UID = 'APP_SOLR_QUEUE.APP_UID';
|
||||
|
||||
/** the column name for the APP_UPDATED field */
|
||||
const APP_UPDATED = 'APP_SOLR_QUEUE.APP_UPDATED';
|
||||
|
||||
/** The PHP to DB Name Mapping */
|
||||
private static $phpNameMap = null;
|
||||
|
||||
|
||||
/**
|
||||
* holds an array of fieldnames
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* 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, )
|
||||
);
|
||||
|
||||
/**
|
||||
* holds an array of keys for quick access to the fieldnames array
|
||||
*
|
||||
* first dimension keys are the type constants
|
||||
* 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, )
|
||||
);
|
||||
|
||||
/**
|
||||
* @return MapBuilder the map builder for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getMapBuilder()
|
||||
{
|
||||
include_once 'classes/model/map/AppSolrQueueMapBuilder.php';
|
||||
return BasePeer::getMapBuilder('classes.model.map.AppSolrQueueMapBuilder');
|
||||
}
|
||||
/**
|
||||
* Gets a map (hash) of PHP names to DB column names.
|
||||
*
|
||||
* @return array The PHP to DB name map for this peer
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
|
||||
*/
|
||||
public static function getPhpNameMap()
|
||||
{
|
||||
if (self::$phpNameMap === null) {
|
||||
$map = AppSolrQueuePeer::getTableMap();
|
||||
$columns = $map->getColumns();
|
||||
$nameMap = array();
|
||||
foreach ($columns as $column) {
|
||||
$nameMap[$column->getPhpName()] = $column->getColumnName();
|
||||
}
|
||||
self::$phpNameMap = $nameMap;
|
||||
}
|
||||
return self::$phpNameMap;
|
||||
}
|
||||
/**
|
||||
* Translates a fieldname to another type
|
||||
*
|
||||
* @param string $name field name
|
||||
* @param string $fromType One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @param string $toType One of the class type constants
|
||||
* @return string translated name of the field.
|
||||
*/
|
||||
static public function translateFieldName($name, $fromType, $toType)
|
||||
{
|
||||
$toNames = self::getFieldNames($toType);
|
||||
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||
if ($key === null) {
|
||||
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||
}
|
||||
return $toNames[$key];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of of field names.
|
||||
*
|
||||
* @param string $type The type of fieldnames to return:
|
||||
* One of the class type constants TYPE_PHPNAME,
|
||||
* TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
|
||||
* @return array A list of field names
|
||||
*/
|
||||
|
||||
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||
{
|
||||
if (!array_key_exists($type, self::$fieldNames)) {
|
||||
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . $type . ' was given.');
|
||||
}
|
||||
return self::$fieldNames[$type];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method which changes table.column to alias.column.
|
||||
*
|
||||
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||
* <code>
|
||||
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||
* </code>
|
||||
* @param string $alias The alias for the current table.
|
||||
* @param string $column The column name for current table. (i.e. AppSolrQueuePeer::COLUMN_NAME).
|
||||
* @return string
|
||||
*/
|
||||
public static function alias($alias, $column)
|
||||
{
|
||||
return str_replace(AppSolrQueuePeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add all the columns needed to create a new object.
|
||||
*
|
||||
* Note: any columns that were marked with lazyLoad="true" in the
|
||||
* XML schema will not be added to the select list and only loaded
|
||||
* on demand.
|
||||
*
|
||||
* @param criteria object containing the columns to add.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function addSelectColumns(Criteria $criteria)
|
||||
{
|
||||
|
||||
$criteria->addSelectColumn(AppSolrQueuePeer::APP_UID);
|
||||
|
||||
$criteria->addSelectColumn(AppSolrQueuePeer::APP_UPDATED);
|
||||
|
||||
}
|
||||
|
||||
const COUNT = 'COUNT(APP_SOLR_QUEUE.APP_UID)';
|
||||
const COUNT_DISTINCT = 'COUNT(DISTINCT APP_SOLR_QUEUE.APP_UID)';
|
||||
|
||||
/**
|
||||
* Returns the number of rows matching criteria.
|
||||
*
|
||||
* @param Criteria $criteria
|
||||
* @param boolean $distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
|
||||
* @param Connection $con
|
||||
* @return int Number of matching rows.
|
||||
*/
|
||||
public static function doCount(Criteria $criteria, $distinct = false, $con = null)
|
||||
{
|
||||
// we're going to modify criteria, so copy it first
|
||||
$criteria = clone $criteria;
|
||||
|
||||
// clear out anything that might confuse the ORDER BY clause
|
||||
$criteria->clearSelectColumns()->clearOrderByColumns();
|
||||
if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||
$criteria->addSelectColumn(AppSolrQueuePeer::COUNT_DISTINCT);
|
||||
} else {
|
||||
$criteria->addSelectColumn(AppSolrQueuePeer::COUNT);
|
||||
}
|
||||
|
||||
// just in case we're grouping: add those columns to the select statement
|
||||
foreach($criteria->getGroupByColumns() as $column)
|
||||
{
|
||||
$criteria->addSelectColumn($column);
|
||||
}
|
||||
|
||||
$rs = AppSolrQueuePeer::doSelectRS($criteria, $con);
|
||||
if ($rs->next()) {
|
||||
return $rs->getInt(1);
|
||||
} else {
|
||||
// no rows returned; we infer that means 0 matches.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Method to select one object from the DB.
|
||||
*
|
||||
* @param Criteria $criteria object used to create the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return AppSolrQueue
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelectOne(Criteria $criteria, $con = null)
|
||||
{
|
||||
$critcopy = clone $criteria;
|
||||
$critcopy->setLimit(1);
|
||||
$objects = AppSolrQueuePeer::doSelect($critcopy, $con);
|
||||
if ($objects) {
|
||||
return $objects[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Method to do selects.
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con
|
||||
* @return array Array of selected Objects
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doSelect(Criteria $criteria, $con = null)
|
||||
{
|
||||
return AppSolrQueuePeer::populateObjects(AppSolrQueuePeer::doSelectRS($criteria, $con));
|
||||
}
|
||||
/**
|
||||
* Prepares the Criteria object and uses the parent doSelect()
|
||||
* method to get a ResultSet.
|
||||
*
|
||||
* Use this method directly if you want to just get the resultset
|
||||
* (instead of an array of objects).
|
||||
*
|
||||
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
* @return ResultSet The resultset object with numerically-indexed fields.
|
||||
* @see BasePeer::doSelect()
|
||||
*/
|
||||
public static function doSelectRS(Criteria $criteria, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if (!$criteria->getSelectColumns()) {
|
||||
$criteria = clone $criteria;
|
||||
AppSolrQueuePeer::addSelectColumns($criteria);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
// BasePeer returns a Creole ResultSet, set to return
|
||||
// rows indexed numerically.
|
||||
return BasePeer::doSelect($criteria, $con);
|
||||
}
|
||||
/**
|
||||
* The returned array will contain objects of the default type or
|
||||
* objects that inherit from the default.
|
||||
*
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function populateObjects(ResultSet $rs)
|
||||
{
|
||||
$results = array();
|
||||
|
||||
// set the class once to avoid overhead in the loop
|
||||
$cls = AppSolrQueuePeer::getOMClass();
|
||||
$cls = Propel::import($cls);
|
||||
// populate the object(s)
|
||||
while($rs->next()) {
|
||||
|
||||
$obj = new $cls();
|
||||
$obj->hydrate($rs);
|
||||
$results[] = $obj;
|
||||
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
/**
|
||||
* Returns the TableMap related to this peer.
|
||||
* This method is not needed for general use but a specific application could have a need.
|
||||
* @return TableMap
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function getTableMap()
|
||||
{
|
||||
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* The class that the Peer will make instances of.
|
||||
*
|
||||
* This uses a dot-path notation which is tranalted into a path
|
||||
* relative to a location on the PHP include_path.
|
||||
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||
*
|
||||
* @return string path.to.ClassName
|
||||
*/
|
||||
public static function getOMClass()
|
||||
{
|
||||
return AppSolrQueuePeer::CLASS_DEFAULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an INSERT on the database, given a AppSolrQueue or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or AppSolrQueue object containing data that is used to create the INSERT statement.
|
||||
* @param Connection $con the connection to use
|
||||
* @return mixed The new primary key.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doInsert($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} else {
|
||||
$criteria = $values->buildCriteria(); // build Criteria from AppSolrQueue object
|
||||
}
|
||||
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table (I guess, conceivably)
|
||||
$con->begin();
|
||||
$pk = BasePeer::doInsert($criteria, $con);
|
||||
$con->commit();
|
||||
} catch(PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return $pk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform an UPDATE on the database, given a AppSolrQueue or Criteria object.
|
||||
*
|
||||
* @param mixed $values Criteria or AppSolrQueue object containing data that is used to create the UPDATE statement.
|
||||
* @param Connection $con The connection to use (specify Connection object to exert more control over transactions).
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doUpdate($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
|
||||
$comparison = $criteria->getComparison(AppSolrQueuePeer::APP_UID);
|
||||
$selectCriteria->add(AppSolrQueuePeer::APP_UID, $criteria->remove(AppSolrQueuePeer::APP_UID), $comparison);
|
||||
|
||||
} else { // $values is AppSolrQueue object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
}
|
||||
|
||||
// set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to DELETE all rows from the APP_SOLR_QUEUE table.
|
||||
*
|
||||
* @return int The number of affected rows (if supported by underlying database driver).
|
||||
*/
|
||||
public static function doDeleteAll($con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
$affectedRows += BasePeer::doDeleteAll(AppSolrQueuePeer::TABLE_NAME, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method perform a DELETE on the database, given a AppSolrQueue or Criteria object OR a primary key value.
|
||||
*
|
||||
* @param mixed $values Criteria or AppSolrQueue object or primary key or array of primary keys
|
||||
* which is used to create the DELETE statement
|
||||
* @param Connection $con the connection to use
|
||||
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||
* if supported by native driver or if emulated using Propel.
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function doDelete($values, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(AppSolrQueuePeer::DATABASE_NAME);
|
||||
}
|
||||
|
||||
if ($values instanceof Criteria) {
|
||||
$criteria = clone $values; // rename for clarity
|
||||
} elseif ($values instanceof AppSolrQueue) {
|
||||
|
||||
$criteria = $values->buildPkeyCriteria();
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(AppSolrQueuePeer::APP_UID, (array) $values, Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
$criteria->setDbName(self::DATABASE_NAME);
|
||||
|
||||
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||
|
||||
try {
|
||||
// use transaction because $criteria could contain info
|
||||
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||
$con->begin();
|
||||
|
||||
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||
$con->commit();
|
||||
return $affectedRows;
|
||||
} catch (PropelException $e) {
|
||||
$con->rollback();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates all modified columns of given AppSolrQueue object.
|
||||
* If parameter $columns is either a single column name or an array of column names
|
||||
* than only those columns are validated.
|
||||
*
|
||||
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||
*
|
||||
* @param AppSolrQueue $obj The object to validate.
|
||||
* @param mixed $cols Column name or array of column names.
|
||||
*
|
||||
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||
*/
|
||||
public static function doValidate(AppSolrQueue $obj, $cols = null)
|
||||
{
|
||||
$columns = array();
|
||||
|
||||
if ($cols) {
|
||||
$dbMap = Propel::getDatabaseMap(AppSolrQueuePeer::DATABASE_NAME);
|
||||
$tableMap = $dbMap->getTable(AppSolrQueuePeer::TABLE_NAME);
|
||||
|
||||
if (! is_array($cols)) {
|
||||
$cols = array($cols);
|
||||
}
|
||||
|
||||
foreach($cols as $colName) {
|
||||
if ($tableMap->containsColumn($colName)) {
|
||||
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||
$columns[$colName] = $obj->$get();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
return BasePeer::doValidate(AppSolrQueuePeer::DATABASE_NAME, AppSolrQueuePeer::TABLE_NAME, $columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* @return AppSolrQueue
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(AppSolrQueuePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(AppSolrQueuePeer::APP_UID, $pk);
|
||||
|
||||
|
||||
$v = AppSolrQueuePeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(AppSolrQueuePeer::APP_UID, $pks, Criteria::IN);
|
||||
$objs = AppSolrQueuePeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseAppSolrQueuePeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
if (Propel::isInit()) {
|
||||
// the MapBuilder classes register themselves with Propel during initialization
|
||||
// so we need to load them here.
|
||||
try {
|
||||
BaseAppSolrQueuePeer::getMapBuilder();
|
||||
} catch (Exception $e) {
|
||||
Propel::log('Could not initialize Peer: ' . $e->getMessage(), Propel::LOG_ERR);
|
||||
}
|
||||
} else {
|
||||
// even if Propel is not yet initialized, the map builder class can be registered
|
||||
// now and then it will be loaded when Propel initializes.
|
||||
require_once 'classes/model/map/AppSolrQueueMapBuilder.php';
|
||||
Propel::registerMapBuilder('classes.model.map.AppSolrQueueMapBuilder');
|
||||
}
|
||||
@@ -2840,4 +2840,28 @@
|
||||
<column name="DAS_INS_UPDATE_DATE" type="TIMESTAMP" required="false" />
|
||||
<column name="DAS_INS_STATUS" type="TINYINT" required="true" default="1"/>
|
||||
</table>
|
||||
<table name="APP_SOLR_QUEUE">
|
||||
<vendor type="mysql">
|
||||
<parameter name="Name" value="APP_SOLR_QUEUE"/>
|
||||
<parameter name="Engine" value="MyISAM"/>
|
||||
<parameter name="Version" value="10"/>
|
||||
<parameter name="Row_format" value="Dynamic"/>
|
||||
<parameter name="Rows" value="129"/>
|
||||
<parameter name="Avg_row_length" value="115"/>
|
||||
<parameter name="Data_length" value="14860"/>
|
||||
<parameter name="Max_data_length" value="281474976710655"/>
|
||||
<parameter name="Index_length" value="5120"/>
|
||||
<parameter name="Data_free" value="0"/>
|
||||
<parameter name="Auto_increment" value=""/>
|
||||
<parameter name="Create_time" value="2012-04-26 07:22:27"/>
|
||||
<parameter name="Update_time" value="2012-04-26 14:08:22"/>
|
||||
<parameter name="Check_time" value=""/>
|
||||
<parameter name="Collation" value="utf8_general_ci"/>
|
||||
<parameter name="Checksum" value=""/>
|
||||
<parameter name="Create_options" value=""/>
|
||||
<parameter name="Comment" value="APP_SOLR_QUEUE"/>
|
||||
</vendor>
|
||||
<column name="APP_UID" type="VARCHAR" size="32" required="true" primaryKey="true" default=""/>
|
||||
<column name="APP_UPDATED" type="TINYINT" required="true" default="1"/>
|
||||
</table>
|
||||
</database>
|
||||
|
||||
@@ -3116,3 +3116,41 @@ CREATE TABLE [DASHLET_INSTANCE]
|
||||
[DAS_INS_STATUS] TINYINT default 1 NOT NULL,
|
||||
CONSTRAINT DASHLET_INSTANCE_PK PRIMARY KEY ([DAS_INS_UID])
|
||||
);
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
/* APP_SOLR_QUEUE */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'APP_SOLR_QUEUE')
|
||||
BEGIN
|
||||
DECLARE @reftable_69 nvarchar(60), @constraintname_69 nvarchar(60)
|
||||
DECLARE refcursor CURSOR FOR
|
||||
select reftables.name tablename, cons.name constraintname
|
||||
from sysobjects tables,
|
||||
sysobjects reftables,
|
||||
sysobjects cons,
|
||||
sysreferences ref
|
||||
where tables.id = ref.rkeyid
|
||||
and cons.id = ref.constid
|
||||
and reftables.id = ref.fkeyid
|
||||
and tables.name = 'APP_SOLR_QUEUE'
|
||||
OPEN refcursor
|
||||
FETCH NEXT from refcursor into @reftable_69, @constraintname_69
|
||||
while @@FETCH_STATUS = 0
|
||||
BEGIN
|
||||
exec ('alter table '+@reftable_69+' drop constraint '+@constraintname_69)
|
||||
FETCH NEXT from refcursor into @reftable_69, @constraintname_69
|
||||
END
|
||||
CLOSE refcursor
|
||||
DEALLOCATE refcursor
|
||||
DROP TABLE [APP_SOLR_QUEUE]
|
||||
END
|
||||
|
||||
|
||||
CREATE TABLE [APP_SOLR_QUEUE]
|
||||
(
|
||||
[APP_UID] VARCHAR(32) default '' NOT NULL,
|
||||
[APP_UPDATED] TINYINT default 1 NOT NULL,
|
||||
CONSTRAINT APP_SOLR_QUEUE_PK PRIMARY KEY ([APP_UID])
|
||||
);
|
||||
|
||||
@@ -1403,5 +1403,18 @@ CREATE TABLE `DASHLET_INSTANCE`
|
||||
`DAS_INS_STATUS` TINYINT default 1 NOT NULL,
|
||||
PRIMARY KEY (`DAS_INS_UID`)
|
||||
)ENGINE=MyISAM DEFAULT CHARSET='utf8' COMMENT='Dashblets definitions';
|
||||
#-----------------------------------------------------------------------------
|
||||
#-- APP_SOLR_QUEUE
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
DROP TABLE IF EXISTS `APP_SOLR_QUEUE`;
|
||||
|
||||
|
||||
CREATE TABLE `APP_SOLR_QUEUE`
|
||||
(
|
||||
`APP_UID` VARCHAR(32) default '' NOT NULL,
|
||||
`APP_UPDATED` TINYINT default 1 NOT NULL,
|
||||
PRIMARY KEY (`APP_UID`)
|
||||
)ENGINE=MyISAM DEFAULT CHARSET='utf8' COMMENT='APP_SOLR_QUEUE';
|
||||
# This restores the fkey checks, after having unset them earlier
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
@@ -18,13 +18,25 @@
|
||||
$dateTo = isset($_POST['dateTo']) ? substr($_POST['dateTo'],0,10) : '';
|
||||
|
||||
try {
|
||||
//
|
||||
G::LoadClass('applications');
|
||||
$apps = new Applications();
|
||||
$userUid = ( isset($_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '' ) ? $_SESSION['USER_LOGGED'] : null;
|
||||
$data = $apps->getAll($userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort);
|
||||
$result ="";
|
||||
|
||||
echo G::json_encode($data);
|
||||
G::LoadClass('AppSolr');
|
||||
$ApplicationSolrIndex = new AppSolr();
|
||||
|
||||
$userUid = ( isset($_SESSION['USER_LOGGED'] ) && $_SESSION['USER_LOGGED'] != '' ) ? $_SESSION['USER_LOGGED'] : null;
|
||||
|
||||
if ($action != 'paused' && $ApplicationSolrIndex->isSolrEnabled()) {
|
||||
$data = $ApplicationSolrIndex->getAppGridData($userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort);
|
||||
$result = G::json_encode($data);
|
||||
}
|
||||
else{
|
||||
G::LoadClass('applications');
|
||||
$apps = new Applications();
|
||||
$data = $apps->getAll($userUid, $start, $limit, $action, $filter, $search, $process, $user, $status, $type, $dateFrom, $dateTo, $callback, $dir, $sort);
|
||||
|
||||
$result = G::json_encode($data);
|
||||
}
|
||||
echo $result;
|
||||
}
|
||||
catch ( Exception $e ) {
|
||||
$msg = array ( 'error' => $e->getMessage() );
|
||||
|
||||
@@ -600,7 +600,16 @@ Ext.onReady ( function() {
|
||||
reader: readerCasesList,
|
||||
writer: writerCasesList, // <-- plug a DataWriter into the store just as you would a Reader
|
||||
autoSave: true, // <-- false would delay executing create, update, destroy requests until specifically told to do so with some [save] buton.
|
||||
sortInfo:{field: 'APP_CACHE_VIEW.APP_NUMBER', direction: "DESC"}
|
||||
sortInfo:{field: 'APP_CACHE_VIEW.APP_NUMBER', direction: "DESC"},
|
||||
listeners: {
|
||||
load: function(response){
|
||||
//console.log(response.reader.jsonData);
|
||||
if (response.reader.jsonData.result === false) {
|
||||
PMExt.notify('ERROR', response.reader.jsonData.message);
|
||||
//PMExt.error
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
storeReassignCases = new Ext.data.Store({
|
||||
|
||||
Reference in New Issue
Block a user