public function addText($text, $x, $y) { try { //Line $swiUid = parent::addText($text, $x, $y); //BPMN //Artifact $arrayData = array( "ART_UID" => $swiUid, "ART_TYPE" => "TEXT_ANNOTATION", "ART_NAME" => $text, "BOU_X" => $x, "BOU_Y" => $y, "BOU_WIDTH" => 100, "BOU_HEIGHT" => 30 ); $artifactUid = $this->bp->addArtifact($arrayData); //Return return $swiUid; } catch (\Exception $e) { throw $e; } }
public function doImport($generateUid = true) { $arrayBpmnTables = $this->importData["tables"]["bpmn"]; $arrayWorkflowTables = $this->importData["tables"]["workflow"]; $arrayWorkflowFiles = $this->importData["files"]["workflow"]; //Import BPMN tables $result = $this->importBpmnTables($arrayBpmnTables, $generateUid); $projectUidOld = $arrayBpmnTables["project"][0]["prj_uid"]; $projectUid = ($generateUid)? $result[0]["new_uid"] : $result; //Import workflow tables if ($generateUid) { $result[0]["object"] = "project"; $result[0]["old_uid"] = $projectUidOld; $result[0]["new_uid"] = $projectUid; $workflow = new \ProcessMaker\Project\Workflow(); list($arrayWorkflowTables, $arrayWorkflowFiles) = $workflow->updateDataUidByArrayUid($arrayWorkflowTables, $arrayWorkflowFiles, $result); } $this->importWfTables($arrayWorkflowTables); //Import workflow files $this->importWfFiles($arrayWorkflowFiles); //Update $workflow = \ProcessMaker\Project\Workflow::load($projectUid); foreach ($arrayWorkflowTables["tasks"] as $key => $value) { $arrayTaskData = $value; if (!in_array($arrayTaskData["TAS_TYPE"], array("GATEWAYTOGATEWAY", "WEBENTRYEVENT", "END-MESSAGE-EVENT", "START-MESSAGE-EVENT", "INTERMEDIATE-THROW-MESSAGE-EVENT", "INTERMEDIATE-CATCH-MESSAGE-EVENT", "START-TIMER-EVENT", "INTERMEDIATE-CATCH-TIMER-EVENT", "END-EMAIL-EVENT", "INTERMEDIATE-EMAIL-EVENT"))) { $result = $workflow->updateTask($arrayTaskData["TAS_UID"], $arrayTaskData); } } unset($arrayWorkflowTables["process"]["PRO_CREATE_USER"]); unset($arrayWorkflowTables["process"]["PRO_CREATE_DATE"]); unset($arrayWorkflowTables["process"]["PRO_UPDATE_DATE"]); $workflow->update($arrayWorkflowTables["process"]); //Process-Files upgrade $filesManager = new \ProcessMaker\BusinessModel\FilesManager(); $filesManager->processFilesUpgrade($projectUid); //Return return $projectUid; }
public function setDisabled($value = true) { parent::setDisabled($value); $this->wp->setDisabled($value); }
/** * Update WebEntry-Event * * @param string $webEntryEventUid Unique id of WebEntry-Event * @param string $userUidUpdater Unique id of updater User * @param array $arrayData Data * * return array Return data of the WebEntry-Event updated */ public function update($webEntryEventUid, $userUidUpdater, array $arrayData) { try { //Verify data $process = new \ProcessMaker\BusinessModel\Process(); $validator = new \ProcessMaker\BusinessModel\Validator(); $validator->throwExceptionIfDataIsNotArray($arrayData, "\$arrayData"); $validator->throwExceptionIfDataIsEmpty($arrayData, "\$arrayData"); //Set data $arrayData = array_change_key_case($arrayData, CASE_UPPER); $arrayDataBackup = $arrayData; unset($arrayData["WEE_UID"]); unset($arrayData["PRJ_UID"]); unset($arrayData["WEE_WE_UID"]); unset($arrayData["WEE_WE_TAS_UID"]); //Set variables $arrayWebEntryEventData = $this->getWebEntryEvent($webEntryEventUid, true); $arrayFinalData = array_merge($arrayWebEntryEventData, $arrayData); //Verify data $this->throwExceptionIfNotExistsWebEntryEvent($webEntryEventUid, $this->arrayFieldNameForException["webEntryEventUid"]); $this->throwExceptionIfDataIsInvalid($webEntryEventUid, $arrayWebEntryEventData["PRJ_UID"], $arrayData); //Update $cnn = \Propel::getConnection("workflow"); $this->webEntryEventWebEntryUid = ""; $this->webEntryEventWebEntryTaskUid = ""; try { //WebEntry $option = "UPDATE"; if (isset($arrayData["WEE_STATUS"])) { if ($arrayData["WEE_STATUS"] == "ENABLED") { if ($arrayWebEntryEventData["WEE_STATUS"] == "DISABLED") { $option = "INSERT"; } } else { if ($arrayWebEntryEventData["WEE_STATUS"] == "ENABLED") { $option = "DELETE"; } } } switch ($option) { case "INSERT": $this->createWebEntry($arrayFinalData["PRJ_UID"], $arrayFinalData["EVN_UID"], $arrayFinalData["ACT_UID"], $arrayFinalData["DYN_UID"], $arrayFinalData["USR_UID"], $arrayFinalData["WEE_TITLE"], $arrayFinalData["WEE_DESCRIPTION"], $userUidUpdater); $arrayData["WEE_WE_UID"] = $this->webEntryEventWebEntryUid; $arrayData["WEE_WE_TAS_UID"] = $this->webEntryEventWebEntryTaskUid; break; case "UPDATE": if ($arrayWebEntryEventData["WEE_WE_UID"] != "") { $task = new \Tasks(); //Task - Step if (isset($arrayData["DYN_UID"]) && $arrayData["DYN_UID"] != $arrayWebEntryEventData["DYN_UID"]) { //Delete $step = new \Step(); $criteria = new \Criteria("workflow"); $criteria->add(\StepPeer::TAS_UID, $arrayWebEntryEventData["WEE_WE_TAS_UID"]); $rsCriteria = \StepPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $result = $step->remove($row["STEP_UID"]); } //Add $step = new \Step(); $stepUid = $step->create(array("PRO_UID" => $arrayWebEntryEventData["PRJ_UID"], "TAS_UID" => $arrayWebEntryEventData["WEE_WE_TAS_UID"])); $result = $step->update(array("STEP_UID" => $stepUid, "STEP_TYPE_OBJ" => "DYNAFORM", "STEP_UID_OBJ" => $arrayData["DYN_UID"], "STEP_POSITION" => 1, "STEP_MODE" => "EDIT")); } //Task - User if (isset($arrayData["USR_UID"]) && $arrayData["USR_UID"] != $arrayWebEntryEventData["USR_UID"]) { //Unassign $taskUser = new \TaskUser(); $criteria = new \Criteria("workflow"); $criteria->add(\TaskUserPeer::TAS_UID, $arrayWebEntryEventData["WEE_WE_TAS_UID"]); $rsCriteria = \TaskUserPeer::doSelectRS($criteria); $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); $result = $taskUser->remove($row["TAS_UID"], $row["USR_UID"], $row["TU_TYPE"], $row["TU_RELATION"]); } //Assign $result = $task->assignUser($arrayWebEntryEventData["WEE_WE_TAS_UID"], $arrayData["USR_UID"], 1); } //Route if (isset($arrayData["ACT_UID"]) && $arrayData["ACT_UID"] != $arrayWebEntryEventData["ACT_UID"]) { //Delete $result = $task->deleteAllRoutesOfTask($arrayWebEntryEventData["PRJ_UID"], $arrayWebEntryEventData["WEE_WE_TAS_UID"], true); //Add $workflow = \ProcessMaker\Project\Workflow::load($arrayWebEntryEventData["PRJ_UID"]); $result = $workflow->addRoute($arrayWebEntryEventData["WEE_WE_TAS_UID"], $arrayData["ACT_UID"], "SEQUENTIAL"); } //WebEntry $arrayDataAux = array(); if (isset($arrayData["DYN_UID"])) { $arrayDataAux["DYN_UID"] = $arrayData["DYN_UID"]; } if (isset($arrayData["USR_UID"])) { $arrayDataAux["USR_UID"] = $arrayData["USR_UID"]; } if (isset($arrayData["WEE_TITLE"])) { $arrayDataAux["WE_TITLE"] = $arrayData["WEE_TITLE"]; } if (isset($arrayData["WEE_DESCRIPTION"])) { $arrayDataAux["WE_DESCRIPTION"] = $arrayData["WEE_DESCRIPTION"]; } if (count($arrayDataAux) > 0) { $arrayDataAux = $this->webEntry->update($arrayWebEntryEventData["WEE_WE_UID"], $userUidUpdater, $arrayDataAux); } } break; case "DELETE": $this->deleteWebEntry($arrayWebEntryEventData["WEE_WE_UID"], $arrayWebEntryEventData["WEE_WE_TAS_UID"]); $arrayData["WEE_WE_UID"] = ""; $arrayData["WEE_WE_TAS_UID"] = ""; break; } //WebEntry-Event $webEntryEvent = \WebEntryEventPeer::retrieveByPK($webEntryEventUid); $webEntryEvent->fromArray($arrayData, \BasePeer::TYPE_FIELDNAME); if ($webEntryEvent->validate()) { $cnn->begin(); $result = $webEntryEvent->save(); $cnn->commit(); //Set WEE_TITLE if (isset($arrayData["WEE_TITLE"])) { $result = \Content::addContent("WEE_TITLE", "", $webEntryEventUid, SYS_LANG, $arrayData["WEE_TITLE"]); } //Set WEE_DESCRIPTION if (isset($arrayData["WEE_DESCRIPTION"])) { $result = \Content::addContent("WEE_DESCRIPTION", "", $webEntryEventUid, SYS_LANG, $arrayData["WEE_DESCRIPTION"]); } //Return $arrayData = $arrayDataBackup; if (!$this->formatFieldNameInUppercase) { $arrayData = array_change_key_case($arrayData, CASE_LOWER); } return $arrayData; } else { $msg = ""; foreach ($webEntryEvent->getValidationFailures() as $validationFailure) { $msg = $msg . ($msg != "" ? "\n" : "") . $validationFailure->getMessage(); } throw new \Exception(\G::LoadTranslation("ID_REGISTRY_CANNOT_BE_UPDATED") . ($msg != "" ? "\n" . $msg : "")); } } catch (\Exception $e) { $cnn->rollback(); $this->deleteWebEntry($this->webEntryEventWebEntryUid, $this->webEntryEventWebEntryTaskUid); throw $e; } } catch (\Exception $e) { throw $e; } }