Adicion de endpoint para steps.
This commit is contained in:
@@ -450,6 +450,7 @@ class Step
|
|||||||
public function delete($stepUid)
|
public function delete($stepUid)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
|
||||||
//Verify data
|
//Verify data
|
||||||
$this->throwExceptionIfNotExistsStep($stepUid);
|
$this->throwExceptionIfNotExistsStep($stepUid);
|
||||||
|
|
||||||
@@ -916,5 +917,243 @@ class Step
|
|||||||
$oStep = new \Step();
|
$oStep = new \Step();
|
||||||
$oStep->update($data);
|
$oStep->update($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Steps for a Task
|
||||||
|
*
|
||||||
|
* @param string $taskUid Unique id of Task
|
||||||
|
* @param string $processUid Unique id of Process
|
||||||
|
* @param array $arrayData Data
|
||||||
|
*
|
||||||
|
* return array Return data of the new Steps created
|
||||||
|
*/
|
||||||
|
public function createAll($taskUid, $processUid, $arrayData)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$stepTrigger = new \ProcessMaker\BusinessModel\Step\Trigger();
|
||||||
|
|
||||||
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||||
|
|
||||||
|
unset($arrayData["STEP_UID"]);
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
$this->throwExceptionIfNotExistsTask($taskUid);
|
||||||
|
|
||||||
|
$this->throwExceptionIfNotExistsProcess($processUid);
|
||||||
|
|
||||||
|
if (!isset($arrayData["STEP_TYPE_OBJ"])) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayParamException["stepTypeObj"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayData["STEP_TYPE_OBJ"] = trim($arrayData["STEP_TYPE_OBJ"]);
|
||||||
|
|
||||||
|
if ($arrayData["STEP_TYPE_OBJ"] == "") {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->arrayParamException["stepTypeObj"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($arrayData["STEP_UID_OBJ"])) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayParamException["stepUidObj"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayData["STEP_UID_OBJ"] = trim($arrayData["STEP_UID_OBJ"]);
|
||||||
|
|
||||||
|
if ($arrayData["STEP_UID_OBJ"] == "") {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->arrayParamException["stepUidObj"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($arrayData["STEP_MODE"])) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayParamException["stepMode"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayData["STEP_MODE"] = trim($arrayData["STEP_MODE"]);
|
||||||
|
|
||||||
|
if ($arrayData["STEP_MODE"] == "") {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->arrayParamException["stepMode"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->throwExceptionIfHaveInvalidValueInTypeObj($arrayData["STEP_TYPE_OBJ"]);
|
||||||
|
|
||||||
|
$this->throwExceptionIfHaveInvalidValueInMode($arrayData["STEP_MODE"]);
|
||||||
|
|
||||||
|
$msg = $this->existsObjectUid($arrayData["STEP_TYPE_OBJ"], $arrayData["STEP_UID_OBJ"], $this->arrayParamException["stepUidObj"]);
|
||||||
|
|
||||||
|
if ($msg != "") {
|
||||||
|
throw new \Exception($msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->existsRecord($taskUid, $arrayData["STEP_TYPE_OBJ"], $arrayData["STEP_UID_OBJ"])) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_RECORD_EXISTS_IN_TABLE", array($taskUid . ", " . $arrayData["STEP_TYPE_OBJ"] . ", " . $arrayData["STEP_UID_OBJ"], "STEP")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create
|
||||||
|
$step = new \Step();
|
||||||
|
|
||||||
|
$stepUid = $step->create(array(
|
||||||
|
"PRO_UID" => $processUid,
|
||||||
|
"TAS_UID" => $taskUid,
|
||||||
|
"STEP_POSITION" => $arrayData["STEP_POSITION"]
|
||||||
|
));
|
||||||
|
|
||||||
|
if (!isset($arrayData["STEP_POSITION"]) || $arrayData["STEP_POSITION"] == "") {
|
||||||
|
unset($arrayData["STEP_POSITION"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$arrayData = $this->updateAll($stepUid, $arrayData);
|
||||||
|
|
||||||
|
//Return
|
||||||
|
unset($arrayData["STEP_UID"]);
|
||||||
|
|
||||||
|
$arrayData = array_merge(array("STEP_UID" => $stepUid), $arrayData);
|
||||||
|
|
||||||
|
if (!$this->formatFieldNameInUppercase) {
|
||||||
|
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arrayData;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Steps of a Task
|
||||||
|
*
|
||||||
|
* @param string $stepUid Unique id of Step
|
||||||
|
* @param array $arrayData Data
|
||||||
|
*
|
||||||
|
* return array Return data of the Steps updated
|
||||||
|
*/
|
||||||
|
public function updateAll($stepUid, $arrayData)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
$this->throwExceptionIfNotExistsStep($stepUid);
|
||||||
|
|
||||||
|
//Load Step
|
||||||
|
$step = new \Step();
|
||||||
|
$arrayStepData = $step->load($stepUid);
|
||||||
|
|
||||||
|
$taskUid = $arrayStepData["TAS_UID"];
|
||||||
|
$proUid = $arrayStepData["PRO_UID"];
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
if (isset($arrayData["STEP_TYPE_OBJ"]) && !isset($arrayData["STEP_UID_OBJ"])) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayParamException["stepUidObj"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isset($arrayData["STEP_TYPE_OBJ"]) && isset($arrayData["STEP_UID_OBJ"])) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_UNDEFINED_VALUE_IS_REQUIRED", array($this->arrayParamException["stepTypeObj"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arrayData["STEP_TYPE_OBJ"])) {
|
||||||
|
$arrayData["STEP_TYPE_OBJ"] = trim($arrayData["STEP_TYPE_OBJ"]);
|
||||||
|
|
||||||
|
if ($arrayData["STEP_TYPE_OBJ"] == "") {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->arrayParamException["stepTypeObj"])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arrayData["STEP_UID_OBJ"])) {
|
||||||
|
$arrayData["STEP_UID_OBJ"] = trim($arrayData["STEP_UID_OBJ"]);
|
||||||
|
|
||||||
|
if ($arrayData["STEP_UID_OBJ"] == "") {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->arrayParamException["stepUidObj"])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arrayData["STEP_MODE"])) {
|
||||||
|
$arrayData["STEP_MODE"] = trim($arrayData["STEP_MODE"]);
|
||||||
|
|
||||||
|
if ($arrayData["STEP_MODE"] == "") {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_CAN_NOT_BE_EMPTY", array($this->arrayParamException["stepMode"])));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arrayData["STEP_TYPE_OBJ"])) {
|
||||||
|
$this->throwExceptionIfHaveInvalidValueInTypeObj($arrayData["STEP_TYPE_OBJ"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arrayData["STEP_MODE"])) {
|
||||||
|
$this->throwExceptionIfHaveInvalidValueInMode($arrayData["STEP_MODE"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($arrayData["STEP_TYPE_OBJ"]) && isset($arrayData["STEP_UID_OBJ"])) {
|
||||||
|
$msg = $this->existsObjectUid($arrayData["STEP_TYPE_OBJ"], $arrayData["STEP_UID_OBJ"], $this->arrayParamException["stepUidObj"]);
|
||||||
|
|
||||||
|
if ($msg != "") {
|
||||||
|
throw new \Exception($msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->existsRecord($taskUid, $arrayData["STEP_TYPE_OBJ"], $arrayData["STEP_UID_OBJ"], 0, $stepUid)) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_RECORD_EXISTS_IN_TABLE", array($taskUid . ", " . $arrayData["STEP_TYPE_OBJ"] . ", " . $arrayData["STEP_UID_OBJ"], "STEP")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update
|
||||||
|
$step = new \Step();
|
||||||
|
|
||||||
|
$arrayData["STEP_UID"] = $stepUid;
|
||||||
|
$result = $step->update($arrayData);
|
||||||
|
|
||||||
|
//Return
|
||||||
|
unset($arrayData["STEP_UID"]);
|
||||||
|
|
||||||
|
if (!$this->formatFieldNameInUppercase) {
|
||||||
|
$arrayData = array_change_key_case($arrayData, CASE_LOWER);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $arrayData;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete Steps and triggers of a Task
|
||||||
|
*
|
||||||
|
* @param string $stepUid Unique id of Step
|
||||||
|
* @param string $taskUid Unique id of Step
|
||||||
|
*
|
||||||
|
* return void
|
||||||
|
*/
|
||||||
|
public function deleteAll($taskUid)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$step = new \Step();
|
||||||
|
$stepTrigger = new \ProcessMaker\BusinessModel\Step\Trigger();
|
||||||
|
|
||||||
|
$criteriaTrigger = new \Criteria("workflow");
|
||||||
|
$criteriaTrigger->addSelectColumn(\StepTriggerPeer::STEP_UID);
|
||||||
|
$criteriaTrigger->addSelectColumn(\StepTriggerPeer::ST_TYPE);
|
||||||
|
$criteriaTrigger->addSelectColumn(\StepTriggerPeer::TRI_UID);
|
||||||
|
$criteriaTrigger->add(\StepTriggerPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
||||||
|
$rsCriteriaTrigger = \StepTriggerPeer::doSelectRS($criteriaTrigger);
|
||||||
|
$rsCriteriaTrigger->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
$rsCriteriaTrigger->next();
|
||||||
|
|
||||||
|
while ($aRowTrigger = $rsCriteriaTrigger->getRow()) {
|
||||||
|
|
||||||
|
$stepTrigger->delete($aRowTrigger['STEP_UID'], $aRowTrigger['ST_TYPE'], $taskUid, $aRowTrigger['TRI_UID']);
|
||||||
|
$rsCriteriaTrigger->next();
|
||||||
|
}
|
||||||
|
|
||||||
|
$criteria = new \Criteria("workflow");
|
||||||
|
$criteria->addSelectColumn(\StepPeer::STEP_UID);
|
||||||
|
$criteria->add(\StepPeer::TAS_UID, $taskUid, \Criteria::EQUAL);
|
||||||
|
$rsCriteria = \StepPeer::doSelectRS($criteria);
|
||||||
|
$rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||||
|
$rsCriteria->next();
|
||||||
|
|
||||||
|
while ($aRow = $rsCriteria->getRow()) {
|
||||||
|
$step->remove($aRow['STEP_UID']);
|
||||||
|
$rsCriteria->next();
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -451,5 +451,161 @@ class Trigger
|
|||||||
$StepTrigger = new \StepTrigger();
|
$StepTrigger = new \StepTrigger();
|
||||||
$StepTrigger->update($data);
|
$StepTrigger->update($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assign Trigger to a Step
|
||||||
|
*
|
||||||
|
* @param string $stepUid Unique id of Step
|
||||||
|
* @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING)
|
||||||
|
* @param string $taskUid Unique id of Task
|
||||||
|
* @param string $triggerUid Unique id of Trigger
|
||||||
|
* @param array $arrayData Data
|
||||||
|
*
|
||||||
|
* return array Data of the Trigger assigned to a Step
|
||||||
|
*/
|
||||||
|
public function createAll($stepUid, $type, $taskUid, $triggerUid, $arrayData)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$stepUidIni = $stepUid;
|
||||||
|
$typeIni = $type;
|
||||||
|
|
||||||
|
$flagStepAssignTask = 0;
|
||||||
|
|
||||||
|
if ($stepUid == "") {
|
||||||
|
$flagStepAssignTask = 1;
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case "BEFORE_ASSIGNMENT":
|
||||||
|
$stepUid = "-1";
|
||||||
|
$type = "BEFORE";
|
||||||
|
break;
|
||||||
|
case "BEFORE_ROUTING":
|
||||||
|
$stepUid = "-2";
|
||||||
|
$type = "BEFORE";
|
||||||
|
break;
|
||||||
|
case "AFTER_ROUTING":
|
||||||
|
$stepUid = "-2";
|
||||||
|
$type = "AFTER";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
if ($flagStepAssignTask == 0) {
|
||||||
|
$step = new \Step();
|
||||||
|
|
||||||
|
if (!$step->StepExists($stepUid)) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_STEP_DOES_NOT_EXIST", array("step_uid", $stepUid)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$task = new \Task();
|
||||||
|
|
||||||
|
if (!$task->taskExists($taskUid)) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_ACTIVITY_DOES_NOT_EXIST", array("act_uid", $taskUid)));
|
||||||
|
}
|
||||||
|
|
||||||
|
$trigger = new \Triggers();
|
||||||
|
|
||||||
|
if (!$trigger->TriggerExists($triggerUid)) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_TRIGGER_DOES_NOT_EXIST", array("tri_uid", $triggerUid)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->existsRecord($stepUid, $type, $taskUid, $triggerUid)) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_RECORD_EXISTS_IN_TABLE", array($stepUid . ", " . $type . ", " . $taskUid . ", " . $triggerUid, "STEP_TRIGGER")));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create
|
||||||
|
$stepTrigger = new \StepTrigger();
|
||||||
|
// $posIni = $stepTrigger->getNextPosition($stepUid, $type, $taskUid);
|
||||||
|
|
||||||
|
$stepTrigger->createRow(array(
|
||||||
|
"STEP_UID" => $stepUid,
|
||||||
|
"TAS_UID" => $taskUid,
|
||||||
|
"TRI_UID" => $triggerUid,
|
||||||
|
"ST_TYPE" => $type,
|
||||||
|
"ST_CONDITION" => (isset($arrayData['st_condition'])) ? $arrayData['st_condition'] : '',
|
||||||
|
"ST_POSITION" => $arrayData['st_position']
|
||||||
|
));
|
||||||
|
|
||||||
|
$arrayData = $this->updateAll($stepUid, $typeIni, $taskUid, $triggerUid, $arrayData);
|
||||||
|
|
||||||
|
return $arrayData;
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update Trigger of a Step
|
||||||
|
*
|
||||||
|
* @param string $stepUid Unique id of Step
|
||||||
|
* @param string $type Type (BEFORE, AFTER, BEFORE_ASSIGNMENT, BEFORE_ROUTING, AFTER_ROUTING)
|
||||||
|
* @param string $taskUid Unique id of Task
|
||||||
|
* @param string $triggerUid Unique id of Trigger
|
||||||
|
* @param array $arrayData Data
|
||||||
|
*
|
||||||
|
* return array Data updated of the Trigger assigned to a Step
|
||||||
|
*/
|
||||||
|
public function updateAll($stepUid, $type, $taskUid, $triggerUid, $arrayData)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$flagStepAssignTask = 0;
|
||||||
|
|
||||||
|
if (($stepUid == "") || ($stepUid == "-1") || ($stepUid == "-2")) {
|
||||||
|
$flagStepAssignTask = 1;
|
||||||
|
|
||||||
|
switch ($type) {
|
||||||
|
case "BEFORE_ASSIGNMENT":
|
||||||
|
$stepUid = "-1";
|
||||||
|
$type = "BEFORE";
|
||||||
|
break;
|
||||||
|
case "BEFORE_ROUTING":
|
||||||
|
$stepUid = "-2";
|
||||||
|
$type = "BEFORE";
|
||||||
|
break;
|
||||||
|
case "AFTER_ROUTING":
|
||||||
|
$stepUid = "-2";
|
||||||
|
$type = "AFTER";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Verify data
|
||||||
|
if ($flagStepAssignTask == 0) {
|
||||||
|
$step = new \Step();
|
||||||
|
|
||||||
|
if (!$step->StepExists($stepUid)) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_STEP_DOES_NOT_EXIST", array("step_uid", $stepUid)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$trigger = new \Triggers();
|
||||||
|
|
||||||
|
if (!$trigger->TriggerExists($triggerUid)) {
|
||||||
|
throw new \Exception(\G::LoadTranslation("ID_TRIGGER_DOES_NOT_EXIST", array("tri_uid", $triggerUid)));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Update
|
||||||
|
$stepTrigger = new \StepTrigger();
|
||||||
|
|
||||||
|
$arrayUpdateData = array();
|
||||||
|
|
||||||
|
$arrayUpdateData["STEP_UID"] = $stepUid;
|
||||||
|
$arrayUpdateData["TAS_UID"] = $taskUid;
|
||||||
|
$arrayUpdateData["TRI_UID"] = $triggerUid;
|
||||||
|
$arrayUpdateData["ST_TYPE"] = $type;
|
||||||
|
|
||||||
|
if (isset($arrayData["st_condition"])) {
|
||||||
|
$arrayUpdateData["ST_CONDITION"] = $arrayData["st_condition"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$stepTrigger->update($arrayUpdateData);
|
||||||
|
|
||||||
|
return array_change_key_case($arrayUpdateData, CASE_LOWER);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,5 +216,64 @@ class Step extends Api
|
|||||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user