Example #1
0
 private function setBoundDefaults()
 {
     $this->bound->setBouElementType(lcfirst(str_replace(__NAMESPACE__, '', __CLASS__)));
     $this->bound->setPrjUid($this->getPrjUid());
     $this->bound->setElementUid($this->getLanUid());
     $project = BpmnProjectPeer::retrieveByPK($this->getPrjUid());
     if (is_object($project)) {
         $criteria = new Criteria('workflow');
         $criteria->addSelectColumn(BpmnProcessPeer::DIA_UID);
         $criteria->add(BpmnProcessPeer::PRJ_UID, $this->getPrjUid(), \Criteria::EQUAL);
         $rsCriteria = BpmnProcessPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
         $rsCriteria->next();
         $row = $rsCriteria->getRow();
         $this->bound->setDiaUid($row["DIA_UID"]);
         $this->bound->setBouContainer('bpmnPool');
         $this->bound->setBouElement($this->getLnsUid());
     }
 }
 /**
  * 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(BpmnProjectPeer::PRJ_UID, $pks, Criteria::IN);
         $objs = BpmnProjectPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * 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 = BpmnProjectPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setPrjUid($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setPrjName($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setPrjDescription($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setPrjTargetNamespace($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setPrjExpresionLanguage($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setPrjTypeLanguage($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setPrjExporter($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setPrjExporterVersion($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setPrjCreateDate($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setPrjUpdateDate($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setPrjAuthor($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setPrjAuthorVersion($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setPrjOriginalSource($arr[$keys[12]]);
     }
 }
 /**
  * Selects a collection of BpmnEvent objects pre-filled with all related objects except BpmnProcess.
  *
  * @return     array Array of BpmnEvent objects.
  * @throws     PropelException Any exceptions caught during processing will be
  *       rethrown wrapped into a PropelException.
  */
 public static function doSelectJoinAllExceptBpmnProcess(Criteria $c, $con = null)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     BpmnEventPeer::addSelectColumns($c);
     $startcol2 = BpmnEventPeer::NUM_COLUMNS - BpmnEventPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     BpmnProjectPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + BpmnProjectPeer::NUM_COLUMNS;
     $c->addJoin(BpmnEventPeer::PRJ_UID, BpmnProjectPeer::PRJ_UID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = BpmnEventPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = BpmnProjectPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getBpmnProject();
             //CHECKME
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addBpmnEvent($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initBpmnEvents();
             $obj2->addBpmnEvent($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }
Example #5
0
    public function generateBpmn($processUid, $processUidFieldNameForException, $userUid = "")
    {
        $bpmnProjectUid = "";

        try {
            //Verify data
            $obj = \ProcessPeer::retrieveByPK($processUid);

            if (is_null($obj)) {
                throw new \Exception(\G::LoadTranslation("ID_PROCESS_DOES_NOT_EXIST", array($processUidFieldNameForException, $processUid)));
            }

            //Verify data
            $criteria = new \Criteria("workflow");

            $criteria->addSelectColumn(\BpmnProjectPeer::PRJ_UID);
            $criteria->add(\BpmnProjectPeer::PRJ_UID, $processUid, \Criteria::EQUAL);

            $rsCriteria = \BpmnProjectPeer::doSelectRS($criteria);

            if ($rsCriteria->next()) {
                throw new \Exception(\G::LoadTranslation("ID_PROJECT_IS_BPMN", array($processUidFieldNameForException, $processUid)));
            }

            //Set data
            $processUidBk = $processUid;

            list($arrayWorkflowData, $arrayWorkflowFile) = $this->getData($processUid); //Get workflow data

            $arrayWorkflowData["process"] = $arrayWorkflowData["process"][0];

            $arrayWorkflowData["groupwfs"] = array();

            //Create WorkflowBpmn
            $arrayUid  = array();
            $arrayUid2 = array();

            //Process
            $arrayProcessData = $arrayWorkflowData["process"];

            unset(
                $arrayProcessData["PRO_UID"],
                $arrayProcessData["PRO_UPDATE_DATE"]
            );

            $arrayProcessData["PRO_PARENT"] = $processUidBk;
            $arrayProcessData["PRO_TITLE"]  = $arrayProcessData["PRO_TITLE"] . " - New version - " . date("M d, H:i:s");
            $arrayProcessData["PRO_CREATE_USER"] = ($userUid != "")? $userUid : "00000000000000000000000000000001";

            $this->create($arrayProcessData);

            $processUid = $this->getUid();

            $bpmnProjectUid = $processUid;

            //Task
            foreach ($arrayWorkflowData["tasks"] as $value) {
                $arrayTaskData = $value;

                $taskUidOld = $arrayTaskData["TAS_UID"];

                //Add
                unset($arrayTaskData["TAS_UID"]);

                $taskUid = $this->addTask($arrayTaskData);

                //Add new UID
                $arrayUid["task"][$taskUidOld] = $taskUid;

                $arrayUid2[] = array(
                    "old_uid" => $taskUidOld,
                    "new_uid" => $taskUid
                );
            }

            //$arrayWorkflowData["tasks"] = array();

            //Route
            $arrayRouteSecJoin = array();

            foreach ($arrayWorkflowData["routes"] as $value) {
                $arrayRouteData = $value;

                $arrayRouteData["TAS_UID"] = $arrayUid["task"][$arrayRouteData["TAS_UID"]];
                $arrayRouteData["ROU_NEXT_TASK"] = ($arrayRouteData["ROU_NEXT_TASK"] != "-1")? $arrayUid["task"][$arrayRouteData["ROU_NEXT_TASK"]] : $arrayRouteData["ROU_NEXT_TASK"];

                if ($arrayRouteData["ROU_TYPE"] != "SEC-JOIN") {
                    //Add
                    $result = $this->addRoute($arrayRouteData["TAS_UID"], $arrayRouteData["ROU_NEXT_TASK"], $arrayRouteData["ROU_TYPE"], $arrayRouteData["ROU_CONDITION"]);
                } else {
                    $arrayRouteSecJoin[] = $arrayRouteData;
                }
            }

            $arrayWorkflowData["routes"] = array();

            //Route SEC-JOIN
            foreach ($arrayRouteSecJoin as $value) {
                $arrayRouteData = $value;

                $result = $this->addRouteSecJoin($arrayRouteData["TAS_UID"], $arrayRouteData["ROU_NEXT_TASK"]);
            }

            //Lane
            foreach ($arrayWorkflowData["lanes"] as $value) {
                $arrayLaneData = $value;

                $swiX = (int)($arrayLaneData["SWI_X"]);
                $swiY = (int)($arrayLaneData["SWI_Y"]);

                switch ($arrayLaneData["SWI_TYPE"]) {
                    case "TEXT":
                        $swiUid = $this->addText($arrayLaneData["SWI_TEXT"], $swiX, $swiY);
                        break;
                    case "LINE":
                        $direction = (($swiX == 0)? "HORIZONTAL" : "VERTICAL");

                        $swiUid = $this->addLine(($direction == "HORIZONTAL")? $swiY : $swiX, $direction);
                        break;
                }
            }

            $arrayWorkflowData["lanes"] = array();

            //Data
            $arrayUid2 = array_merge(
                array(
                    array(
                        "old_uid" => $processUidBk,
                        "new_uid" => $processUid
                    )
                ),
                $arrayUid2
            );

            list($arrayWorkflowData, $arrayWorkflowFile) = $this->updateDataUidByArrayUid($arrayWorkflowData, $arrayWorkflowFile, $arrayUid2);

            $arrayWorkflowData["tasks"] = array();

            $this->createDataByArrayData($arrayWorkflowData);
            $this->createDataFileByArrayFile($arrayWorkflowFile);

            //Return
            return $bpmnProjectUid;
        } catch (\Exception $e) {
            if ($bpmnProjectUid != "") {
                $this->remove();
            }

            throw $e;
        }
    }
 /**
  * Get the associated BpmnProject object
  *
  * @param      Connection Optional Connection object.
  * @return     BpmnProject The associated BpmnProject object.
  * @throws     PropelException
  */
 public function getBpmnProject($con = null)
 {
     // include the related Peer class
     include_once 'classes/model/om/BaseBpmnProjectPeer.php';
     if ($this->aBpmnProject === null && ($this->prj_uid !== "" && $this->prj_uid !== null)) {
         $this->aBpmnProject = BpmnProjectPeer::retrieveByPK($this->prj_uid, $con);
         /* The following can be used instead of the line above to
              guarantee the related object contains a reference
              to this object, but this level of coupling
              may be undesirable in many circumstances.
              As it can lead to a db query with many results that may
              never be used.
              $obj = BpmnProjectPeer::retrieveByPK($this->prj_uid, $con);
              $obj->addBpmnProjects($this);
            */
     }
     return $this->aBpmnProject;
 }
Example #7
0
    /**
     * Process-Files upgrade
     *
     * @param string $projectUid Unique id of Project
     *
     * return void
     */
    public function processFilesUpgrade($projectUid = "")
    {
        try {
            //Set variables
            $conf = new \Configuration();

            //Create/Get PROCESS_FILES_CHECKED
            $arrayProjectUid = array();

            $configuration = \ConfigurationPeer::retrieveByPK("PROCESS_FILES_CHECKED", "", "", "", "");

            if (is_null($configuration)) {
                $result = $conf->create(array(
                    "CFG_UID"   => "PROCESS_FILES_CHECKED",
                    "OBJ_UID"   => "",
                    "CFG_VALUE" => serialize($arrayProjectUid),
                    "PRO_UID"   => "",
                    "USR_UID"   => "",
                    "APP_UID"   => ""
                ));
            } else {
                $arrayProjectUid = unserialize($configuration->getCfgValue());
            }

            //Set variables
            $arrayPath = array("templates" => PATH_DATA_MAILTEMPLATES, "public" => PATH_DATA_PUBLIC);
            $flagProjectUid = false;

            //Query
            $criteria = new \Criteria("workflow");

            $criteria->addSelectColumn(\BpmnProjectPeer::PRJ_UID);

            if ($projectUid != "") {
                $criteria->add(
                    $criteria->getNewCriterion(\BpmnProjectPeer::PRJ_UID, $arrayProjectUid, \Criteria::NOT_IN)->addAnd(
                    $criteria->getNewCriterion(\BpmnProjectPeer::PRJ_UID, $projectUid, \Criteria::EQUAL))
                );
            } else {
                $criteria->add(\BpmnProjectPeer::PRJ_UID, $arrayProjectUid, \Criteria::NOT_IN);
            }

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

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

                foreach ($arrayPath as $key => $value) {
                    $path = $key;
                    $dir  = $value . $row["PRJ_UID"];

                    if (is_dir($dir)) {
                        if ($dirh = opendir($dir)) {
                            while (($file = readdir($dirh)) !== false) {
                                if ($file != "" && $file != "." && $file != "..") {
                                    $f = $dir . PATH_SEP . $file;

                                    if (is_file($f)) {
                                        $arrayProcessFilesData = $this->getFileManagerUid($f);

                                        if (is_null($arrayProcessFilesData["PRF_UID"])) {
                                            rename($dir . PATH_SEP . $file, $dir . PATH_SEP . $file . ".tmp");

                                            $arrayData = array(
                                                "prf_path"     => $path,
                                                "prf_filename" => $file,
                                                "prf_content"  => ""
                                            );

                                            $arrayData = $this->addProcessFilesManager($row["PRJ_UID"], "00000000000000000000000000000001", $arrayData);

                                            rename($dir . PATH_SEP . $file . ".tmp", $dir . PATH_SEP . $file);
                                        }
                                    }
                                }
                            }

                            closedir($dirh);
                        }
                    }
                }

                $arrayProjectUid[$row["PRJ_UID"]] = $row["PRJ_UID"];
                $flagProjectUid = true;
            }

            //Update PROCESS_FILES_CHECKED
            if ($flagProjectUid) {
                $result = $conf->update(array(
                    "CFG_UID"   => "PROCESS_FILES_CHECKED",
                    "OBJ_UID"   => "",
                    "CFG_VALUE" => serialize($arrayProjectUid),
                    "PRO_UID"   => "",
                    "USR_UID"   => "",
                    "APP_UID"   => ""
                ));
            }
        } catch (\Exception $e) {
            throw $e;
        }
    }
Example #8
0
    /**
     * Verify if the project already exists
     * @return mixed
     */
    public function targetExists()
    {
        $prjUid = $this->importData["tables"]["bpmn"]["project"][0]["prj_uid"];

        $bpmnProject = \BpmnProjectPeer::retrieveByPK($prjUid);

        return is_object($bpmnProject);
    }
Example #9
0
    public static function removeIfExists($prjUid)
    {
        $project = ProjectPeer::retrieveByPK($prjUid);

        if ($project) {
            $me = new self();
            $me->prjUid = $project->getPrjUid();
            $me->project = $project;
            $me->remove();
        }
    }
Example #10
0
 public static function exists($prjUid)
 {
     $c = new Criteria("workflow");
     $c->add(BpmnProjectPeer::PRJ_UID, $prjUid);
     return BpmnProjectPeer::doCount($c) > 0;
 }
Example #11
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;
 }