diff --git a/composer.json b/composer.json index 143db58e7..3e840153f 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,6 @@ }, "require-dev":{ "guzzle/guzzle":"~3.1.1", - "behat/behat":"2.4.*@stable", - "lisachenko/go-aop-php": "*" + "behat/behat":"2.4.*@stable" } } diff --git a/features/backend/input_documents/negative_tests_input.feature b/features/backend/input_documents/negative_tests_input.feature index d2dfe485b..0dad05152 100644 --- a/features/backend/input_documents/negative_tests_input.feature +++ b/features/backend/input_documents/negative_tests_input.feature @@ -27,13 +27,13 @@ Feature: Output Documents Negative Tests Examples: | test_description | project | inp_doc_title | inp_doc_description | inp_doc_form_needed | inp_doc_original | inp_doc_published | inp_doc_versioning | inp_doc_destination_path | inp_doc_tags | error_code | error_message | - | Create with project invalid | 14414793652a5d718b65590036 | My InputDocument1 | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | project | + | Create with project invalid | 14414793652a5d718b65590036 | My InputDocument1 | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | prj_uid | | Invalid inp doc from needed | 14414793652a5d718b65590036026581 | My InputDocument4 | My InputDocument4 DESCRIPTION | VRESAMPLE12334$%#@ | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_form_needed | | Invalid inp doc original | 14414793652a5d718b65590036026581 | My InputDocument5 | My InputDocument5 DESCRIPTION | VIRTUAL | COORIGI 123@#$%$% | PRIVATE | 1 | | INPUT | 400 | inp_doc_original | | Invalid inp doc published | 14414793652a5d718b65590036026581 | My InputDocument6 | My InputDocument6 DESCRIPTION | VIRTUAL | ORIGINAL | PRIV123234@##$$%% | 0 | | INPUT | 400 | inp_doc_published | | Invalid inp doc versioning | 14414793652a5d718b65590036026581 | My InputDocument7 | My InputDocument7 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 87 | | INPUT | 400 | inp_doc_versioning | - | Create without id of project | | My InputDocument10 | My InputDocument10 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | project | + | Create without id of project | | My InputDocument10 | My InputDocument10 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | prj_uid | | Create without inp doc form needed | 14414793652a5d718b65590036026581 | My InputDocument11 | My InputDocument11 DESCRIPTION | | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_form_needed | | Create without inp doc original | 14414793652a5d718b65590036026581 | My InputDocument12 | My InputDocument12 DESCRIPTION | REAL | | PRIVATE | 1 | | INPUT | 400 | inp_doc_original | | Create without inp doc published | 14414793652a5d718b65590036026581 | My InputDocument13 | My InputDocument13 DESCRIPTION | VREAL | ORIGINAL | | 1 | | INPUT | 400 | inp_doc_published | - | Create without inp doc title | 14414793652a5d718b65590036026581 | | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_title | \ No newline at end of file + | Create without inp doc title | 14414793652a5d718b65590036026581 | | My InputDocument1 DESCRIPTION | VIRTUAL | ORIGINAL | PRIVATE | 1 | | INPUT | 400 | inp_doc_title | diff --git a/gulliver/system/class.bootstrap.php b/gulliver/system/class.bootstrap.php index 5bee61115..d2465cf60 100644 --- a/gulliver/system/class.bootstrap.php +++ b/gulliver/system/class.bootstrap.php @@ -3095,7 +3095,10 @@ class Bootstrap ); } - require_once PATH_TRUNK . 'vendor' . PATH_SEP . "autoload.php"; + //require_once PATH_TRUNK . 'vendor' . PATH_SEP . "autoload.php"; + + $loader = require PATH_TRUNK . 'vendor' . PATH_SEP . "autoload.php"; + $loader->add('', PATH_HOME . 'engine/src/'); } public static function parseIniFile($filename) diff --git a/gulliver/system/class.g.php b/gulliver/system/class.g.php index 765e54827..7544e4a9e 100755 --- a/gulliver/system/class.g.php +++ b/gulliver/system/class.g.php @@ -3294,7 +3294,7 @@ class G * * @author Erik A.O. */ - public function json_encode($Json) + public static function json_encode($Json) { if ( function_exists('json_encode') ) { return json_encode($Json); diff --git a/workflow/engine/classes/model/BpmnFlow.php b/workflow/engine/classes/model/BpmnFlow.php index 9d9964da8..40f2cb69e 100644 --- a/workflow/engine/classes/model/BpmnFlow.php +++ b/workflow/engine/classes/model/BpmnFlow.php @@ -16,6 +16,11 @@ require_once 'classes/model/om/BaseBpmnFlow.php'; */ class BpmnFlow extends BaseBpmnFlow { + /** + * @param $field string coming from \BpmnFlowPeer:: + * @param $value string + * @return \BpmnFlow|null + */ public static function findOneBy($field, $value) { $rows = self::findAllBy($field, $value); diff --git a/workflow/engine/classes/model/Route.php b/workflow/engine/classes/model/Route.php index c9e972fb3..ecafc14c0 100755 --- a/workflow/engine/classes/model/Route.php +++ b/workflow/engine/classes/model/Route.php @@ -213,5 +213,30 @@ class Route extends BaseRoute } return $value; } + + /** + * @param $field + * @param null $value + * @return \Route|null + */ + public static function findOneBy($field, $value = null) + { + $rows = self::findAllBy($field, $value); + + return empty($rows) ? null : $rows[0]; + } + + public static function findAllBy($field, $value = null) + { + $field = is_array($field) ? $field : array($field => $value); + + $c = new Criteria('workflow'); + + foreach ($field as $key => $value) { + $c->add($key, $value, Criteria::EQUAL); + } + + return RoutePeer::doSelect($c); + } } diff --git a/workflow/engine/methods/processes/processes_Delete.php b/workflow/engine/methods/processes/processes_Delete.php index 67d9cf8b0..e3a5a15b1 100755 --- a/workflow/engine/methods/processes/processes_Delete.php +++ b/workflow/engine/methods/processes/processes_Delete.php @@ -38,24 +38,28 @@ if ($access != 1) { break; } } -G::LoadClass( 'processMap' ); -$oProcessMap = new ProcessMap(); +//G::LoadClass( 'processMap' ); +//$oProcessMap = new ProcessMap(); -$UIDS = explode( ',', $_POST['PRO_UIDS'] ); +$uids = explode(',', $_POST['PRO_UIDS']); try { - - foreach ($UIDS as $UID) { - $oProcessMap->deleteProcess($UID); - //ProcessMaker\Adapter\Bpmn\Model::deleteProject($UID); + foreach ($uids as $uid) { + //$oProcessMap->deleteProcess($uid); + ProcessMaker\Project\Workflow::removeIfExists($uid); + ProcessMaker\Project\Bpmn::removeIfExists($uid); } + + $resp = new StdClass(); $resp->status = 0; $resp->msg = 'All process was deleted successfully'; - echo G::json_encode( $resp ); + + echo G::json_encode($resp); + } catch (Exception $e) { $resp->status = 1; $resp->msg = $e->getMessage(); - echo G::json_encode( $resp ); + echo G::json_encode($resp); } diff --git a/workflow/engine/src/BusinessModel/DynaForm.php b/workflow/engine/src/BusinessModel/DynaForm.php index fcfe8b90f..c9d6c80a6 100644 --- a/workflow/engine/src/BusinessModel/DynaForm.php +++ b/workflow/engine/src/BusinessModel/DynaForm.php @@ -180,6 +180,40 @@ class DynaForm } } + /** + * Verify if doesn't exist the DynaForm in table DYNAFORM + * + * @param string $dynaFormUid Unique id of DynaForm + * @param string $processUid Unique id of Process + * @param string $fieldNameForException Field name for the exception + * + * return void Throw exception if doesn't exist the DynaForm in table DYNAFORM + */ + public function throwExceptionIfNotExistsDynaForm($dynaFormUid, $processUid, $fieldNameForException) + { + try { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\DynaformPeer::DYN_UID); + + if ($processUid != "") { + $criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL); + } + + $criteria->add(\DynaformPeer::DYN_UID, $dynaFormUid, \Criteria::EQUAL); + + $rsCriteria = \DynaformPeer::doSelectRS($criteria); + + if (!$rsCriteria->next()) { + $msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $dynaFormUid), "The DynaForm with {0}: {1}, does not exist"); + + throw (new \Exception($msg)); + } + } catch (\Exception $e) { + throw $e; + } + } + /** * Verify if exists the title of a DynaForm * @@ -265,9 +299,7 @@ class DynaForm $arrayData = array_change_key_case($arrayData, CASE_UPPER); //Verify data - $process = new \BusinessModel\Process(); - - $process->throwExceptionIfNotExistsDynaForm("", $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]); + $this->throwExceptionIfNotExistsDynaForm($dynaFormUid, "", $this->arrayFieldNameForException["dynaFormUid"]); //Load DynaForm $dynaForm = new \Dynaform(); @@ -277,6 +309,8 @@ class DynaForm $processUid = $arrayDynaFormData["PRO_UID"]; //Verify data + $process = new \BusinessModel\Process(); + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false); if (isset($arrayData["DYN_TITLE"])) { @@ -312,9 +346,7 @@ class DynaForm { try { //Verify data - $process = new \BusinessModel\Process(); - - $process->throwExceptionIfNotExistsDynaForm("", $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]); + $this->throwExceptionIfNotExistsDynaForm($dynaFormUid, "", $this->arrayFieldNameForException["dynaFormUid"]); //Load DynaForm $dynaForm = new \Dynaform(); @@ -408,7 +440,7 @@ class DynaForm //Verify data $process->throwExceptionIfNoExistsProcess($processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.PRJ_UID")); - $process->throwExceptionIfNotExistsDynaForm($processUidCopyImport, $dynaFormUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID")); + $this->throwExceptionIfNotExistsDynaForm($dynaFormUidCopyImport, $processUidCopyImport, $this->getFieldNameByFormatFieldName("COPY_IMPORT.DYN_UID")); //Copy/Import //Create @@ -840,9 +872,7 @@ class DynaForm { try { //Verify data - $process = new \BusinessModel\Process(); - - $process->throwExceptionIfNotExistsDynaForm("", $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]); + $this->throwExceptionIfNotExistsDynaForm($dynaFormUid, "", $this->arrayFieldNameForException["dynaFormUid"]); //Get data $criteria = $this->getDynaFormCriteria(); diff --git a/workflow/engine/src/BusinessModel/InputDocument.php b/workflow/engine/src/BusinessModel/InputDocument.php index 6dfd8f8a9..b7677e79e 100644 --- a/workflow/engine/src/BusinessModel/InputDocument.php +++ b/workflow/engine/src/BusinessModel/InputDocument.php @@ -3,16 +3,103 @@ namespace BusinessModel; class InputDocument { + private $arrayFieldDefinition = array( + "INP_DOC_UID" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "inputDocumentUid"), + + "INP_DOC_TITLE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "inputDocumentTitle"), + "INP_DOC_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "inputDocumentDescription"), + "INP_DOC_FORM_NEEDED" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("VIRTUAL", "REAL", "VREAL"), "fieldNameAux" => "inputDocumentFormNeeded"), + "INP_DOC_ORIGINAL" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("ORIGINAL", "COPY", "COPYLEGAL"), "fieldNameAux" => "inputDocumentOriginal"), + "INP_DOC_PUBLISHED" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array("PRIVATE"), "fieldNameAux" => "inputDocumentPublished"), + "INP_DOC_VERSIONING" => array("type" => "int", "required" => false, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "inputDocumentVersioning"), + "INP_DOC_DESTINATION_PATH" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "inputDocumentDestinationPath"), + "INP_DOC_TAGS" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "inputDocumentTags") + ); + + private $formatFieldNameInUppercase = true; + + private $arrayFieldNameForException = array( + "processUid" => "PRO_UID" + ); + /** - * Verify if the title exists in the InputDocuments of Process + * Constructor of the class * - * @param string $processUid Unique id of Process - * @param string $title Title + * return void + */ + public function __construct() + { + try { + foreach ($this->arrayFieldDefinition as $key => $value) { + $this->arrayFieldNameForException[$value["fieldNameAux"]] = $key; + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set the format of the fields name (uppercase, lowercase) + * + * @param bool $flag Value that set the format + * + * return void + */ + public function setFormatFieldNameInUppercase($flag) + { + try { + $this->formatFieldNameInUppercase = $flag; + + $this->setArrayFieldNameForException($this->arrayFieldNameForException); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Set exception messages for fields + * + * @param array $arrayData Data with the fields + * + * return void + */ + public function setArrayFieldNameForException($arrayData) + { + try { + foreach ($arrayData as $key => $value) { + $this->arrayFieldNameForException[$key] = $this->getFieldNameByFormatFieldName($value); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Get the name of the field according to the format + * + * @param string $fieldName Field name + * + * return string Return the field name according the format + */ + public function getFieldNameByFormatFieldName($fieldName) + { + try { + return ($this->formatFieldNameInUppercase)? strtoupper($fieldName) : strtolower($fieldName); + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the title of a InputDocument + * + * @param string $processUid Unique id of Process + * @param string $inputDocumentTitle Title * @param string $inputDocumentUidExclude Unique id of InputDocument to exclude * - * return bool Return true if the title exists in the InputDocuments of Process, false otherwise + * return bool Return true if exists the title of a InputDocument, false otherwise */ - public function titleExists($processUid, $title, $inputDocumentUidExclude = "") + public function existsTitle($processUid, $inputDocumentTitle, $inputDocumentUidExclude = "") { try { $delimiter = \DBAdapter::getStringDelimiter(); @@ -35,10 +122,9 @@ class InputDocument $criteria->add(\InputDocumentPeer::INP_DOC_UID, $inputDocumentUidExclude, \Criteria::NOT_EQUAL); } - $criteria->add("CT.CON_VALUE", $title, \Criteria::EQUAL); + $criteria->add("CT.CON_VALUE", $inputDocumentTitle, \Criteria::EQUAL); $rsCriteria = \InputDocumentPeer::doSelectRS($criteria); - $rsCriteria->setFetchmode(\ResultSet::FETCHMODE_ASSOC); if ($rsCriteria->next()) { return true; @@ -50,6 +136,63 @@ class InputDocument } } + /** + * Verify if doesn't exist the InputDocument in table INPUT_DOCUMENT + * + * @param string $inputDocumentUid Unique id of InputDocument + * @param string $processUid Unique id of Process + * @param string $fieldNameForException Field name for the exception + * + * return void Throw exception if doesn't exist the InputDocument in table INPUT_DOCUMENT + */ + public function throwExceptionIfNotExistsInputDocument($inputDocumentUid, $processUid, $fieldNameForException) + { + try { + $criteria = new \Criteria("workflow"); + + $criteria->addSelectColumn(\InputDocumentPeer::INP_DOC_UID); + + if ($processUid != "") { + $criteria->add(\InputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL); + } + + $criteria->add(\InputDocumentPeer::INP_DOC_UID, $inputDocumentUid, \Criteria::EQUAL); + + $rsCriteria = \InputDocumentPeer::doSelectRS($criteria); + + if (!$rsCriteria->next()) { + $msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $inputDocumentUid), "The InputDocument with {0}: {1}, does not exist"); + + throw (new \Exception($msg)); + } + } catch (\Exception $e) { + throw $e; + } + } + + /** + * Verify if exists the title of a InputDocument + * + * @param string $processUid Unique id of Process + * @param string $inputDocumentTitle Title + * @param string $fieldNameForException Field name for the exception + * @param string $inputDocumentUidExclude Unique id of InputDocument to exclude + * + * return void Throw exception if exists the title of a InputDocument + */ + public function throwExceptionIfExistsTitle($processUid, $inputDocumentTitle, $fieldNameForException, $inputDocumentUidExclude = "") + { + try { + if ($this->existsTitle($processUid, $inputDocumentTitle, $inputDocumentUidExclude)) { + $msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $inputDocumentTitle), "The InputDocument title with {0}: \"{1}\", already exists"); + + throw (new \Exception($msg)); + } + } catch (\Exception $e) { + throw $e; + } + } + /** * Create InputDocument for a Process * @@ -66,23 +209,13 @@ class InputDocument unset($arrayData["INP_DOC_UID"]); //Verify data - $process = new \Process(); + $process = new \BusinessModel\Process(); - if (!$process->exists($processUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($processUid, "PROCESS"), "The UID \"{0}\" doesn't exist in table {1}"))); - } + $process->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); - if (!isset($arrayData["INP_DOC_TITLE"])) { - throw (new \Exception(str_replace(array("{0}"), array(strtolower("INP_DOC_TITLE")), "The \"{0}\" attribute is not defined"))); - } + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true); - if (isset($arrayData["INP_DOC_TITLE"]) && trim($arrayData["INP_DOC_TITLE"]) == "") { - throw (new \Exception(str_replace(array("{0}"), array(strtolower("INP_DOC_TITLE")), "The \"{0}\" attribute is empty"))); - } - - if (isset($arrayData["INP_DOC_TITLE"]) && $this->titleExists($processUid, $arrayData["INP_DOC_TITLE"])) { - throw (new \Exception(\G::LoadTranslation("ID_INPUT_NOT_SAVE"))); - } + $this->throwExceptionIfExistsTitle($processUid, $arrayData["INP_DOC_TITLE"], $this->arrayFieldNameForException["inputDocumentTitle"]); //Flags $flagDataDestinationPath = (isset($arrayData["INP_DOC_DESTINATION_PATH"]))? 1 : 0; @@ -109,11 +242,13 @@ class InputDocument unset($arrayData["INP_DOC_TAGS"]); } - $arrayData = array_change_key_case($arrayData, CASE_LOWER); + $arrayData = array_merge(array("INP_DOC_UID" => $inputDocumentUid), $arrayData); - unset($arrayData["inp_doc_uid"]); + if (!$this->formatFieldNameInUppercase) { + $arrayData = array_change_key_case($arrayData, CASE_LOWER); + } - return array_merge(array("inp_doc_uid" => $inputDocumentUid), $arrayData); + return $arrayData; } catch (\Exception $e) { throw $e; } @@ -132,24 +267,23 @@ class InputDocument try { $arrayData = array_change_key_case($arrayData, CASE_UPPER); + //Verify data + $this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]); + + //Load InputDocument $inputDocument = new \InputDocument(); $arrayInputDocumentData = $inputDocument->load($inputDocumentUid); - //Uids $processUid = $arrayInputDocumentData["PRO_UID"]; //Verify data - if (!$inputDocument->InputExists($inputDocumentUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($inputDocumentUid, "INPUT_DOCUMENT"), "The UID \"{0}\" doesn't exist in table {1}"))); - } + $process = new \BusinessModel\Process(); - if (isset($arrayData["INP_DOC_TITLE"]) && trim($arrayData["INP_DOC_TITLE"]) == "") { - throw (new \Exception(str_replace(array("{0}"), array(strtolower("INP_DOC_TITLE")), "The \"{0}\" attribute is empty"))); - } + $process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, false); - if (isset($arrayData["INP_DOC_TITLE"]) && $this->titleExists($processUid, $arrayData["INP_DOC_TITLE"], $inputDocumentUid)) { - throw (new \Exception(\G::LoadTranslation("ID_INPUT_NOT_SAVE"))); + if (isset($arrayData["INP_DOC_TITLE"])) { + $this->throwExceptionIfExistsTitle($processUid, $arrayData["INP_DOC_TITLE"], $this->arrayFieldNameForException["inputDocumentTitle"], $inputDocumentUid); } //Update @@ -160,7 +294,11 @@ class InputDocument //Return unset($arrayData["INP_DOC_UID"]); - return array_change_key_case($arrayData, CASE_LOWER); + if (!$this->formatFieldNameInUppercase) { + $arrayData = array_change_key_case($arrayData, CASE_LOWER); + } + + return $arrayData; } catch (\Exception $e) { throw $e; } @@ -177,11 +315,7 @@ class InputDocument { try { //Verify data - $inputDocument = new \InputDocument(); - - if (!$inputDocument->InputExists($inputDocumentUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($inputDocumentUid, "INPUT_DOCUMENT"), "The UID \"{0}\" doesn't exist in table {1}"))); - } + $this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]); //Delete //StepSupervisor @@ -266,31 +400,32 @@ class InputDocument * * @param array $record Record * - * return array Return an array with data of an InputDocument + * return array Return an array with data InputDocument */ public function getInputDocumentDataFromRecord($record) { try { if ($record["INP_DOC_TITLE"] . "" == "") { + //Load InputDocument $inputDocument = new \InputDocument(); - //There is no transaltion for this Document name, try to get/regenerate the label - $arrayInputdocData = $inputDocument->load($record["INP_DOC_UID"]); + $arrayInputDocumentData = $inputDocument->load($record["INP_DOC_UID"]); - $record["INP_DOC_TITLE"] = $arrayInputdocData["INP_DOC_TITLE"]; - $record["INP_DOC_DESCRIPTION"] = $arrayInputdocData["INP_DOC_DESCRIPTION"]; + //There is no transaltion for this Document name, try to get/regenerate the label + $record["INP_DOC_TITLE"] = $arrayInputDocumentData["INP_DOC_TITLE"]; + $record["INP_DOC_DESCRIPTION"] = $arrayInputDocumentData["INP_DOC_DESCRIPTION"]; } return array( - "inp_doc_uid" => $record["INP_DOC_UID"], - "inp_doc_title" => $record["INP_DOC_TITLE"], - "inp_doc_description" => $record["INP_DOC_DESCRIPTION"] . "", - "inp_doc_form_needed" => $record["INP_DOC_FORM_NEEDED"], - "inp_doc_original" => $record["INP_DOC_ORIGINAL"], - "inp_doc_published" => $record["INP_DOC_PUBLISHED"], - "inp_doc_versioning" => (int)($record["INP_DOC_VERSIONING"]), - "inp_doc_destination_path" => $record["INP_DOC_DESTINATION_PATH"] . "", - "inp_doc_tags" => $record["INP_DOC_TAGS"] . "" + $this->getFieldNameByFormatFieldName("INP_DOC_UID") => $record["INP_DOC_UID"], + $this->getFieldNameByFormatFieldName("INP_DOC_TITLE") => $record["INP_DOC_TITLE"], + $this->getFieldNameByFormatFieldName("INP_DOC_DESCRIPTION") => $record["INP_DOC_DESCRIPTION"] . "", + $this->getFieldNameByFormatFieldName("INP_DOC_FORM_NEEDED") => $record["INP_DOC_FORM_NEEDED"] . "", + $this->getFieldNameByFormatFieldName("INP_DOC_ORIGINAL") => $record["INP_DOC_ORIGINAL"] . "", + $this->getFieldNameByFormatFieldName("INP_DOC_PUBLISHED") => $record["INP_DOC_PUBLISHED"] . "", + $this->getFieldNameByFormatFieldName("INP_DOC_VERSIONING") => (int)($record["INP_DOC_VERSIONING"]), + $this->getFieldNameByFormatFieldName("INP_DOC_DESTINATION_PATH") => $record["INP_DOC_DESTINATION_PATH"] . "", + $this->getFieldNameByFormatFieldName("INP_DOC_TAGS") => $record["INP_DOC_TAGS"] . "" ); } catch (\Exception $e) { throw $e; @@ -308,11 +443,7 @@ class InputDocument { try { //Verify data - $inputDocument = new \InputDocument(); - - if (!$inputDocument->InputExists($inputDocumentUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($inputDocumentUid, "INPUT_DOCUMENT"), "The UID \"{0}\" doesn't exist in table {1}"))); - } + $this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]); //Get data $criteria = $this->getInputDocumentCriteria(); diff --git a/workflow/engine/src/BusinessModel/Process.php b/workflow/engine/src/BusinessModel/Process.php index eab39e776..ea87ac16b 100644 --- a/workflow/engine/src/BusinessModel/Process.php +++ b/workflow/engine/src/BusinessModel/Process.php @@ -420,40 +420,6 @@ class Process } } - /** - * Verify if doesn't exist the DynaForm in table DYNAFORM - * - * @param string $processUid Unique id of Process - * @param string $dynaFormUid Unique id of DynaForm - * @param string $fieldNameForException Field name for the exception - * - * return void Throw exception if doesn't exist the DynaForm in table DYNAFORM - */ - public function throwExceptionIfNotExistsDynaForm($processUid, $dynaFormUid, $fieldNameForException) - { - try { - $criteria = new \Criteria("workflow"); - - $criteria->addSelectColumn(\DynaformPeer::DYN_UID); - - if ($processUid != "") { - $criteria->add(\DynaformPeer::PRO_UID, $processUid, \Criteria::EQUAL); - } - - $criteria->add(\DynaformPeer::DYN_UID, $dynaFormUid, \Criteria::EQUAL); - - $rsCriteria = \DynaformPeer::doSelectRS($criteria); - - if (!$rsCriteria->next()) { - $msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $dynaFormUid), "The DynaForm with {0}: {1}, does not exist"); - - throw (new \Exception($msg)); - } - } catch (\Exception $e) { - throw $e; - } - } - /** * Verify if doesn't exist the Template in Routing Screen Template * @@ -553,7 +519,9 @@ class Process } if (isset($arrayData["PRO_SUMMARY_DYNAFORM"]) && $arrayData["PRO_SUMMARY_DYNAFORM"] . "" != "") { - $this->throwExceptionIfNotExistsDynaForm($processUid, $arrayData["PRO_SUMMARY_DYNAFORM"], $this->arrayFieldNameForException["processSummaryDynaform"]); + $dynaForm = new \BusinessModel\DynaForm(); + + $dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["PRO_SUMMARY_DYNAFORM"], $processUid, $this->arrayFieldNameForException["processSummaryDynaform"]); } if (isset($arrayData["PRO_DERIVATION_SCREEN_TPL"]) && $arrayData["PRO_DERIVATION_SCREEN_TPL"] . "" != "") { @@ -1444,19 +1412,17 @@ class Process public function getInputDocuments($processUid) { try { - //Verify data - $process = new \Process(); - - if (!$process->exists($processUid)) { - throw (new \Exception(str_replace(array("{0}", "{1}"), array($processUid, "PROCESS"), "The UID \"{0}\" doesn't exist in table {1}"))); - } - - //Get data $arrayInputDocument = array(); - $inputdoc = new \BusinessModel\InputDocument(); + //Verify data + $this->throwExceptionIfNoExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]); - $criteria = $inputdoc->getInputDocumentCriteria(); + //Get data + $inputDocument = new \BusinessModel\InputDocument(); + $inputDocument->setFormatFieldNameInUppercase($this->formatFieldNameInUppercase); + $inputDocument->setArrayFieldNameForException($this->arrayFieldNameForException); + + $criteria = $inputDocument->getInputDocumentCriteria(); $criteria->add(\InputDocumentPeer::PRO_UID, $processUid, \Criteria::EQUAL); $criteria->addAscendingOrderByColumn("INP_DOC_TITLE"); @@ -1467,9 +1433,10 @@ class Process while ($rsCriteria->next()) { $row = $rsCriteria->getRow(); - $arrayInputDocument[] = $inputdoc->getInputDocumentDataFromRecord($row); + $arrayInputDocument[] = $inputDocument->getInputDocumentDataFromRecord($row); } + //Return return $arrayInputDocument; } catch (\Exception $e) { throw $e; diff --git a/workflow/engine/src/BusinessModel/WebEntry.php b/workflow/engine/src/BusinessModel/WebEntry.php index 0b7a564ae..00eca8340 100644 --- a/workflow/engine/src/BusinessModel/WebEntry.php +++ b/workflow/engine/src/BusinessModel/WebEntry.php @@ -151,7 +151,9 @@ class WebEntry } if ($dynaFormUid != "") { - $process->throwExceptionIfNotExistsDynaForm($processUid, $dynaFormUid, $this->arrayFieldNameForException["dynaFormUid"]); + $dynaForm = new \BusinessModel\DynaForm(); + + $dynaForm->throwExceptionIfNotExistsDynaForm($dynaFormUid, $processUid, $this->arrayFieldNameForException["dynaFormUid"]); } //Get data @@ -293,7 +295,10 @@ class WebEntry } $process->throwExceptionIfNotExistsTask($processUid, $arrayData["TAS_UID"], $this->arrayFieldNameForException["taskUid"]); - $process->throwExceptionIfNotExistsDynaForm($processUid, $arrayData["DYN_UID"], $this->arrayFieldNameForException["dynaFormUid"]); + + $dynaForm = new \BusinessModel\DynaForm(); + + $dynaForm->throwExceptionIfNotExistsDynaForm($arrayData["DYN_UID"], $processUid, $this->arrayFieldNameForException["dynaFormUid"]); $task = new \Task(); diff --git a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php index e8f56f694..637b2208e 100644 --- a/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Adapter/BpmnWorkflow.php @@ -163,12 +163,8 @@ class BpmnWorkflow extends Project\Bpmn switch ($event && $event->getEvnType()) { case "START": - self::log("Setting Task:" . $data["FLO_ELEMENT_DEST"] . " as STARTING TASK"); - // then set that activity/task as "Start Task" - $this->wp->updateTask($data["FLO_ELEMENT_DEST"], array("TAS_START" => "TRUE")); - - self::log("Setting as \"Stating Task\" Success!"); + $this->wp->setStartTask($data["FLO_ELEMENT_DEST"]); break; } break; @@ -177,6 +173,10 @@ class BpmnWorkflow extends Project\Bpmn } } + public function removeFlow($floUid) + { + parent::removeFlow($floUid); + } public function addEvent($data) { @@ -189,32 +189,27 @@ class BpmnWorkflow extends Project\Bpmn public function removeEvent($evnUid) { - $flow = \BpmnFlowPeer::retrieveByPK($evnUid); + $event = \BpmnEventPeer::retrieveByPK($evnUid); - if (! is_null($flow)) { - $data = $flow->toArray(); - - // to add start event->activity as initial or end task - switch ($data["FLO_ELEMENT_ORIGIN_TYPE"]) { - case "bpmnEvent": - switch ($data["FLO_ELEMENT_DEST_TYPE"]) { - case "bpmnActivity": - $event = \BpmnEventPeer::retrieveByPK($data["FLO_ELEMENT_ORIGIN"]); - - switch ($event && $event->getEvnType()) { - case "START": - self::log("Unset Task:" . $data["FLO_ELEMENT_DEST"] . " as NOT STARTING TASK"); - - // then set that activity/task as "Start Task" - $this->wp->updateTask($data["FLO_ELEMENT_DEST"], array("TAS_START" => "FALSE")); - - self::log("Unset as \"Stating Task\" Success!"); - break; - } - break; + switch ($event->getEvnType()) { + case "START": + $flow = \BpmnFlow::findOneBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $event->getEvnUid()); + if (! is_null($flow) && $flow->getFloElementDestType() == "bpmnActivity") { + $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementDest()); + if (! is_null($activity)) { + $this->wp->setStartTask($activity->getActUid(), false); } - break; - } + } + break; + case "END": + $flow = \BpmnFlow::findOneBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $event->getEvnUid()); + if (! is_null($flow) && $flow->getFloElementOriginType() == "bpmnActivity") { + $activity = \BpmnActivityPeer::retrieveByPK($flow->getFloElementOrigin()); + if (! is_null($activity)) { + $this->wp->setEndTask($activity->getActUid(), false); + } + } + break; } parent::removeEvent($evnUid); diff --git a/workflow/engine/src/ProcessMaker/Project/Bpmn.php b/workflow/engine/src/ProcessMaker/Project/Bpmn.php index 59fa5a78a..c41e1a03e 100644 --- a/workflow/engine/src/ProcessMaker/Project/Bpmn.php +++ b/workflow/engine/src/ProcessMaker/Project/Bpmn.php @@ -86,12 +86,14 @@ class Bpmn extends Handler // setting defaults $data['PRJ_UID'] = array_key_exists('PRJ_UID', $data) ? $data['PRJ_UID'] : Hash::generateUID(); + self::log("Create Project with data: ", $data); $this->project = new Project(); $this->project->fromArray($data, BasePeer::TYPE_FIELDNAME); $this->project->setPrjCreateDate(date("Y-m-d H:i:s")); $this->project->save(); $this->prjUid = $this->project->getPrjUid(); + self::log("Create Project Success!"); } public function update() @@ -106,11 +108,20 @@ class Bpmn extends Handler * 2. Remove Project related objects */ - $activities = $this->getActivities(); - - foreach ($activities as $activity) { + self::log("Remove Project With Uid: {$this->prjUid}"); + foreach ($this->getActivities() as $activity) { $this->removeActivity($activity["ACT_UID"]); } + foreach ($this->getGateways() as $gateway) { + $this->removeGateway($gateway["GAT_UID"]); + } + foreach ($this->getEvents() as $event) { + $this->removeEvent($event["EVN_UID"]); + } + foreach ($this->getFlows() as $flow) { + $this->removeFlow($flow["FLO_UID"]); + } + if ($process = $this->getProcess("object")) { $process->delete(); } @@ -120,6 +131,19 @@ class Bpmn extends Handler if ($project = $this->getProject("object")) { $project->delete(); } + self::log("Remove Project Success!"); + } + + public static function removeIfExists($prjUid) + { + $project = ProjectPeer::retrieveByPK($prjUid); + + if ($project) { + $me = new self(); + $me->prjUid = $project->getPrjUid(); + $me->project = $project; + $me->remove(); + } } public static function getList($start = null, $limit = null, $filter = "", $changeCaseTo = CASE_UPPER) diff --git a/workflow/engine/src/ProcessMaker/Project/Workflow.php b/workflow/engine/src/ProcessMaker/Project/Workflow.php index 9a9bd791d..2cf39990f 100644 --- a/workflow/engine/src/ProcessMaker/Project/Workflow.php +++ b/workflow/engine/src/ProcessMaker/Project/Workflow.php @@ -54,15 +54,15 @@ class Workflow extends Handler public function create($data) { + // setting defaults + $data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Hash::generateUID(); + $data['USR_UID'] = array_key_exists('PRO_CREATE_USER', $data) ? $data['PRO_CREATE_USER'] : null; + $data['PRO_TITLE'] = array_key_exists('PRO_TITLE', $data) ? trim($data['PRO_TITLE']) : ""; + $data['PRO_CATEGORY'] = array_key_exists('PRO_CATEGORY', $data) ? $data['PRO_CATEGORY'] : ""; + try { self::log("===> Executing -> ".__METHOD__, "Create Process with data:", $data); - // setting defaults - $data['PRO_UID'] = array_key_exists('PRO_UID', $data) ? $data['PRO_UID'] : Hash::generateUID(); - $data['USR_UID'] = array_key_exists('PRO_CREATE_USER', $data) ? $data['PRO_CREATE_USER'] : null; - $data['PRO_TITLE'] = array_key_exists('PRO_TITLE', $data) ? trim($data['PRO_TITLE']) : ""; - $data['PRO_CATEGORY'] = array_key_exists('PRO_CATEGORY', $data) ? $data['PRO_CATEGORY'] : ""; - //validate if process with specified name already exists if (Process::existsByProTitle($data["PRO_TITLE"])) { throw new Exception\ProjectAlreadyExists($this, $data["PRO_TITLE"]); @@ -111,6 +111,17 @@ class Workflow extends Handler } } + public static function removeIfExists($proUid) + { + $process = \ProcessPeer::retrieveByPK($proUid); + + if ($process) { + $me = new self(); + $me->proUid = $process->getProUid(); + $me->remove(); + } + } + public static function getList($start = null, $limit = null, $filter = "", $changeCaseTo = CASE_UPPER) { //return Project::getAll($start, $limit, $filter, $changeCaseTo); @@ -211,16 +222,33 @@ class Workflow extends Handler return $tasks->getAllTasks($this->proUid); } - public function setStartTask($tasUid) + public function setStartTask($tasUid, $value = true) { + $value = $value ? "TRUE" : "FALSE"; + + self::log("Setting Start Task with Uid: $tasUid: $value"); $task = \TaskPeer::retrieveByPK($tasUid); - $task->setTasStart("TRUE"); + $task->setTasStart($value); $task->save(); + self::log("Setting Start Task -> $value, Success!"); } - public function setEndTask($tasUid) + public function setEndTask($tasUid, $value = true) { - $this->addSequentialRoute($tasUid, "-1", "SEQUENTIAL", true); + self::log("Setting End Task with Uid: $tasUid: " . ($value ? "TRUE" : "FALSE")); + if ($value) { + $this->addSequentialRoute($tasUid, "-1"); + } else { + $route = \Route::findOneBy(array( + \RoutePeer::TAS_UID => $tasUid, + \RoutePeer::ROU_NEXT_TASK => "-1" + )); + + if (! is_null($route)) { + $this->removeRoute($route->getRouUid()); + } + } + self::log("Setting End Task -> ".($value ? "TRUE" : "FALSE").", Success!"); } public function addSequentialRoute($fromTasUid, $toTasUid, $delete = null) @@ -239,32 +267,6 @@ class Workflow extends Handler { try { self::log("Add Route from task: $fromTasUid -> to task: $toTasUid ($type)"); - /*switch ($type) { - case 0: - $sType = 'SEQUENTIAL'; - break; - case 1: - $sType = 'SELECT'; - break; - case 2: - $sType = 'EVALUATE'; - break; - case 3: - $sType = 'PARALLEL'; - break; - case 4: - $sType = 'PARALLEL-BY-EVALUATION'; - break; - case 5: - $sType = 'SEC-JOIN'; - break; - case 8: - $sType = 'DISCRIMINATOR'; - break; - default: - throw new \Exception("Invalid type code, given: $type, expected: integer [1...8]"); - } - }*/ $validTypes = array("SEQUENTIAL", "SELECT", "EVALUATE", "PARALLEL", "PARALLEL-BY-EVALUATION", "SEC-JOIN", "DISCRIMINATOR"); @@ -272,21 +274,16 @@ class Workflow extends Handler throw new \Exception("Invalid Route type, given: $type, expected: [".implode(",", $validTypes)."]"); } - //if ($type != 0 && $type != 5 && $type != 8) { if ($type != 'SEQUENTIAL' && $type != 'SEC-JOIN' && $type != 'DISCRIMINATOR') { if ($this->getNumberOfRoutes($this->proUid, $fromTasUid, $toTasUid, $type) > 0) { - // die(); ???? - throw new \RuntimeException("Unexpected behaviour"); + throw new \LogicException("Unexpected behaviour"); } - //unset($aRow); } - //if ($delete || $type == 0 || $type == 5 || $type == 8) { - if ($delete || $type == 'SEQUENTIAL' || $type == 'SEC-JOIN' || $type == 'DISCRIMINATOR') { - //$oTasks = new Tasks(); - //$oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid); - //$oTasks->deleteAllGatewayOfTask($this->proUid, $fromTasUid); - } + //if ($delete || $type == 'SEQUENTIAL' || $type == 'SEC-JOIN' || $type == 'DISCRIMINATOR') { + $oTasks = new Tasks(); + $oTasks->deleteAllRoutesOfTask($this->proUid, $fromTasUid); + //} $result = $this->saveNewPattern($this->proUid, $fromTasUid, $toTasUid, $type, $delete); self::log("Add Route Success! -> ", $result); diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project.php b/workflow/engine/src/Services/Api/ProcessMaker/Project.php index 268a71519..0ba87fe8c 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project.php @@ -237,7 +237,7 @@ class Project extends Api if ($mappedUid !== false) { $flowData["FLO_ELEMENT_ORIGIN"] = $mappedUid; } - + $mappedUid = self::mapUid($flowData["FLO_ELEMENT_DEST"], $result); if ($mappedUid !== false) { $flowData["FLO_ELEMENT_DEST"] = $mappedUid; @@ -358,6 +358,8 @@ class Project extends Api { try { $process = new \BusinessModel\Process(); + $process->setFormatFieldNameInUppercase(false); + $process->setArrayFieldNameForException(array("processUid" => "prj_uid")); $response = $process->getInputDocuments($prj_uid); diff --git a/workflow/engine/src/Services/Api/ProcessMaker/Project/InputDocument.php b/workflow/engine/src/Services/Api/ProcessMaker/Project/InputDocument.php index 89351ad4b..a74275552 100644 --- a/workflow/engine/src/Services/Api/ProcessMaker/Project/InputDocument.php +++ b/workflow/engine/src/Services/Api/ProcessMaker/Project/InputDocument.php @@ -12,17 +12,19 @@ use \Luracast\Restler\RestException; class InputDocument extends Api { /** - * @url GET /:projectUid/input-document/:inputDocumentUid + * @url GET /:prj_uid/input-document/:inp_doc_uid * - * @param string $inputDocumentUid {@min 32}{@max 32} - * @param string $projectUid {@min 32}{@max 32} + * @param string $inp_doc_uid {@min 32}{@max 32} + * @param string $prj_uid {@min 32}{@max 32} */ - public function doGetInputDocument($inputDocumentUid, $projectUid) + public function doGetInputDocument($inp_doc_uid, $prj_uid) { try { - $inputdoc = new \BusinessModel\InputDocument(); + $inputDocument = new \BusinessModel\InputDocument(); + $inputDocument->setFormatFieldNameInUppercase(false); + $inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid")); - $response = $inputdoc->getInputDocument($inputDocumentUid); + $response = $inputDocument->getInputDocument($inp_doc_uid); return $response; } catch (\Exception $e) { @@ -31,37 +33,21 @@ class InputDocument extends Api } /** - * @url POST /:projectUid/input-document + * @url POST /:prj_uid/input-document * - * @param string $projectUid {@min 32}{@max 32} + * @param string $prj_uid {@min 32}{@max 32} * @param array $request_data - * @param string $inp_doc_title {@from body}{@required true} - * @param string $inp_doc_description {@from body} - * @param string $inp_doc_form_needed {@from body}{@choice VIRTUAL,REAL,VREAL} - * @param string $inp_doc_original {@from body}{@choice ORIGINAL,COPY,COPYLEGAL} - * @param string $inp_doc_published {@from body}{@choice PRIVATE} - * @param int $inp_doc_versioning {@from body}{@choice 0,1} - * @param string $inp_doc_destination_path {@from body} - * @param string $inp_doc_tags {@from body} * * @status 201 */ - public function doPostInputDocument( - $projectUid, - $request_data, - $inp_doc_title = "", - $inp_doc_description = "", - $inp_doc_form_needed = "VIRTUAL", - $inp_doc_original = "ORIGINAL", - $inp_doc_published = "PRIVATE", - $inp_doc_versioning = 0, - $inp_doc_destination_path = "", - $inp_doc_tags = "" - ) { + public function doPostInputDocument($prj_uid, $request_data) + { try { - $inputdoc = new \BusinessModel\InputDocument(); + $inputDocument = new \BusinessModel\InputDocument(); + $inputDocument->setFormatFieldNameInUppercase(false); + $inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid")); - $arrayData = $inputdoc->create($projectUid, $request_data); + $arrayData = $inputDocument->create($prj_uid, $request_data); $response = $arrayData; @@ -72,54 +58,39 @@ class InputDocument extends Api } /** - * @url PUT /:projectUid/input-document/:inputDocumentUid + * @url PUT /:prj_uid/input-document/:inp_doc_uid * - * @param string $inputDocumentUid {@min 32}{@max 32} - * @param string $projectUid {@min 32}{@max 32} + * @param string $inp_doc_uid {@min 32}{@max 32} + * @param string $prj_uid {@min 32}{@max 32} * @param array $request_data - * @param string $inp_doc_title {@from body} - * @param string $inp_doc_description {@from body} - * @param string $inp_doc_form_needed {@from body}{@choice VIRTUAL,REAL,VREAL} - * @param string $inp_doc_original {@from body}{@choice ORIGINAL,COPY,COPYLEGAL} - * @param string $inp_doc_published {@from body}{@choice PRIVATE} - * @param int $inp_doc_versioning {@from body}{@choice 0,1} - * @param string $inp_doc_destination_path {@from body} - * @param string $inp_doc_tags {@from body} */ - public function doPutInputDocument( - $inputDocumentUid, - $projectUid, - $request_data, - $inp_doc_title = "", - $inp_doc_description = "", - $inp_doc_form_needed = "VIRTUAL", - $inp_doc_original = "ORIGINAL", - $inp_doc_published = "PRIVATE", - $inp_doc_versioning = 0, - $inp_doc_destination_path = "", - $inp_doc_tags = "" - ) { + public function doPutInputDocument($inp_doc_uid, $prj_uid, $request_data) + { try { - $inputdoc = new \BusinessModel\InputDocument(); + $inputDocument = new \BusinessModel\InputDocument(); + $inputDocument->setFormatFieldNameInUppercase(false); + $inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid")); - $arrayData = $inputdoc->update($inputDocumentUid, $request_data); + $arrayData = $inputDocument->update($inp_doc_uid, $request_data); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); } } /** - * @url DELETE /:projectUid/input-document/:inputDocumentUid + * @url DELETE /:prj_uid/input-document/:inp_doc_uid * - * @param string $inputDocumentUid {@min 32}{@max 32} - * @param string $projectUid {@min 32}{@max 32} + * @param string $inp_doc_uid {@min 32}{@max 32} + * @param string $prj_uid {@min 32}{@max 32} */ - public function doDeleteInputDocument($inputDocumentUid, $projectUid) + public function doDeleteInputDocument($inp_doc_uid, $prj_uid) { try { - $inputdoc = new \BusinessModel\InputDocument(); + $inputDocument = new \BusinessModel\InputDocument(); + $inputDocument->setFormatFieldNameInUppercase(false); + $inputDocument->setArrayFieldNameForException(array("processUid" => "prj_uid")); - $inputdoc->delete($inputDocumentUid); + $inputDocument->delete($inp_doc_uid); } catch (\Exception $e) { throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage())); }