* @package taoDelivery */ class ServiceProxy extends tao_models_classes_Service implements DeliveryExecutionService { const CONFIG_KEY = 'execution_service'; public function setImplementation(DeliveryExecutionService $implementation) { $this->getServiceLocator()->register(self::SERVICE_ID, $implementation); } protected function getImplementation(): DeliveryExecutionService { /** @noinspection PhpIncompatibleReturnTypeInspection */ return $this->getServiceLocator()->get(self::SERVICE_ID); } /** * (non-PHPdoc) * @see DeliveryExecutionService::getUserExecutions() */ public function getUserExecutions(core_kernel_classes_Resource $assembly, $userUri) { return $this->getImplementation()->getUserExecutions($assembly, $userUri); } /** * (non-PHPdoc) * @see DeliveryExecutionService::getDeliveryExecutionsByStatus() */ public function getDeliveryExecutionsByStatus($userUri, $status) { return $this->getImplementation()->getDeliveryExecutionsByStatus($userUri, $status); } public function getActiveDeliveryExecutions($userUri) { return $this->getDeliveryExecutionsByStatus($userUri, DeliveryExecutionInterface::STATE_ACTIVE); } public function getPausedDeliveryExecutions($userUri) { return $this->getDeliveryExecutionsByStatus($userUri, DeliveryExecutionInterface::STATE_PAUSED); } public function getFinishedDeliveryExecutions($userUri) { return $this->getDeliveryExecutionsByStatus($userUri, DeliveryExecutionInterface::STATE_FINISHED); } /** * @deprecated * (non-PHPdoc) * @see DeliveryExecutionService::initDeliveryExecution() * @throws \common_exception_Error */ public function initDeliveryExecution(core_kernel_classes_Resource $assembly, $user) { if (is_string($user)) { common_Logger::w('Deprecated use of initDeliveryExecution()'); $sessionUser = common_session_SessionManager::getSession()->getUser(); if ($user == $sessionUser->getIdentifier()) { $user = $sessionUser; } else { $generisUser = new core_kernel_classes_Resource($user); if ($generisUser->exists()) { $user = new core_kernel_users_GenerisUser($generisUser); } else { throw new common_exception_NotFound('Unable to find User "' . $user . '"'); } } } $deliveryExecution = $this->getImplementation()->initDeliveryExecution($assembly, $user->getIdentifier()); $eventManager = ServiceManager::getServiceManager()->get(EventManager::SERVICE_ID); $eventManager->trigger(new DeliveryExecutionCreated($deliveryExecution, $user)); return $deliveryExecution; } /** * (non-PHPdoc) * @see DeliveryExecutionService::getDeliveryExecution() */ public function getDeliveryExecution($identifier) { return $this->getImplementation()->getDeliveryExecution($identifier); } /** * Implemented in the monitoring interface * * @param core_kernel_classes_Resource $compiled * @return DeliveryExecution[] executions for a single compilation * @throws \common_exception_Error * @throws common_exception_NoImplementation */ public function getExecutionsByDelivery(core_kernel_classes_Resource $compiled) { if (!$this->implementsMonitoring()) { throw new common_exception_NoImplementation(get_class($this->getImplementation()) . ' does not implement \oat\taoDelivery\model\execution\Monitoring'); } return $this->getImplementation()->getExecutionsByDelivery($compiled); } /** * Whenever or not the current implementation supports monitoring * * @return boolean * @throws \common_exception_Error */ public function implementsMonitoring() { return $this->getImplementation() instanceof Monitoring; } /** * @inheritdoc */ public function deleteDeliveryExecutionData(DeliveryExecutionDeleteRequest $request) { return $this->getImplementation()->deleteDeliveryExecutionData($request); } }