Beispiel #1
0
    public static function exists($floUid)
    {
        $c = new Criteria('workflow');
        $c->add(BpmnFlowPeer::FLO_UID, $floUid);

        return BpmnFlowPeer::doCount($c) > 0 ? true : false;
    }
 /**
  * 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 BpmnFlows 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 getBpmnFlowsJoinBpmnDiagram($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'classes/model/om/BaseBpmnFlowPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collBpmnFlows === null) {
         if ($this->isNew()) {
             $this->collBpmnFlows = array();
         } else {
             $criteria->add(BpmnFlowPeer::PRJ_UID, $this->getPrjUid());
             $this->collBpmnFlows = BpmnFlowPeer::doSelectJoinBpmnDiagram($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(BpmnFlowPeer::PRJ_UID, $this->getPrjUid());
         if (!isset($this->lastBpmnFlowCriteria) || !$this->lastBpmnFlowCriteria->equals($criteria)) {
             $this->collBpmnFlows = BpmnFlowPeer::doSelectJoinBpmnDiagram($criteria, $con);
         }
     }
     $this->lastBpmnFlowCriteria = $criteria;
     return $this->collBpmnFlows;
 }
Beispiel #3
0
    public function removeFlow($floUid)
    {
        $flow = \BpmnFlowPeer::retrieveByPK($floUid);
        parent::removeFlow($floUid);

        // verify case: event(start) -> activity
        // => find the corresponding task and unset it as start task
        if ($flow->getFloElementOriginType() == "bpmnEvent" &&
            $flow->getFloElementDestType() == "bpmnActivity"
        ) {
            $bpmnFlow = \BpmnFlow::findOneBy(array(
                \BpmnFlowPeer::FLO_ELEMENT_ORIGIN      => $flow->getFloElementOrigin(),
                \BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE => "bpmnEvent",
                \BpmnFlowPeer::FLO_ELEMENT_DEST        => $flow->getFloElementDest(),
                \BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE   => "bpmnActivity"
            ));

            if (is_null($bpmnFlow)) {
                $event = \BpmnEventPeer::retrieveByPK($flow->getFloElementOrigin());

                if (!is_null($event) && $event->getEvnType() == "START" && $event->getEvnMarker() == "EMPTY") {
                    $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementDest());

                    //Remove as start Task
                    if (!is_null($activity)) {
                        $this->wp->setStartTask($activity->getActUid(), false);
                    }
                }
            }

            //$this->updateEventStartObjects($flow->getFloElementOrigin(), "");

            //WebEntry-Event - Update
            if (is_null($bpmnFlow)) {
                $this->updateWebEntryEventByEvent($flow->getFloElementOrigin(), array("WEE_STATUS" => "DISABLED"));
            }
        } elseif ($flow->getFloElementOriginType() == "bpmnActivity" &&
            $flow->getFloElementDestType() == "bpmnEvent") {
            // verify case: activity -> event(end)
            // => find the corresponding task and unset it as start task
            $event = \BpmnEventPeer::retrieveByPK($flow->getFloElementDest());

            if (!is_null($event) && $event->getEvnType() == "END" && $event->getEvnMarker() == "EMPTY") {
                $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementOrigin());

                //Remove as end Task
                if (! is_null($activity)) {
                    $this->wp->setEndTask($activity->getActUid(), false);
                }
            }
        } else {
            switch ($flow->getFloElementOriginType()) {
                case "bpmnActivity":
                    switch ($flow->getFloElementDestType()) {
                        //Activity1 -> Activity2
                        case "bpmnActivity":
                            $this->wp->removeRouteFromTo($flow->getFloElementOrigin(), $flow->getFloElementDest());
                            break;
                    }
                    break;
                case "bpmnEvent":
                    switch ($flow->getFloElementDestType()) {
                        //Event1 -> Event2
                        case "bpmnEvent":
                            if ($flow->getFloType() == "MESSAGE") {
                                //Delete Message-Event-Relation
                                $messageEventRelation = new \ProcessMaker\BusinessModel\MessageEventRelation();

                                $messageEventRelation->deleteWhere(array(
                                    \MessageEventRelationPeer::PRJ_UID       => $flow->getPrjUid(),
                                    \MessageEventRelationPeer::EVN_UID_THROW => $flow->getFloElementOrigin(),
                                    \MessageEventRelationPeer::EVN_UID_CATCH => $flow->getFloElementDest()
                                ));
                            }
                            break;
                    }
                    break;
            }
        }

        // TODO Complete for other routes, activity->activity, activity->gateway and viceversa
    }
    public function addRouteSecJoin($taskUid, $nextTaskUid)
    {
        try {
            //Route
            $result = parent::addRoute($taskUid, $nextTaskUid, "SEC-JOIN");

            //BPMN
            $arrayTaskData = $this->getTask($taskUid);

            $activityUid = $arrayTaskData["TAS_UID"];
            $activityBouX = (int)($arrayTaskData["TAS_POSX"]);
            $activityBouY = (int)($arrayTaskData["TAS_POSY"]);
            $activityBouWidth  = (int)($arrayTaskData["TAS_WIDTH"]);
            $activityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);

            $arrayTaskData = $this->getTask($nextTaskUid);

            $nextActivityUid = $arrayTaskData["TAS_UID"];
            $nextActivityBouX = (int)($arrayTaskData["TAS_POSX"]);
            $nextActivityBouY = (int)($arrayTaskData["TAS_POSY"]);
            $nextActivityBouWidth  = (int)($arrayTaskData["TAS_WIDTH"]);
            $nextActivityBouHeight = (int)($arrayTaskData["TAS_HEIGHT"]);

            $result = $this->bp->getGatewayByDirectionActivityAndFlow("CONVERGING", $nextActivityUid);

            if (!is_array($result)) {
                $criteria = new \Criteria("workflow");

                $criteria->addSelectColumn(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN . " AS GAT_UID");

                $criteria->add(\BpmnFlowPeer::PRJ_UID, $this->bp->getUid(), \Criteria::EQUAL);
                $criteria->add(\BpmnFlowPeer::FLO_TYPE, "SEQUENCE", \Criteria::EQUAL);
                $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE, "bpmnGateway", \Criteria::EQUAL);
                $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_DEST, $activityUid, \Criteria::EQUAL);
                $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_DEST_TYPE, "bpmnActivity", \Criteria::EQUAL);

                $rsCriteria = \BpmnFlowPeer::doSelectRS($criteria);
                $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);

                $gatewayParentUid = "";

                if ($rsCriteria->next()) {
                    $row = $rsCriteria->getRow();

                    $gatewayParentUid = $row["GAT_UID"];
                } else {
                    throw new \Exception(\G::LoadTranslation("ID_ROUTE_PARENT_DOES_NOT_EXIST_FOR_ROUTE_SECJOIN"));
                }

                $arrayGatewayData = $this->bp->getGateway2($gatewayParentUid);

                $gatewayParentType = $arrayGatewayData["GAT_TYPE"];

                $gatewayUid = $this->routeToBpmnGateway(
                    "bpmnActivity",
                    $nextActivityUid,
                    $nextActivityBouX,
                    $nextActivityBouY,
                    $nextActivityBouWidth,
                    $nextActivityBouHeight,
                    "",
                    $gatewayParentType,
                    "CONVERGING"
                );

                $arrayGatewayData = $this->bp->getGateway2($gatewayUid);
            } else {
                $arrayGatewayData = $result;
            }

            $gatewayUid  = $arrayGatewayData["GAT_UID"];
            $gatewayType = $arrayGatewayData["GAT_TYPE"];
            $gatewayBouX = $arrayGatewayData["BOU_X"];
            $gatewayBouY = $arrayGatewayData["BOU_Y"];
            $gatewayBouWidth  = $arrayGatewayData["BOU_WIDTH"];
            $gatewayBouHeight = $arrayGatewayData["BOU_HEIGHT"];

            $flowUid = $this->routeToBpmnFlow(
                "bpmnActivity",
                $activityUid,
                $activityBouX,
                $activityBouY,
                $activityBouWidth,
                $activityBouHeight,
                "bpmnGateway",
                $gatewayUid,
                $gatewayBouX,
                $gatewayBouY,
                $gatewayBouWidth,
                $gatewayBouHeight
            );

            //Return
            return $result;
        } catch (\Exception $e) {
            $this->removeRouteFromTo($taskUid, $nextTaskUid);

            throw $e;
        }
    }
Beispiel #5
0
 public function reOrderFlowPosition ($sFloOrigin, $iPosition)
 {
     try {
         $con = \Propel::getConnection('workflow');
         $oCriteria = new Criteria( 'workflow' );
         $oCriteria->add( \BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $sFloOrigin );
         $oCriteria->add( \BpmnFlowPeer::FLO_POSITION, $iPosition, '>' );
         $oDataset = \BpmnFlowPeer::doSelectRS( $oCriteria );
         $oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
         while ($oDataset->next()) {
             $aRow = $oDataset->getRow();
             $newPosition = ((int)$aRow['FLO_POSITION'])-1;
             $oCriteriaTemp = new Criteria( 'workflow' );
             $oCriteriaTemp->add( \BpmnFlowPeer::FLO_UID, $aRow['FLO_UID'] );
             $oCriteria2 = new Criteria('workflow');
             $oCriteria2->add(\BpmnFlowPeer::FLO_POSITION, $newPosition);
             BasePeer::doUpdate($oCriteriaTemp, $oCriteria2, $con);
         }
     } catch (Exception $oException) {
         throw $oException;
     }
 }
 /**
  * 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 = BpmnFlowPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setFloUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setPrjUid($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setDiaUid($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setFloType($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setFloName($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setFloElementOrigin($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setFloElementOriginType($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setFloElementOriginPort($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setFloElementDest($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setFloElementDestType($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setFloElementDestPort($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setFloIsInmediate($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setFloCondition($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setFloX1($arr[$keys[13]]);
     }
     if (array_key_exists($keys[14], $arr)) {
         $this->setFloY1($arr[$keys[14]]);
     }
     if (array_key_exists($keys[15], $arr)) {
         $this->setFloX2($arr[$keys[15]]);
     }
     if (array_key_exists($keys[16], $arr)) {
         $this->setFloY2($arr[$keys[16]]);
     }
     if (array_key_exists($keys[17], $arr)) {
         $this->setFloState($arr[$keys[17]]);
     }
     if (array_key_exists($keys[18], $arr)) {
         $this->setFloPosition($arr[$keys[18]]);
     }
 }
 /**
  * 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;
     }
 }
Beispiel #8
0
 public function updateRouteOrderFromProject($prjUid)
 {
     $accountsArray = array();
     $criteria = new \Criteria("workflow");
     $criteria->clearSelectColumns();
     $criteria->addSelectColumn(\BpmnFlowPeer::FLO_POSITION);
     $criteria->addSelectColumn(\BpmnFlowPeer::FLO_ELEMENT_DEST);
     $criteria->addSelectColumn(\BpmnFlowPeer::PRJ_UID);
     $criteria->addSelectColumn(\BpmnFlowPeer::FLO_TYPE);
     $criteria->add(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN_TYPE, 'bpmnGateway');
     $criteria->add(\BpmnFlowPeer::PRJ_UID, $prjUid);
     $criteria->addAscendingOrderByColumn(BpmnFlowPeer::FLO_POSITION);
     $result = \BpmnFlowPeer::doSelectRS($criteria);
     $result->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
     $result->next();
     $j = 0;
     $k = 1;
     while ($aRow = $result->getRow()) {
         $accountsArray[$j]['PRO_UID'] = $aRow['PRJ_UID'];
         $accountsArray[$j]['ROU_NEXT_TASK'] = $aRow['FLO_ELEMENT_DEST'];
         $accountsArray[$j]['ROU_CASE'] = $k++;
         $result->next();
         $j++;
     }
     if (sizeof($accountsArray)) {
         $this->updateRouteOrder($accountsArray);
     }
 }
 /**
  * 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(BpmnFlowPeer::FLO_UID, $pks, Criteria::IN);
         $objs = BpmnFlowPeer::doSelect($criteria, $con);
     }
     return $objs;
 }