/**
  * Validates all modified columns of given TimerEvent object.
  * If parameter $columns is either a single column name or an array of column names
  * than only those columns are validated.
  *
  * NOTICE: This does not apply to primary or foreign keys for now.
  *
  * @param      TimerEvent $obj The object to validate.
  * @param      mixed $cols Column name or array of column names.
  *
  * @return     mixed TRUE if all columns are valid or the error message of the first invalid column.
  */
 public static function doValidate(TimerEvent $obj, $cols = null)
 {
     $columns = array();
     if ($cols) {
         $dbMap = Propel::getDatabaseMap(TimerEventPeer::DATABASE_NAME);
         $tableMap = $dbMap->getTable(TimerEventPeer::TABLE_NAME);
         if (!is_array($cols)) {
             $cols = array($cols);
         }
         foreach ($cols as $colName) {
             if ($tableMap->containsColumn($colName)) {
                 $get = 'get' . $tableMap->getColumn($colName)->getPhpName();
                 $columns[$colName] = $obj->{$get}();
             }
         }
     } else {
         if ($obj->isNew() || $obj->isColumnModified(TimerEventPeer::TMREVN_OPTION)) {
             $columns[TimerEventPeer::TMREVN_OPTION] = $obj->getTmrevnOption();
         }
         if ($obj->isNew() || $obj->isColumnModified(TimerEventPeer::TMREVN_STATUS)) {
             $columns[TimerEventPeer::TMREVN_STATUS] = $obj->getTmrevnStatus();
         }
     }
     return BasePeer::doValidate(TimerEventPeer::DATABASE_NAME, TimerEventPeer::TABLE_NAME, $columns);
 }
Example #2
0
 /**
  * Single create Timer-Event
  *
  * @param string $projectUid Unique id of Project
  * @param array  $arrayData  Data
  *
  * return string Return unique id of Timer-Event
  */
 public function singleCreate($projectUid, array $arrayData)
 {
     try {
         $cnn = \Propel::getConnection("workflow");
         try {
             $timerEvent = new \TimerEvent();
             $timerEventUid = \ProcessMaker\Util\Common::generateUID();
             $timerEvent->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME);
             $timerEvent->setTmrevnUid($timerEventUid);
             $timerEvent->setPrjUid($projectUid);
             if ($timerEvent->validate()) {
                 $cnn->begin();
                 $result = $timerEvent->save();
                 $cnn->commit();
                 //Return
                 return $timerEventUid;
             } else {
                 $msg = "";
                 foreach ($timerEvent->getValidationFailures() as $validationFailure) {
                     $msg = $msg . ($msg != "" ? "\n" : "") . $validationFailure->getMessage();
                 }
                 throw new \Exception(\G::LoadTranslation("ID_RECORD_CANNOT_BE_CREATED") . ($msg != "" ? "\n" . $msg : ""));
             }
         } catch (\Exception $e) {
             $cnn->rollback();
             throw $e;
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }