BUG-15280 "No se verifica la dependencia que existe al..." SOLVED
- No se verifica la dependencia que existe al eliminar un inputDocument - Se agrego la validacion
This commit is contained in:
@@ -136,6 +136,68 @@ class InputDocument
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the InputDocument it's assigned in other objects
|
||||
*
|
||||
* @param string $inputDocumentUid Unique id of InputDocument
|
||||
*
|
||||
* return array Return array (true if it's assigned or false otherwise and data)
|
||||
*/
|
||||
public function itsAssignedInOtherObjects($inputDocumentUid)
|
||||
{
|
||||
try {
|
||||
$flagAssigned = false;
|
||||
$arrayData = array();
|
||||
|
||||
//Step
|
||||
$criteria = new \Criteria("workflow");
|
||||
|
||||
$criteria->addSelectColumn(\StepPeer::STEP_UID);
|
||||
$criteria->add(\StepPeer::STEP_TYPE_OBJ, "INPUT_DOCUMENT", \Criteria::EQUAL);
|
||||
$criteria->add(\StepPeer::STEP_UID_OBJ, $inputDocumentUid, \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, "INPUT_DOCUMENT", \Criteria::EQUAL);
|
||||
$criteria->add(\StepSupervisorPeer::STEP_UID_OBJ, $inputDocumentUid, \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, "INPUT", \Criteria::EQUAL);
|
||||
$criteria->add(\ObjectPermissionPeer::OP_OBJ_UID, $inputDocumentUid, \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 doesn't exists the InputDocument in table INPUT_DOCUMENT
|
||||
*
|
||||
@@ -189,6 +251,27 @@ class InputDocument
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify if the InputDocument it's assigned in other objects
|
||||
*
|
||||
* @param string $inputDocumentUid Unique id of InputDocument
|
||||
* @param string $fieldNameForException Field name for the exception
|
||||
*
|
||||
* return void Throw exception if the InputDocument it's assigned in other objects
|
||||
*/
|
||||
public function throwExceptionIfItsAssignedInOtherObjects($inputDocumentUid, $fieldNameForException)
|
||||
{
|
||||
try {
|
||||
list($flagAssigned, $arrayData) = $this->itsAssignedInOtherObjects($inputDocumentUid);
|
||||
|
||||
if ($flagAssigned) {
|
||||
throw new \Exception(\G::LoadTranslation("ID_INPUT_DOCUMENT_ITS_ASSIGNED", array($fieldNameForException, $inputDocumentUid, implode(", ", $arrayData))));
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create InputDocument for a Process
|
||||
*
|
||||
@@ -313,6 +396,8 @@ class InputDocument
|
||||
//Verify data
|
||||
$this->throwExceptionIfNotExistsInputDocument($inputDocumentUid, "", $this->arrayFieldNameForException["inputDocumentUid"]);
|
||||
|
||||
$this->throwExceptionIfItsAssignedInOtherObjects($inputDocumentUid, $this->arrayFieldNameForException["inputDocumentUid"]);
|
||||
|
||||
//Delete
|
||||
//StepSupervisor
|
||||
$stepSupervisor = new \StepSupervisor();
|
||||
|
||||
Reference in New Issue
Block a user