Merge remote branch 'upstream/master'

This commit is contained in:
Fernando Ontiveros
2012-07-04 17:58:02 -04:00
4 changed files with 808 additions and 812 deletions

View File

@@ -2094,3 +2094,4 @@ function PMFGetCaseNotes ($applicationID, $type='array', $userUid='')
$response = Cases::getCaseNotes($applicationID, $type, $userUid); $response = Cases::getCaseNotes($applicationID, $type, $userUid);
return $response; return $response;
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* class.case.php * class.case.php
* @package workflow.engine.classes * @package workflow.engine.classes
@@ -23,7 +24,6 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
* *
*/ */
require_once 'classes/model/AdditionalTables.php'; require_once 'classes/model/AdditionalTables.php';
/** /**
@@ -33,28 +33,24 @@ require_once 'classes/model/AdditionalTables.php';
*/ */
class PmTable class PmTable
{ {
private $dom = null; private $dom = null;
private $schemaFile = ''; private $schemaFile = '';
private $tableName; private $tableName;
private $columns; private $columns;
private $baseDir = ''; private $baseDir = '';
private $targetDir = ''; private $targetDir = '';
private $configDir = ''; private $configDir = '';
private $dataDir = ''; private $dataDir = '';
private $classesDir = ''; private $classesDir = '';
private $className = ''; private $className = '';
private $dataSource = ''; private $dataSource = '';
private $rootNode; private $rootNode;
private $dbConfig; private $dbConfig;
private $db; private $db;
private $alterTable = true; private $alterTable = true;
function __construct($tableName = null) public function __construct($tableName=null)
{ {
if (isset($tableName)) { if (isset($tableName)) {
$this->tableName = $tableName; $this->tableName = $tableName;
@@ -64,13 +60,12 @@ class PmTable
$this->dbConfig = new StdClass(); $this->dbConfig = new StdClass();
} }
/** /**
* Set columns to pmTable * Set columns to pmTable
* @param array $columns contains a array of abjects * @param array $columns contains a array of abjects
* array(StdClass->field_name, field_type, field_size, field_null, field_key, field_autoincrement,...) * array(StdClass->field_name, field_type, field_size, field_null, field_key, field_autoincrement,...)
*/ */
function setColumns($columns) public function setColumns($columns)
{ {
$this->columns = $columns; $this->columns = $columns;
} }
@@ -79,29 +74,27 @@ class PmTable
* Set a data source * Set a data source
* @param string $dbsUid DBS_UID to relate the pmTable to phisical table * @param string $dbsUid DBS_UID to relate the pmTable to phisical table
*/ */
function setDataSource($dbsUid) public function setDataSource($dbsUid)
{ {
$this->dataSource = self::resolveDbSource($dbsUid); $this->dataSource = self::resolveDbSource($dbsUid);
switch ($this->dataSource) { switch ($this->dataSource) {
case 'workflow': case 'workflow':
$this->dbConfig->adapter= DB_ADAPTER; $this->dbConfig->adapter = DB_ADAPTER;
$this->dbConfig->host = DB_HOST; $this->dbConfig->host = DB_HOST;
$this->dbConfig->name = DB_NAME; $this->dbConfig->name = DB_NAME;
$this->dbConfig->user = DB_USER; $this->dbConfig->user = DB_USER;
$this->dbConfig->passwd = DB_PASS; $this->dbConfig->passwd = DB_PASS;
$this->dbConfig->port = 3306; //FIXME update this when port for workflow dsn will be available $this->dbConfig->port = 3306; //FIXME update this when port for workflow dsn will be available
break; break;
case 'rp': case 'rp':
$this->dbConfig->adapter= DB_ADAPTER; $this->dbConfig->adapter = DB_ADAPTER;
$this->dbConfig->host = DB_REPORT_HOST; $this->dbConfig->host = DB_REPORT_HOST;
$this->dbConfig->name = DB_REPORT_NAME; $this->dbConfig->name = DB_REPORT_NAME;
$this->dbConfig->user = DB_REPORT_USER; $this->dbConfig->user = DB_REPORT_USER;
$this->dbConfig->passwd = DB_REPORT_PASS; $this->dbConfig->passwd = DB_REPORT_PASS;
$this->dbConfig->port = 3306; //FIXME update this when port for rp dsn will be available $this->dbConfig->port = 3306; //FIXME update this when port for rp dsn will be available
break; break;
default: default:
require_once 'classes/model/DbSource.php'; require_once 'classes/model/DbSource.php';
$oDBSource = new DbSource(); $oDBSource = new DbSource();
@@ -109,7 +102,7 @@ class PmTable
$dbSource = $oDBSource->load($this->dataSource, $proUid); $dbSource = $oDBSource->load($this->dataSource, $proUid);
if (is_object($dbSource)) { if (is_object($dbSource)) {
$this->dbConfig->adapter= $dbSource->getDbsType(); $this->dbConfig->adapter = $dbSource->getDbsType();
$this->dbConfig->host = $dbSource->getDbsServer(); $this->dbConfig->host = $dbSource->getDbsServer();
$this->dbConfig->name = $dbSource->getDbsDatabaseName(); $this->dbConfig->name = $dbSource->getDbsDatabaseName();
$this->dbConfig->user = $dbSource->getDbsUsername(); $this->dbConfig->user = $dbSource->getDbsUsername();
@@ -117,14 +110,13 @@ class PmTable
$this->dbConfig->port = $dbSource->getDbsPort(); $this->dbConfig->port = $dbSource->getDbsPort();
} }
if (is_array($dbSource)) { if (is_array($dbSource)) {
$this->dbConfig->adapter= $dbSource['DBS_TYPE']; $this->dbConfig->adapter = $dbSource['DBS_TYPE'];
$this->dbConfig->host = $dbSource['DBS_SERVER']; $this->dbConfig->host = $dbSource['DBS_SERVER'];
$this->dbConfig->name = $dbSource['DBS_DATABASE_NAME']; $this->dbConfig->name = $dbSource['DBS_DATABASE_NAME'];
$this->dbConfig->user = $dbSource['DBS_USERNAME']; $this->dbConfig->user = $dbSource['DBS_USERNAME'];
$this->dbConfig->passwd = $dbSource['DBS_PASSWORD'] ; $this->dbConfig->passwd = $dbSource['DBS_PASSWORD'];
$this->dbConfig->port = $dbSource['DBS_PORT']; $this->dbConfig->port = $dbSource['DBS_PORT'];
} } else {
else {
throw new Exception("Db source with id $dbsUid does not exist!"); throw new Exception("Db source with id $dbsUid does not exist!");
} }
} }
@@ -139,10 +131,15 @@ class PmTable
public function resolveDbSource($dbsUid) public function resolveDbSource($dbsUid)
{ {
switch ($dbsUid) { switch ($dbsUid) {
case 'workflow': case 'wf': case '0': case '': case null: case 'workflow':
case 'wf':
case '0':
case '':
case null:
$dbsUid = 'workflow'; $dbsUid = 'workflow';
break; break;
case 'rp': case 'report': case 'rp':
case 'report':
$dbsUid = 'rp'; $dbsUid = 'rp';
break; break;
} }
@@ -172,7 +169,7 @@ class PmTable
/** /**
* Build the pmTable with all dependencies * Build the pmTable with all dependencies
*/ */
function build() public function build()
{ {
$this->prepare(); $this->prepare();
$this->preparePropelIniFile(); $this->preparePropelIniFile();
@@ -185,7 +182,7 @@ class PmTable
} }
} }
function buildModelFor($dbsUid, $tablesList) public function buildModelFor($dbsUid, $tablesList)
{ {
$this->setDataSource($dbsUid); $this->setDataSource($dbsUid);
$loadSchema = false; $loadSchema = false;
@@ -198,7 +195,7 @@ class PmTable
/** /**
* Prepare the pmTable env * Prepare the pmTable env
*/ */
function prepare($loadSchema = true) public function prepare($loadSchema=true)
{ {
//prevent execute prepare() twice or more //prevent execute prepare() twice or more
if (is_object($this->dom)) { 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 = new DOMDocument('1.0', 'utf-8');
$this->dom->preserveWhiteSpace = false; $this->dom->preserveWhiteSpace = false;
@@ -232,8 +229,7 @@ class PmTable
throw new Exception('Error: ' . $this->schemaFilename . ' is a invalid xml file!'); throw new Exception('Error: ' . $this->schemaFilename . ' is a invalid xml file!');
} }
$this->rootNode = $this->dom->firstChild; $this->rootNode = $this->dom->firstChild;
} } else {
else {
$this->rootNode = $this->dom->createElement('database'); $this->rootNode = $this->dom->createElement('database');
$this->rootNode->setAttribute('name', $this->dataSource); $this->rootNode->setAttribute('name', $this->dataSource);
$this->dom->appendChild($this->rootNode); $this->dom->appendChild($this->rootNode);
@@ -243,7 +239,7 @@ class PmTable
/** /**
* Build the xml schema for propel * Build the xml schema for propel
*/ */
function buildSchema() public function buildSchema()
{ {
$tableNode = $this->dom->createElement('table'); $tableNode = $this->dom->createElement('table');
$tableNode->setAttribute('name', $this->tableName); $tableNode->setAttribute('name', $this->tableName);
@@ -278,7 +274,7 @@ class PmTable
$columnNode->setAttribute('size', $column->field_size); $columnNode->setAttribute('size', $column->field_size);
} }
$columnNode->setAttribute('required', ($column->field_null? 'false' : 'true')); $columnNode->setAttribute('required', ($column->field_null ? 'false' : 'true'));
// only define the primaryKey attribute if it is defined // only define the primaryKey attribute if it is defined
if ($column->field_key) { if ($column->field_key) {
@@ -295,10 +291,11 @@ class PmTable
$xpath = new DOMXPath($this->dom); $xpath = new DOMXPath($this->dom);
$xtable = $xpath->query('/database/table[@name="' . $this->tableName . '"]'); $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); $this->rootNode->appendChild($tableNode);
} } else {
else { // the table definition already exist, then replace the node // the table definition already exist, then replace the node
$replacedNode = $xtable->item(0); $replacedNode = $xtable->item(0);
$this->rootNode->replaceChild($tableNode, $replacedNode); $this->rootNode->replaceChild($tableNode, $replacedNode);
} }
@@ -350,7 +347,7 @@ class PmTable
/** /**
* Drop the phisical table of target pmTable or any specified as parameter * Drop the phisical table of target pmTable or any specified as parameter
*/ */
public function dropTable($tableName = null) public function dropTable($tableName=null)
{ {
$tableName = isset($tableName) ? $tableName : $this->tableName; $tableName = isset($tableName) ? $tableName : $this->tableName;
$con = Propel::getConnection($this->dataSource); $con = Propel::getConnection($this->dataSource);
@@ -359,8 +356,7 @@ class PmTable
if (is_object($con)) { if (is_object($con)) {
try { try {
$stmt->executeQuery("DROP TABLE {$tableName}"); $stmt->executeQuery("DROP TABLE {$tableName}");
} } catch (Exception $e) {
catch (Exception $e) {
throw new Exception("Physical table '$tableName' does not exist!"); throw new Exception("Physical table '$tableName' does not exist!");
} }
} }
@@ -374,7 +370,6 @@ class PmTable
$this->dom->save($this->configDir . $this->schemaFilename); $this->dom->save($this->configDir . $this->schemaFilename);
} }
/** /**
* Prepare and create if not exists the propel ini file * Prepare and create if not exists the propel ini file
*/ */
@@ -386,11 +381,12 @@ class PmTable
return true; return true;
} }
if (!file_exists(PATH_CORE. PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini")) { if (!file_exists(PATH_CORE . PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini")) {
throw new Exception("Invalid or not supported engine '$adapter'!"); 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,14 +400,14 @@ class PmTable
$con = Propel::getConnection($this->dataSource); $con = Propel::getConnection($this->dataSource);
$stmt = $con->createStatement(); $stmt = $con->createStatement();
$lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql'); $lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql');
$previous = NULL; $previous = null;
$queryStack = array(); $queryStack = array();
$aDNS = $con->getDSN(); $aDNS = $con->getDSN();
$dbEngine = $aDNS["phptype"]; $dbEngine = $aDNS["phptype"];
foreach ($lines as $j => $line) { foreach ($lines as $j => $line) {
switch($dbEngine) { switch ($dbEngine) {
case 'mysql' : case 'mysql':
$line = trim($line); // Remove comments from the script $line = trim($line); // Remove comments from the script
if (strpos($line, "--") === 0) { if (strpos($line, "--") === 0) {
@@ -434,7 +430,7 @@ class PmTable
if ($previous) { if ($previous) {
$line = $previous . " " . $line; $line = $previous . " " . $line;
} }
$previous = NULL; $previous = null;
// If the current line doesnt end with ; then put this line together // If the current line doesnt end with ; then put this line together
// with the next one, thus supporting multi-line statements. // with the next one, thus supporting multi-line statements.
@@ -446,19 +442,20 @@ class PmTable
$line = substr($line, 0, strrpos($line, ";")); $line = substr($line, 0, strrpos($line, ";"));
// just execute the drop and create table for target table nad not for others // 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) { 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) { if ($isCreateForCurrentTable) {
$queryStack['create'] = $line; $queryStack['create'] = $line;
} } else {
else { $isDropForCurrentTable = preg_match('/DROP TABLE.*[\[\'\"\`]{1}' . $this->tableName
$isDropForCurrentTable = preg_match('/DROP TABLE.*[\[\'\"\`]{1}' . $this->tableName . '[\]\'\"\`]{1}/i', $line, $match); . '[\]\'\"\`]{1}/i', $line, $match);
if ($isDropForCurrentTable) { if ($isDropForCurrentTable) {
$queryStack['drop'] = $line; $queryStack['drop'] = $line;
} }
} }
} }
break; break;
case 'mssql' : case 'mssql':
$line = trim($line); // Remove comments from the script $line = trim($line); // Remove comments from the script
if (strpos($line, "--") === 0) { if (strpos($line, "--") === 0) {
@@ -481,7 +478,7 @@ class PmTable
if ($previous) { if ($previous) {
$line = $previous . " " . $line; $line = $previous . " " . $line;
} }
$previous = NULL; $previous = null;
// If the current line doesnt end with ; then put this line together // If the current line doesnt end with ; then put this line together
// with the next one, thus supporting multi-line statements. // with the next one, thus supporting multi-line statements.
@@ -503,12 +500,12 @@ class PmTable
$queryStack['create'] = 'CREATE' . $auxCreate['1']; $queryStack['create'] = 'CREATE' . $auxCreate['1'];
break; break;
case 'oracle' : case 'oracle':
$line = trim($line); $line = trim($line); // Remove comments from the script
if (empty($line)) { if (empty($line)) {
continue; continue;
} }
switch(true) { switch (true) {
case preg_match("/^CREATE TABLE\s/i", $line): case preg_match("/^CREATE TABLE\s/i", $line):
if (strpos($line, $this->tableName) == true) { if (strpos($line, $this->tableName) == true) {
$inCreate = true; $inCreate = true;
@@ -531,7 +528,7 @@ class PmTable
} }
} }
break; break;
default : default:
if ($inCreate) { if ($inCreate) {
$lineCreate .= $line . ' '; $lineCreate .= $line . ' ';
if (strrpos($line, ";") > 0) { if (strrpos($line, ";") > 0) {
@@ -548,7 +545,7 @@ class PmTable
} }
if ($inDrop) { if ($inDrop) {
$lineDrop .= $line . ' '; $lineDrop .= $line . ' ';
if (strrpos($line, ";")>0) { if (strrpos($line, ";") > 0) {
$queryStack['drop'] = $lineDrop; $queryStack['drop'] = $lineDrop;
$inDrop = false; $inDrop = false;
} }
@@ -556,7 +553,6 @@ class PmTable
} }
break; break;
} }
} }
if ($dbEngine == 'oracle') { if ($dbEngine == 'oracle') {
@@ -571,8 +567,7 @@ class PmTable
} }
$stmt->executeQuery($queryStack['create']); $stmt->executeQuery($queryStack['create']);
$stmt->executeQuery($queryStack['alter']); $stmt->executeQuery($queryStack['alter']);
} } else {
else {
if (isset($queryStack['create'])) { if (isset($queryStack['create'])) {
// first at all we need to verify if we have a valid schema defined, // first at all we need to verify if we have a valid schema defined,
// so we verify that creating a dummy table // so we verify that creating a dummy table
@@ -595,12 +590,12 @@ class PmTable
} }
} }
public function upgradeDatabaseFor($dataSource, $tablesList = array()) public function upgradeDatabaseFor($dataSource, $tablesList=array())
{ {
$con = Propel::getConnection($dataSource); $con = Propel::getConnection($dataSource);
$stmt = $con->createStatement(); $stmt = $con->createStatement();
$lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql'); $lines = file($this->dataDir . $this->dbConfig->adapter . PATH_SEP . 'schema.sql');
$previous = NULL; $previous = null;
$errors = ''; $errors = '';
foreach ($lines as $j => $line) { foreach ($lines as $j => $line) {
@@ -626,7 +621,7 @@ class PmTable
if ($previous) { if ($previous) {
$line = $previous . " " . $line; $line = $previous . " " . $line;
} }
$previous = NULL; $previous = null;
// If the current line doesnt end with ; then put this line together // If the current line doesnt end with ; then put this line together
// with the next one, thus supporting multi-line statements. // with the next one, thus supporting multi-line statements.
@@ -647,12 +642,10 @@ class PmTable
//error_log($line); //error_log($line);
try { try {
$stmt->executeQuery($line); $stmt->executeQuery($line);
} } catch (Exception $e) {
catch(Exception $e) {
$errors .= $e->getMessage() . "\n"; $errors .= $e->getMessage() . "\n";
continue; continue;
} }
} }
} }
} }
@@ -665,7 +658,7 @@ class PmTable
* verify if on the columns list was set a column as primary key * verify if on the columns list was set a column as primary key
* @return boolean to affirm if was defined a column as pk. * @return boolean to affirm if was defined a column as pk.
*/ */
function hasAutoIncrementPKey() public function hasAutoIncrementPKey()
{ {
foreach ($this->columns as $column) { foreach ($this->columns as $column) {
if ($column->field_autoincrement) { if ($column->field_autoincrement) {
@@ -680,11 +673,12 @@ class PmTable
* *
* @return array contains all supported columns types provided by propel * @return array contains all supported columns types provided by propel
*/ */
function getPropelSupportedColumnTypes() public function getPropelSupportedColumnTypes()
{ {
/** /**
* http://www.propelorm.org/wiki/Documentation/1.2/Schema * 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(); $types = array();
@@ -761,7 +755,7 @@ class PmTable
* @param array $options - array options to override the options on .ini file * @param array $options - array options to override the options on .ini file
* @param bool $verbose - to show a verbose output * @param bool $verbose - to show a verbose output
*/ */
public static function callPhing($target, $buildFile = '', $options = array(), $verbose = true) public static function callPhing($target, $buildFile='', $options=array(), $verbose=true)
{ {
G::loadClass('pmPhing'); G::loadClass('pmPhing');
@@ -781,8 +775,7 @@ class PmTable
if (is_array($target)) { if (is_array($target)) {
$args = array_merge($args, $target); $args = array_merge($args, $target);
} } else {
else {
$args[] = $target; $args[] = $target;
} }
@@ -798,5 +791,5 @@ class PmTable
$m->execute($args); $m->execute($args);
$m->runBuild(); $m->runBuild();
} }
} }

View File

@@ -1,4 +1,5 @@
<?php <?php
/** /**
* DbSource.php * DbSource.php
* @package workflow.engine.classes.model * @package workflow.engine.classes.model
@@ -23,11 +24,9 @@
* Coral Gables, FL, 33134, USA, or email info@colosa.com. * Coral Gables, FL, 33134, USA, or email info@colosa.com.
* *
*/ */
require_once 'classes/model/Content.php'; require_once 'classes/model/Content.php';
require_once 'classes/model/om/BaseDbSource.php'; require_once 'classes/model/om/BaseDbSource.php';
/** /**
* Skeleton subclass for representing a row from the 'DB_SOURCE' table. * Skeleton subclass for representing a row from the 'DB_SOURCE' table.
* *
@@ -52,16 +51,17 @@ class DbSource extends BaseDbSource
* Get the rep_tab_title column value. * Get the rep_tab_title column value.
* @return string * @return string
*/ */
public function getDBSourceDescription() { public function getDBSourceDescription()
if ( $this->getDbsUid() == "" ) { {
throw ( new Exception( "Error in getDBSourceDescription, the getDbsUid() can't be blank") ); if ($this->getDbsUid() == "") {
throw ( new Exception("Error in getDBSourceDescription, the getDbsUid() can't be blank") );
} }
$lang = defined ( 'SYS_LANG' ) ? SYS_LANG : 'en'; $lang = defined('SYS_LANG') ? SYS_LANG : 'en';
$this->db_source_description = Content::load ( 'DBS_DESCRIPTION', '', $this->getDbsUid(), $lang ); $this->db_source_description = Content::load('DBS_DESCRIPTION', '', $this->getDbsUid(), $lang);
return $this->db_source_description; return $this->db_source_description;
} }
function getCriteriaDBSList($sProcessUID) public function getCriteriaDBSList($sProcessUID)
{ {
$sDelimiter = DBAdapter::getStringDelimiter(); $sDelimiter = DBAdapter::getStringDelimiter();
$oCriteria = new Criteria('workflow'); $oCriteria = new Criteria('workflow');
@@ -95,10 +95,9 @@ class DbSource extends BaseDbSource
$this->setNew(false); $this->setNew(false);
return $aFields; return $aFields;
} else { } else {
throw(new Exception( "The row '$Uid'/'$ProUID' in table DbSource doesn't exist!" )); throw(new Exception("The row '$Uid'/'$ProUID' in table DbSource doesn't exist!"));
} }
} } catch (exception $oError) {
catch (exception $oError) {
throw ($oError); throw ($oError);
} }
} }
@@ -115,24 +114,23 @@ class DbSource extends BaseDbSource
return $aRow[0]; return $aRow[0];
} }
function Exists ( $Uid, $ProUID ) { public function Exists($Uid, $ProUID)
{
try { try {
$oPro = DbSourcePeer::retrieveByPk( $Uid, $ProUID ); $oPro = DbSourcePeer::retrieveByPk($Uid, $ProUID);
if (is_object($oPro) && get_class ($oPro) == 'DbSource' ) { if (is_object($oPro) && get_class($oPro) == 'DbSource') {
return true; return true;
} } else {
else {
return false; return false;
} }
} } catch (Exception $oError) {
catch (Exception $oError) {
throw($oError); throw($oError);
} }
} }
public function update($fields) public function update($fields)
{ {
if( $fields['DBS_ENCODE'] == '0'){ if ($fields['DBS_ENCODE'] == '0') {
unset($fields['DBS_ENCODE']); unset($fields['DBS_ENCODE']);
} }
$con = Propel::getConnection(DbSourcePeer::DATABASE_NAME); $con = Propel::getConnection(DbSourcePeer::DATABASE_NAME);
@@ -148,14 +146,13 @@ class DbSource extends BaseDbSource
$con->rollback(); $con->rollback();
throw (new Exception("Failed Validation in class " . get_class($this) . ".")); throw (new Exception("Failed Validation in class " . get_class($this) . "."));
} }
} } catch (exception $e) {
catch (exception $e) {
$con->rollback(); $con->rollback();
throw ($e); throw ($e);
} }
} }
function remove($DbsUid, $ProUID ) public function remove($DbsUid, $ProUID)
{ {
$con = Propel::getConnection(DbSourcePeer::DATABASE_NAME); $con = Propel::getConnection(DbSourcePeer::DATABASE_NAME);
try { try {
@@ -165,30 +162,31 @@ class DbSource extends BaseDbSource
// note added by gustavo cruz gustavo-at-colosa-dot-com // note added by gustavo cruz gustavo-at-colosa-dot-com
// we assure that the _delete attribute must be set to false // we assure that the _delete attribute must be set to false
// if a record exists in the database with that uid. // if a record exists in the database with that uid.
if ($this->Exists($DbsUid, $ProUID)){ if ($this->Exists($DbsUid, $ProUID)) {
$this->setDeleted(false); $this->setDeleted(false);
} }
$result = $this->delete(); $result = $this->delete();
$con->commit(); $con->commit();
return $result; return $result;
} } catch (exception $e) {
catch (exception $e) {
$con->rollback(); $con->rollback();
throw ($e); throw ($e);
} }
} }
function create($aData) public function create($aData)
{ {
if( $aData['DBS_ENCODE'] == '0'){ if ($aData['DBS_ENCODE'] == '0') {
unset($aData['DBS_ENCODE']); unset($aData['DBS_ENCODE']);
} }
$con = Propel::getConnection(DbSourcePeer::DATABASE_NAME); $con = Propel::getConnection(DbSourcePeer::DATABASE_NAME);
try { try {
if ( isset ( $aData['DBS_UID'] ) && $aData['DBS_UID']== '' ) if (isset($aData['DBS_UID']) && $aData['DBS_UID'] == '') {
unset ( $aData['DBS_UID'] ); unset($aData['DBS_UID']);
if ( !isset ( $aData['DBS_UID'] ) ) }
if (!isset($aData['DBS_UID'])) {
$aData['DBS_UID'] = G::generateUniqueID(); $aData['DBS_UID'] = G::generateUniqueID();
}
$this->fromArray($aData, BasePeer::TYPE_FIELDNAME); $this->fromArray($aData, BasePeer::TYPE_FIELDNAME);
if ($this->validate()) { if ($this->validate()) {
$result = $this->save(); $result = $this->save();
@@ -199,11 +197,11 @@ class DbSource extends BaseDbSource
} }
$con->commit(); $con->commit();
return $this->getDbsUid(); return $this->getDbsUid();
} } catch (exception $e) {
catch (exception $e) {
$con->rollback(); $con->rollback();
throw ($e); throw ($e);
} }
} }
}
// DbSource
} // DbSource

View File

@@ -53,8 +53,12 @@ try {
$bReturnValue = true; $bReturnValue = true;
$displayMode = 'display:block'; $displayMode = 'display:block';
$methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ( 'ID_NONE')) ) $methodreturnDescription = "";
? G::LoadTranslation ( 'ID_NOT_REQUIRED') : $methodreturnA [3]; if (isset($methodreturnA[3])) {
$methodreturnDescription = (trim(strtoupper($methodreturnA [3])) == strtoupper(G::LoadTranslation ('ID_NONE')))
? G::LoadTranslation ( 'ID_NOT_REQUIRED')
: $methodreturnA [3];
}
$methodReturnLabel = isset ( $methodreturnA [3] ) ? $methodreturnDescription : $methodReturn; $methodReturnLabel = isset ( $methodreturnA [3] ) ? $methodreturnDescription : $methodReturn;
if ( (isset($methodreturnA[0]) && isset($methodreturnA[1])) if ( (isset($methodreturnA[0]) && isset($methodreturnA[1]))
&& (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) { && (trim(strtoupper($methodreturnA[0]) ) != strtoupper(G::LoadTranslation ( 'ID_NONE')) ) ) {