BUG 12173 "Trigger Execution" SOLVED

- No execute triggers according the configuration in case scheduler
- Solved problem, add code to execute triggers in method newCase() in wsBase class
* Available from version ProcessMaker-2.5.1-testing.3
This commit is contained in:
Victor Saisa Lopez
2013-06-24 10:24:45 -04:00
parent 5f17fdb236
commit d615959042
4 changed files with 37 additions and 8 deletions

View File

@@ -770,7 +770,7 @@ class wsBase
}
$oSpool = new spoolRun();
$oSpool->setConfig(
$oSpool->setConfig(
array (
'MESS_ENGINE' => $aSetup['MESS_ENGINE'],
'MESS_SERVER' => $aSetup['MESS_SERVER'],
@@ -1706,10 +1706,13 @@ class wsBase
* @param string $userId
* @param string $taskId
* @param string $variables
* @param int $executeTriggers : Optional parameter. The execution all triggers of the task, according to your steps, 1 yes 0 no.
* @return $result will return an object
*/
public function newCase ($processId, $userId, $taskId, $variables)
public function newCase($processId, $userId, $taskId, $variables, $executeTriggers = 0)
{
//$executeTriggers, this parameter is not important, it may be the last parameter in the method
$g = new G();
try {
@@ -1737,7 +1740,6 @@ class wsBase
}
$oCase = new Cases();
$oTask = new Tasks();
$startingTasks = $oCase->getStartCases( $userId );
array_shift( $startingTasks ); //remove the first row, the header row
$founded = '';
@@ -1778,6 +1780,7 @@ class wsBase
return $result;
}
//Start case
$case = $oCase->startCase( $taskId, $userId );
$_SESSION['APPLICATION'] = $case['APPLICATION'];
@@ -1799,6 +1802,22 @@ class wsBase
$oldFields['TAS_UID'] = $taskId;
$up_case = $oCase->updateCase( $caseId, $oldFields );
//Execute all triggers of the task, according to your steps
if ($executeTriggers == 1) {
$task = new Tasks();
$arrayStep = $task->getStepsOfTask($taskId);
foreach ($arrayStep as $step) {
$arrayField = $oCase->loadCase($caseId);
$arrayField["APP_DATA"] = $oCase->executeTriggers($taskId, $step["STEP_TYPE_OBJ"], $step["STEP_UID_OBJ"], "BEFORE", $arrayField["APP_DATA"]);
$arrayField["APP_DATA"] = $oCase->executeTriggers($taskId, $step["STEP_TYPE_OBJ"], $step["STEP_UID_OBJ"], "AFTER", $arrayField["APP_DATA"]);
$arrayField = $oCase->updateCase($caseId, $arrayField);
}
}
//Response
$result = new wsResponse( 0, G::loadTranslation( 'ID_STARTED_SUCCESSFULLY' ) );
$result->caseId = $caseId;
$result->caseNumber = $caseNr;

View File

@@ -396,7 +396,12 @@ class CaseScheduler extends BaseCaseScheduler
$paramsRouteLogResult = $paramsLogResultFromPlugin['paramsRouteLogResult'];
} else {
eprint( " - Creating the new case............." );
$result = $client->__SoapCall( 'NewCase', array ($params) );
$paramsAux = $params;
$paramsAux["executeTriggers"] = 1;
$result = $client->__SoapCall("NewCase", array($paramsAux));
if ($result->status_code == 0) {
eprintln( "OK+ CASE #{$result->caseNumber} was created!", 'green' );
@@ -499,7 +504,10 @@ class CaseScheduler extends BaseCaseScheduler
$paramsLog = array ('PRO_UID' => $processId,'TAS_UID' => $taskId,'SCH_UID' => $sSchedulerUid,'USR_NAME' => $user,'RESULT' => '','EXEC_DATE' => date( 'Y-m-d' ),'EXEC_HOUR' => date( 'H:i:s' ),'WS_CREATE_CASE_STATUS' => '','WS_ROUTE_CASE_STATUS' => ''
);
$result = $client->__SoapCall( 'NewCase', array ($params) );
$paramsAux = $params;
$paramsAux["executeTriggers"] = 1;
$result = $client->__SoapCall("NewCase", array($paramsAux));
eprint( " - Creating the new case............." );
if ($result->status_code == 0) {

View File

@@ -410,6 +410,7 @@
<xs:element name="processId" type="xs:string"/>
<xs:element name="taskId" type="xs:string"/>
<xs:element name="variables" maxOccurs="unbounded" type="xs0:variableListStruct"/>
<xs:element name="executeTriggers" minOccurs="0" maxOccurs="unbounded" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
</xs:element>

View File

@@ -589,7 +589,7 @@ function DerivateCase ($params)
$oStd->wsSessionId = $params->sessionId;
$ws = new wsBase( $oStd );
$res = $ws->derivateCase( $user['USR_UID'], $params->caseId, $params->delIndex );
$res = $ws->derivateCase($user["USR_UID"], $params->caseId, $params->delIndex, true);
return $res;
}
@@ -616,7 +616,7 @@ function RouteCase ($params)
$oStd->wsSessionId = $params->sessionId;
$ws = new wsBase( $oStd );
$res = $ws->derivateCase( $user['USR_UID'], $params->caseId, $params->delIndex );
$res = $ws->derivateCase($user["USR_UID"], $params->caseId, $params->delIndex, true);
return $res;
@@ -765,7 +765,8 @@ function NewCase ($params)
$params->variables = $field;
$ws = new wsBase();
$res = $ws->newCase( $params->processId, $userId, $params->taskId, $params->variables );
$res = $ws->newCase($params->processId, $userId, $params->taskId, $params->variables, (isset($params->executeTriggers))? (int)($params->executeTriggers) : 0);
// we need to register the case id for a stored session variable. like a normal Session.
$oSession->registerGlobal( "APPLICATION", $res->caseId );