Exemple #1
0
 /**
  * Builds Project Data Structure
  *
  * @return array
  */
 protected function buildData()
 {
     $data = array();
     $data["metadata"] = $this->getMetadata();
     $data["metadata"]["workspace"] = defined("SYS_SYS") ? SYS_SYS : "Unknown";
     $data["metadata"]["name"] = $this->getProjectName();
     $data["metadata"]["uid"] = $this->getProjectUid();
     $bpmnStruct["ACTIVITY"] = \BpmnActivity::getAll($this->prjUid);
     $bpmnStruct["ARTIFACT"] = \BpmnArtifact::getAll($this->prjUid);
     $bpmnStruct["BOUND"] = \BpmnBound::getAll($this->prjUid);
     $bpmnStruct["DATA"] = \BpmnData::getAll($this->prjUid);
     $bpmnStruct["DIAGRAM"] = \BpmnDiagram::getAll($this->prjUid);
     $bpmnStruct["DOCUMENTATION"] = array();
     $bpmnStruct["EVENT"] = \BpmnEvent::getAll($this->prjUid);
     $bpmnStruct["EXTENSION"] = array();
     $bpmnStruct["FLOW"] = \BpmnFlow::getAll($this->prjUid, null, null, "", CASE_UPPER, false);
     $bpmnStruct["GATEWAY"] = \BpmnGateway::getAll($this->prjUid);
     $bpmnStruct["LANE"] = \BpmnLane::getAll($this->prjUid);
     $bpmnStruct["LANESET"] = \BpmnLaneset::getAll($this->prjUid);
     $bpmnStruct["PARTICIPANT"] = \BpmnParticipant::getAll($this->prjUid);
     $bpmnStruct["PROCESS"] = \BpmnProcess::getAll($this->prjUid);
     $bpmnStruct["PROJECT"] = array(\BpmnProjectPeer::retrieveByPK($this->prjUid)->toArray());
     $workflow = new \ProcessMaker\Project\Workflow();
     list($workflowData, $workflowFile) = $workflow->getData($this->prjUid);
     $data["bpmn-definition"] = $bpmnStruct;
     $data["workflow-definition"] = $workflowData;
     $data["workflow-files"] = $workflowFile;
     return $data;
 }
 /**
  * Method called to associate a BpmnFlow object to this object
  * through the BpmnFlow foreign key attribute
  *
  * @param      BpmnFlow $l BpmnFlow
  * @return     void
  * @throws     PropelException
  */
 public function addBpmnFlow(BpmnFlow $l)
 {
     $this->collBpmnFlows[] = $l;
     $l->setBpmnProject($this);
 }
Exemple #3
0
    public function createMessageEventRelationByBpmnFlow(\BpmnFlow $bpmnFlow)
    {
        try {
            $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();

            $messageEventRelationUid = "";

            if ($bpmnFlow->getFloType() == "MESSAGE" &&
                $bpmnFlow->getFloElementOriginType() == "bpmnEvent" && $bpmnFlow->getFloElementDestType() == "bpmnEvent" &&
                !$messageEventRelation->existsEventRelation($bpmnFlow->getPrjUid(), $bpmnFlow->getFloElementOrigin(), $bpmnFlow->getFloElementDest())
            ) {
                $arrayResult = $messageEventRelation->create(
                    $bpmnFlow->getPrjUid(),
                    array(
                        "EVN_UID_THROW" => $bpmnFlow->getFloElementOrigin(),
                        "EVN_UID_CATCH" => $bpmnFlow->getFloElementDest()
                    )
                );

                $messageEventRelationUid = $arrayResult["MSGER_UID"];
            }

            //Return
            return $messageEventRelationUid;
        } catch (\Exception $e) {
            throw $e;
        }
    }
Exemple #4
0
    public function getElementsBetweenElementOriginAndElementDest(
        $elementOriginUid,
        $elementOriginType,
        $elementDestUid,
        $elementDestType,
        $index
    ) {
        try {
            if (isset($this->arrayElementOriginChecked[$elementOriginUid]) && $this->arrayElementOriginChecked[$elementOriginUid] == $elementOriginType) {
                //Return
                return array();
            }

            $this->arrayElementOriginChecked[$elementOriginUid] = $elementOriginType;

            if ($elementOriginType == $elementDestType && $elementOriginUid == $elementDestUid) {
                $arrayEvent = array();
                $arrayEvent[$index] = array($elementDestUid, $elementDestType);

                //Return
                return $arrayEvent;
            } else {
                //Flows
                $arrayFlow = \BpmnFlow::findAllBy(array(
                    \BpmnFlowPeer::FLO_TYPE                => array("MESSAGE", \Criteria::NOT_EQUAL),
                    \BpmnFlowPeer::FLO_ELEMENT_ORIGIN      => $elementOriginUid,
                    \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => $elementOriginType
                ));

                foreach ($arrayFlow as $value) {
                    $arrayFlowData = $value->toArray();

                    $arrayEvent = $this->getElementsBetweenElementOriginAndElementDest(
                        $arrayFlowData["FLO_ELEMENT_DEST"],
                        $arrayFlowData["FLO_ELEMENT_DEST_TYPE"],
                        $elementDestUid,
                        $elementDestType,
                        $index + 1
                    );

                    if (!empty($arrayEvent)) {
                        $arrayEvent[$index] = array($elementOriginUid, $elementOriginType);

                        //Return
                        return $arrayEvent;
                    }
                }

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

            throw $e;
        }
    }
 /**
  * Validate the data if they are invalid (INSERT and UPDATE)
  *
  * @param string $messageEventRelationUid Unique id of Message-Event-Relation
  * @param string $projectUid              Unique id of Project
  * @param array  $arrayData               Data
  *
  * return void Throw exception if data has an invalid value
  */
 public function throwExceptionIfDataIsInvalid($messageEventRelationUid, $projectUid, array $arrayData)
 {
     try {
         //Set variables
         $arrayMessageEventRelationData = $messageEventRelationUid == "" ? array() : $this->getMessageEventRelation($messageEventRelationUid, true);
         $flagInsert = $messageEventRelationUid == "" ? true : false;
         $arrayFinalData = array_merge($arrayMessageEventRelationData, $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_THROW"]) || isset($arrayData["EVN_UID_CATCH"])) {
             $this->throwExceptionIfEventRelationIsRegistered($projectUid, $arrayFinalData["EVN_UID_THROW"], $arrayFinalData["EVN_UID_CATCH"], $messageEventRelationUid);
         }
         if (isset($arrayData["EVN_UID_THROW"]) || isset($arrayData["EVN_UID_CATCH"])) {
             //Flow
             $bpmnFlow = \BpmnFlow::findOneBy(array(\BpmnFlowPeer::FLO_TYPE => "MESSAGE", \BpmnFlowPeer::FLO_ELEMENT_ORIGIN => $arrayFinalData["EVN_UID_THROW"], \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent", \BpmnFlowPeer::FLO_ELEMENT_DEST => $arrayFinalData["EVN_UID_CATCH"], \BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE => "bpmnEvent"));
             if (is_null($bpmnFlow)) {
                 throw new \Exception(\G::LoadTranslation("ID_MESSAGE_EVENT_RELATION_DOES_NOT_EXIST_MESSAGE_FLOW", array($this->arrayFieldNameForException["eventUidThrow"], $arrayFinalData["EVN_UID_THROW"], $this->arrayFieldNameForException["eventUidCatch"], $arrayFinalData["EVN_UID_CATCH"])));
             }
             //Check and validate Message Flow
             $bpmn = new \ProcessMaker\Project\Bpmn();
             $bpmn->throwExceptionFlowIfIsAnInvalidMessageFlow(array("FLO_TYPE" => "MESSAGE", "FLO_ELEMENT_ORIGIN" => $arrayFinalData["EVN_UID_THROW"], "FLO_ELEMENT_ORIGIN_TYPE" => "bpmnEvent", "FLO_ELEMENT_DEST" => $arrayFinalData["EVN_UID_CATCH"], "FLO_ELEMENT_DEST_TYPE" => "bpmnEvent"));
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
 /**
  * Method called to associate a BpmnFlow object to this object
  * through the BpmnFlow foreign key attribute
  *
  * @param      BpmnFlow $l BpmnFlow
  * @return     void
  * @throws     PropelException
  */
 public function addBpmnFlow(BpmnFlow $l)
 {
     $this->collBpmnFlows[] = $l;
     $l->setBpmnDiagram($this);
 }
 /**
  * Throw all events to End Process
  *
  * @param string $currentTask     Task uid
  *
  * @return void
  */
 private function throwElementToEnd($currentTask, $routeCondition)
 {
     try {
         $bpmnFlow = new BpmnFlow();
         $rsCriFlow = $bpmnFlow->getElementOriginToElementDest($currentTask);
         $arrayElement = array();
         $count = 0;
         $continue = false;
         if ($rsCriFlow->next()) {
             $continue = true;
             $row = $rsCriFlow->getRow();
         }
         while ($continue) {
             $array[0] = $row["FLO_ELEMENT_DEST"];
             $array[1] = $row["FLO_ELEMENT_DEST_TYPE"];
             $arrayElement[$count++] = $array;
             $continue = false;
             if ($rsCriFlow->next()) {
                 $continue = true;
                 $row = $rsCriFlow->getRow();
             } else {
                 $rsCriFlow = $bpmnFlow->getElementOriginToElementDest($row["FLO_ELEMENT_DEST"], $routeCondition, "bpmnEvent");
                 $routeCondition = '';
                 $continue = false;
                 if ($rsCriFlow->next()) {
                     $continue = true;
                     $row = $rsCriFlow->getRow();
                 }
             }
         }
         return $arrayElement;
     } catch (Exception $e) {
         throw $e;
     }
 }