(non-PHPdoc)
@see \oat\taoDelivery\model\execution\StateServiceInterface::createDeliveryExecution()
348844
public function createDeliveryExecution($deliveryId, User $user, $label)
    {
        $status = $this->getInitialStatus($deliveryId, $user);
        $deliveryExecution = $this->getStorageEngine()->spawnDeliveryExecution($label, $deliveryId, $user->getIdentifier(), $status);
        // trigger event
        $event = new DeliveryExecutionCreated($deliveryExecution, $user);
        $this->getServiceLocator()->get(EventManager::SERVICE_ID)->trigger($event);
        return $deliveryExecution;
    }
379648
public function actionFolderCreate() {
		$source = $this->getSource();
		$destinationPath = $source->getPath();

		$this->accessControl->checkPermission($this->getUserRole(), $this->action, $destinationPath);

		$folderName = Helper::makeSafe($this->request->name);

		if ($destinationPath) {
			if ($folderName) {
				if (!realpath($destinationPath . $folderName)) {
					mkdir($destinationPath . $folderName, $source->defaultPermission);
					if (is_dir($destinationPath . $folderName)) {
						return ['messages' => ['Directory successfully created']];
					}
					throw new \Exception('Directory was not created', Consts::ERROR_CODE_NOT_EXISTS);
				}
				throw new \Exception('Directory already exists', Consts::ERROR_CODE_NOT_ACCEPTABLE);
			}
			throw new \Exception('The name for new directory has not been set', Consts::ERROR_CODE_NOT_ACCEPTABLE);
		}
		throw new \Exception('The destination directory has not been set', Consts::ERROR_CODE_NOT_ACCEPTABLE);
	}
778186
public function setExecution(\Minibus\Model\Entity\Execution $execution)
    {
        $this->execution = $execution;
        
        return $this;
    }
1285978
public final ControlDecisionExpected createNewControlDecisionExpected() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewControlDecisionExpected");
    ControlDecisionExpected msg = null;
    try {
      msg = new ControlDecisionExpectedImpl(MfpConstants.CONSTRUCTOR_NO_OP);
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewControlDecisionExpected");
    return msg;
  }
817807
public function performExecution()
    {
        if (!$this->interceptors->isEmpty()) {
            return $this->interceptors->extract()->interceptExecution($this, $this->executionDepth);
        }
        
        return ($this->callback)();
    }
1140138
public function create()
        {
            $sql = $this->generateCreateSql();
            $query = new RawQuery($sql);
            try {
                $this->drop();
                return Statement::getPreparedStatement($query)->execute();
            } catch (\Exception $e) {
                throw new Exception('Error creating table ' . $this->getB2DBName() . ': ' . $e->getMessage(), $sql);
            }
        }
782325
protected function prepareExecute()
    {
        $packageName = $this->getOption('package');

        /** @var AbstractPackage $package */
        $package = $this->console->getPackage($packageName);

        $class = null;

        if ($package) {
            $class = MvcHelper::getPackageNamespace(get_class($package), 1) . '\\Seed\\DatabaseSeeder';
        }

        if (!class_exists($class)) {
            $class = $this->getOption('class');
        }

        $class = StringNormalise::toClassNamespace($class);

        if (!class_exists($class)) {
            $file = $package ? $package->getDir() . '/Seed/' . $class . '.php' : null;

            if (!$file || !is_file($file)) {
                $file = $this->getOption(
                    'd',
                    Ioc::getConfig()->get('path.seeders')
                ) . '/' . str_replace('\\', DIRECTORY_SEPARATOR, $class) . '.php';

                if ($file[0] !== '/' && substr($file, 1, 2) !== ':\\') {
                    $file = $this->console->get('path.root') . '/' . $file;
                }
            }

            if (is_file($file)) {
                include_once $file;
            }
        }

        if (!class_exists($class)) {
            throw new \RuntimeException('Class: ' . $class . ' not exists.');
        }

        if (!is_subclass_of($class, 'Windwalker\Core\Seeder\AbstractSeeder')) {
            throw new \RuntimeException('Class: ' . $class . ' should be sub class of Windwalker\Core\Seeder\AbstractSeeder.');
        }

        // Auto include classes
        $path = dirname(ReflectionHelper::getPath($class));

        $files  = Filesystem::files($path);
        $loader = new ClassLoader();
        $loader->register();

        /** @var \SplFileInfo $file */
        foreach ($files as $file) {
            $loader->addMap($file->getBasename('.php'), $file->getPathname());
        }

        $this->console->set('seed.class', $class);
    }
587110
public static function create()
    {
        return new ResolverStack([
            new OffsetResolver(false),
            new HeadResolver(false),
            new FirstLastResolver(false),
            new FilenameResolver(false),
            new LazyIdResolver(false),
        ]);
    }
556020
private function createWithArguments(
        string $className,
        array $constructorArguments,
        &$implementationClassName = null
    ) {
        if (interface_exists($className)) {
            $className = $implementationClassName = $this->getClassForInterface($className);
        }
        if (!class_exists($className)) {
            throw ClassDoesNotExistException::exceptionWithClassName($className);
        }
        if ($constructorArguments) {
            $reflector = new ReflectionClass($className);

            return $reflector->newInstanceArgs($constructorArguments);
        }

        return new $className();
    }
1267165
public function getExecutionContainer(DeliveryExecution $execution)
    {
        $container = new ExecutionClientContainer($execution);
        $containerService = $this->getServiceLocator()->get(DeliveryContainerService::SERVICE_ID);

        // set the test parameters
        $container->setData('testDefinition', $this->getSourceTest($execution));
        $container->setData('testCompilation', $this->getPrivateDirId($execution).'|'.$this->getPublicDirId($execution));
        $container->setData('providers', $containerService->getProviders($execution));
        $container->setData('plugins', $containerService->getPlugins($execution));
        $container->setData('bootstrap', $containerService->getBootstrap($execution));
        $container->setData('serviceCallId', $execution->getIdentifier());
        $container->setData('deliveryExecution', $execution->getIdentifier());
        $container->setData('deliveryServerConfig', []);
        return $container;
    }
818492
private function handle(TaskExecutionInterface $execution)
    {
        $process = $this->processFactory->create($execution->getUuid());
        $process->run();

        if (!$process->isSuccessful()) {
            throw $this->createException($process->getErrorOutput());
        }

        return $process->getOutput();
    }
390208
public function terminateExecution(DeliveryExecution $deliveryExecution, $reason = null)
    {
        $executionState = $deliveryExecution->getState()->getUri();
        $result = false;

        if (ProctoredDeliveryExecution::STATE_TERMINATED !== $executionState && ProctoredDeliveryExecution::STATE_FINISHED !== $executionState) {
            $proctor = \common_session_SessionManager::getSession()->getUser();
            $eventManager = $this->getServiceManager()->get(EventManager::CONFIG_ID);

            $session = $this->getTestSessionService()->getTestSession($deliveryExecution);
            $logData = [
                'reason' => $reason,
                'timestamp' => microtime(true),
                'context' => $this->getContext($deliveryExecution),
                'itemId' => $session ? $this->getCurrentItemId($deliveryExecution) : null,
            ];

            $this->getDeliveryLogService()->log($deliveryExecution->getIdentifier(), 'TEST_TERMINATE', $logData);

            if ($session) {
                if ($session->isRunning()) {
                    $session->endTestSession();
                }
                $this->getTestSessionService()->persist($session);
                $this->getServiceLocator()->get(ExtendedStateService::SERVICE_ID)->persist($session->getSessionId());
            }

            // Delivery execution state changes after test session ends, in the same way as it happens
            // when a human test taker takes the test.
            $this->setState($deliveryExecution, ProctoredDeliveryExecution::STATE_TERMINATED);
            $eventManager->trigger(new DeliveryExecutionTerminated($deliveryExecution, $proctor, $reason));
            $result = true;
        }

        return $result;
    }
927871
protected function action($deliveryExecution, $executionId, $isEndDate = false)
    {
        $this->getDeliveryStateService()->terminateExecution($deliveryExecution, [
            'reasons' =>[
                'category' => 'Technical'
            ],
            'comment' => $isEndDate
                ? 'The assessment was automatically terminated because end time expired.'
                : 'The assessment was automatically terminated.'
        ]);
        $this->report->add(Report::createSuccess('Execution terminated with success:'. $executionId ));
    }
962256
public function getDeliveryExecutionById($deliveryExecutionId)
    {
        $deliveryExecution = $this->getDeliveryExecutionService()->getDeliveryExecution($deliveryExecutionId);
        try {
            $deliveryExecution->getDelivery();
        } catch (\common_exception_NotFound $e) {
            throw new \common_exception_NotFound('Provided parameters don\'t match with any delivery execution.');
        }
        return $deliveryExecution;
    }
768527
public function byDeliveryExecution()
    {
        try
        {
            $this->checkMethod();

            $this->validateParams(array(self::DELIVERY_EXECUTION));

            $deliveryExecution = $this->getQtiResultService()->getDeliveryExecutionById(
                $this->getRequestParameter(self::DELIVERY_EXECUTION)
            );

            $this->returnValidXml($this->getQtiResultService()->getDeliveryExecutionXml($deliveryExecution));
        } catch (Exception $e) {
            $this->returnFailure($e);
        }
    }
158187
public function createAction()
	{
		$this->isPostRequest();

		$type = $this->getRequestParameter('type');

		$page = null;

		switch ($type) {
			case Entity::APPLICATION_DISCR:
				$page = new ApplicationPage(
						$this->getRequestParameter('application_id')
				);
				break;
			case Entity::PAGE_DISCR:
				$page = new Page();
				break;
			default:
				throw new \InvalidArgumentException(sprintf('Unknown page type [%s]', $type));
		}

		$localeId = $this->getCurrentLocale()->getId();

		$localization = Localization::factory($page, $localeId);
		/* @var $localization PageLocalization */

		if (! $localization instanceof PageLocalization) {
			throw new \UnexpectedValueException(sprintf(
					'Expecting created localization to be instance of PageLocalization, [%s] received.',
					get_class($localization)
			));
		}

		$templateId = $this->getRequestParameter('template');
		
		$template = $this->getEntityManager()
				->find(Template::CN(), $templateId);
		/* @var $template Template */

		if ($template === null) {
			throw new CmsException(null, 'Template not specified or found.');
		}

		$templateLocalization = $template->getLocalization($localeId);

		if ($templateLocalization === null) {
			throw new \InvalidArgumentException(
					"Specified template has no localization for [{$localeId}] locale."
			);
		}

		$localization->setTemplate($template);

		// copy values from template
		$localization->setIncludedInSearch($templateLocalization->isIncludedInSearch());
		$localization->setVisibleInMenu($templateLocalization->isVisibleInMenu());
		$localization->setVisibleInSitemap($templateLocalization->isVisibleInSitemap());

		$title = trim($this->getRequestParameter('title', ''));

		if (empty($title)) {
			throw new CmsException(null, 'Page title cannot be empty.');
		}
		
		$localization->setTitle($title);

		$parentLocalization = $pathPart
				= null;

		$parentLocalizationId = $this->getRequestParameter('parent_id');
		
		if (! empty($parentLocalizationId)) {

			$parentLocalization = $this->getEntityManager()
					->find(Localization::CN(), $parentLocalizationId);

			if ($parentLocalization === null) {
				throw new CmsException(null, sprintf(
						'Specified parent page [%s] not found.',
						$parentLocalizationId
				));
			}

			$pathPart = trim($this->getRequestParameter('path'));

			// path part cannot be empty for non-root pages.
			if (empty($pathPart)) {
				throw new CmsException(null, 'Page path can not be empty.');
			}
		}

		if ($parentLocalization && $pathPart) {
			$localization->setPathPart($pathPart);
		} else {
			$rootPath = $localization->getPathEntity();
			$rootPath->setPath('');
			$localization->setPathPart('');
		}

		$entityManager = $this->getEntityManager();

		$entityManager->transactional(function (EntityManager $entityManager) use ($page, $localization, $parentLocalization) {

			$this->lockNestedSet($page);

			$entityManager->persist($page);
			$entityManager->persist($localization);

			if ($parentLocalization) {
				$page->moveAsLastChildOf($parentLocalization->getMaster());
			}

			$this->unlockNestedSet($page);
		});

		return new SupraJsonResponse($this->loadNodeMainData($localization));
	}
633017
protected CaseExecutionImpl createCaseExecution(CmmnActivity activity) {
    CaseExecutionImpl child = newCaseExecution();

    // set activity to execute
    child.setActivity(activity);

    // handle child/parent-relation
    child.setParent(this);
    getCaseExecutionsInternal().add(child);

    // set case instance
    child.setCaseInstance(getCaseInstance());

    // set case definition
    child.setCaseDefinition(getCaseDefinition());

    return child;
  }