Example #1
0
    public function removeElementTaskRelation($elementUid, $elementType)
    {
        try {
            $elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation();

            $arrayElementTaskRelationData = $elementTaskRelation->getElementTaskRelationWhere(
                array(
                    \ElementTaskRelationPeer::PRJ_UID      => $this->wp->getUid(),
                    \ElementTaskRelationPeer::ELEMENT_UID  => $elementUid,
                    \ElementTaskRelationPeer::ELEMENT_TYPE => $elementType
                ),
                true
            );

            if (!is_null($arrayElementTaskRelationData)) {
                //Task - Delete
                $arrayTaskData = $this->wp->getTask($arrayElementTaskRelationData["TAS_UID"]);

                if (!is_null($arrayTaskData)) {
                    $this->wp->removeTask($arrayElementTaskRelationData["TAS_UID"]);
                }

                //Element-Task-Relation - Delete
                $elementTaskRelation->deleteWhere(array(\ElementTaskRelationPeer::ETR_UID => $arrayElementTaskRelationData["ETR_UID"]));

                //Array - Delete element
                unset($this->arrayElementTaskRelation[$elementUid]);
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
Example #2
0
    /**
     * Email-event for the Case
     *
     * @param string $elementOriginUid     Unique id of Element Origin (unique id of Task)
     * @param string $elementDestUid       Unique id of Element Dest   (unique id of Task)
     * @param array  $arrayApplicationData Case data
     *
     * return void
     */
    public function emailEventBetweenElementOriginAndElementDest($elementOriginUid, $elementDestUid, array $arrayApplicationData)
    {
        try {
            //Verify if the Project is BPMN
            $bpmn = new \ProcessMaker\Project\Bpmn();
            if (!$bpmn->exists($arrayApplicationData["PRO_UID"])) {
                return;
            }

            //Element origin and dest
            $elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation();

            $arrayElement = array(
                "elementOrigin" => array("uid" => $elementOriginUid, "type" => "bpmnActivity"),
                "elementDest"   => array("uid" => $elementDestUid,   "type" => "bpmnActivity")
            );
            
            foreach ($arrayElement as $key => $value) {
                $arrayElementTaskRelationData = $elementTaskRelation->getElementTaskRelationWhere(
                    array(
                        \ElementTaskRelationPeer::PRJ_UID      => $arrayApplicationData["PRO_UID"],
                        \ElementTaskRelationPeer::ELEMENT_TYPE => "bpmnEvent",
                        \ElementTaskRelationPeer::TAS_UID      => $arrayElement[$key]["uid"]
                    ),
                    true
                );

                if (!is_null($arrayElementTaskRelationData)) {
                    $arrayElement[$key]["uid"]  = $arrayElementTaskRelationData["ELEMENT_UID"];
                    $arrayElement[$key]["type"] = "bpmnEvent";
                }
            }

            $elementOriginUid  = $arrayElement["elementOrigin"]["uid"];
            $elementOriginType = $arrayElement["elementOrigin"]["type"];
            $elementDestUid    = $arrayElement["elementDest"]["uid"];
            $elementDestType   = $arrayElement["elementDest"]["type"];

            //Get Message-Events of throw type
            $arrayEvent = $bpmn->getEmailEventTypeBetweenElementOriginAndElementDest(
                $elementOriginUid,
                $elementOriginType,
                $elementDestUid,
                $elementDestType
            );

            //Email-event
            foreach ($arrayEvent as $value) {
                $result = $this->sendEmail($arrayApplicationData["APP_UID"], $arrayApplicationData["PRO_UID"], $value[0], $arrayApplicationData);
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
 /**
  * Throw Events for the Case
  *
  * @param string $elementOriginUid              Unique id of Element Origin      (unique id of Task)
  * @param string $elementDestUid                Unique id of Element Destination (unique id of Task)
  * @param array  $arrayApplicationData          Case data
  * @param bool   $flagEventExecuteBeforeGateway Execute event before gateway
  * @param bool   $flagEventExecuteAfterGateway  Execute event after gateway
  *
  * @return void
  */
 private function throwEventsBetweenElementOriginAndElementDest($elementOriginUid, $elementDestUid, array $arrayApplicationData, $flagEventExecuteBeforeGateway = true, $flagEventExecuteAfterGateway = true, $rouCondition = "")
 {
     try {
         //Verify if the Project is BPMN
         $bpmn = new \ProcessMaker\Project\Bpmn();
         if (!$bpmn->exists($arrayApplicationData["PRO_UID"])) {
             return;
         }
         //Element origin and dest
         $elementTaskRelation = new \ProcessMaker\BusinessModel\ElementTaskRelation();
         $arrayElement = ["elementOrigin" => ["uid" => $elementOriginUid, "type" => "bpmnActivity"], "elementDest" => ["uid" => $elementDestUid, "type" => "bpmnActivity"]];
         foreach ($arrayElement as $key => $value) {
             $arrayElementTaskRelationData = $elementTaskRelation->getElementTaskRelationWhere([ElementTaskRelationPeer::PRJ_UID => $arrayApplicationData["PRO_UID"], ElementTaskRelationPeer::ELEMENT_TYPE => "bpmnEvent", ElementTaskRelationPeer::TAS_UID => $arrayElement[$key]["uid"]], true);
             if (!is_null($arrayElementTaskRelationData)) {
                 $arrayElement[$key]["uid"] = $arrayElementTaskRelationData["ELEMENT_UID"];
                 $arrayElement[$key]["type"] = "bpmnEvent";
             }
         }
         $elementOriginUid = $arrayElement["elementOrigin"]["uid"];
         $elementOriginType = $arrayElement["elementOrigin"]["type"];
         $elementDestUid = $arrayElement["elementDest"]["uid"];
         $elementDestType = $arrayElement["elementDest"]["type"];
         //Throw Events
         $messageApplication = new \ProcessMaker\BusinessModel\MessageApplication();
         $emailEvent = new \ProcessMaker\BusinessModel\EmailEvent();
         $arrayEventExecute = ["BEFORE" => $flagEventExecuteBeforeGateway, "AFTER" => $flagEventExecuteAfterGateway];
         $positionEventExecute = "BEFORE";
         $arrayElement = $bpmn->getElementsBetweenElementOriginAndElementDest($elementOriginUid, $elementOriginType, $elementDestUid, $elementDestType);
         if ($elementDestUid == "-1" || count($arrayElement) == 0) {
             $arrayElement = $this->throwElementToEnd($elementOriginUid, $rouCondition);
         }
         foreach ($arrayElement as $value) {
             switch ($value[1]) {
                 case "bpmnEvent":
                     if ($arrayEventExecute[$positionEventExecute]) {
                         $event = \BpmnEventPeer::retrieveByPK($value[0]);
                         if (!is_null($event)) {
                             if (preg_match("/^(?:END|INTERMEDIATE)\$/", $event->getEvnType()) && $event->getEvnMarker() == "MESSAGETHROW") {
                                 //Message-Application throw
                                 $result = $messageApplication->create($arrayApplicationData["APP_UID"], $arrayApplicationData["PRO_UID"], $value[0], $arrayApplicationData);
                             }
                             if (preg_match("/^(?:END|INTERMEDIATE)\$/", $event->getEvnType()) && $event->getEvnMarker() == "EMAIL") {
                                 //Email-Event throw
                                 $result = $emailEvent->sendEmail($arrayApplicationData["APP_UID"], $arrayApplicationData["PRO_UID"], $value[0], $arrayApplicationData);
                             }
                         }
                     }
                     break;
                 case "bpmnGateway":
                     $positionEventExecute = "AFTER";
                     break;
             }
         }
     } catch (Exception $e) {
         throw $e;
     }
 }