BUG 6588 Problems importing a process that has Report Tables

Fixed an issue whe a process is imported with Report Tables when there are duplicate fields
This commit is contained in:
Hugo Loza
2011-04-01 18:00:09 -04:00
parent 3d46ebae6d
commit aab27bfaaf
2 changed files with 60 additions and 52 deletions

View File

@@ -968,7 +968,7 @@ class Processes {
$aEvent[] = $oEvent->load($aRow['EVN_UID']);
$oDataset->next();
}
return $aEvent;
return $aEvent;
}
catch (Exception $oError) {
throw($oError);
@@ -994,7 +994,7 @@ class Processes {
$aCaseScheduler[] = $oCaseScheduler->load($aRow['SCH_UID']);
$oDataset->next();
}
return $aCaseScheduler;
return $aCaseScheduler;
}
catch (Exception $oError) {
throw($oError);
@@ -1215,7 +1215,7 @@ class Processes {
}
/**
* Create Field Conditions from an array of Field Conditions and Dynaforms,
* Create Field Conditions from an array of Field Conditions and Dynaforms,
* removing those Objects with the same UID, and recreaiting the records
* from the arrays data.
* @param $aFieldCondition array.
@@ -1259,7 +1259,7 @@ class Processes {
function createCaseSchedulerRows ($CaseScheduler ) {
foreach ( $CaseScheduler as $key => $row ) {
$oCaseScheduler = new CaseScheduler();
if($oCaseScheduler->Exists($row['SCH_UID']))
if($oCaseScheduler->Exists($row['SCH_UID']))
$oCaseScheduler->remove($row['SCH_UID']);
$res = $oCaseScheduler->create($row);
@@ -1491,7 +1491,7 @@ class Processes {
*/
function renewAllDBSourceGuid ( &$oData ) {
$map = array ();
$aSqlConnections = array();
$aSqlConnections = array();
foreach ( $oData->dbconnections as $key => $val ) {
$newGuid = $val['DBS_UID']; ///-- $this->getUnusedDBSourceGUID();
$map[ $val['DBS_UID'] ] = $newGuid;
@@ -1577,8 +1577,13 @@ class Processes {
$oData->reportTables[$key]['REP_TAB_UID'] = $newGuid;
}
foreach ( $oData->reportTablesVars as $key => $val ) {
$newGuid = $map[ $val['REP_TAB_UID'] ];
$oData->reportTablesVars[$key]['REP_TAB_UID'] = $newGuid;
if(isset($map[ $val['REP_TAB_UID'] ])){
/*TODO: Why this can be not defined?? The scenario was when
* imported an existing process but as a new one
*/
$newGuid = $map[ $val['REP_TAB_UID'] ];
$oData->reportTablesVars[$key]['REP_TAB_UID'] = $newGuid;
}
}
}
@@ -1608,7 +1613,7 @@ class Processes {
$map[ $val['FCD_UID'] ] = $newGuid;
$oData->fieldCondition[$key]['FCD_UID'] = $newGuid;
}
}
}
/**
* Renew the GUID's for all the Events Objects
@@ -2146,7 +2151,7 @@ class Processes {
if( $oContent->Exists($ConCategory, $ConParent, $ConId, $ConLang) ) {
$oContent->removeContent($ConCategory, $ConParent, $ConId);
}
$oContent->addContent($ConCategory, $ConParent, $ConId, $ConLang);
$oContent->addContent($ConCategory, $ConParent, $ConId, $ConLang,"");
}
} #@!neyek
@@ -2268,7 +2273,7 @@ class Processes {
//krumo ($oData);die;
//$oJSON = new Services_JSON();
//krumo ( $oJSON->encode($oData) );
//return $oJSON->encode($oData);
//return $oJSON->encode($oData);
return serialize($oData);
}
@@ -3415,7 +3420,7 @@ class ObjectCellection{
}
/**
* get the collection of ObjectDocument
* get the collection of ObjectDocument
* @param $name name object document
* @param $type type object document
* @param $data data object document

View File

@@ -33,7 +33,7 @@ G::LoadClass('case');
* @copyright 2007 COLOSA
*/
class ReportTables
class ReportTables
{
private $aDef = array('mysql' => array('number' => 'DOUBLE',
'char' => 'VARCHAR(255)',
@@ -53,12 +53,12 @@ class ReportTables
/**
* Function deleteAllReportVars
* This function delete all reports
* This function delete all reports
* @access public
* @param string $$sRepTabUid
* @return void
*/
public function deleteAllReportVars($sRepTabUid = '')
public function deleteAllReportVars($sRepTabUid = '')
{
try {
$oCriteria = new Criteria('workflow');
@@ -78,7 +78,7 @@ class ReportTables
* @param string $sConnection Conexion
* @return void
*/
public function dropTable($sTableName, $sConnection = 'report')
public function dropTable($sTableName, $sConnection = 'report')
{
$sTableName = $this->sPrefix . $sTableName;
//we have to do the propel connection
@@ -107,12 +107,12 @@ class ReportTables
* @access public
* @param string $sTableName Table name
* @param string $sConnection Connection name
* @param string $sType
* @param array $aFields
* @param string $sType
* @param array $aFields
* @param string $bDefaultFields
* @return void
*/
public function createTable($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $bDefaultFields = true)
public function createTable($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $bDefaultFields = true)
{
$sTableName = $this->sPrefix . $sTableName;
//we have to do the propel connection
@@ -199,13 +199,13 @@ class ReportTables
* @access public
* @param string $sTableName Table name
* @param string $sConnection Connection name
* @param string $sType
* @param array $aFields
* @param string $sType
* @param array $aFields
* @param string $sProcessUid
* @param string $sGrid
* @return void
*/
public function populateTable($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $sProcessUid = '', $sGrid = '')
public function populateTable($sTableName, $sConnection = 'report', $sType = 'NORMAL', $aFields = array(), $sProcessUid = '', $sGrid = '')
{
$sTableName = $this->sPrefix . $sTableName;
//we have to do the propel connection
@@ -391,13 +391,16 @@ class ReportTables
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
$aVars = array();
$aImportedVars = array();//This array will help to control if the variable already exist
while ($aRow = $oDataset->getRow()) {
if ($bWhitType) {
$aVars[] = array('sFieldName' => $aRow['REP_VAR_NAME'], 'sType' => $aRow['REP_VAR_TYPE']);
}
else {
$aVars[] = $aRow['REP_VAR_NAME'];
}
if ($bWhitType) {
if(in_array($aRow['REP_VAR_NAME'],$aImportedVars)){
$aImportedVars[]=$aRow['REP_VAR_NAME'];
$aVars[] = array('sFieldName' => $aRow['REP_VAR_NAME'], 'sType' => $aRow['REP_VAR_TYPE']);
}
}else {
$aVars[] = $aRow['REP_VAR_NAME'];
}
$oDataset->next();
}
return $aVars;
@@ -432,7 +435,7 @@ class ReportTables
/**
* Function getSplitDate
* This function gets the split date
* This function gets the split date
* @access public
* @param date $date
* @param string $mask
@@ -446,13 +449,13 @@ class ReportTables
switch($item){
case 'Y':
switch($i){
case 0:
case 0:
$d1 = substr($date, 0, 4);
break;
case 1:
case 1:
$d1 = substr($date, 3, 4);
break;
case 2:
case 2:
$d1 = substr($date, 6, 4);
break;
}
@@ -460,40 +463,40 @@ class ReportTables
break;
case 'y':
switch($i){
case 0:
case 0:
$d1 = substr($date, 0, 2);
break;
case 1:
case 1:
$d1 = substr($date, 3, 2);
break;
case 2:
case 2:
$d1 = substr($date, 6, 2);
break;
}
break;
case 'm':
switch($i){
case 0:
$d2 = substr($date, 0, 2);
case 0:
$d2 = substr($date, 0, 2);
break;
case 1:
$d2 = ($sw1)? substr($date, 5, 2): substr($date, 3, 2);
case 1:
$d2 = ($sw1)? substr($date, 5, 2): substr($date, 3, 2);
break;
case 2:
$d2 = ($sw1)? substr($date, 8, 2): substr($date, 5, 2);
case 2:
$d2 = ($sw1)? substr($date, 8, 2): substr($date, 5, 2);
break;
}
break;
case 'd':
switch($i){
case 0:
$d3 = substr($date, 0, 2);
case 0:
$d3 = substr($date, 0, 2);
break;
case 1:
$d3 = ($sw1)? substr($date, 5, 2): substr($date, 3, 2);
case 1:
$d3 = ($sw1)? substr($date, 5, 2): substr($date, 3, 2);
break;
case 2:
$d3 = ($sw1)? substr($date, 8, 2): substr($date, 5, 2);
case 2:
$d3 = ($sw1)? substr($date, 8, 2): substr($date, 5, 2);
break;
}
break;
@@ -513,7 +516,7 @@ class ReportTables
function getFormatDate($sDate, $sMask)
{
//print $sDate." *** ". $sMask."<BR>";
$dateTime = explode(" ",$sDate); //To accept the Hour part
$dateTime = explode(" ",$sDate); //To accept the Hour part
$aDate = explode ( '-', str_replace("/", "-", $dateTime[0]) );
$bResult = true;
foreach($aDate as $sDate){
@@ -549,9 +552,9 @@ class ReportTables
* @param string $aFields
* @return void
*/
public function updateTables($sProcessUid, $sApplicationUid, $iApplicationNumber, $aFields)
public function updateTables($sProcessUid, $sApplicationUid, $iApplicationNumber, $aFields)
{
try {
try {
//get all Active Report Tables
$oCriteria = new Criteria('workflow');
$oCriteria->add(ReportTablePeer::PRO_UID, $sProcessUid);
@@ -638,7 +641,7 @@ class ReportTables
}
else {
//remove old rows from database
$sqlDelete = 'DELETE FROM `' . $aRow['REP_TAB_NAME'] . "` WHERE APP_UID = '" . $sApplicationUid . "'";
$sqlDelete = 'DELETE FROM `' . $aRow['REP_TAB_NAME'] . "` WHERE APP_UID = '" . $sApplicationUid . "'";
$rsDelete = $stmt->executeQuery( $sqlDelete );
$aAux = explode('-', $aRow['REP_TAB_GRID']);
@@ -668,7 +671,7 @@ class ReportTables
}
}
$sQuery .= ')';
$rs =$stmt->executeQuery( $sQuery );
$rs =$stmt->executeQuery( $sQuery );
}
}
}
@@ -812,7 +815,7 @@ class ReportTables
{
$repTabConnection = trim( strtoupper( $TabConnectionk ) );
$PropelDatabase = 'rp';
if ( $repTabConnection == '' || $repTabConnection == 'REPORT' )
if ( $repTabConnection == '' || $repTabConnection == 'REPORT' )
$PropelDatabase = 'rp';
if ( $repTabConnection == 'RBAC' )
$PropelDatabase = 'rbac';