Merge remote branch 'upstream/master'
This commit is contained in:
@@ -2094,3 +2094,4 @@ function PMFGetCaseNotes ($applicationID, $type='array', $userUid='')
|
||||
$response = Cases::getCaseNotes($applicationID, $type, $userUid);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.case.php
|
||||
* @package workflow.engine.classes
|
||||
@@ -23,7 +24,6 @@
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/AdditionalTables.php';
|
||||
|
||||
/**
|
||||
@@ -33,28 +33,24 @@ require_once 'classes/model/AdditionalTables.php';
|
||||
*/
|
||||
class PmTable
|
||||
{
|
||||
|
||||
private $dom = null;
|
||||
private $schemaFile = '';
|
||||
|
||||
private $tableName;
|
||||
private $columns;
|
||||
|
||||
private $baseDir = '';
|
||||
private $targetDir = '';
|
||||
private $configDir = '';
|
||||
private $dataDir = '';
|
||||
private $classesDir = '';
|
||||
private $className = '';
|
||||
|
||||
private $dataSource = '';
|
||||
private $rootNode;
|
||||
|
||||
private $dbConfig;
|
||||
private $db;
|
||||
|
||||
private $alterTable = true;
|
||||
|
||||
function __construct($tableName = null)
|
||||
public function __construct($tableName=null)
|
||||
{
|
||||
if (isset($tableName)) {
|
||||
$this->tableName = $tableName;
|
||||
@@ -64,13 +60,12 @@ class PmTable
|
||||
$this->dbConfig = new StdClass();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set columns to pmTable
|
||||
* @param array $columns contains a array of abjects
|
||||
* array(StdClass->field_name, field_type, field_size, field_null, field_key, field_autoincrement,...)
|
||||
*/
|
||||
function setColumns($columns)
|
||||
public function setColumns($columns)
|
||||
{
|
||||
$this->columns = $columns;
|
||||
}
|
||||
@@ -79,7 +74,7 @@ class PmTable
|
||||
* Set a data source
|
||||
* @param string $dbsUid DBS_UID to relate the pmTable to phisical table
|
||||
*/
|
||||
function setDataSource($dbsUid)
|
||||
public function setDataSource($dbsUid)
|
||||
{
|
||||
$this->dataSource = self::resolveDbSource($dbsUid);
|
||||
|
||||
@@ -92,7 +87,6 @@ class PmTable
|
||||
$this->dbConfig->passwd = DB_PASS;
|
||||
$this->dbConfig->port = 3306; //FIXME update this when port for workflow dsn will be available
|
||||
break;
|
||||
|
||||
case 'rp':
|
||||
$this->dbConfig->adapter = DB_ADAPTER;
|
||||
$this->dbConfig->host = DB_REPORT_HOST;
|
||||
@@ -101,7 +95,6 @@ class PmTable
|
||||
$this->dbConfig->passwd = DB_REPORT_PASS;
|
||||
$this->dbConfig->port = 3306; //FIXME update this when port for rp dsn will be available
|
||||
break;
|
||||
|
||||
default:
|
||||
require_once 'classes/model/DbSource.php';
|
||||
$oDBSource = new DbSource();
|
||||
@@ -123,8 +116,7 @@ class PmTable
|
||||
$this->dbConfig->user = $dbSource['DBS_USERNAME'];
|
||||
$this->dbConfig->passwd = $dbSource['DBS_PASSWORD'];
|
||||
$this->dbConfig->port = $dbSource['DBS_PORT'];
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
throw new Exception("Db source with id $dbsUid does not exist!");
|
||||
}
|
||||
}
|
||||
@@ -139,10 +131,15 @@ class PmTable
|
||||
public function resolveDbSource($dbsUid)
|
||||
{
|
||||
switch ($dbsUid) {
|
||||
case 'workflow': case 'wf': case '0': case '': case null:
|
||||
case 'workflow':
|
||||
case 'wf':
|
||||
case '0':
|
||||
case '':
|
||||
case null:
|
||||
$dbsUid = 'workflow';
|
||||
break;
|
||||
case 'rp': case 'report':
|
||||
case 'rp':
|
||||
case 'report':
|
||||
$dbsUid = 'rp';
|
||||
break;
|
||||
}
|
||||
@@ -172,7 +169,7 @@ class PmTable
|
||||
/**
|
||||
* Build the pmTable with all dependencies
|
||||
*/
|
||||
function build()
|
||||
public function build()
|
||||
{
|
||||
$this->prepare();
|
||||
$this->preparePropelIniFile();
|
||||
@@ -185,7 +182,7 @@ class PmTable
|
||||
}
|
||||
}
|
||||
|
||||
function buildModelFor($dbsUid, $tablesList)
|
||||
public function buildModelFor($dbsUid, $tablesList)
|
||||
{
|
||||
$this->setDataSource($dbsUid);
|
||||
$loadSchema = false;
|
||||
@@ -198,7 +195,7 @@ class PmTable
|
||||
/**
|
||||
* Prepare the pmTable env
|
||||
*/
|
||||
function prepare($loadSchema = true)
|
||||
public function prepare($loadSchema=true)
|
||||
{
|
||||
//prevent execute prepare() twice or more
|
||||
if (is_object($this->dom)) {
|
||||
@@ -221,7 +218,7 @@ class PmTable
|
||||
}
|
||||
}
|
||||
|
||||
function loadSchema()
|
||||
public function loadSchema()
|
||||
{
|
||||
$this->dom = new DOMDocument('1.0', 'utf-8');
|
||||
$this->dom->preserveWhiteSpace = false;
|
||||
@@ -232,8 +229,7 @@ class PmTable
|
||||
throw new Exception('Error: ' . $this->schemaFilename . ' is a invalid xml file!');
|
||||
}
|
||||
$this->rootNode = $this->dom->firstChild;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->rootNode = $this->dom->createElement('database');
|
||||
$this->rootNode->setAttribute('name', $this->dataSource);
|
||||
$this->dom->appendChild($this->rootNode);
|
||||
@@ -243,7 +239,7 @@ class PmTable
|
||||
/**
|
||||
* Build the xml schema for propel
|
||||
*/
|
||||
function buildSchema()
|
||||
public function buildSchema()
|
||||
{
|
||||
$tableNode = $this->dom->createElement('table');
|
||||
$tableNode->setAttribute('name', $this->tableName);
|
||||
@@ -295,10 +291,11 @@ class PmTable
|
||||
$xpath = new DOMXPath($this->dom);
|
||||
$xtable = $xpath->query('/database/table[@name="' . $this->tableName . '"]');
|
||||
|
||||
if ($xtable->length == 0) { //the table definition does not exist, then just append the new node
|
||||
if ($xtable->length == 0) {
|
||||
//the table definition does not exist, then just append the new node
|
||||
$this->rootNode->appendChild($tableNode);
|
||||
}
|
||||
else { // the table definition already exist, then replace the node
|
||||
} else {
|
||||
// the table definition already exist, then replace the node
|
||||
$replacedNode = $xtable->item(0);
|
||||
$this->rootNode->replaceChild($tableNode, $replacedNode);
|
||||
}
|
||||
@@ -359,8 +356,7 @@ class PmTable
|
||||
if (is_object($con)) {
|
||||
try {
|
||||
$stmt->executeQuery("DROP TABLE {$tableName}");
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new Exception("Physical table '$tableName' does not exist!");
|
||||
}
|
||||
}
|
||||
@@ -374,7 +370,6 @@ class PmTable
|
||||
$this->dom->save($this->configDir . $this->schemaFilename);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prepare and create if not exists the propel ini file
|
||||
*/
|
||||
@@ -390,7 +385,8 @@ class PmTable
|
||||
throw new Exception("Invalid or not supported engine '$adapter'!");
|
||||
}
|
||||
|
||||
@copy(PATH_CORE. PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini", $this->configDir . "propel.$adapter.ini");
|
||||
@copy(PATH_CORE . PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini",
|
||||
$this->configDir . "propel.$adapter.ini");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -404,7 +400,7 @@ class PmTable
|
||||
$con = Propel::getConnection($this->dataSource);
|
||||
$stmt = $con->createStatement();
|
||||
$lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql');
|
||||
$previous = NULL;
|
||||
$previous = null;
|
||||
$queryStack = array();
|
||||
$aDNS = $con->getDSN();
|
||||
$dbEngine = $aDNS["phptype"];
|
||||
@@ -434,7 +430,7 @@ class PmTable
|
||||
if ($previous) {
|
||||
$line = $previous . " " . $line;
|
||||
}
|
||||
$previous = NULL;
|
||||
$previous = null;
|
||||
|
||||
// If the current line doesnt end with ; then put this line together
|
||||
// with the next one, thus supporting multi-line statements.
|
||||
@@ -446,12 +442,13 @@ class PmTable
|
||||
$line = substr($line, 0, strrpos($line, ";"));
|
||||
// just execute the drop and create table for target table nad not for others
|
||||
if (stripos($line, 'CREATE TABLE') !== false || stripos($line, 'DROP TABLE') !== false) {
|
||||
$isCreateForCurrentTable = preg_match('/CREATE\sTABLE\s[\[\'\"\`]{1}' . $this->tableName . '[\]\'\"\`]{1}/i', $line, $match);
|
||||
$isCreateForCurrentTable = preg_match('/CREATE\sTABLE\s[\[\'\"\`]{1}' . $this->tableName
|
||||
. '[\]\'\"\`]{1}/i', $line, $match);
|
||||
if ($isCreateForCurrentTable) {
|
||||
$queryStack['create'] = $line;
|
||||
}
|
||||
else {
|
||||
$isDropForCurrentTable = preg_match('/DROP TABLE.*[\[\'\"\`]{1}' . $this->tableName . '[\]\'\"\`]{1}/i', $line, $match);
|
||||
} else {
|
||||
$isDropForCurrentTable = preg_match('/DROP TABLE.*[\[\'\"\`]{1}' . $this->tableName
|
||||
. '[\]\'\"\`]{1}/i', $line, $match);
|
||||
if ($isDropForCurrentTable) {
|
||||
$queryStack['drop'] = $line;
|
||||
}
|
||||
@@ -481,7 +478,7 @@ class PmTable
|
||||
if ($previous) {
|
||||
$line = $previous . " " . $line;
|
||||
}
|
||||
$previous = NULL;
|
||||
$previous = null;
|
||||
|
||||
// If the current line doesnt end with ; then put this line together
|
||||
// with the next one, thus supporting multi-line statements.
|
||||
@@ -504,7 +501,7 @@ class PmTable
|
||||
|
||||
break;
|
||||
case 'oracle':
|
||||
$line = trim($line);
|
||||
$line = trim($line); // Remove comments from the script
|
||||
if (empty($line)) {
|
||||
continue;
|
||||
}
|
||||
@@ -556,7 +553,6 @@ class PmTable
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($dbEngine == 'oracle') {
|
||||
@@ -571,8 +567,7 @@ class PmTable
|
||||
}
|
||||
$stmt->executeQuery($queryStack['create']);
|
||||
$stmt->executeQuery($queryStack['alter']);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
if (isset($queryStack['create'])) {
|
||||
// first at all we need to verify if we have a valid schema defined,
|
||||
// so we verify that creating a dummy table
|
||||
@@ -600,7 +595,7 @@ class PmTable
|
||||
$con = Propel::getConnection($dataSource);
|
||||
$stmt = $con->createStatement();
|
||||
$lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql');
|
||||
$previous = NULL;
|
||||
$previous = null;
|
||||
$errors = '';
|
||||
|
||||
foreach ($lines as $j => $line) {
|
||||
@@ -626,7 +621,7 @@ class PmTable
|
||||
if ($previous) {
|
||||
$line = $previous . " " . $line;
|
||||
}
|
||||
$previous = NULL;
|
||||
$previous = null;
|
||||
|
||||
// If the current line doesnt end with ; then put this line together
|
||||
// with the next one, thus supporting multi-line statements.
|
||||
@@ -647,12 +642,10 @@ class PmTable
|
||||
//error_log($line);
|
||||
try {
|
||||
$stmt->executeQuery($line);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$errors .= $e->getMessage() . "\n";
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -665,7 +658,7 @@ class PmTable
|
||||
* verify if on the columns list was set a column as primary key
|
||||
* @return boolean to affirm if was defined a column as pk.
|
||||
*/
|
||||
function hasAutoIncrementPKey()
|
||||
public function hasAutoIncrementPKey()
|
||||
{
|
||||
foreach ($this->columns as $column) {
|
||||
if ($column->field_autoincrement) {
|
||||
@@ -680,11 +673,12 @@ class PmTable
|
||||
*
|
||||
* @return array contains all supported columns types provided by propel
|
||||
*/
|
||||
function getPropelSupportedColumnTypes()
|
||||
public function getPropelSupportedColumnTypes()
|
||||
{
|
||||
/**
|
||||
* http://www.propelorm.org/wiki/Documentation/1.2/Schema
|
||||
* [type = "BOOLEAN|TINYINT|SMALLINT|INTEGER|BIGINT|DOUBLE|FLOAT|REAL|DECIMAL|CHAR|{VARCHAR}|LONGVARCHAR|DATE|TIME|TIMESTAMP|BLOB|CLOB"]
|
||||
* [type = "BOOLEAN|TINYINT|SMALLINT|INTEGER|BIGINT|DOUBLE|FLOAT|REAL|DECIMAL|CHAR|{VARCHAR}
|
||||
* |LONGVARCHAR|DATE|TIME|TIMESTAMP|BLOB|CLOB"]
|
||||
*/
|
||||
$types = array();
|
||||
|
||||
@@ -781,8 +775,7 @@ class PmTable
|
||||
|
||||
if (is_array($target)) {
|
||||
$args = array_merge($args, $target);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$args[] = $target;
|
||||
}
|
||||
|
||||
@@ -798,5 +791,5 @@ class PmTable
|
||||
$m->execute($args);
|
||||
$m->runBuild();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* DbSource.php
|
||||
* @package workflow.engine.classes.model
|
||||
@@ -23,11 +24,9 @@
|
||||
* Coral Gables, FL, 33134, USA, or email info@colosa.com.
|
||||
*
|
||||
*/
|
||||
|
||||
require_once 'classes/model/Content.php';
|
||||
require_once 'classes/model/om/BaseDbSource.php';
|
||||
|
||||
|
||||
/**
|
||||
* Skeleton subclass for representing a row from the 'DB_SOURCE' table.
|
||||
*
|
||||
@@ -52,7 +51,8 @@ class DbSource extends BaseDbSource
|
||||
* Get the rep_tab_title column value.
|
||||
* @return string
|
||||
*/
|
||||
public function getDBSourceDescription() {
|
||||
public function getDBSourceDescription()
|
||||
{
|
||||
if ($this->getDbsUid() == "") {
|
||||
throw ( new Exception("Error in getDBSourceDescription, the getDbsUid() can't be blank") );
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class DbSource extends BaseDbSource
|
||||
return $this->db_source_description;
|
||||
}
|
||||
|
||||
function getCriteriaDBSList($sProcessUID)
|
||||
public function getCriteriaDBSList($sProcessUID)
|
||||
{
|
||||
$sDelimiter = DBAdapter::getStringDelimiter();
|
||||
$oCriteria = new Criteria('workflow');
|
||||
@@ -97,8 +97,7 @@ class DbSource extends BaseDbSource
|
||||
} else {
|
||||
throw(new Exception("The row '$Uid'/'$ProUID' in table DbSource doesn't exist!"));
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
} catch (exception $oError) {
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
@@ -115,17 +114,16 @@ class DbSource extends BaseDbSource
|
||||
return $aRow[0];
|
||||
}
|
||||
|
||||
function Exists ( $Uid, $ProUID ) {
|
||||
public function Exists($Uid, $ProUID)
|
||||
{
|
||||
try {
|
||||
$oPro = DbSourcePeer::retrieveByPk($Uid, $ProUID);
|
||||
if (is_object($oPro) && get_class($oPro) == 'DbSource') {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception $oError) {
|
||||
} catch (Exception $oError) {
|
||||
throw($oError);
|
||||
}
|
||||
}
|
||||
@@ -148,14 +146,13 @@ class DbSource extends BaseDbSource
|
||||
$con->rollback();
|
||||
throw (new Exception("Failed Validation in class " . get_class($this) . "."));
|
||||
}
|
||||
}
|
||||
catch (exception $e) {
|
||||
} catch (exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function remove($DbsUid, $ProUID )
|
||||
public function remove($DbsUid, $ProUID)
|
||||
{
|
||||
$con = Propel::getConnection(DbSourcePeer::DATABASE_NAME);
|
||||
try {
|
||||
@@ -171,24 +168,25 @@ class DbSource extends BaseDbSource
|
||||
$result = $this->delete();
|
||||
$con->commit();
|
||||
return $result;
|
||||
}
|
||||
catch (exception $e) {
|
||||
} catch (exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
function create($aData)
|
||||
public function create($aData)
|
||||
{
|
||||
if ($aData['DBS_ENCODE'] == '0') {
|
||||
unset($aData['DBS_ENCODE']);
|
||||
}
|
||||
$con = Propel::getConnection(DbSourcePeer::DATABASE_NAME);
|
||||
try {
|
||||
if ( isset ( $aData['DBS_UID'] ) && $aData['DBS_UID']== '' )
|
||||
if (isset($aData['DBS_UID']) && $aData['DBS_UID'] == '') {
|
||||
unset($aData['DBS_UID']);
|
||||
if ( !isset ( $aData['DBS_UID'] ) )
|
||||
}
|
||||
if (!isset($aData['DBS_UID'])) {
|
||||
$aData['DBS_UID'] = G::generateUniqueID();
|
||||
}
|
||||
$this->fromArray($aData, BasePeer::TYPE_FIELDNAME);
|
||||
if ($this->validate()) {
|
||||
$result = $this->save();
|
||||
@@ -199,11 +197,11 @@ class DbSource extends BaseDbSource
|
||||
}
|
||||
$con->commit();
|
||||
return $this->getDbsUid();
|
||||
}
|
||||
catch (exception $e) {
|
||||
} catch (exception $e) {
|
||||
$con->rollback();
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
// DbSource
|
||||
|
||||
} // DbSource
|
||||
|
||||
@@ -53,8 +53,12 @@ try {
|
||||
|
||||
$bReturnValue = true;
|
||||
$displayMode = 'display:block';
|
||||
$methodreturnDescription = "";
|
||||
if (isset($methodreturnA[3])) {
|
||||
$methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ('ID_NONE')))
|
||||
? G::LoadTranslation ( 'ID_NOT_REQUIRED') : $methodreturnA [3];
|
||||
? G::LoadTranslation ( 'ID_NOT_REQUIRED')
|
||||
: $methodreturnA [3];
|
||||
}
|
||||
$methodReturnLabel = isset ( $methodreturnA [3] ) ? $methodreturnDescription : $methodReturn;
|
||||
if ( (isset($methodreturnA[0]) && isset($methodreturnA[1]))
|
||||
&& (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) {
|
||||
|
||||
Reference in New Issue
Block a user