Merge remote branch 'upstream/master' into pmsql

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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