Merge branch 'master' of bitbucket.org:colosa/processmaker
Conflicts: workflow/engine/src/ProcessMaker/BusinessModel/Variable.php
This commit is contained in:
@@ -3,38 +3,6 @@ namespace ProcessMaker\BusinessModel;
|
||||
|
||||
class Variable
|
||||
{
|
||||
private $arrayFieldDefinition = array(
|
||||
"VAR_NAME" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "varName"),
|
||||
"VAR_FIELD_TYPE" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "varFieldType"),
|
||||
"VAR_FIELD_SIZE" => array("type" => "int", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "varFieldSize"),
|
||||
"VAR_LABEL" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "varLabel"),
|
||||
"VAR_DBCONNECTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "varDbconnection"),
|
||||
"VAR_SQL" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "varSql"),
|
||||
"VAR_NULL" => array("type" => "int", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "varNull"),
|
||||
"VAR_DEFAULT" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "varDefault"),
|
||||
"VAR_ACCEPTED_VALUES" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "varAcceptedValues")
|
||||
);
|
||||
|
||||
private $arrayFieldNameForException = array(
|
||||
"processUid" => "PRO_UID"
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor of the class
|
||||
*
|
||||
* return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
try {
|
||||
foreach ($this->arrayFieldDefinition as $key => $value) {
|
||||
$this->arrayFieldNameForException[$value["fieldNameAux"]] = $key;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create Variable for a Process
|
||||
*
|
||||
@@ -47,13 +15,14 @@ class Variable
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
|
||||
Validator::proUid($processUid, '$prj_uid');
|
||||
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
$this->existsName($processUid, $arrayData["VAR_NAME"]);
|
||||
|
||||
$this->throwExceptionFieldDefinition($arrayData);
|
||||
|
||||
//Create
|
||||
$cnn = \Propel::getConnection("workflow");
|
||||
try {
|
||||
@@ -121,12 +90,10 @@ class Variable
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
|
||||
|
||||
$this->throwExceptionIfNotExistsVariable($variableUid);
|
||||
|
||||
Validator::proUid($processUid, '$prj_uid');
|
||||
$arrayData = array_change_key_case($arrayData, CASE_UPPER);
|
||||
|
||||
$this->throwExceptionFieldDefinition($arrayData);
|
||||
$this->existsName($processUid, $arrayData["VAR_NAME"]);
|
||||
//Update
|
||||
$cnn = \Propel::getConnection("workflow");
|
||||
@@ -183,9 +150,7 @@ class Variable
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
|
||||
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
|
||||
Validator::proUid($processUid, '$prj_uid');
|
||||
|
||||
$this->throwExceptionIfNotExistsVariable($variableUid);
|
||||
|
||||
@@ -211,16 +176,12 @@ class Variable
|
||||
public function getVariable($processUid, $variableUid)
|
||||
{
|
||||
try {
|
||||
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
|
||||
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
|
||||
Validator::proUid($processUid, '$prj_uid');
|
||||
|
||||
$this->throwExceptionIfNotExistsVariable($variableUid);
|
||||
|
||||
//Get data
|
||||
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_UID);
|
||||
@@ -279,12 +240,9 @@ class Variable
|
||||
{
|
||||
try {
|
||||
//Verify data
|
||||
$process = new \ProcessMaker\BusinessModel\Process();
|
||||
|
||||
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
|
||||
Validator::proUid($processUid, '$prj_uid');
|
||||
|
||||
//Get data
|
||||
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\ProcessVariablesPeer::VAR_UID);
|
||||
@@ -331,19 +289,40 @@ class Variable
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if does not exist the variable in table PROCESS_VARIABLES
|
||||
* Verify field definition
|
||||
*
|
||||
* @param string $variableUid Unique id of variable
|
||||
* @param array $aData Unique id of Variable to exclude
|
||||
*
|
||||
* return void Throw exception if does not exist the variable in table PROCESS_VARIABLES
|
||||
*/
|
||||
public function throwExceptionIfNotExistsVariable($variableUid)
|
||||
public function throwExceptionFieldDefinition($aData)
|
||||
{
|
||||
try {
|
||||
$obj = \ProcessVariablesPeer::retrieveByPK($variableUid);
|
||||
|
||||
if (is_null($obj)) {
|
||||
throw new \Exception('var_uid: '.$variableUid. ' '.\G::LoadTranslation("ID_DOES_NOT_EXIST"));
|
||||
if (isset($aData["VAR_NAME"])) {
|
||||
Validator::isString($aData['VAR_NAME'], '$var_name');
|
||||
}
|
||||
if (isset($aData["VAR_FIELD_TYPE"])) {
|
||||
Validator::isString($aData['VAR_FIELD_TYPE'], '$var_field_type');
|
||||
}
|
||||
if (isset($aData["VAR_FIELD_SIZE"])) {
|
||||
Validator::isInteger($aData["VAR_FIELD_SIZE"], '$var_field_size');
|
||||
}
|
||||
if (isset($aData["VAR_LABEL"])) {
|
||||
Validator::isString($aData['VAR_LABEL'], '$var_label');
|
||||
}
|
||||
if (isset($aData["VAR_DBCONNECTION"])) {
|
||||
Validator::isString($aData['VAR_DBCONNECTION'], '$var_dbconnection');
|
||||
}
|
||||
if (isset($aData["VAR_SQL"])) {
|
||||
Validator::isString($aData['VAR_SQL'], '$var_sql');
|
||||
}
|
||||
if (isset($aData["VAR_NULL"])) {
|
||||
Validator::isInteger($aData['VAR_NULL'], '$var_null');
|
||||
}
|
||||
if (isset($aData["VAR_DEFAULT"])) {
|
||||
Validator::isString($aData['VAR_DEFAULT'], '$var_default');
|
||||
}
|
||||
if (isset($aData["VAR_ACCEPTED_VALUES"])) {
|
||||
Validator::isString($aData['VAR_ACCEPTED_VALUES'], '$var_accepted_values');
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
|
||||
Reference in New Issue
Block a user