Exemple #1
0
 /**
  * Get all Steps of a Task
  *
  * @param string $taskUid Unique id of Task
  *
  * return array Return an array with all Steps of a Task
  */
 public function getSteps($taskUid)
 {
     try {
         $arrayStep = array();
         $step = new \ProcessMaker\BusinessModel\Step();
         $step->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase);
         $step->setArrayParamException($this->arrayParamException);
         //Verify data
         $this->throwExceptionIfNotExistsTask("", $taskUid, $this->arrayParamException["taskUid"]);
         //Get data
         $criteria = new \Criteria("workflow");
         $criteria->add(\StepPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
         $criteria->addAscendingOrderByColumn(\StepPeer::STEP_POSITION);
         $rsCriteria = \StepPeer::doSelectRS($criteria);
         $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
         while ($rsCriteria->next()) {
             $row = $rsCriteria->getRow();
             $arrayData = $step->getStep($row["STEP_UID"]);
             if (count($arrayData) > 0) {
                 $arrayStep[] = $arrayData;
             }
         }
         //Return
         return $arrayStep;
     } catch (\Exception $e) {
         throw $e;
     }
 }
Exemple #2
0
    /**
     * Execute Trigger case
     *
     * @param string $prj_uid  {@min 1}{@max 32}
     * @param string $act_uid  {@min 1}{@max 32}
     * @param string $cas_uid  {@min 1}{@max 32}
     * @param string $step_uid {@min 32}{@max 32}
     * @param string $type     {@choice before,after}
     *
     * @copyright Colosa - Bolivia
     *
     * @url POST /process/:prj_uid/task/:act_uid/case/:cas_uid/step/:step_uid/execute-trigger/:type
     */
    public function doPutExecuteTriggerCase($prj_uid, $act_uid, $cas_uid, $step_uid, $type)
    {
        try {
            $userUid = $this->getUserId();
            $step = new \ProcessMaker\Services\Api\Project\Activity\Step();
            $triggers= $step->doGetActivityStepTriggers($step_uid, $act_uid, $prj_uid);

            $step = new \ProcessMaker\BusinessModel\Step();
            $step->setFormatFieldNameInUppercase(false);
            $step->setArrayParamException(array("stepUid" => "step_uid", "taskUid" => "act_uid", "processUid" => "prj_uid"));

            $cases = new \ProcessMaker\BusinessModel\Cases();
            foreach($triggers as $trigger){
                if (strtolower($trigger['st_type']) == $type) {
                    $cases->putExecuteTriggerCase($cas_uid, $trigger['tri_uid'], $userUid);
                }
            }
        } catch (\Exception $e) {
            throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
        }
    }
 /**
  * Update Case Tracker Object
  *
  * @param string $caseTrackerObjectUid Unique id of Case Tracker Object
  * @param array  $arrayData Data
  *
  * return array Return data of the Case Tracker Object updated
  */
 public function update($caseTrackerObjectUid, $arrayData)
 {
     try {
         $arrayData = array_change_key_case($arrayData, CASE_UPPER);
         $caseTrackerObject = new \CaseTrackerObject();
         $arrayCaseTrackerObjectData = $caseTrackerObject->load($caseTrackerObjectUid);
         //Uids
         $processUid = $arrayCaseTrackerObjectData["PRO_UID"];
         //Verify data
         if (!$caseTrackerObject->caseTrackerObjectExists($caseTrackerObjectUid)) {
             throw new \Exception(\G::LoadTranslation("ID_CASE_TRACKER_OBJECT_DOES_NOT_EXIST", array(strtolower("CTO_UID"), $caseTrackerObjectUid)));
         }
         if (isset($arrayData["CTO_TYPE_OBJ"]) && !isset($arrayData["CTO_UID_OBJ"])) {
             throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array(strtolower("CTO_UID_OBJ"))));
         }
         if (!isset($arrayData["CTO_TYPE_OBJ"]) && isset($arrayData["CTO_UID_OBJ"])) {
             throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array(strtolower("CTO_TYPE_OBJ"))));
         }
         if (isset($arrayData["CTO_TYPE_OBJ"]) && isset($arrayData["CTO_UID_OBJ"])) {
             $step = new \ProcessMaker\BusinessModel\Step();
             $msg = $step->existsObjectUid($arrayData["CTO_TYPE_OBJ"], $arrayData["CTO_UID_OBJ"], strtolower("CTO_UID_OBJ"));
             if ($msg != "") {
                 throw new \Exception($msg);
             }
             if ($this->existsRecord($processUid, $arrayData["CTO_TYPE_OBJ"], $arrayData["CTO_UID_OBJ"], 0, $caseTrackerObjectUid)) {
                 throw new \Exception(\G::LoadTranslation("ID_RECORD_EXISTS_IN_TABLE", array($processUid . ", " . $arrayData["CTO_TYPE_OBJ"] . ", " . $arrayData["CTO_UID_OBJ"], "CASE_TRACKER_OBJECT")));
             }
         }
         //Flags
         $flagDataOject = isset($arrayData["CTO_TYPE_OBJ"]) && isset($arrayData["CTO_UID_OBJ"]) ? 1 : 0;
         $flagDataCondition = isset($arrayData["CTO_CONDITION"]) ? 1 : 0;
         $flagDataPosition = isset($arrayData["CTO_POSITION"]) ? 1 : 0;
         //Update
         $tempPosition = isset($arrayData["CTO_POSITION"]) ? $arrayData["CTO_POSITION"] : $arrayCaseTrackerObjectData["CTO_POSITION"];
         $arrayData["CTO_POSITION"] = $arrayCaseTrackerObjectData["CTO_POSITION"];
         $arrayData["CTO_UID"] = $caseTrackerObjectUid;
         $arrayData = array_merge($arrayCaseTrackerObjectData, $arrayData);
         $caseTrackerObject->update($arrayData);
         if ($tempPosition != $arrayCaseTrackerObjectData["CTO_POSITION"]) {
             $this->moveCaseTrackerObject($caseTrackerObjectUid, $arrayData['PRO_UID'], $tempPosition);
         }
         //Return
         unset($arrayData["CTO_UID"]);
         if ($flagDataOject == 0) {
             unset($arrayData["CTO_TYPE_OBJ"]);
             unset($arrayData["CTO_UID_OBJ"]);
         }
         if ($flagDataCondition == 0) {
             unset($arrayData["CTO_CONDITION"]);
         }
         if ($flagDataPosition == 0) {
             unset($arrayData["CTO_POSITION"]);
         }
         unset($arrayData["PRO_UID"]);
         return array_change_key_case($arrayData, CASE_LOWER);
     } catch (\Exception $e) {
         throw $e;
     }
 }
Exemple #4
0
 /**
  * Validate the data if they are invalid (INSERT and UPDATE)
  *
  * @param string $webEntryUid Unique id of Web Entry
  * @param string $processUid  Unique id of Process
  * @param array  $arrayData   Data
  *
  * return void Throw exception if data has an invalid value
  */
 public function throwExceptionIfDataIsInvalid($webEntryUid, $processUid, array $arrayData)
 {
     try {
         //Set variables
         $arrayWebEntryData = $webEntryUid == "" ? array() : $this->getWebEntry($webEntryUid, true);
         $flagInsert = $webEntryUid == "" ? true : false;
         $arrayDataMain = array_merge($arrayWebEntryData, $arrayData);
         //Verify data - Field definition
         $process = new \ProcessMaker\BusinessModel\Process();
         $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
         if ($arrayDataMain["WE_METHOD"] == "WS") {
             $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayUserFieldDefinition, $this->arrayFieldNameForException, $flagInsert);
         }
         //Verify data
         if (isset($arrayData["WE_TITLE"])) {
             $this->throwExceptionIfExistsTitle($processUid, $arrayData["WE_TITLE"], $this->arrayFieldNameForException["webEntryTitle"], $webEntryUid);
         }
         if (isset($arrayData["TAS_UID"])) {
             $task = new \ProcessMaker\BusinessModel\Task();
             $task->throwExceptionIfNotExistsTask($processUid, $arrayData["TAS_UID"], $this->arrayFieldNameForException["taskUid"]);
         }
         if (isset($arrayData["DYN_UID"])) {
             $dynaForm = new \ProcessMaker\BusinessModel\DynaForm();
             $dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $processUid, $this->arrayFieldNameForException["dynaFormUid"]);
         }
         if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["USR_UID"])) {
             $process->throwExceptionIfNotExistsUser($arrayData["USR_UID"], $this->arrayFieldNameForException["userUid"]);
         }
         $task = new \Task();
         $arrayTaskData = $task->load($arrayDataMain["TAS_UID"]);
         if (isset($arrayData["TAS_UID"])) {
             if ($arrayTaskData["TAS_START"] == "FALSE") {
                 throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_IS_NOT_INITIAL_ACTIVITY", array($arrayTaskData["TAS_TITLE"])));
             }
             if ($arrayTaskData["TAS_ASSIGN_TYPE"] != "BALANCED") {
                 throw new \Exception(\G::LoadTranslation("ID_WEB_ENTRY_ACTIVITY_DOES_NOT_HAVE_VALID_ASSIGNMENT_TYPE", array($arrayTaskData["TAS_TITLE"])));
             }
         }
         if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["TAS_UID"])) {
             $task = new \Tasks();
             if ($task->assignUsertoTask($arrayData["TAS_UID"]) == 0) {
                 throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_DOES_NOT_HAVE_USERS", array($arrayTaskData["TAS_TITLE"])));
             }
         }
         if (isset($arrayData["DYN_UID"])) {
             $dynaForm = new \Dynaform();
             $arrayDynaFormData = $dynaForm->Load($arrayData["DYN_UID"]);
             $step = new \ProcessMaker\BusinessModel\Step();
             if (!$step->existsRecord($arrayDataMain["TAS_UID"], "DYNAFORM", $arrayData["DYN_UID"])) {
                 throw new \Exception(\G::LoadTranslation("ID_DYNAFORM_IS_NOT_ASSIGNED_TO_ACTIVITY", array($arrayDynaFormData["DYN_TITLE"], $arrayTaskData["TAS_TITLE"])));
             }
         }
         if ($arrayDataMain["WE_METHOD"] == "WS" && isset($arrayData["USR_UID"])) {
             $user = new \Users();
             $arrayUserData = $user->load($arrayData["USR_UID"]);
             //Verify if User is assigned to Task
             $projectUser = new \ProcessMaker\BusinessModel\ProjectUser();
             if (!$projectUser->userIsAssignedToTask($arrayData["USR_UID"], $arrayDataMain["TAS_UID"])) {
                 throw new \Exception(\G::LoadTranslation("ID_USER_DOES_NOT_HAVE_ACTIVITY_ASSIGNED", array($arrayUserData["USR_USERNAME"], $arrayTaskData["TAS_TITLE"])));
             }
         }
     } catch (\Exception $e) {
         throw $e;
     }
 }
Exemple #5
0
 /**
  * @url POST /:prj_uid/activity/:act_uid/step/all
  *
  * @param string $act_uid        {@min 32}{@max 32}
  * @param string $prj_uid        {@min 32}{@max 32}
  * @param array  $request_data
  * @param string $step_type_obj  {@from body}{@choice DYNAFORM,INPUT_DOCUMENT,OUTPUT_DOCUMENT,EXTERNAL}{@required true}
  * @param string $step_uid_obj   {@from body}{@min 32}{@max 32}{@required true}
  * @param string $step_condition {@from body}
  * @param int    $step_position  {@from body}{@min 1}
  * @param string $step_mode      {@from body}{@choice EDIT,VIEW}{@required true}
  *
  * @status 201
  */
 public function doPostActivityStepAll($act_uid, $prj_uid, $request_data, $step_type_obj = "DYNAFORM", $step_uid_obj = "00000000000000000000000000000000", $step_condition = "", $step_position = 1, $step_mode = "EDIT")
 {
     try {
         $step = new \ProcessMaker\BusinessModel\Step();
         $stepTrigger = new \ProcessMaker\BusinessModel\Step\Trigger();
         $step->deleteAll($act_uid);
         foreach ($request_data as $key => $valueRequest) {
             if (array_key_exists('tri_uid', $valueRequest)) {
                 $response[] = $stepTrigger->createAll("", $valueRequest["st_type"], $act_uid, $valueRequest["tri_uid"], $valueRequest);
             } else {
                 $step->setFormatFieldNameInUppercase(false);
                 $step->setArrayParamException(array("stepUid" => "step_uid", "taskUid" => "act_uid", "processUid" => "prj_uid"));
                 $arrayData[] = $step->createAll($act_uid, $prj_uid, $valueRequest);
                 if (array_key_exists('triggers', $valueRequest)) {
                     foreach ($valueRequest["triggers"] as $key => $valueTrigger) {
                         $response["triggers"] = $stepTrigger->createAll($arrayData[0]["step_uid"], $valueTrigger["st_type"], $act_uid, $valueTrigger["tri_uid"], $valueTrigger);
                     }
                 }
                 $response = $arrayData;
             }
         }
         return $response;
     } catch (\Exception $e) {
         throw new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage());
     }
 }