Change in form of storage Connection Record for export and import of cases with connections to external databases.
This commit is contained in:
@@ -1379,7 +1379,7 @@ class Processes {
|
||||
$map = array ();
|
||||
$aSqlConnections = array();
|
||||
foreach ( $oData->dbconnections as $key => $val ) {
|
||||
$newGuid = $this->getUnusedDBSourceGUID();
|
||||
$newGuid = $val['DBS_UID']; ///-- $this->getUnusedDBSourceGUID();
|
||||
$map[ $val['DBS_UID'] ] = $newGuid;
|
||||
$oData->dbconnections[$key]['DBS_UID'] = $newGuid;
|
||||
}
|
||||
@@ -1848,7 +1848,7 @@ class Processes {
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
$oConnection = new DbSource();
|
||||
$aConnections[] = $oConnection->Load($aRow['DBS_UID']);
|
||||
$aConnections[] = $oConnection->Load($aRow['DBS_UID'], $aRow['PRO_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
return $aConnections;
|
||||
@@ -2016,8 +2016,8 @@ class Processes {
|
||||
function createDBConnectionsRows ($aConnections ) {
|
||||
foreach ( $aConnections as $sKey => $aRow ) {
|
||||
$oConnection = new DbSource();
|
||||
if( $oConnection->Exists($aRow['DBS_UID']) ) {
|
||||
$oConnection->remove($aRow['DBS_UID']);
|
||||
if( $oConnection->Exists($aRow['DBS_UID'], $aRow['PRO_UID']) ) {
|
||||
$oConnection->remove($aRow['DBS_UID'], $aRow['PRO_UID']);
|
||||
}
|
||||
$oConnection->create($aRow);
|
||||
|
||||
@@ -2882,8 +2882,8 @@ class Processes {
|
||||
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset->next();
|
||||
while ($aRow = $oDataset->getRow()) {
|
||||
if ($oConnection->Exists($aRow['DBS_UID']))
|
||||
$oConnection->remove($aRow['DBS_UID']);
|
||||
if ($oConnection->Exists($aRow['DBS_UID'], $aRow['PRO_UID']))
|
||||
$oConnection->remove($aRow['DBS_UID'], $aRow['PRO_UID']);
|
||||
$oDataset->next();
|
||||
}
|
||||
|
||||
|
||||
@@ -83,10 +83,10 @@ class DbSource extends BaseDbSource
|
||||
return $oCriteria;
|
||||
}
|
||||
|
||||
public function load($Uid)
|
||||
public function load($Uid, $ProUID)
|
||||
{
|
||||
try {
|
||||
$oRow = DbSourcePeer::retrieveByPK($Uid);
|
||||
$oRow = DbSourcePeer::retrieveByPK($Uid, $ProUID);
|
||||
if (!is_null($oRow)) {
|
||||
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME);
|
||||
@@ -94,7 +94,7 @@ class DbSource extends BaseDbSource
|
||||
$this->setNew(false);
|
||||
return $aFields;
|
||||
} else {
|
||||
throw(new Exception( "The row '$Uid' in table DbSource doesn't exist!" ));
|
||||
throw(new Exception( "The row '$Uid'/'$ProUID' in table DbSource doesn't exist!" ));
|
||||
}
|
||||
}
|
||||
catch (exception $oError) {
|
||||
@@ -102,9 +102,9 @@ class DbSource extends BaseDbSource
|
||||
}
|
||||
}
|
||||
|
||||
function Exists ( $Uid ) {
|
||||
function Exists ( $Uid, $ProUID ) {
|
||||
try {
|
||||
$oPro = DbSourcePeer::retrieveByPk( $Uid );
|
||||
$oPro = DbSourcePeer::retrieveByPk( $Uid, $ProUID );
|
||||
if (is_object($oPro) && get_class ($oPro) == 'DbSource' ) {
|
||||
return true;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ class DbSource extends BaseDbSource
|
||||
$con = Propel::getConnection(DbSourcePeer::DATABASE_NAME);
|
||||
try {
|
||||
$con->begin();
|
||||
$this->load($fields['DBS_UID']);
|
||||
$this->load($fields['DBS_UID'], $fields['PRO_UID']);
|
||||
$this->fromArray($fields, BasePeer::TYPE_FIELDNAME);
|
||||
if ($this->validate()) {
|
||||
$result = $this->save();
|
||||
@@ -142,16 +142,17 @@ class DbSource extends BaseDbSource
|
||||
}
|
||||
}
|
||||
|
||||
function remove($DbsUid)
|
||||
function remove($DbsUid, $ProUID )
|
||||
{
|
||||
$con = Propel::getConnection(DbSourcePeer::DATABASE_NAME);
|
||||
try {
|
||||
$con->begin();
|
||||
$this->setDbsUid($DbsUid);
|
||||
$this->setProUid($ProUID);
|
||||
// note added by gustavo cruz gustavo-at-colosa-dot-com
|
||||
// we assure that the _delete attribute must be set to false
|
||||
// if a record exists in the database with that uid.
|
||||
if ($this->Exists($DbsUid)){
|
||||
if ($this->Exists($DbsUid, $ProUID)){
|
||||
$this->setDeleted(false);
|
||||
}
|
||||
$result = $this->delete();
|
||||
|
||||
@@ -66,7 +66,7 @@ class DbSourceMapBuilder {
|
||||
|
||||
$tMap->addPrimaryKey('DBS_UID', 'DbsUid', 'string', CreoleTypes::VARCHAR, true, 32);
|
||||
|
||||
$tMap->addColumn('PRO_UID', 'ProUid', 'string', CreoleTypes::VARCHAR, true, 32);
|
||||
$tMap->addPrimaryKey('PRO_UID', 'ProUid', 'string', CreoleTypes::VARCHAR, true, 32);
|
||||
|
||||
$tMap->addColumn('DBS_TYPE', 'DbsType', 'string', CreoleTypes::VARCHAR, true, 8);
|
||||
|
||||
|
||||
@@ -827,28 +827,40 @@ abstract class BaseDbSource extends BaseObject implements Persistent {
|
||||
$criteria = new Criteria(DbSourcePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DbSourcePeer::DBS_UID, $this->dbs_uid);
|
||||
$criteria->add(DbSourcePeer::PRO_UID, $this->pro_uid);
|
||||
|
||||
return $criteria;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the primary key for this object (row).
|
||||
* @return string
|
||||
* Returns the composite primary key for this object.
|
||||
* The array elements will be in same order as specified in XML.
|
||||
* @return array
|
||||
*/
|
||||
public function getPrimaryKey()
|
||||
{
|
||||
return $this->getDbsUid();
|
||||
$pks = array();
|
||||
|
||||
$pks[0] = $this->getDbsUid();
|
||||
|
||||
$pks[1] = $this->getProUid();
|
||||
|
||||
return $pks;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method to set the primary key (dbs_uid column).
|
||||
* Set the [composite] primary key.
|
||||
*
|
||||
* @param string $key Primary key.
|
||||
* @param array $keys The elements of the composite key (order must match the order in XML file).
|
||||
* @return void
|
||||
*/
|
||||
public function setPrimaryKey($key)
|
||||
public function setPrimaryKey($keys)
|
||||
{
|
||||
$this->setDbsUid($key);
|
||||
|
||||
$this->setDbsUid($keys[0]);
|
||||
|
||||
$this->setProUid($keys[1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -864,8 +876,6 @@ abstract class BaseDbSource extends BaseObject implements Persistent {
|
||||
public function copyInto($copyObj, $deepCopy = false)
|
||||
{
|
||||
|
||||
$copyObj->setProUid($this->pro_uid);
|
||||
|
||||
$copyObj->setDbsType($this->dbs_type);
|
||||
|
||||
$copyObj->setDbsServer($this->dbs_server);
|
||||
@@ -885,6 +895,8 @@ abstract class BaseDbSource extends BaseObject implements Persistent {
|
||||
|
||||
$copyObj->setDbsUid(''); // this is a pkey column, so set to default value
|
||||
|
||||
$copyObj->setProUid('0'); // this is a pkey column, so set to default value
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -419,6 +419,9 @@ abstract class BaseDbSourcePeer {
|
||||
$comparison = $criteria->getComparison(DbSourcePeer::DBS_UID);
|
||||
$selectCriteria->add(DbSourcePeer::DBS_UID, $criteria->remove(DbSourcePeer::DBS_UID), $comparison);
|
||||
|
||||
$comparison = $criteria->getComparison(DbSourcePeer::PRO_UID);
|
||||
$selectCriteria->add(DbSourcePeer::PRO_UID, $criteria->remove(DbSourcePeer::PRO_UID), $comparison);
|
||||
|
||||
} else { // $values is DbSource object
|
||||
$criteria = $values->buildCriteria(); // gets full criteria
|
||||
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||
@@ -479,7 +482,24 @@ abstract class BaseDbSourcePeer {
|
||||
} else {
|
||||
// it must be the primary key
|
||||
$criteria = new Criteria(self::DATABASE_NAME);
|
||||
$criteria->add(DbSourcePeer::DBS_UID, (array) $values, Criteria::IN);
|
||||
// primary key is composite; we therefore, expect
|
||||
// the primary key passed to be an array of pkey
|
||||
// values
|
||||
if(count($values) == count($values, COUNT_RECURSIVE))
|
||||
{
|
||||
// array is not multi-dimensional
|
||||
$values = array($values);
|
||||
}
|
||||
$vals = array();
|
||||
foreach($values as $value)
|
||||
{
|
||||
|
||||
$vals[0][] = $value[0];
|
||||
$vals[1][] = $value[1];
|
||||
}
|
||||
|
||||
$criteria->add(DbSourcePeer::DBS_UID, $vals[0], Criteria::IN);
|
||||
$criteria->add(DbSourcePeer::PRO_UID, $vals[1], Criteria::IN);
|
||||
}
|
||||
|
||||
// Set the correct dbName
|
||||
@@ -539,53 +559,24 @@ abstract class BaseDbSourcePeer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single object by pkey.
|
||||
*
|
||||
* @param mixed $pk the primary key.
|
||||
* @param Connection $con the connection to use
|
||||
* Retrieve object using using composite pkey values.
|
||||
* @param string $dbs_uid
|
||||
@param string $pro_uid
|
||||
|
||||
* @param Connection $con
|
||||
* @return DbSource
|
||||
*/
|
||||
public static function retrieveByPK($pk, $con = null)
|
||||
{
|
||||
public static function retrieveByPK( $dbs_uid, $pro_uid, $con = null) {
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$criteria = new Criteria(DbSourcePeer::DATABASE_NAME);
|
||||
|
||||
$criteria->add(DbSourcePeer::DBS_UID, $pk);
|
||||
|
||||
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(DbSourcePeer::DBS_UID, $dbs_uid);
|
||||
$criteria->add(DbSourcePeer::PRO_UID, $pro_uid);
|
||||
$v = DbSourcePeer::doSelect($criteria, $con);
|
||||
|
||||
return !empty($v) > 0 ? $v[0] : null;
|
||||
return !empty($v) ? $v[0] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve multiple objects by pkey.
|
||||
*
|
||||
* @param array $pks List of primary keys
|
||||
* @param Connection $con the connection to use
|
||||
* @throws PropelException Any exceptions caught during processing will be
|
||||
* rethrown wrapped into a PropelException.
|
||||
*/
|
||||
public static function retrieveByPKs($pks, $con = null)
|
||||
{
|
||||
if ($con === null) {
|
||||
$con = Propel::getConnection(self::DATABASE_NAME);
|
||||
}
|
||||
|
||||
$objs = null;
|
||||
if (empty($pks)) {
|
||||
$objs = array();
|
||||
} else {
|
||||
$criteria = new Criteria();
|
||||
$criteria->add(DbSourcePeer::DBS_UID, $pks, Criteria::IN);
|
||||
$objs = DbSourcePeer::doSelect($criteria, $con);
|
||||
}
|
||||
return $objs;
|
||||
}
|
||||
|
||||
} // BaseDbSourcePeer
|
||||
|
||||
// static code to register the map builder for this Peer with the main Propel class
|
||||
|
||||
@@ -4532,12 +4532,12 @@
|
||||
<parameter name="Extra" value=""/>
|
||||
</vendor>
|
||||
</column>
|
||||
<column name="PRO_UID" type="VARCHAR" size="32" required="true" default="0">
|
||||
<column name="PRO_UID" type="VARCHAR" size="32" required="true" primaryKey="true" default="0">
|
||||
<vendor type="mysql">
|
||||
<parameter name="Field" value="PRO_UID"/>
|
||||
<parameter name="Type" value="varchar(32)"/>
|
||||
<parameter name="Null" value="NO"/>
|
||||
<parameter name="Key" value=""/>
|
||||
<parameter name="Key" value="PRI"/>
|
||||
<parameter name="Default" value=""/>
|
||||
<parameter name="Extra" value=""/>
|
||||
</vendor>
|
||||
|
||||
@@ -752,7 +752,7 @@ CREATE TABLE `DB_SOURCE`
|
||||
`DBS_PASSWORD` VARCHAR(32) default '',
|
||||
`DBS_PORT` INTEGER default 0,
|
||||
`DBS_ENCODE` VARCHAR(32) default '',
|
||||
PRIMARY KEY (`DBS_UID`),
|
||||
PRIMARY KEY (`DBS_UID`,`PRO_UID`),
|
||||
KEY `indexDBSource`(`PRO_UID`)
|
||||
)Type=MyISAM ;
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
@@ -122,7 +122,7 @@ switch ( $action ){
|
||||
$_SESSION['_DBArray'] = $_DBArray;
|
||||
|
||||
$o = new DbSource();
|
||||
$aFields = $o->load($_POST['DBS_UID']);
|
||||
$aFields = $o->load($_POST['DBS_UID'], $_SESSION['PROCESS']);
|
||||
if ($aFields['DBS_PORT'] == '0') {
|
||||
$aFields['DBS_PORT'] = '';
|
||||
}
|
||||
@@ -178,7 +178,8 @@ switch ( $action ){
|
||||
$oContent = new Content();
|
||||
|
||||
$DBS_UID = $_POST['dbs_uid'];
|
||||
$oDBSource->remove($DBS_UID);
|
||||
$PRO_UID = $_SESSION['PROCESS'];
|
||||
$oDBSource->remove($DBS_UID, $PRO_UID);
|
||||
$oContent->removeContent('DBS_DESCRIPTION', "", $DBS_UID);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user