/** * Short description of method createJoin * * @access public * @author Joel Bout, <*****@*****.**> * @param array sources * @param Resource destination * @return core_kernel_classes_Resource */ public function createJoin($sources, core_kernel_classes_Resource $destination) { $returnValue = null; foreach ($sources as $step) { $followings = $step->getPropertyValues(new core_kernel_classes_Property(PROPERTY_STEP_NEXT)); if (count($followings) > 0) { foreach ($followings as $followingUri) { $following = new core_kernel_classes_Resource($followingUri); if ($this->isConnector($following)) { $this->delete($following); } else { throw new common_Exception('Step ' . $step->getUri() . ' already has a non-connector attached'); } } } } $first = current($sources); $returnValue = $this->createConnector($first, "c_" . $destination->getLabel()); common_Logger::d('spawned connector ' . $returnValue->getUri()); $this->setConnectorType($returnValue, new core_kernel_classes_Resource(INSTANCE_TYPEOFCONNECTORS_JOIN)); $first->removePropertyValues(new core_kernel_classes_Property(PROPERTY_STEP_NEXT)); $returnValue->setPropertyValue(new core_kernel_classes_Property(PROPERTY_STEP_NEXT), $destination); common_Logger::d('removed previous connections, added next'); foreach ($sources as $activity) { $flow = new wfEngine_models_classes_ProcessFlow(); $multiplicity = $flow->getCardinality($activity); $cardinality = wfEngine_models_classes_ActivityCardinalityService::singleton()->createCardinality($returnValue, $multiplicity); $activity->setPropertyValue(new core_kernel_classes_Property(PROPERTY_STEP_NEXT), $cardinality); common_Logger::d('spawned cardinality ' . $cardinality->getUri() . ' with value ' . $multiplicity); } return $returnValue; }