/**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this BpmnProject is new, it will return
  * an empty collection; or if this BpmnProject has previously
  * been saved, it will retrieve related BpmnEvents from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in BpmnProject.
  */
 public function getBpmnEventsJoinBpmnProcess($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'classes/model/om/BaseBpmnEventPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collBpmnEvents === null) {
         if ($this->isNew()) {
             $this->collBpmnEvents = array();
         } else {
             $criteria->add(BpmnEventPeer::PRJ_UID, $this->getPrjUid());
             $this->collBpmnEvents = BpmnEventPeer::doSelectJoinBpmnProcess($criteria, $con);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(BpmnEventPeer::PRJ_UID, $this->getPrjUid());
         if (!isset($this->lastBpmnEventCriteria) || !$this->lastBpmnEventCriteria->equals($criteria)) {
             $this->collBpmnEvents = BpmnEventPeer::doSelectJoinBpmnProcess($criteria, $con);
         }
     }
     $this->lastBpmnEventCriteria = $criteria;
     return $this->collBpmnEvents;
 }
示例#2
0
    public function updateWebEntryEventByEvent($eventUid, array $arrayData)
    {
        try {
            $bpmnEvent = \BpmnEventPeer::retrieveByPK($eventUid);

            if (!is_null($bpmnEvent) && $bpmnEvent->getEvnType() == "START" && $bpmnEvent->getEvnMarker() == "EMPTY") {
                $webEntryEvent = new \ProcessMaker\BusinessModel\WebEntryEvent();

                if ($webEntryEvent->existsEvent($bpmnEvent->getPrjUid(), $bpmnEvent->getEvnUid())) {
                    $arrayWebEntryEventData = $webEntryEvent->getWebEntryEventByEvent($bpmnEvent->getPrjUid(), $bpmnEvent->getEvnUid(), true);

                    $bpmn = \ProcessMaker\Project\Bpmn::load($bpmnEvent->getPrjUid());
                    $bpmnProject = $bpmn->getProject("object");

                    $arrayResult = $webEntryEvent->update($arrayWebEntryEventData["WEE_UID"], $bpmnProject->getPrjAuthor(), $arrayData);
                }
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
 /**
  * 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(BpmnEventPeer::EVN_UID, $pks, Criteria::IN);
         $objs = BpmnEventPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
示例#4
0
 /**
  * Get data of a Timer-Event by unique id of Event
  *
  * @param string $projectUid    Unique id of Project
  * @param string $eventUid      Unique id of Event
  * @param bool   $flagGetRecord Value that set the getting
  *
  * return array Return an array with data of a Timer-Event by unique id of Event
  */
 public function getTimerEventByEvent($projectUid, $eventUid, $flagGetRecord = false)
 {
     try {
         //Verify data
         $process = new \ProcessMaker\BusinessModel\Process();
         $bpmnEvent = \BpmnEventPeer::retrieveByPK($eventUid);
         $process->throwExceptionIfNotExistsProcess($projectUid, $this->arrayFieldNameForException["projectUid"]);
         if (is_null($bpmnEvent)) {
             throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_EXIST", array($this->arrayFieldNameForException["eventUid"], $eventUid)));
         }
         if ($bpmnEvent->getPrjUid() != $projectUid) {
             throw new \Exception(\G::LoadTranslation("ID_EVENT_EVENT_NOT_BELONG_TO_PROJECT", array($this->arrayFieldNameForException["eventUid"], $eventUid, $this->arrayFieldNameForException["projectUid"], $projectUid)));
         }
         //Get data
         if (!$this->existsEvent($projectUid, $eventUid)) {
             //Return
             return array();
         }
         $criteria = $this->getTimerEventCriteria();
         $criteria->add(\TimerEventPeer::PRJ_UID, $projectUid, \Criteria::EQUAL);
         $criteria->add(\TimerEventPeer::EVN_UID, $eventUid, \Criteria::EQUAL);
         $rsCriteria = \TimerEventPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         $result = $rsCriteria->next();
         $row = $rsCriteria->getRow();
         $row["TMREVN_CONFIGURATION_DATA"] = unserialize($row["TMREVN_CONFIGURATION_DATA"]);
         //Return
         return !$flagGetRecord ? $this->getTimerEventDataFromRecord($row) : $row;
     } catch (\Exception $e) {
         throw $e;
     }
 }
示例#5
0
 /**
  * Delete a case scheduler of a project
  *
  * @param string $sSchUID
  *
  * @access public
  */
 public function deleteCaseScheduler($sSchUID)
 {
     try {
         require_once PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "CaseScheduler.php";
         $oCaseScheduler = new \CaseScheduler();
         if (!isset($sSchUID)) {
             return;
         }
         $event = \BpmnEventPeer::retrieveByPK($sSchUID);
         if (is_object($event)) {
             $event->delete();
         }
         $oCaseScheduler->remove($sSchUID);
     } catch (\Exception $e) {
         throw $e;
     }
 }
示例#6
0
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = BpmnEventPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setEvnUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setPrjUid($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setProUid($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setEvnName($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setEvnType($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setEvnMarker($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setEvnIsInterrupting($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setEvnAttachedTo($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setEvnCancelActivity($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setEvnActivityRef($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setEvnWaitForCompletion($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setEvnErrorName($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setEvnErrorCode($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setEvnEscalationName($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setEvnEscalationCode($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setEvnCondition($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setEvnMessage($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setEvnOperationName($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setEvnOperationImplementationRef($arr[$keys[18]]);
     }
     if (array_key_exists($keys[19], $arr)) {
         $this->setEvnTimeDate($arr[$keys[19]]);
     }
     if (array_key_exists($keys[20], $arr)) {
         $this->setEvnTimeCycle($arr[$keys[20]]);
     }
     if (array_key_exists($keys[21], $arr)) {
         $this->setEvnTimeDuration($arr[$keys[21]]);
     }
     if (array_key_exists($keys[22], $arr)) {
         $this->setEvnBehavior($arr[$keys[22]]);
     }
 }
示例#7
0
    public function getMessageEventsOfThrowTypeBetweenElementOriginAndElementDest(
        $elementOriginUid,
        $elementOriginType,
        $elementDestUid,
        $elementDestType
    ) {
        try {
            $arrayEventType   = array("END", "INTERMEDIATE");
            $arrayEventMarker = array("MESSAGETHROW");

            $this->arrayElementOriginChecked = array();

            $arrayEventAux = $this->getElementsBetweenElementOriginAndElementDest(
                $elementOriginUid,
                $elementOriginType,
                $elementDestUid,
                $elementDestType,
                0
            );

            ksort($arrayEventAux);

            $arrayEvent = array();

            foreach ($arrayEventAux as $value) {
                if ($value[1] == "bpmnEvent") {
                    $event = \BpmnEventPeer::retrieveByPK($value[0]);

                    if (!is_null($event) &&
                        in_array($event->getEvnType(), $arrayEventType) && in_array($event->getEvnMarker(), $arrayEventMarker)
                    ) {
                        $arrayEvent[] = $value;
                    }
                }
            }

            //Return
            return $arrayEvent;
        } catch (\Exception $e) {
            self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());

            throw $e;
        }
    }
示例#8
0
 public function throwExceptionFlowIfIsAnInvalidMessageFlow(array $bpmnFlow)
 {
     try {
         if ($bpmnFlow["FLO_TYPE"] == "MESSAGE" && $bpmnFlow["FLO_ELEMENT_ORIGIN_TYPE"] == "bpmnEvent" && $bpmnFlow["FLO_ELEMENT_DEST_TYPE"] == "bpmnEvent") {
             $flagValid = true;
             $arrayEventType = array("START", "END", "INTERMEDIATE");
             $arrayAux = array(array("eventUid" => $bpmnFlow["FLO_ELEMENT_ORIGIN"], "eventMarker" => array("MESSAGETHROW", "EMAIL")), array("eventUid" => $bpmnFlow["FLO_ELEMENT_DEST"], "eventMarker" => array("MESSAGECATCH")));
             foreach ($arrayAux as $value) {
                 $criteria = new \Criteria("workflow");
                 $criteria->addSelectColumn(\BpmnEventPeer::EVN_UID);
                 $criteria->add(\BpmnEventPeer::EVN_UID, $value["eventUid"], \Criteria::EQUAL);
                 $criteria->add(\BpmnEventPeer::EVN_TYPE, $arrayEventType, \Criteria::IN);
                 $criteria->add(\BpmnEventPeer::EVN_MARKER, $value["eventMarker"], \Criteria::IN);
                 $rsCriteria = \BpmnEventPeer::doSelectRS($criteria);
                 if (!$rsCriteria->next()) {
                     $flagValid = false;
                     break;
                 }
             }
             if (!$flagValid) {
                 throw new \RuntimeException("Invalid Message Flow.");
             }
         }
     } catch (\Exception $e) {
         self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
         throw $e;
     }
 }
示例#9
0
 /**
  * Validate the data if they are invalid (INSERT and UPDATE)
  *
  * @param string $webEntryEventUid Unique id of WebEntry-Event
  * @param string $projectUid       Unique id of Project
  * @param array  $arrayData        Data
  *
  * return void Throw exception if data has an invalid value
  */
 public function throwExceptionIfDataIsInvalid($webEntryEventUid, $projectUid, array $arrayData)
 {
     try {
         //Set variables
         $arrayWebEntryEventData = $webEntryEventUid == "" ? array() : $this->getWebEntryEvent($webEntryEventUid, true);
         $flagInsert = $webEntryEventUid == "" ? true : false;
         $arrayFinalData = array_merge($arrayWebEntryEventData, $arrayData);
         //Verify data - Field definition
         $process = new \ProcessMaker\BusinessModel\Process();
         $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
         //Verify data
         if (isset($arrayData["EVN_UID"])) {
             $this->throwExceptionIfEventIsRegistered($projectUid, $arrayData["EVN_UID"], $this->arrayFieldNameForException["eventUid"], $webEntryEventUid);
         }
         if (isset($arrayData["EVN_UID"])) {
             $obj = \BpmnEventPeer::retrieveByPK($arrayData["EVN_UID"]);
             if (is_null($obj)) {
                 throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_EXIST", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"])));
             }
             if ($obj->getEvnType() != "START" || $obj->getEvnType() == "START" && $obj->getEvnMarker() != "EMPTY") {
                 throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_IS_START_EVENT", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"])));
             }
         }
         if (isset($arrayData["WEE_TITLE"])) {
             $this->throwExceptionIfExistsTitle($projectUid, $arrayData["WEE_TITLE"], $this->arrayFieldNameForException["webEntryEventTitle"], $webEntryEventUid);
         }
         if (isset($arrayData["ACT_UID"])) {
             $bpmn = new \ProcessMaker\Project\Bpmn();
             if (!$bpmn->activityExists($arrayData["ACT_UID"])) {
                 throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_DOES_NOT_EXIST", array($this->arrayFieldNameForException["activityUid"], $arrayData["ACT_UID"])));
             }
         }
         if (isset($arrayData["EVN_UID"]) || isset($arrayData["ACT_UID"])) {
             $criteria = new \Criteria("workflow");
             $criteria->addSelectColumn(\BpmnFlowPeer::FLO_UID);
             $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $arrayFinalData["EVN_UID"], \Criteria::EQUAL);
             $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE, "bpmnEvent", \Criteria::EQUAL);
             $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_DEST, $arrayFinalData["ACT_UID"], \Criteria::EQUAL);
             $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE, "bpmnActivity", \Criteria::EQUAL);
             $rsCriteria = \BpmnFlowPeer::doSelectRS($criteria);
             if (!$rsCriteria->next()) {
                 throw new \Exception(\G::LoadTranslation("ID_WEB_ENTRY_EVENT_FLOW_EVENT_TO_ACTIVITY_DOES_NOT_EXIST"));
             }
         }
         if (isset($arrayData["DYN_UID"])) {
             $dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
             $dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $projectUid, $this->arrayFieldNameForException["dynaFormUid"]);
         }
         if (isset($arrayData["USR_UID"])) {
             $process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
示例#10
0
 public static function exists($evnUid)
 {
     $c = new Criteria("workflow");
     $c->add(BpmnEventPeer::EVN_UID, $evnUid);
     return BpmnEventPeer::doCount($c) > 0 ? true : false;
 }
示例#11
0
 /**
  * Throw Events for the Case
  *
  * @param string $eventUid           Unique id of Event
  * @param array  $appFields          Case data
  *
  * @return void
  */
 private function throwEventsElemntOriginToElementDest($eventUid, $appFields)
 {
     try {
         //Verify if the Project is BPMN
         $bpmn = new \ProcessMaker\Project\Bpmn();
         if (!$bpmn->exists($appFields["PRO_UID"])) {
             return;
         }
         //Throw Events
         $messageApplication = new \ProcessMaker\BusinessModel\MessageApplication();
         $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
         $event = \BpmnEventPeer::retrieveByPK($eventUid);
         if (!is_null($event)) {
             if (preg_match("/^(?:END|INTERMEDIATE)\$/", $event->getEvnType()) && $event->getEvnMarker() == "MESSAGETHROW") {
                 //Message-Application throw
                 $result = $messageApplication->create($appFields["APP_UID"], $appFields["PRO_UID"], $value[0], $appFields);
             }
             if (preg_match("/^(?:END|INTERMEDIATE)\$/", $event->getEvnType()) && $event->getEvnMarker() == "EMAIL") {
                 //Email-Event throw
                 $result = $emailEvent->sendEmail($appFields["APP_UID"], $appFields["PRO_UID"], $eventUid, $appFields);
             }
         }
     } catch (Exception $e) {
         throw $e;
     }
 }
 /**
  * Validate the data if they are invalid (INSERT and UPDATE)
  *
  * @param string $messageEventDefinitionUid Unique id of Message-Event-Definition
  * @param string $projectUid                Unique id of Project
  * @param array  $arrayData                 Data
  *
  * return void Throw exception if data has an invalid value
  */
 public function throwExceptionIfDataIsInvalid($messageEventDefinitionUid, $projectUid, array $arrayData)
 {
     try {
         //Set variables
         $arrayMessageEventDefinitionData = $messageEventDefinitionUid == "" ? array() : $this->getMessageEventDefinition($messageEventDefinitionUid, true);
         $flagInsert = $messageEventDefinitionUid == "" ? true : false;
         $arrayFinalData = array_merge($arrayMessageEventDefinitionData, $arrayData);
         //Verify data - Field definition
         $process = new \ProcessMaker\BusinessModel\Process();
         $messageType = new \ProcessMaker\BusinessModel\MessageType();
         $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
         //Verify data
         if (isset($arrayData["EVN_UID"])) {
             $this->throwExceptionIfEventIsRegistered($projectUid, $arrayData["EVN_UID"], $this->arrayFieldNameForException["eventUid"], $messageEventDefinitionUid);
         }
         if (isset($arrayData["EVN_UID"])) {
             $arrayEventType = array("START", "END", "INTERMEDIATE");
             $arrayEventMarker = array("MESSAGETHROW", "MESSAGECATCH");
             $bpmnEvent = \BpmnEventPeer::retrieveByPK($arrayData["EVN_UID"]);
             if (is_null($bpmnEvent)) {
                 throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_EXIST", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"])));
             }
             if (!in_array($bpmnEvent->getEvnType(), $arrayEventType) || !in_array($bpmnEvent->getEvnMarker(), $arrayEventMarker)) {
                 throw new \Exception(\G::LoadTranslation("ID_EVENT_NOT_IS_MESSAGE_EVENT", array($this->arrayFieldNameForException["eventUid"], $arrayData["EVN_UID"])));
             }
         }
         if (isset($arrayData["MSGT_UID"]) && $arrayData["MSGT_UID"] . "" != "") {
             $messageType->throwExceptionIfNotExistsMessageType($arrayData["MSGT_UID"], $this->arrayFieldNameForException["messageTypeUid"]);
         }
         $flagCheckData = false;
         $flagCheckData = isset($arrayData["MSGT_UID"]) && $arrayData["MSGT_UID"] . "" != "" ? true : $flagCheckData;
         $flagCheckData = isset($arrayData["MSGED_VARIABLES"]) ? true : $flagCheckData;
         if (isset($arrayFinalData["MSGT_UID"]) && $arrayFinalData["MSGT_UID"] . "" != "" && $flagCheckData) {
             $arrayMessageTypeVariable = array();
             $arrayMessageTypeData = $messageType->getMessageType($arrayFinalData["MSGT_UID"], true);
             foreach ($arrayMessageTypeData["MSGT_VARIABLES"] as $value) {
                 $arrayMessageTypeVariable[$value["MSGTV_NAME"]] = $value["MSGTV_DEFAULT_VALUE"];
             }
             if (count($arrayMessageTypeVariable) != count($arrayFinalData["MSGED_VARIABLES"]) || count(array_diff_key($arrayMessageTypeVariable, $arrayFinalData["MSGED_VARIABLES"])) > 0) {
                 throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_DEFINITION_VARIABLES_DO_NOT_MEET_DEFINITION"));
             }
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }