Merged in darojas/processmaker (pull request #569)
Se adiciona dyn_version en data/mysql/schema.sql. Se adiciona validaciones para OutputDocument, Dynaform y ProcessVariable
This commit is contained in:
@@ -283,8 +283,10 @@ class CaseScheduler
|
||||
if (!preg_match($patternDate, $caseSchedulerData['SCH_START_DATE'])) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_START_DATE"));
|
||||
}
|
||||
if (!preg_match($patternDate, $caseSchedulerData['SCH_END_DATE'])) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_END_DATE"));
|
||||
if (!isset($caseSchedulerData['SCH_END_DATE'])) {
|
||||
if (!preg_match($patternDate, $caseSchedulerData['SCH_END_DATE'])) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_END_DATE"));
|
||||
}
|
||||
}
|
||||
if ($caseSchedulerData['SCH_START_DATE'] == "") {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_date')));
|
||||
@@ -568,8 +570,10 @@ class CaseScheduler
|
||||
if (!preg_match($patternDate, $caseSchedulerData['SCH_START_DATE'])) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_START_DATE"));
|
||||
}
|
||||
if (!preg_match($patternDate, $caseSchedulerData['SCH_END_DATE'])) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_END_DATE"));
|
||||
if (isset($caseSchedulerData['SCH_END_DATE'])) {
|
||||
if (!preg_match($patternDate, $caseSchedulerData['SCH_END_DATE'])) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_INVALID_SCH_END_DATE"));
|
||||
}
|
||||
}
|
||||
if ($caseSchedulerData['SCH_START_DATE'] == "") {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('sch_start_date')));
|
||||
|
||||
@@ -10,7 +10,7 @@ class DynaForm
|
||||
"DYN_DESCRIPTION" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormDescription"),
|
||||
"DYN_TYPE" => array("type" => "string", "required" => true, "empty" => false, "defaultValues" => array("xmlform", "grid"), "fieldNameAux" => "dynaFormType"),
|
||||
"DYN_CONTENT" => array("type" => "string", "required" => false, "empty" => true, "defaultValues" => array(), "fieldNameAux" => "dynaFormContent"),
|
||||
"DYN_VERSION" => array("type" => "int", "required" => false, "empty" => false, "defaultValues" => array(), "fieldNameAux" => "dynaFormVersion")
|
||||
"DYN_VERSION" => array("type" => "int", "required" => true, "empty" => false, "defaultValues" => array(1 ,2), "fieldNameAux" => "dynaFormVersion")
|
||||
);
|
||||
|
||||
private $formatFieldNameInUppercase = true;
|
||||
@@ -358,6 +358,10 @@ class DynaForm
|
||||
|
||||
$process->throwExceptionIfNotExistsProcess($processUid, $this->arrayFieldNameForException["processUid"]);
|
||||
|
||||
if (!isset($arrayData["DYN_VERSION"])) {
|
||||
$arrayData["DYN_VERSION"] = 1;
|
||||
}
|
||||
|
||||
$process->throwExceptionIfDataNotMetFieldDefinition($arrayData, $this->arrayFieldDefinition, $this->arrayFieldNameForException, true);
|
||||
|
||||
$this->throwExceptionIfExistsTitle($processUid, $arrayData["DYN_TITLE"], $this->arrayFieldNameForException["dynaFormTitle"]);
|
||||
@@ -365,10 +369,6 @@ class DynaForm
|
||||
//Create
|
||||
$dynaForm = new \Dynaform();
|
||||
|
||||
if (isset($arrayData["DYN_VERSION"])) {
|
||||
$arrayData["DYN_VERSION"] = 1;
|
||||
}
|
||||
|
||||
$arrayData["PRO_UID"] = $processUid;
|
||||
|
||||
$dynaFormUid = $dynaForm->create($arrayData);
|
||||
|
||||
@@ -363,6 +363,7 @@ class OutputDocument
|
||||
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "OutputDocument.php");
|
||||
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "ObjectPermission.php");
|
||||
require_once(PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes" . PATH_SEP . "model" . PATH_SEP . "Step.php");
|
||||
$this->throwExceptionIfItsAssignedInOtherObjects($sOutputDocumentUID, "outputDocumentUid");
|
||||
\G::LoadClass( 'processMap' );
|
||||
$oOutputDocument = new \OutputDocument();
|
||||
$fields = $oOutputDocument->load( $sOutputDocumentUID );
|
||||
@@ -443,5 +444,87 @@ class OutputDocument
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the OutputDocument it's assigned in other objects
|
||||
*
|
||||
* @param string $outputDocumentUid Unique id of OutputDocument
|
||||
*
|
||||
* return array Return array (true if it's assigned or false otherwise and data)
|
||||
*/
|
||||
public function itsAssignedInOtherObjects($outputDocumentUid)
|
||||
{
|
||||
try {
|
||||
$flagAssigned = false;
|
||||
$arrayData = array();
|
||||
//Step
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\StepPeer::STEP_UID);
|
||||
$criteria->add(\StepPeer::STEP_TYPE_OBJ, "OUTPUT_DOCUMENT", \Criteria::EQUAL);
|
||||
$criteria->add(\StepPeer::STEP_UID_OBJ, $outputDocumentUid, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \StepPeer::doSelectRS($criteria);
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
$flagAssigned = true;
|
||||
$arrayData[] = \G::LoadTranslation("ID_STEPS");
|
||||
}
|
||||
|
||||
//StepSupervisor
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\StepSupervisorPeer::STEP_UID);
|
||||
$criteria->add(\StepSupervisorPeer::STEP_TYPE_OBJ, "OUTPUT_DOCUMENT", \Criteria::EQUAL);
|
||||
$criteria->add(\StepSupervisorPeer::STEP_UID_OBJ, $outputDocumentUid, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \StepSupervisorPeer::doSelectRS($criteria);
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
$flagAssigned = true;
|
||||
$arrayData[] = \G::LoadTranslation("ID_CASES_MENU_ADMIN");
|
||||
}
|
||||
|
||||
//ObjectPermission
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\ObjectPermissionPeer::OP_UID);
|
||||
$criteria->add(\ObjectPermissionPeer::OP_OBJ_TYPE, "OUTPUT", \Criteria::EQUAL);
|
||||
$criteria->add(\ObjectPermissionPeer::OP_OBJ_UID, $outputDocumentUid, \Criteria::EQUAL);
|
||||
|
||||
$rsCriteria = \ObjectPermissionPeer::doSelectRS($criteria);
|
||||
|
||||
if ($rsCriteria->next()) {
|
||||
$flagAssigned = true;
|
||||
$arrayData[] = \G::LoadTranslation("ID_PROCESS_PERMISSIONS");
|
||||
}
|
||||
|
||||
//Return
|
||||
return array($flagAssigned, $arrayData);
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the OutputDocument it's assigned in other objects
|
||||
*
|
||||
* @param string $outputDocumentUid Unique id of OutputDocument
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if the OutputDocument it's assigned in other objects
|
||||
*/
|
||||
public function throwExceptionIfItsAssignedInOtherObjects($outputDocumentUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
list($flagAssigned, $arrayData) = $this->itsAssignedInOtherObjects($outputDocumentUid);
|
||||
|
||||
if ($flagAssigned) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_OUTPUT_DOCUMENT_ITS_ASSIGNED", array($fieldNameForException, $outputDocumentUid, implode(", ", $arrayData))));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -299,15 +299,23 @@ class Variable
|
||||
try {
|
||||
if (isset($aData["VAR_NAME"])) {
|
||||
Validator::isString($aData['VAR_NAME'], '$var_name');
|
||||
} else {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_name' )));
|
||||
}
|
||||
if (isset($aData["VAR_FIELD_TYPE"])) {
|
||||
Validator::isString($aData['VAR_FIELD_TYPE'], '$var_field_type');
|
||||
} else {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_field_type' )));
|
||||
}
|
||||
if (isset($aData["VAR_FIELD_SIZE"])) {
|
||||
Validator::isInteger($aData["VAR_FIELD_SIZE"], '$var_field_size');
|
||||
} else {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_field_size' )));
|
||||
}
|
||||
if (isset($aData["VAR_LABEL"])) {
|
||||
Validator::isString($aData['VAR_LABEL'], '$var_label');
|
||||
} else {
|
||||
throw new \Exception(\G::LoadTranslation("ID_CAN_NOT_BE_NULL", array('$var_label' )));
|
||||
}
|
||||
if (isset($aData["VAR_DBCONNECTION"])) {
|
||||
Validator::isString($aData['VAR_DBCONNECTION'], '$var_dbconnection');
|
||||
@@ -316,7 +324,10 @@ class Variable
|
||||
Validator::isString($aData['VAR_SQL'], '$var_sql');
|
||||
}
|
||||
if (isset($aData["VAR_NULL"])) {
|
||||
Validator::isInteger($aData['VAR_NULL'], '$var_null');
|
||||
Validator::isInteger($aData['VAR_NULL'], '$var_null');
|
||||
if ($aData["VAR_NULL"] != 0 || $aData["VAR_NULL"] !=1 ) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_INVALID_VALUE_ONLY_ACCEPTS_VALUES", array('$var_null','0, 1' )));
|
||||
}
|
||||
}
|
||||
if (isset($aData["VAR_DEFAULT"])) {
|
||||
Validator::isString($aData['VAR_DEFAULT'], '$var_default');
|
||||
|
||||
Reference in New Issue
Block a user