Merged in victorsl/processmaker (pull request #196)
ProcessMaker-MA "Process Variables (fixes & behat)"
This commit is contained in:
49
features/backend/process_variables/basic_sequence.feature
Normal file
49
features/backend/process_variables/basic_sequence.feature
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
@ProcessMakerMichelangelo @RestAPI
|
||||||
|
Feature: Process Variables
|
||||||
|
Requirements:
|
||||||
|
a workspace with the process 14414793652a5d718b65590036026581 ("Sample Project #1") already loaded
|
||||||
|
there are three activities in the process
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given that I have a valid access_token
|
||||||
|
|
||||||
|
#GET /api/1.0/{workspace}/project/{prj_uid}/variables
|
||||||
|
# Get all variables of a Process
|
||||||
|
Scenario Outline: Get all variables of a Process
|
||||||
|
And I request "project/14414793652a5d718b65590036026581/variables"
|
||||||
|
And the content type is "application/json"
|
||||||
|
Then the response status code should be 200
|
||||||
|
And the response charset is "UTF-8"
|
||||||
|
And the type is "array"
|
||||||
|
And the "var_name" property in row <i> equals "<var_name>"
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| i | var_name |
|
||||||
|
| 0 | SYS_LANG |
|
||||||
|
| 1 | SYS_SKIN |
|
||||||
|
| 2 | SYS_SYS |
|
||||||
|
|
||||||
|
#GET /api/1.0/{workspace}/project/{prj_uid}/grid/variables
|
||||||
|
# Get grid variables of a Process
|
||||||
|
Scenario: Get grid variables of a Process
|
||||||
|
Given I request "project/14414793652a5d718b65590036026581/grid/variables"
|
||||||
|
And the content type is "application/json"
|
||||||
|
Then the response status code should be 200
|
||||||
|
And the response charset is "UTF-8"
|
||||||
|
And the type is "array"
|
||||||
|
And the json data is an empty array
|
||||||
|
|
||||||
|
#GET /api/1.0/{workspace}/project/{prj_uid}/grid/{grid_uid}/variables
|
||||||
|
# Get all variables of a Grid
|
||||||
|
Scenario Outline: Get all variables of a Grid
|
||||||
|
Given I request "project/14414793652a5d718b65590036026581/grid/00000000000000000000000000000000/variables"
|
||||||
|
And the content type is "application/json"
|
||||||
|
Then the response status code should be <status_code>
|
||||||
|
And the response charset is "UTF-8"
|
||||||
|
And the type is "object"
|
||||||
|
And the response status message should have the following text "<status_message>"
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
| status_code | status_message |
|
||||||
|
| 400 | grid_uid |
|
||||||
|
|
||||||
@@ -237,6 +237,32 @@ class DynaForm
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify if not is grid DynaForm
|
||||||
|
*
|
||||||
|
* @param string $dynaFormUid Unique id of DynaForm
|
||||||
|
* @param string $fieldNameForException Field name for the exception
|
||||||
|
*
|
||||||
|
* return void Throw exception if not is grid DynaForm
|
||||||
|
*/
|
||||||
|
public function throwExceptionIfNotIsGridDynaForm($dynaFormUid, $fieldNameForException)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
//Load DynaForm
|
||||||
|
$dynaForm = new \Dynaform();
|
||||||
|
|
||||||
|
$arrayDynaFormData = $dynaForm->Load($dynaFormUid);
|
||||||
|
|
||||||
|
if ($arrayDynaFormData["DYN_TYPE"] != "grid") {
|
||||||
|
$msg = str_replace(array("{0}", "{1}"), array($fieldNameForException, $dynaFormUid), "The DynaForm with {0}: {1}, not is grid");
|
||||||
|
|
||||||
|
throw (new \Exception($msg));
|
||||||
|
}
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create DynaForm for a Process
|
* Create DynaForm for a Process
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1569,6 +1569,7 @@ class Process
|
|||||||
$dynaForm = new \BusinessModel\DynaForm();
|
$dynaForm = new \BusinessModel\DynaForm();
|
||||||
|
|
||||||
$dynaForm->throwExceptionIfNotExistsDynaForm($gridUid, $processUid, $this->arrayFieldNameForException["gridUid"]);
|
$dynaForm->throwExceptionIfNotExistsDynaForm($gridUid, $processUid, $this->arrayFieldNameForException["gridUid"]);
|
||||||
|
$dynaForm->throwExceptionIfNotIsGridDynaForm($gridUid, $this->arrayFieldNameForException["gridUid"]);
|
||||||
|
|
||||||
//Get data
|
//Get data
|
||||||
$file = PATH_DYNAFORM . $processUid . PATH_SEP . $gridUid . ".xml";
|
$file = PATH_DYNAFORM . $processUid . PATH_SEP . $gridUid . ".xml";
|
||||||
|
|||||||
@@ -7,9 +7,12 @@ class WebEntry
|
|||||||
"TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid"),
|
"TAS_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "taskUid"),
|
||||||
"DYN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"),
|
"DYN_UID" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormUid"),
|
||||||
"METHOD" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("WS", "HTML"), "fieldNameAux" => "method"),
|
"METHOD" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("WS", "HTML"), "fieldNameAux" => "method"),
|
||||||
"INPUT_DOCUMENT_ACCESS" => array("type" => "int", "required" => true, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "inputDocumentAccess"),
|
"INPUT_DOCUMENT_ACCESS" => array("type" => "int", "required" => true, "empty" => false, "defaultValues" => array(0, 1), "fieldNameAux" => "inputDocumentAccess")
|
||||||
"USR_USERNAME" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUsername"),
|
);
|
||||||
"USR_PASSWORD" => array("type" => "string", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userPassword")
|
|
||||||
|
private $arrayUserFieldDefinition = array(
|
||||||
|
"USR_USERNAME" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userUsername"),
|
||||||
|
"USR_PASSWORD" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "userPassword")
|
||||||
);
|
);
|
||||||
|
|
||||||
private $formatFieldNameInUppercase = true;
|
private $formatFieldNameInUppercase = true;
|
||||||
@@ -29,6 +32,10 @@ class WebEntry
|
|||||||
foreach ($this->arrayFieldDefinition as $key => $value) {
|
foreach ($this->arrayFieldDefinition as $key => $value) {
|
||||||
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->arrayUserFieldDefinition as $key => $value) {
|
||||||
|
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw $e;
|
throw $e;
|
||||||
}
|
}
|
||||||
@@ -279,13 +286,7 @@ class WebEntry
|
|||||||
$projectUser = new \BusinessModel\ProjectUser();
|
$projectUser = new \BusinessModel\ProjectUser();
|
||||||
|
|
||||||
if ($arrayData["METHOD"] == "WS") {
|
if ($arrayData["METHOD"] == "WS") {
|
||||||
if (!isset($arrayData["USR_USERNAME"])) {
|
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayUserFieldDefinition, $this->arrayFieldNameForException, true);
|
||||||
throw (new \Exception(str_replace(array("{0}"), array($this->arrayFieldNameForException["userUsername"]), "The \"{0}\" attribute is not defined")));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($arrayData["USR_PASSWORD"])) {
|
|
||||||
throw (new \Exception(str_replace(array("{0}"), array($this->arrayFieldNameForException["userPassword"]), "The \"{0}\" attribute is not defined")));
|
|
||||||
}
|
|
||||||
|
|
||||||
$loginData = $projectUser->userLogin($arrayData["USR_USERNAME"], $arrayData["USR_PASSWORD"]);
|
$loginData = $projectUser->userLogin($arrayData["USR_USERNAME"], $arrayData["USR_PASSWORD"]);
|
||||||
|
|
||||||
|
|||||||
@@ -425,9 +425,8 @@ class Project extends Api
|
|||||||
* @url GET /:prj_uid/grid/:grid_uid/variables
|
* @url GET /:prj_uid/grid/:grid_uid/variables
|
||||||
*
|
*
|
||||||
* @param string $prj_uid {@min 32}{@max 32}
|
* @param string $prj_uid {@min 32}{@max 32}
|
||||||
* @param string $grid_uid
|
|
||||||
*/
|
*/
|
||||||
public function doGetGridVariablesByGridUid($prj_uid, $grid_uid = "")
|
public function doGetGridVariables($prj_uid, $grid_uid = "")
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$process = new \BusinessModel\Process();
|
$process = new \BusinessModel\Process();
|
||||||
|
|||||||
Reference in New Issue
Block a user