示例#1
0
 /**
  * Implementation for 'GET' method for Rest API
  *
  * @param  mixed $stepUid Primary key
  *
  * @return array $result Returns array within multiple records or a single record depending if
  *                       a single selection was requested passing id(s) as param
  */
 protected function get($stepUid = null)
 {
     $result = array();
     try {
         $noArguments = true;
         $argumentList = func_get_args();
         foreach ($argumentList as $arg) {
             if (!is_null($arg)) {
                 $noArguments = false;
             }
         }
         if ($noArguments) {
             $criteria = new Criteria('workflow');
             $criteria->addSelectColumn(StepSupervisorPeer::STEP_UID);
             $criteria->addSelectColumn(StepSupervisorPeer::PRO_UID);
             $criteria->addSelectColumn(StepSupervisorPeer::STEP_TYPE_OBJ);
             $criteria->addSelectColumn(StepSupervisorPeer::STEP_UID_OBJ);
             $criteria->addSelectColumn(StepSupervisorPeer::STEP_POSITION);
             $dataset = AppEventPeer::doSelectRS($criteria);
             $dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
             while ($dataset->next()) {
                 $result[] = $dataset->getRow();
             }
         } else {
             $record = StepSupervisorPeer::retrieveByPK($stepUid);
             if ($record) {
                 $result = $record->toArray(BasePeer::TYPE_FIELDNAME);
             } else {
                 $paramValues = "";
                 foreach ($argumentList as $arg) {
                     $paramValues .= strlen($paramValues) ? ', ' : '';
                     if (!is_null($arg)) {
                         $paramValues .= "{$arg}";
                     } else {
                         $paramValues .= "NULL";
                     }
                 }
                 throw new RestException(417, "table StepSupervisor ({$paramValues})");
             }
         }
     } catch (RestException $e) {
         throw new RestException($e->getCode(), $e->getMessage());
     } catch (Exception $e) {
         throw new RestException(412, $e->getMessage());
     }
     return $result;
 }
 /**
  * Validate Process Uid
  * @var string $pro_uid. Uid for process
  *
  */
 public function changePosStep ($step_uid, $pos)
 {
     $oCriteria=\StepSupervisorPeer::retrieveByPK($step_uid);
     $oCriteria->setStepPosition($pos);
     $oCriteria->save();
 }
示例#3
0
 /**
  * Update the step supervisor registry
  *
  * @param array $aData
  * @return integer
  *
  */
 public function update ($aData)
 {
     $oConnection = Propel::getConnection( StepSupervisorPeer::DATABASE_NAME );
     try {
         $oStepSupervisor = StepSupervisorPeer::retrieveByPK( $aData['STEP_UID'] );
         if (! is_null( $oStepSupervisor )) {
             $oStepSupervisor->fromArray( $aData, BasePeer::TYPE_FIELDNAME );
             if ($oStepSupervisor->validate()) {
                 $oConnection->begin();
                 $iResult = $oStepSupervisor->save();
                 $oConnection->commit();
                 return $iResult;
             } else {
                 $sMessage = '';
                 $aValidationFailures = $oStepSupervisor->getValidationFailures();
                 foreach ($aValidationFailures as $oValidationFailure) {
                     $sMessage .= $oValidationFailure->getMessage() . '<br />';
                 }
                 throw (new Exception( 'The registry cannot be updated!<br />' . $sMessage ));
             }
         } else {
             throw (new Exception( 'This row doesn\'t exist!' ));
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw ($oError);
     }
 }