/** * Short description of method isIsolatedConnector * * @access public * @author Joel Bout, <*****@*****.**> * @param Resource connector * @return boolean */ public function isIsolatedConnector(core_kernel_classes_Resource $connector) { $returnValue = (bool) false; $returnValue = true; //need to be initiated as true $propNextActivities = new core_kernel_classes_Property(PROPERTY_STEP_NEXT); foreach ($connector->getPropertyValuesCollection($propNextActivities)->getIterator() as $nextActivityOrConnector) { if ($this->activityService->isActivity($nextActivityOrConnector)) { $returnValue = false; } else { if ($this->connectorService->isConnector($nextActivityOrConnector)) { $isolated = $this->isIsolatedConnector($nextActivityOrConnector); if ($returnValue) { $returnValue = $isolated; } } else { throw new common_exception_Error('the next acitivty of "' . $connector->getUri() . '" is neither an activity nor a connector'); } } } if ($returnValue) { $this->isolatedConnectors[$connector->getUri()] = $connector; } return (bool) $returnValue; }
/** * Short description of method getNewActivityFromOldActivity * * @access protected * @author Joel Bout, <*****@*****.**> * @param Resource oldActivity * @param Resource oldReferenceActivity * @param string connectionType * @param Resource clonedConnector * @return core_kernel_classes_Resource */ protected function getNewActivityFromOldActivity(core_kernel_classes_Resource $oldActivity, core_kernel_classes_Resource $oldReferenceActivity, $connectionType, core_kernel_classes_Resource $clonedConnector) { $returnValue = null; $activity = $oldActivity; $activityIO = ''; switch ($connectionType) { case 'next': case 'then': case 'else': //explanation: we are looking for the activity than is in the property "next activity" so it is the activity entering point that should be considered $activityIO = 'in'; break; case 'prev': $activityIO = 'out'; break; default: throw new Exception("unknown connectionType"); } //note: most of the time, $this->clonedActivities[$activity->getUri()]['in'] = $this->clonedActivities[$activity->getUri()]['out'] if (!is_null($activity) && !is_null($oldReferenceActivity)) { if ($this->activityService->isActivity($activity)) { $newActivity = $this->getClonedActivity($activity, $activityIO); if (!is_null($newActivity)) { $returnValue = $newActivity; //note: works for parallel activity too, where multiple branch is created a parallelized branch } else { //must have been cloned! // print_r($this->clonedActivities); throw new common_exception_Error("the activity {$activity->getLabel()} ({$activity->getUri()}) has not been cloned!"); } } else { if ($this->connectorService->isConnector($activity)) { $newConnector = $this->getClonedConnector($activity); if (!is_null($newConnector)) { //it is a reference to a connector with another activity reference and it has been cloned already $returnValue = $newConnector; } else { //not cloned yet: //clone it only if the reference id is the current activity //OR if the previous activities of a split connector: if ($oldReferenceActivity->getUri() == $activity->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_CONNECTORS_ACTIVITYREFERENCE))->getUri() && $activityIO == 'in') { //recursively clone it $nextConnectorClone = $this->cloneConnector($activity); // $this->setWaitingConnector($activity, 'prev', $nextConnectorClone);//important to set the connector as a required one // if(!$this->updateWaitingConnector($activity, $nextConnectorClone)){ // throw new Exception("the next connector clone cannot be updated"); // } if (!is_null($nextConnectorClone)) { $returnValue = $nextConnectorClone; } else { throw new Exception("the next connector cannot be cloned"); } } else { //it is a connector of another activityReference branch and it is not cloned yet, so set it as such: //put in the waiting list: $this->setWaitingConnector($activity, $connectionType, $clonedConnector); } } } } } return $returnValue; }