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
499721
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);
    }
168353
public function compile(array $expression, CompilationContext $compilationContext)
    {
        $compilationContext->headersManager->add('kernel/object');

        $exprVariable = new Expression($expression['left']);
        $exprVariable->setReadOnly(true);
        $exprVariable->setExpectReturn(true);

        $exprCompiledVariable = $exprVariable->compile($compilationContext);
        if ('variable' != $exprCompiledVariable->getType()) {
            throw new CompilerException('Expression type: '.$exprCompiledVariable->getType().' cannot be used as array', $expression);
        }

        $clonedVariable = $compilationContext->symbolTable->getVariableForRead($exprCompiledVariable->getCode(), $compilationContext, $expression);
        if ('variable' != $clonedVariable->getType()) {
            throw new CompilerException('Variable type: '.$exprVariable->getType().' cannot be cloned');
        }

        if ($clonedVariable->hasDifferentDynamicType(['undefined', 'object', 'null'])) {
            $compilationContext->logger->warning(
                'Possible attempt to use non array in "clone" operator',
                ['non-valid-clone', $expression]
            );
        }

        $symbolVariable = $this->getExpected($compilationContext, $expression);
        if (!$symbolVariable->isVariable()) {
            throw new CompilerException('Objects can only be cloned into dynamic variables', $expression);
        }

        $symbolVariable->setDynamicTypes('object');

        $symbolVariable->setIsInitialized(true, $compilationContext);

        /* Inherit the dynamic type data from the cloned object */
        $symbolVariable->setDynamicTypes($clonedVariable->getDynamicTypes());
        $symbolVariable->setClassTypes($clonedVariable->getClassTypes());

        $symbol = $compilationContext->backend->getVariableCode($symbolVariable);
        $clonedSymbol = $compilationContext->backend->getVariableCode($clonedVariable);

        $compilationContext->codePrinter->output('if (zephir_clone('.$symbol.', '.$clonedSymbol.' TSRMLS_CC) == FAILURE) {');
        $compilationContext->codePrinter->output("\t".'RETURN_MM();');
        $compilationContext->codePrinter->output('}');

        return new CompiledExpression('variable', $symbolVariable->getName(), $expression);
    }
563583
public function getUserExecutions(core_kernel_classes_Resource $assembly, $userUri)
    {
        $query = $this->getQueryBuilder()
            ->select("*")
            ->from(self::TABLE_NAME)
            ->where(self::COLUMN_DELIVERY_ID . " = :deliveryId")
            ->andWhere(self::COLUMN_USER_ID . " = :userId")
            ->setParameter("deliveryId", $assembly->getUri())
            ->setParameter("userId", $userUri)
        ;

        return array_map(function($row) {
            return $this->parseQueryResult($row);
        }, $query->execute()->fetchAll());
    }
1317114
public function compile(array $expression, CompilationContext $compilationContext)
    {
        $classDefinition = new ClassDefinition(
            $compilationContext->config->get('namespace'),
            self::$id.'__closure'
        );

        $classDefinition->setIsFinal(true);

        $compilerFile = new CompilerFileAnonymous($classDefinition, $compilationContext->config, $compilationContext);
        $compilerFile->setLogger($compilationContext->logger);

        $compilationContext->compiler->addClassDefinition($compilerFile, $classDefinition);

        if (isset($expression['left'])) {
            $parameters = new ClassMethodParameters($expression['left']);
        } else {
            $parameters = null;
        }

        if (isset($expression['right'])) {
            $block = $expression['right'];
        } else {
            $block = [];
        }

        $staticVariables = [];
        if (isset($expression['use']) && \is_array($expression['use'])) {
            foreach ($expression['use'] as $parameter) {
                $staticVariables[$parameter['name']] = $compilationContext->symbolTable->getVariable($parameter['name']);
            }
        }

        foreach ($staticVariables as $var) {
            $classDefinition->addProperty(new \Zephir\ClassProperty(
                $classDefinition,
                ['public', 'static'],
                $var->getName(),
                null,
                null,
                null
            ));
        }

        $classMethod = new ClassMethod(
            $classDefinition,
            ['public', 'final'],
            '__invoke',
            $parameters,
            new StatementsBlock($block),
            null,
            null,
            $expression,
            $staticVariables
        );
        $classDefinition->addMethod($classMethod, $block);

        $compilationContext->headersManager->add('kernel/object');

        if ($this->expecting) {
            if ($this->expectingVariable) {
                $symbolVariable = $this->expectingVariable;
            } else {
                $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $expression);
            }
        } else {
            $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $expression);
        }

        $symbolVariable->initVariant($compilationContext);
        $compilationContext->backend->createClosure($symbolVariable, $classDefinition, $compilationContext);
        $compilationContext->headersManager->add('kernel/object');
        foreach ($staticVariables as $var) {
            if ('variable' == $var->getType() || 'array' == $var->getType()) {
                $compilationContext->backend->updateStaticProperty($classDefinition->getClassEntry(), $var->getName(), $var, $compilationContext);
            } else {
                $tempVariable = $compilationContext->symbolTable->getTempNonTrackedVariable('variable', $compilationContext, true);
                switch ($var->getType()) {
                    case 'int':
                    case 'uint':
                    case 'long':
                    case 'ulong':
                    case 'char':
                    case 'uchar':
                        $compilationContext->backend->assignLong($tempVariable, $var, $compilationContext);
                        break;
                    case 'double':
                        $compilationContext->backend->assignDouble($tempVariable, $var, $compilationContext);
                        break;
                    case 'bool':
                        $compilationContext->backend->assignBool($tempVariable, $var, $compilationContext);
                        break;
                    case 'string':
                        $compilationContext->backend->assignString($tempVariable, $var, $compilationContext);
                        break;
                    default:
                        break;
                }
                $compilationContext->backend->updateStaticProperty($classDefinition->getClassEntry(), $var->getName(), $tempVariable, $compilationContext);
            }
        }
        ++self::$id;

        return new CompiledExpression('variable', $symbolVariable->getRealName(), $expression);
    }
634679
protected function _getResolvedArrayItem(CompiledExpression $resolvedExpr, CompilationContext $compilationContext)
    {
        switch ($resolvedExpr->getType()) {
            case 'null':
                $symbolVariable = new GlobalConstant('ZEPHIR_GLOBAL(global_null)');
                break;

            case 'int':
            case 'uint':
            case 'long':
                $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $resolvedExpr->getOriginal());
                $compilationContext->backend->assignLong($symbolVariable, $resolvedExpr->getCode(), $compilationContext);
                break;

            case 'char':
                $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $resolvedExpr->getOriginal());
                $compilationContext->backend->assignLong($symbolVariable, '\''.$resolvedExpr->getCode().'\'', $compilationContext);
                break;

            case 'double':
                $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $resolvedExpr->getOriginal());
                $compilationContext->backend->assignDouble($symbolVariable, $resolvedExpr->getCode(), $compilationContext);
                break;

            case 'bool':
                if ('1' == $resolvedExpr->getBooleanCode()) {
                    $symbolVariable = new GlobalConstant('ZEPHIR_GLOBAL(global_true)');
                } else {
                    if ('0' == $resolvedExpr->getBooleanCode()) {
                        $symbolVariable = new GlobalConstant('ZEPHIR_GLOBAL(global_false)');
                    } else {
                        $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $resolvedExpr->getOriginal());
                        $compilationContext->backend->assignBool($symbolVariable, $resolvedExpr->getBooleanCode(), $compilationContext);
                    }
                }
                break;

            case 'string':
                $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $resolvedExpr->getOriginal());
                $compilationContext->backend->assignString($symbolVariable, $resolvedExpr->getCode(), $compilationContext);
                break;

            case 'array':
                $symbolVariable = $compilationContext->symbolTable->getVariableForRead($resolvedExpr->getCode(), $compilationContext, $resolvedExpr->getOriginal());
                break;

            case 'variable':
                $variableExpr = $compilationContext->symbolTable->getVariableForRead($resolvedExpr->getCode(), $compilationContext, $resolvedExpr->getOriginal());
                switch ($variableExpr->getType()) {
                    case 'int':
                    case 'uint':
                    case 'long':
                    case 'ulong':
                        $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $resolvedExpr->getOriginal());
                        $compilationContext->backend->assignLong($symbolVariable, $variableExpr, $compilationContext);
                        break;

                    case 'double':
                        $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $resolvedExpr->getOriginal());
                        $compilationContext->backend->assignDouble($symbolVariable, $variableExpr, $compilationContext);
                        break;

                    case 'bool':
                        $symbolVariable = $compilationContext->symbolTable->getTempVariableForWrite('variable', $compilationContext, $resolvedExpr->getOriginal());
                        $compilationContext->backend->assignBool($symbolVariable, $variableExpr, $compilationContext);
                        break;

                    case 'variable':
                    case 'string':
                    case 'array':
                        $symbolVariable = $variableExpr;
                        break;

                    default:
                        throw new CompilerException('Variable: '.$variableExpr->getType().' cannot be assigned to array offset', $resolvedExpr->getOriginal());
                }
                break;

            default:
                throw new CompilerException('Expression: '.$resolvedExpr->getType().' cannot be assigned to array offset', $resolvedExpr->getOriginal());
        }

        return $symbolVariable;
    }
1309256
private function listAction()
    {
        $deliveryClass = $this->getClass(DeliveryAssemblyService::CLASS_URI );
        $deliveries = $deliveryClass->getInstances(true);
        $result = [];
        foreach ($deliveries as $delivery) {
            /** @var \core_kernel_classes_Resource $delivery */
            $result[] = $this->deliveryDescription($delivery);
        }
        $this->report = new Report(
            Report::TYPE_INFO,
            implode(PHP_EOL, $result)
        );
    }
570413
public function getData(DeliveryExecutionInterface $deliveryExecution)
    {
        $data = $this->loadData($deliveryExecution->getIdentifier());
        $data = $data == false ? [] : $data;
        return $this->buildData($deliveryExecution, $data);
    }
1062255
public function compile(CompilationContext $compilationContext)
    {
        $expression = [
            'type' => 'require',
            'left' => $this->statement['expr'],
            'file' => $this->statement['file'],
            'line' => $this->statement['line'],
            'char' => $this->statement['char'],
        ];

        $expr = new Expression($expression);
        $expr->setExpectReturn(false, null);
        $expr->compile($compilationContext);
    }
1280331
protected function getRequiredClientBundleCodeGenerators($bundle)
    {
        return [
            $this->createClientDependencyProviderCodeGenerator($bundle),
            $this->createClientFactoryCodeGenerator($bundle),
            $this->createClientCodeGenerator($bundle),
            $this->createClientInterfaceCodeGenerator($bundle),
            $this->createStubCodeGenerator($bundle),
            $this->createStubInterfaceCodeGenerator($bundle),
            $this->createGatewayControllerCodeGenerator($bundle),
        ];
    }
655706
public function updateDeferred()
    {
        try {
            if ($this->getRequestMethod() !== \Request::HTTP_POST) {
                throw new \common_exception_NotImplemented('Only post method is accepted to updating delivery');
            }
            if (! $this->hasRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)) {
                throw new \common_exception_MissingParameter(self::REST_DELIVERY_SEARCH_PARAMS, $this->getRequestURI());
            }
            $where = json_decode(html_entity_decode($this->getRequestParameter(self::REST_DELIVERY_SEARCH_PARAMS)), true);
            $propertyValues = $this->getRequestParameters();
            unset($propertyValues[self::REST_DELIVERY_SEARCH_PARAMS]);

            $task = UpdateDelivery::createTask($where, $propertyValues);

            $result = [
                'reference_id' => $task->getId()
            ];

            /** @var TaskLogInterface $taskLog */
            $taskLog = $this->getServiceManager()->get(TaskLogInterface::SERVICE_ID);
            $report = $taskLog->getReport($task->getId());
            if (!empty($report)) {
                if ($report instanceof \common_report_Report) {
                    //serialize report to array
                    $report = json_decode($report);
                }
                $result['common_report_Report'] = $report;
            }
            return $this->returnSuccess($result);
        }catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
498536
public function handleInstall(): array
    {
        $result = [];

        $handlers = AbstractOperation::getOperationHandlers($this->composer);
        $handlersMap = [];

        foreach ($handlers as $handler) {
            $handler = new $handler($this->package, $this->projectType, $this->composer);
            if ($handler instanceof SupportedProjectTypesInterface) {
                if (in_array($this->projectType->getMachineName(), $handler->getSupportedProjectTypes())) {
                    $handlersMap[] = $handler;
                }
            }
        }

        foreach ($this->projectType->getTypes() as $type) {
            if (isset($handlers[$type])) {
                $class = $handlers[$type];
                /** @var AbstractOperation $handler */
                $handler = new $class($this->package, $this->projectType, $this->composer);
                $handlersMap[] = $handler;
            }
        }

        foreach ($handlersMap as $handler) {
            if ($handler instanceof AvailableOperationInterface) {
                if (!$handler->isAvailable()) {
                    continue;
                }
            }
            $result[] = $handler->install();
        }

        return $result;
    }
415776
private static function adjustDeliveryExecutions($deliveryExecutions) {

        /** @var TestSessionConnectivityStatusService $testSessionConnectivityStatusService */
        $testSessionConnectivityStatusService = ServiceManager::getServiceManager()->get(TestSessionConnectivityStatusService::SERVICE_ID);

        $executions = [];
        foreach ($deliveryExecutions as $cachedData) {

            $state = [
                'status' => $cachedData[DeliveryMonitoringService::STATUS],
                'progress' => $cachedData[DeliveryMonitoringService::CURRENT_ASSESSMENT_ITEM]
            ];

            $testTaker = [];
            $extraFields = [];

            /* @var $user User */
            $testTaker['id'] = $cachedData[DeliveryMonitoringService::TEST_TAKER];
            $testTaker['test_taker_last_name'] = (isset($cachedData[DeliveryMonitoringService::TEST_TAKER_LAST_NAME]))?_dh($cachedData[DeliveryMonitoringService::TEST_TAKER_LAST_NAME]):'';
            $testTaker['test_taker_first_name'] = (isset($cachedData[DeliveryMonitoringService::TEST_TAKER_FIRST_NAME]))?_dh($cachedData[DeliveryMonitoringService::TEST_TAKER_FIRST_NAME]):'';

            foreach(self::_getUserExtraFields() as $field){
                $extraFields[$field['id']] = isset($cachedData[$field['id']]) ? _dh($cachedData[$field['id']]) : '';
            }

            $online = null;
            if ($testSessionConnectivityStatusService->hasOnlineMode()) {
                $rawConnectivity = isset($cachedData[DeliveryMonitoringService::CONNECTIVITY]) ? $cachedData[DeliveryMonitoringService::CONNECTIVITY] : false;
                $online = $testSessionConnectivityStatusService->isOnline($cachedData[DeliveryMonitoringService::DELIVERY_EXECUTION_ID], $rawConnectivity);
            }

            if (isset($cachedData[DeliveryMonitoringService::LAST_TEST_TAKER_ACTIVITY]) && $online) {
                $lastActivity = $cachedData[DeliveryMonitoringService::LAST_TEST_TAKER_ACTIVITY];
            } else {
                $lastActivity = null;
            }

            $executionState = $cachedData[DeliveryMonitoringService::STATUS];
            $extraTime = (isset($cachedData[DeliveryMonitoringService::EXTRA_TIME])) ? floatval($cachedData[DeliveryMonitoringService::EXTRA_TIME]) : 0;
            $remaining = self::getRemainingTime($cachedData);
            $approximatedRemaining = self::getApproximatedRemainingTime($cachedData, $online, $lastActivity);

            $execution = array(
                'id' => $cachedData[DeliveryMonitoringService::DELIVERY_EXECUTION_ID],
                'delivery' => array(
                    'uri' => $cachedData[DeliveryMonitoringService::DELIVERY_ID],
                    'label' => _dh($cachedData[DeliveryMonitoringService::DELIVERY_NAME]),
                ),
                'start_time' => $cachedData[DeliveryMonitoringService::START_TIME],
                'allowExtraTime' => (isset($cachedData[DeliveryMonitoringService::ALLOW_EXTRA_TIME])) ? boolval($cachedData[DeliveryMonitoringService::ALLOW_EXTRA_TIME]) : null,
                'timer' => [
                    'lastActivity' => $lastActivity,
                    'countDown' => (DeliveryExecution::STATE_ACTIVE == $executionState && $online) ? true : false,
                    'approximatedRemaining' => $approximatedRemaining,
                    'remaining_time' => $remaining,
                    'extraTime' => $extraTime,
                    'extendedTime' => (isset($cachedData[DeliveryMonitoringService::EXTENDED_TIME]) && $cachedData[DeliveryMonitoringService::EXTENDED_TIME] > 1) ? floatval($cachedData[DeliveryMonitoringService::EXTENDED_TIME]) : '',
                    'consumedExtraTime' => (isset($cachedData[DeliveryMonitoringService::CONSUMED_EXTRA_TIME])) ? floatval($cachedData[DeliveryMonitoringService::CONSUMED_EXTRA_TIME]) : 0
                ],
                'testTaker' => $testTaker,
                'extraFields' => $extraFields,
                'state' => $state,
            );

            if ($online) {
                $execution['online'] = $online;
            }

            $executions[] = $execution;
        }

        return $executions;
    }
128743
public function createAssemblyFromTemplate(core_kernel_classes_Resource $deliveryTemplate) {
    
        $assemblyClass = $this->getRootClass();
    
        $content = DeliveryTemplateService::singleton()->getContent($deliveryTemplate);
        if (is_null($content)) {
            throw new EmptyDeliveryException('Delivery '.$deliveryTemplate->getUri().' has no content');
        }
    
        $props = $deliveryTemplate->getPropertiesValues(array(
            OntologyRdfs::RDFS_LABEL,
            TAO_DELIVERY_RESULTSERVER_PROP,
            TAO_DELIVERY_MAXEXEC_PROP,
            TAO_DELIVERY_START_PROP,
            TAO_DELIVERY_END_PROP,
            TAO_DELIVERY_EXCLUDEDSUBJECTS_PROP
        ));
        $props[PROPERTY_COMPILEDDELIVERY_DELIVERY] = array($deliveryTemplate);
    
        return $this->createAssemblyByContent($assemblyClass, $content, $props);

    }
639210
public function getDeliveryData(DeliveryExecutionInterface $deliveryExecution)
    {
        $result = [
            'start' => $deliveryExecution->getStartTime(),
            'end' => $deliveryExecution->getFinishTime(),
            'label' => $deliveryExecution->getLabel()
        ];
        return $result;
    }
842757
public function getDeliveryContainer(DeliveryExecution $deliveryExecution)
    {
        $runtimeService = $this->getServiceLocator()->get(RuntimeService::SERVICE_ID);
        $deliveryContainer = $runtimeService->getDeliveryContainer($deliveryExecution->getDelivery()->getUri());
        return $deliveryContainer->getExecutionContainer($deliveryExecution);
    }
29878
public function getRuntime($deliveryId)
    {
        $delivery = $this->getResource($deliveryId);
        if (!$delivery->exists()) {
            throw new \common_exception_NoContent('Unable to load runtime associated for delivery ' . $deliveryId .
                ' Delivery probably deleted.');
        }
        $runtimeResource = $delivery->getUniquePropertyValue($this->getProperty(self::PROPERTY_RUNTIME));
        return \tao_models_classes_service_ServiceCall::fromResource($runtimeResource);
    }
1311157
public function execute($compiled)
    {
        // Get matched parameters
        $matches = null;
        preg_match_all($this->getCompiled(), $compiled, $matches);

        $params = array();
        if (count($matches) > 1) {
            // Has parameters, parse.
            $params = array_slice($matches, 1);
            $params = array_map(function($param) {
                return $param[0];
            }, $params);
        }

        if (is_string($this->callback)) {
            // Will call the controller here
            if (stristr($this->callback, '::')) {
                $parts = explode('::', $this->callback);
                $controllerClass = $parts[0];
                $controllerMethod = $parts[1];
            } else {
                $controllerClass = $this->callback;
                $controllerMethod = 'dispatch';
            }

            if (! class_exists($controllerClass)) {
                throw new ControllerNotFoundException("The controller declared in your route is not found: '{$controllerClass}'");
            }

            $controller = new $controllerClass();

            if (! $controller instanceof Controller) {
                throw new ControllerNotFoundException("The controller doesn't extend the abstract framework controller: '{$controllerClass}'");
            }

            if (! method_exists($controller, $controllerMethod)) {
                throw new ControllerNotFoundException("The controller doesn't have the method you declared in the route!: '{$controllerClass}' method: {$controllerMethod}");
            }

            // When the prepare is false we will stop!
            if ($controller->prepare() === false) {
                return;
            }

            // Make sure we only give the first parameters the method allow us to give.
            $methodMeta = new \ReflectionMethod($controller, $controllerMethod);
            if (count($params) !== $methodMeta->getNumberOfParameters() && count($params) >= $methodMeta->getNumberOfRequiredParameters()) {
                if ($methodMeta->getNumberOfParameters() <= count($params)) {
                    $params = array_splice($params, 0, $methodMeta->getNumberOfParameters());
                }
            }

            // Call the method
            $callable = [$controller, $controllerMethod];
        } elseif (is_callable($this->callback)) {
            $callable = $this->callback;
        } else {
            throw new RouterException('Invalid route!'); // @codeCoverageIgnore
        }

        // Execute route.
        $response = call_user_func_array($callable, $params);

        // Convert string to response.
        if (is_string($response)) {
            $response = new Response($response);
        }
        if (is_int($response) && $response >= 100 && $response <= 599) {
            $response = new Response('', $response);
        }

        // Parse response.
        if ($response instanceof Response) {
            // ok
        } elseif ($response instanceof ResponseInterface) {
            $httpFoundationFactory = new HttpFoundationFactory();

            $response = $httpFoundationFactory->createResponse($response);
        } else {
            throw new RouterException('Route should return a valid response!');
        }

        $response->prepare(Http::getInstance()->getRequest());

        if (Configuration::get('app.env') === 'development' && Configuration::get('app.profiler', false)) {
            DebugBarHelper::getInstance()->inject($response);
        }

        $response->send();
    }