/** * Short description of method isActivityFinal * * @access public * @author Joel Bout, <*****@*****.**> * @param Resource activity * @return boolean */ public static function isActivityFinal(core_kernel_classes_Resource $activity) { $returnValue = (bool) false; $next = wfEngine_models_classes_StepService::singleton()->getNextSteps($activity); $returnValue = empty($next); return (bool) $returnValue; }
/** * Tests a process, to see if it corresponds to the reference * Returns the last activity after the end of the reference was reached * * @param unknown $activity * @param unknown $reference */ protected function assertProcessPartCorresponds($activity, $reference) { $current = $activity; $currentRef = $reference; do { $this->assertCorresponds($current, $currentRef); $arr = wfEngine_models_classes_StepService::singleton()->getNextSteps($currentRef); $currentRef = count($arr) == 1 ? current($arr) : null; if (!is_null($currentRef)) { $arr = wfEngine_models_classes_StepService::singleton()->getNextSteps($current); if (count($arr) != 1) { $this->fail(count($arr) . ' next activities instead of 1'); return $current; } else { $current = current($arr); } } } while (!is_null($currentRef)); return $current; }
/** * Short description of method __construct * * @access protected * @author Joel Bout, <*****@*****.**> * @return mixed */ protected function __construct() { $this->instancesCache = array(); $this->cache = true; parent::__construct(); }
/** * returns all the activities that are final * aka which have no following step * * @access public * @author Joel Bout, <*****@*****.**> * @param Resource process * @return array */ public function getFinalSteps(core_kernel_classes_Resource $process) { $returnValue = array(); foreach ($this->getAllActivities($process) as $activity) { $nexts = wfEngine_models_classes_StepService::singleton()->getNextSteps($activity); if (empty($nexts)) { $returnValue[] = $activity; } } return (array) $returnValue; }
/** * The method creates the array representation of jstree, for a process definition * * @access public * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu} * @param core_kernel_classes_Resource process * @return array */ public function activityTree(core_kernel_classes_Resource $process = null) { $this->currentActivity = null; // $this->addedConnectors = array();//reinitialized for each activity loop $data = array(); if (empty($process) && !empty($this->currentProcess)) { $process = $this->currentProcess; } if (empty($process)) { throw new Exception("no process instance to populate the activity tree"); return $data; } //initiate the return data value: $data = array('data' => __("Process Tree:") . ' ' . $process->getLabel(), 'attributes' => array('id' => 'node-process-root', 'class' => 'node-process-root', 'rel' => tao_helpers_Uri::encode($process->getUri())), 'children' => array()); //instanciate the processAuthoring service $processDefService = new wfEngine_models_classes_ProcessDefinitionService(); $activities = array(); $activities = $processDefService->getAllActivities($process); // throw new Exception(var_dump($activities)); foreach ($activities as $activity) { $this->currentActivity = $activity; $this->addedConnectors = array(); //required to prevent cyclic connexion between connectors of a given activity $initial = false; $last = false; $activityData = array(); $activityData = $this->activityNode($activity, 'next', false); //default value will do //get connectors $connectors = wfEngine_models_classes_StepService::singleton()->getNextSteps($activity); //following nodes: if (!empty($connectors['next'])) { //connector following the current activity: there should be only one foreach ($connectors['next'] as $connector) { $this->currentConnector = $connector; $activityData['children'][] = $this->connectorNode($connector, '', true); } } else { // throw new Exception("no connector associated to the activity: {$activity->getUri()}"); //Simply not add a connector here: this should be considered as the last activity: $last = true; } //check if it is the first activity node: $isIntial = $activity->getOnePropertyValue(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_ISINITIAL)); if (!is_null($isIntial) && $isIntial instanceof core_kernel_classes_Resource) { if ($isIntial->getUri() == GENERIS_TRUE) { $initial = true; } } if ($initial) { $activityData = $this->addNodeClass($activityData, "node-activity-initial"); if ($last) { $activityData = $this->addNodeClass($activityData, 'node-activity-last'); $activityData = $this->addNodeClass($activityData, "node-activity-unique"); } } elseif ($last) { $activityData = $this->addNodeClass($activityData, 'node-activity-last'); } //get interactive services $services = null; $services = $activity->getPropertyValuesCollection(new core_kernel_classes_Property(PROPERTY_ACTIVITIES_INTERACTIVESERVICES)); foreach ($services->getIterator() as $service) { if ($service instanceof core_kernel_classes_Resource) { $activityData['children'][] = array('data' => $service->getLabel(), 'attributes' => array('id' => tao_helpers_Uri::encode($service->getUri()), 'class' => 'node-interactive-service')); } } //add children here if ($initial) { array_unshift($data["children"], $activityData); } else { $data["children"][] = $activityData; } } return $data; }