2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
2012-10-22 05:57:53 -04:00
|
|
|
class Configuration extends BaseConfiguration
|
|
|
|
|
{
|
2015-05-18 14:13:06 -04:00
|
|
|
public function create(array $arrayData)
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2015-05-18 14:13:06 -04:00
|
|
|
$cnn = Propel::getConnection(ConfigurationPeer::DATABASE_NAME);
|
|
|
|
|
|
2012-10-22 05:57:53 -04:00
|
|
|
try {
|
2015-05-27 14:53:05 -04:00
|
|
|
$this->setCfgUid($arrayData["CFG_UID"]);
|
|
|
|
|
$this->setObjUid($arrayData["OBJ_UID"]);
|
|
|
|
|
$this->setCfgValue((isset($arrayData["CFG_VALUE"]))? $arrayData["CFG_VALUE"] : "");
|
|
|
|
|
$this->setProUid($arrayData["PRO_UID"]);
|
|
|
|
|
$this->setUsrUid($arrayData["USR_UID"]);
|
|
|
|
|
$this->setAppUid($arrayData["APP_UID"]);
|
|
|
|
|
|
|
|
|
|
if ($this->validate()) {
|
2015-05-18 14:13:06 -04:00
|
|
|
$cnn->begin();
|
|
|
|
|
|
2015-05-27 14:53:05 -04:00
|
|
|
$result = $this->save();
|
2015-05-18 14:13:06 -04:00
|
|
|
|
|
|
|
|
$cnn->commit();
|
|
|
|
|
|
|
|
|
|
//Return
|
2012-10-22 05:57:53 -04:00
|
|
|
return $result;
|
|
|
|
|
} else {
|
2015-05-18 14:13:06 -04:00
|
|
|
$msg = "";
|
|
|
|
|
|
2015-05-27 14:53:05 -04:00
|
|
|
foreach ($this->getValidationFailures() as $validationFailure) {
|
2015-05-18 14:13:06 -04:00
|
|
|
$msg = $msg . (($msg != "")? "\n" : "") . $validationFailure->getMessage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
throw new Exception(G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . (($msg != "")? "\n" . $msg : ""));
|
2012-10-22 05:57:53 -04:00
|
|
|
}
|
|
|
|
|
} catch (Exception $e) {
|
2015-05-18 14:13:06 -04:00
|
|
|
$cnn->rollback();
|
|
|
|
|
|
|
|
|
|
throw $e;
|
2012-10-22 05:57:53 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-22 05:57:53 -04:00
|
|
|
|
|
|
|
|
public function load($CfgUid, $ObjUid = '', $ProUid = '', $UsrUid = '', $AppUid = '')
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2012-10-22 05:57:53 -04:00
|
|
|
try {
|
|
|
|
|
$oRow = ConfigurationPeer::retrieveByPK( $CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid );
|
|
|
|
|
if (!is_null($oRow)) {
|
|
|
|
|
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
|
|
|
|
|
$this->fromArray($aFields,BasePeer::TYPE_FIELDNAME);
|
|
|
|
|
$this->setNew(false);
|
|
|
|
|
return $aFields;
|
|
|
|
|
} else {
|
|
|
|
|
throw(new Exception( "The row '$CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid' in table Configuration doesn't exist!" ));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
throw($oError);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-22 05:57:53 -04:00
|
|
|
|
|
|
|
|
public function update($fields)
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2012-10-22 05:57:53 -04:00
|
|
|
$con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME);
|
|
|
|
|
try {
|
|
|
|
|
$con->begin();
|
|
|
|
|
$this->load($fields['CFG_UID'], $fields['OBJ_UID'], $fields['PRO_UID'], $fields['USR_UID'], $fields['APP_UID']);
|
|
|
|
|
$this->fromArray($fields,BasePeer::TYPE_FIELDNAME);
|
|
|
|
|
if ($this->validate()) {
|
|
|
|
|
$contentResult=0;
|
|
|
|
|
$result=$this->save();
|
|
|
|
|
$result=($result==0)?($contentResult>0?1:0):$result;
|
|
|
|
|
$con->commit();
|
|
|
|
|
return $result;
|
|
|
|
|
} else {
|
|
|
|
|
$con->rollback();
|
|
|
|
|
throw(new Exception("Failed Validation in class ".get_class($this)."."));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$con->rollback();
|
|
|
|
|
throw($e);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-22 05:57:53 -04:00
|
|
|
|
|
|
|
|
public function remove($CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid)
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2012-10-22 05:57:53 -04:00
|
|
|
$con = Propel::getConnection(ConfigurationPeer::DATABASE_NAME);
|
|
|
|
|
try {
|
|
|
|
|
$con->begin();
|
|
|
|
|
$this->setCfgUid($CfgUid);
|
|
|
|
|
$this->setObjUid($ObjUid);
|
|
|
|
|
$this->setProUid($ProUid);
|
|
|
|
|
$this->setUsrUid($UsrUid);
|
|
|
|
|
$this->setAppUid($AppUid);
|
|
|
|
|
$result=$this->delete();
|
|
|
|
|
$con->commit();
|
|
|
|
|
return $result;
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
$con->rollback();
|
|
|
|
|
throw($e);
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2012-10-22 05:57:53 -04:00
|
|
|
|
2013-05-08 12:00:12 -04:00
|
|
|
/**
|
2015-04-22 17:01:34 -04:00
|
|
|
* To check if the configuration row exists, by using Configuration Uid data
|
2013-05-08 12:00:12 -04:00
|
|
|
*/
|
2015-04-22 17:01:34 -04:00
|
|
|
public function exists($CfgUid, $ObjUid = "", $ProUid = "", $UsrUid = "", $AppUid = "")
|
2010-12-02 23:34:41 +00:00
|
|
|
{
|
2012-10-22 05:57:53 -04:00
|
|
|
$oRow = ConfigurationPeer::retrieveByPK( $CfgUid, $ObjUid, $ProUid, $UsrUid, $AppUid );
|
2019-11-28 10:22:23 -04:00
|
|
|
return (!is_null($oRow) && get_class($oRow) === 'Configuration');
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2013-04-09 17:45:08 -04:00
|
|
|
|
|
|
|
|
public function getAll ()
|
|
|
|
|
{
|
|
|
|
|
$oCriteria = new Criteria( 'workflow' );
|
|
|
|
|
|
|
|
|
|
$oCriteria->addSelectColumn( ConfigurationPeer::CFG_UID );
|
|
|
|
|
$oCriteria->addSelectColumn( ConfigurationPeer::OBJ_UID );
|
|
|
|
|
$oCriteria->addSelectColumn( ConfigurationPeer::CFG_VALUE );
|
|
|
|
|
$oCriteria->addSelectColumn( ConfigurationPeer::PRO_UID );
|
|
|
|
|
$oCriteria->addSelectColumn( ConfigurationPeer::USR_UID );
|
|
|
|
|
$oCriteria->addSelectColumn( ConfigurationPeer::APP_UID );
|
|
|
|
|
|
|
|
|
|
//execute the query
|
|
|
|
|
$oDataset = ConfigurationPeer::doSelectRS( $oCriteria );
|
|
|
|
|
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
|
|
|
|
$aRows = array ();
|
|
|
|
|
while ($oDataset->next()) {
|
|
|
|
|
$aRows[] = $oDataset->getRow();
|
|
|
|
|
}
|
|
|
|
|
return $aRows;
|
|
|
|
|
}
|
2012-10-22 05:57:53 -04:00
|
|
|
}
|
|
|
|
|
|