CODE STYLE class.pmTable.php

This commit is contained in:
Fernando Ontiveros
2012-10-09 13:00:37 -04:00
parent edf40d2490
commit adf671539a

View File

@@ -2,6 +2,7 @@
/** /**
* class.case.php * class.case.php
*
* @package workflow.engine.classes * @package workflow.engine.classes
* *
* ProcessMaker Open Source Edition * ProcessMaker Open Source Edition
@@ -29,6 +30,7 @@ require_once 'classes/model/AdditionalTables.php';
/** /**
* PmTable Class * PmTable Class
* New class to handle pmTable in native form invoking to Phing & Propel * New class to handle pmTable in native form invoking to Phing & Propel
*
* @author Erik Amaru Ortiz <erik@colosa.com> * @author Erik Amaru Ortiz <erik@colosa.com>
*/ */
class PmTable class PmTable
@@ -62,6 +64,7 @@ class PmTable
/** /**
* 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,...)
*/ */
@@ -72,6 +75,7 @@ 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
*/ */
public function setDataSource ($dbsUid) public function setDataSource ($dbsUid)
@@ -125,6 +129,7 @@ class PmTable
/** /**
* Backward compatibility function * Backward compatibility function
* Resolve a propel data source * Resolve a propel data source
*
* @param string $dbsUid corresponding to DBS_UID key * @param string $dbsUid corresponding to DBS_UID key
* @return string contains resolved DBS_UID * @return string contains resolved DBS_UID
*/ */
@@ -154,6 +159,7 @@ class PmTable
/** /**
* get Data base config object * get Data base config object
*
* @return object containing dbConfig var * @return object containing dbConfig var
*/ */
public function getDbConfig () public function getDbConfig ()
@@ -261,7 +267,6 @@ class PmTable
break; break;
} }
foreach ($this->columns as $column) { foreach ($this->columns as $column) {
// create the column node // create the column node
@@ -385,8 +390,7 @@ class PmTable
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", @copy( PATH_CORE . PATH_SEP . 'config' . PATH_SEP . "propel.$adapter.ini", $this->configDir . "propel.$adapter.ini" );
$this->configDir . "propel.$adapter.ini");
} }
/** /**
@@ -410,6 +414,7 @@ class PmTable
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) {
$line = substr( $line, 0, strpos( $line, "--" ) ); $line = substr( $line, 0, strpos( $line, "--" ) );
} }
@@ -442,13 +447,11 @@ 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 $isCreateForCurrentTable = preg_match( '/CREATE\sTABLE\s[\[\'\"\`]{1}' . $this->tableName . '[\]\'\"\`]{1}/i', $line, $match );
. '[\]\'\"\`]{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;
} }
@@ -458,6 +461,7 @@ class PmTable
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) {
$line = substr( $line, 0, strpos( $line, "--" ) ); $line = substr( $line, 0, strpos( $line, "--" ) );
} }
@@ -601,6 +605,7 @@ class PmTable
foreach ($lines as $j => $line) { foreach ($lines as $j => $line) {
$line = trim( $line ); // Remove comments from the script $line = trim( $line ); // Remove comments from the script
if (strpos( $line, "--" ) === 0) { if (strpos( $line, "--" ) === 0) {
$line = substr( $line, 0, strpos( $line, "--" ) ); $line = substr( $line, 0, strpos( $line, "--" ) );
} }
@@ -656,6 +661,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.
*/ */
public function hasAutoIncrementPKey () public function hasAutoIncrementPKey ()
@@ -700,10 +706,12 @@ class PmTable
//$types['BLOB'] = 'BLOB'; <- disabled //$types['BLOB'] = 'BLOB'; <- disabled
//$types['CLOB'] = 'CLOB'; <- disabled //$types['CLOB'] = 'CLOB'; <- disabled
return $types; return $types;
} }
/** /**
*
* @param string $name any string witha name separated by underscore * @param string $name any string witha name separated by underscore
* @return string contains a camelcase expresion for $name * @return string contains a camelcase expresion for $name
*/ */
@@ -734,22 +742,20 @@ class PmTable
/** /**
* call phing to execute a determinated task * call phing to execute a determinated task
*
* @param string $taskName [om|sql] * @param string $taskName [om|sql]
*/ */
private function _callPhing ($taskName) private function _callPhing ($taskName)
{ {
$options = array( $options = array ('project.dir' => $this->configDir,'build.properties' => "propel.{$this->dbConfig->adapter}.ini",'propel.targetPackage' => 'classes','propel.output.dir' => $this->targetDir,'propel.php.dir' => $this->baseDir
'project.dir' => $this->configDir,
'build.properties' => "propel.{$this->dbConfig->adapter}.ini",
'propel.targetPackage' => 'classes',
'propel.output.dir' => $this->targetDir,
'propel.php.dir' => $this->baseDir
); );
self::callPhing(array($taskName), PATH_THIRDPARTY . 'propel-generator/build.xml', $options, false); self::callPhing( array ($taskName
), PATH_THIRDPARTY . 'propel-generator/build.xml', $options, false );
} }
/** /**
*
* @param string $target - task name to execute * @param string $target - task name to execute
* @param string $buildFile - build file path * @param string $buildFile - build file path
* @param array $options - array options to override the options on .ini file * @param array $options - array options to override the options on .ini file