Пример #1
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;
        }
    }
Пример #2
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;
     }
 }
Пример #3
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;
     }
 }
Пример #4
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;
        }
    }
Пример #5
0
 public function removeEvent($evnUid)
 {
     try {
         self::log("Remove Event: {$evnUid}");
         $event = EventPeer::retrieveByPK($evnUid);
         $event->delete();
         self::log("Remove Event Success!");
     } catch (\Exception $e) {
         self::log("Exception: ", $e->getMessage(), "Trace: ", $e->getTraceAsString());
         throw $e;
     }
 }
Пример #6
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;
     }
 }
Пример #7
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;
     }
 }