Se adiciona validaciones para OutputDocument y ProcessVariable
This commit is contained in:
@@ -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, "inputDocumentUid");
|
||||
\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