public function getValue($rowId, $columnId, $data = null) { $returnValue = null; if (isset($this->data[$rowId])) { //return values: if (isset($this->data[$rowId][$columnId])) { $returnValue = $this->data[$rowId][$columnId]; } } else { if (common_Utils::isUri($rowId)) { $processInstance = new core_kernel_classes_Resource($rowId); //TODO: property uris need to be set in the constant files: $unit = $processInstance->getOnePropertyValue(TranslationProcessHelper::getProperty('unitUri')); $countryCode = $processInstance->getOnePropertyValue(TranslationProcessHelper::getProperty('CountryCOde')); $langCode = $processInstance->getOnePropertyValue(TranslationProcessHelper::getProperty('LanguageCode')); $this->data[$rowId] = array('unit' => is_null($unit) ? 'n/a' : $unit->getLabel(), 'country' => $countryCode instanceof core_kernel_classes_Literal ? $countryCode->literal : 'n/a', 'language' => $langCode instanceof core_kernel_classes_Literal ? $langCode->literal : 'n/a'); if (isset($this->data[$rowId][$columnId])) { $returnValue = $this->data[$rowId][$columnId]; } } } return $returnValue; }
private function executeProcessBooklet($processDefinition, $unitUri, $countryCode, $languageCode, $simulationOptions) { $activityExecutionService = tao_models_classes_ServiceFactory::get('wfEngine_models_classes_ActivityExecutionService'); $processExecutionService = tao_models_classes_ServiceFactory::get('wfEngine_models_classes_ProcessExecutionService'); $processDefinitionService = tao_models_classes_ServiceFactory::get('wfEngine_models_classes_ProcessDefinitionService'); $loginProperty = new core_kernel_classes_Property(PROPERTY_USER_LOGIN); $processExecName = 'Test Translation Process Execution'; $processExecComment = 'created by ' . __CLASS__ . '::' . __METHOD__; $users = $this->getAuthorizedUsersByCountryLanguage($countryCode, $languageCode); if (empty($users)) { $this->fail("cannot find the authorized npm, verifier and reconciler for this country-language : {$countryCode}/{$languageCode}"); return; } //check that the xliff and vff exist for the given country-language: $unit = new core_kernel_classes_Resource($unitUri); $vffRevision = 0; $xliffRevision = 0; $initVariables = array($this->vars['unitUri']->getUri() => $unit->getUri(), $this->vars['countryCode']->getUri() => $countryCode, $this->vars['languageCode']->getUri() => $languageCode, $this->vars['npm']->getUri() => $users['npm'], $this->vars['reconciler']->getUri() => $users['reconciler'], $this->vars['verifier']->getUri() => $users['verifier'], $this->vars['xliff']->getUri() => $xliffRevision, $this->vars['vff']->getUri() => $vffRevision); $this->changeUser($this->userLogins['consortium'][1]); $this->assertTrue($processDefinitionService->checkAcl($processDefinition, $this->currentUser)); $processInstance = $processExecutionService->createProcessExecution($processDefinition, $processExecName, $processExecComment, $initVariables); $this->assertEqual($processDefinition->getUri(), $processExecutionService->getExecutionOf($processInstance)->getUri()); $processInstance->setPropertyValue($this->properties[TranslationProcessHelper::getPropertyName('unitUri')], $unit); $processInstance->setPropertyValue($this->properties[TranslationProcessHelper::getPropertyName('countryCode')], $countryCode); $processInstance->setPropertyValue($this->properties[TranslationProcessHelper::getPropertyName('languageCode')], $languageCode); $this->assertTrue($processExecutionService->checkStatus($processInstance, 'started')); $this->out(__METHOD__, true); $this->processExecutions[$processInstance->getUri()] = $processInstance; $currentActivityExecutions = $processExecutionService->getCurrentActivityExecutions($processInstance); $this->assertEqual(count($currentActivityExecutions), 1); if (isset($simulationOptions['execute']) && $simulationOptions['execute'] === false) { return; } $this->out("<strong>Forward transitions:</strong>", true); // $nbTranslators = (isset($simulationOptions['translations']) && intval($simulationOptions['translations']) >= 1 ) ? intval($simulationOptions['translations']) : 2; //>=1 $nbLoops = isset($simulationOptions['repeatLoop']) ? intval($simulationOptions['repeatLoop']) : 1; $nbBacks = isset($simulationOptions['repeatBack']) ? intval($simulationOptions['repeatBack']) : 0; $stopProbability = isset($simulationOptions['stopProbability']) ? floatval($simulationOptions['stopProbability']) : 0; $loopsCounter = array(); $iterations = 5; $this->changeUser($this->userLogins[$countryCode]['NPM']); $i = 1; $activityIndex = $i; while ($activityIndex <= $iterations) { $activityExecution = null; $activity = null; $activityExecutions = $processExecutionService->getCurrentActivityExecutions($processInstance); $this->assertEqual(count($activityExecutions), 1); $activityExecution = reset($activityExecutions); $activity = $activityExecutionService->getExecutionOf($activityExecution); $this->out("<strong>Iteration {$i} : activity no{$activityIndex} : " . $activity->getLabel() . "</strong>", true); $this->out("current user : "******"' . $this->currentUser->getUri() . '"', true); $this->checkAccessControl($activityExecution); $currentActivityExecution = null; //for loop managements: $goto = 0; $login = ''; //access control checking: switch ($activityIndex) { case 1: case 5: //reconciliation: //correct verification issues: $login = $this->userLogins[$countryCode][$languageCode]['reconciler']; case 3: //verify translations : if (empty($login)) { $login = $this->userLogins[$countryCode][$languageCode]['verifier']; } $this->assertFalse(empty($login)); $this->bashCheckAcl($activityExecution, array($login), array_rand($this->users, 5)); $this->changeUser($login); $currentActivityExecution = $this->initCurrentActivityExecution($activityExecution); break; case 2: case 4: //final check by TD: TD sign off: $developersLogins = $this->userLogins['testDeveloper']; $this->bashCheckAcl($activityExecution, $developersLogins); $this->changeUser($developersLogins[array_rand($developersLogins)]); $currentActivityExecution = $this->initCurrentActivityExecution($activityExecution); break; } //execute services: $loopName = ''; switch ($activityIndex) { case 1: //let it be break; case 2: if (empty($loopName)) { $loopName = 'LayoutCheck'; } case 3: if (empty($loopName)) { $loopName = 'FinalCheck'; } case 4: if (empty($loopName)) { $loopName = 'TDsignOff'; } case 5: if (empty($loopName)) { $loopName = 'CountrySignOff'; } $serviceName = 'executeServiceBooklet' . $loopName; if (!method_exists($this, $serviceName)) { throw new Exception('the method does not exist : ' . $serviceName); break; } if (!isset($loopsCounter[$loopName])) { // $loopsCounter = array(); //reinitialize the loops counter $loopsCounter[$loopName] = $nbLoops; $this->assertTrue($this->{$serviceName}(false)); $goto = $activityIndex - 1; //go back } else { $this->assertTrue($this->{$serviceName}(true)); } break; } //transition to next activity $transitionResult = $processExecutionService->performTransition($processInstance, $currentActivityExecution); $goto = intval($goto); if ($activityIndex == $iterations && !$goto) { //process finished: $this->assertEqual(count($transitionResult), 0); $this->assertTrue($processExecutionService->isFinished($processInstance)); } else { $this->assertEqual(count($transitionResult), 0); $this->assertTrue($processExecutionService->isPaused($processInstance)); } //manage next activity index: if ($goto) { $activityIndex = $goto; } else { $activityIndex++; } //increment iteration counts: $i++; $this->out("activity status : " . $activityExecutionService->getStatus($currentActivityExecution)->getLabel()); $this->out("process status : " . $processExecutionService->getStatus($processInstance)->getLabel()); $rand = rand(0, $iterations); $prob = $activityIndex * $stopProbability; if ($rand < $prob) { $this->out("process instance stopped by probability"); break; } } $activityExecutionsData = $processExecutionService->getAllActivityExecutions($processInstance); // var_dump($activityExecutionsData); $executionHistory = $processExecutionService->getExecutionHistory($processInstance); $this->assertEqual(count($executionHistory), $i); //there is one hidden activity }