Register tasks for this application

@param Workflow $workflow
@param Deployment $deployment
499281
public function registerTasks(Workflow $workflow, Deployment $deployment)
    {
        parent::registerTasks($workflow, $deployment);

        $this->checkIfMandatoryOptionsExist();
        $this->buildConfiguration();
        $this->defineTasks($workflow, $deployment);

        if ($this->getOption('enableTests') !== false) {
            $workflow
                ->addTask([
                    UnitTestTask::class,
                    FunctionalTestTask::class
                ], 'test', $this);
        }

        $workflow->addTask([
                'TYPO3\\Surf\\DefinedTask\\CreateZipDistributionTask',
                'TYPO3\\Surf\\DefinedTask\\CreateTarGzDistributionTask',
                'TYPO3\\Surf\\DefinedTask\\CreateTarBz2DistributionTask',
            ], 'cleanup', $this);

        if ($this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
            $workflow->addTask(SourceforgeUploadTask::class, 'cleanup', $this);
        }
        if ($this->hasOption('releaseHost')) {
            $workflow->addTask(PrepareReleaseTask::class, 'initialize', $this);
            $workflow->addTask(ReleaseTask::class, 'cleanup', $this);
        }
        if ($this->hasOption('releaseHost') && $this->hasOption('enableSourceforgeUpload') && $this->getOption('enableSourceforgeUpload') === true) {
            $workflow->addTask(AddDownloadTask::class, 'cleanup', $this);
        }
        if ($this->hasOption('createTags') && $this->getOption('createTags') === true) {
            $workflow->addTask(TagTask::class, 'cleanup', $this);
            if ($this->hasOption('TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask') && $this->getOption('TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask') === true) {
                $workflow->afterTask(TagTask::class, 'TYPO3\\Surf\\DefinedTask\\Git\\PushTagsTask', $this);
            }
        }

        $workflow->removeTask(MigrateTask::class);
    }
323816
protected function printApplications(array $applications, Workflow $workflow)
    {
        $this->output->writeln(PHP_EOL . 'Applications:' . PHP_EOL);
        foreach ($applications as $application) {
            $this->output->writeln('  <success>' . $application->getName() . ':</success>');
            $this->output->writeln('    <comment>Deployment path</comment>: <success>' . $application->getDeploymentPath() . '</success>');
            $this->output->writeln('    <comment>Options</comment>: ');
            foreach ($application->getOptions() as $key => $value) {
                if (is_array($value)) {
                    $this->output->writeln('      ' . $key . ' =>');
                    foreach ($value as $itemKey => $itemValue) {
                        $itemOutput = is_string($itemKey) ? sprintf('%s => %s', $itemKey, $itemValue) : $itemValue;
                        $this->output->writeln(sprintf('        <success>%s</success>', $itemOutput));
                    }
                } else {
                    $printableValue = is_scalar($value) ? $value : gettype($value);
                    $this->output->writeln('      ' . $key . ' => <success>' . $printableValue . '</success>');
                }
            }
            $this->output->writeln('    <comment>Nodes</comment>: <success>' . implode(
                ', ',
                    $application->getNodes()
            ) . '</success>');

            if ($workflow instanceof SimpleWorkflow) {
                $this->output->writeln('    <comment>Detailed workflow</comment>: ');
                $this->printStages($application, $workflow->getStages(), $workflow->getTasks());
            }
        }
    }
1138337
def initialize_workflow(self, workflow):
        
        self.workflow = workflow()
        self.workflow.tasks = self.tasks

        self.workflow.input_file = self.input_file
        self.workflow.input_format = self.input_format
        self.workflow.target_file = self.target_file
        self.workflow.target_format = self.target_format
        self.workflow.run_id = self.run_id

        self.workflow.setup()
340810
public function configureWorkflow($workflowName)
    {
        $this->workflowName = $workflowName;

        $this->workflow = $this->container->getParameter('free_agent_workflow.workflows.'.$this->workflowName, null);

        if (is_null($this->workflow)) {
            throw new WorkflowException('The workflow "'.$this->workflowName.'" does not exist');
        }

        $defaultStep = $this->workflow['default_step'];
        if (!array_key_exists($defaultStep, $this->workflow['steps'])) {
            throw new WorkflowException('The default step of "'.$this->workflowName.'" does not exist');
        }

        foreach ($this->workflow['steps'] as $stepName => $stepConfiguration) {
            $this->steps->offsetSet($stepName, new Step($stepName, $stepConfiguration));
        }

        $this->defaultStep = new Step($defaultStep, $this->workflow['steps'][$defaultStep]);
        $this->actions     = array_key_exists('actions', $this->workflow) ? $this->workflow['actions'] : array();
        $this->validations = array_key_exists('validations', $this->workflow) ? $this->workflow['validations'] : array();

        return $this->getSteps();
    }
607422
private function runTask($workflow, $taskServiceId, $taskId)
    {
        $task = $this->container->get("{$workflow}.task.{$taskServiceId}");

        if (!$task instanceof ExecutableTaskInterface) {
            throw new InvalidTaskClassException(
                "The service {$taskServiceId} must implement the ExecutableTaskInterface interface."
            );
        }

        if ($task instanceof ContainerAwareInterface) {
            $task->setContainer($this->container);
        }

        if ($task instanceof LoggerAwareInterface) {
            /** @var LoggerInterface $logger */
            $logger = $this->container->get('logger');
            $task->setLogger($logger);
        }

        $parameters = new ParameterBag();
        $parameterBagId = "{$workflow}{$taskId}";

        /** @var ProviderInterface $stateStorage */
        $stateStorage = $this->container->get('state_storage');

        // Try to load the state file.
        try {
            $stateStorage->load($parameterBagId, $parameters);
        } catch (IOException $ignored) {
        }

        if ($task instanceof ParameterAwareInterface) {
            $task->setParameters($parameters);
        }

        $task->execute();

        $stateStorage->persist($parameterBagId, $parameters);
    }
330697
public function perform(WorkflowEngine $workflowEngine, WorkflowMessage $workflowMessage = null)
    {
        if (is_null($workflowMessage)) {
            $this->startWithoutMessage($workflowEngine);
            return;
        }

        $taskListEntry = $this->taskList->getNextNotStartedTaskListEntry();

        if ($taskListEntry) {
            $this->recordThat(TaskEntryMarkedAsRunning::at($taskListEntry->taskListPosition()));

            if (! $this->isCorrectMessageFor($taskListEntry->task(), $workflowMessage)) {
                $this->receiveMessage(
                    LogMessage::logWrongMessageReceivedFor(
                        $taskListEntry->task(),
                        $taskListEntry->taskListPosition(),
                        $workflowMessage
                    ),
                    $workflowEngine
                );

                return;
            }



            $this->performTask($taskListEntry->task(), $taskListEntry->taskListPosition(), $workflowEngine, $workflowMessage);
            return;
        }
    }
479686
public static void registerDeploymentResource(final DeploymentResourceSupport deploymentResourceSupport, final LoggingConfigurationService service) {
        final PathElement base = PathElement.pathElement("configuration", service.getConfiguration());
        deploymentResourceSupport.getDeploymentSubModel(LoggingExtension.SUBSYSTEM_NAME, base);
        final LogContextConfiguration configuration = service.getValue();
        // Register the child resources if the configuration is not null in cases where a log4j configuration was used
        if (configuration != null) {
            registerDeploymentResource(deploymentResourceSupport, base, HANDLER, configuration.getHandlerNames());
            registerDeploymentResource(deploymentResourceSupport, base, LOGGER, configuration.getLoggerNames());
            registerDeploymentResource(deploymentResourceSupport, base, FORMATTER, configuration.getFormatterNames());
            registerDeploymentResource(deploymentResourceSupport, base, FILTER, configuration.getFilterNames());
            registerDeploymentResource(deploymentResourceSupport, base, POJO, configuration.getPojoNames());
            registerDeploymentResource(deploymentResourceSupport, base, ERROR_MANAGER, configuration.getErrorManagerNames());
        }
    }
799857
def _run_workflow(data, workflow_file, work_dir):
    
    utils.remove_safe(os.path.join(work_dir, "workspace"))
    cmd = [utils.get_program_python("configureStrelkaGermlineWorkflow.py"),
           workflow_file, "-m", "local", "-j", dd.get_num_cores(data), "--quiet"]
    do.run(cmd, "Run Strelka2: %s" % dd.get_sample_name(data))
    utils.remove_safe(os.path.join(work_dir, "workspace"))
243611
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = $output;
        $configurationPath = $input->getOption('configurationPath');
        $deploymentName = $input->getArgument('deploymentName');
        $deployment = $this->factory->getDeployment($deploymentName, $configurationPath);
        $workflow = $deployment->getWorkflow();

        if (! $deployment instanceof FailedDeployment) {
            $output->writeln('<success>Deployment ' . $deployment->getName() . '</success>');
            $output->writeln('');
            $output->writeln('Workflow: <success>' . $workflow->getName() . '</success>');

            if ($workflow instanceof SimpleWorkflow) {
                $value = $workflow->isEnableRollback() ? 'true' : 'false';
                $output->writeln('    <comment>Rollback enabled:</comment> <info>' . $value . '</info>');
            }

            $output->writeln('');

            $this->printNodes($deployment->getNodes());

            $this->printApplications($deployment->getApplications(), $deployment->getWorkflow());
        }
    }
256652
public static synchronized void deployment(Class<?> deployment) {
		Preconditions.checkArgument(deployment != null, 
				"Parameter 'deployment' must not be [" + deployment + "]");
		Preconditions.checkArgument(deployment.getAnnotation(Deployment.class) != null,
				"'deployment' [" + deployment + "] must be annotated with @Deployment");
		Jaguar.deployment = deployment;
		logger.info("Deployment has been set to [" + deployment.getSimpleName() + "]");
	}
1161583
public function execute(Node $node, Application $application, Deployment $deployment, array $options = [])
    {
        $deploymentPath = $application->getDeploymentPath();
        $sharedPath = $application->getSharedPath();
        $releasesPath = $application->getReleasesPath();
        $releaseIdentifier = $deployment->getReleaseIdentifier();
        $releasePath = $deployment->getApplicationReleasePath($application);
        $result = $this->shell->execute('test -d ' . $deploymentPath, $node, $deployment, true);
        if ($result === false) {
            throw new TaskExecutionException('Deployment directory "' . $deploymentPath . '" does not exist on node ' . $node->getName(), 1311003253);
        }
        $commands = [
            'mkdir -p ' . $releasesPath,
            'mkdir -p ' . $sharedPath,
            'mkdir -p ' . $releasePath,
            'cd ' . $releasesPath . ';ln -snf ./' . $releaseIdentifier . ' next'
        ];
        $this->shell->executeOrSimulate($commands, $node, $deployment);
    }
766822
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$this->workflowRegistry instanceof Registry) {
            throw new Exception('Can not execute task: No workflows were defined');
        }

        $taskId = $input->getArgument('task-id');

        $callback = function () use ($taskId) {
            $task = $this->entityManager->find(Task::class, $taskId);

            if ($task instanceof Task) {
                $task->setStatus('in-progress');
            }

            return $task;
        };

        $task = $this->entityManager->transactional($callback);

        if (!$task instanceof Task) {
            $output->writeln(sprintf('No task found for id %d', $taskId));

            return;
        }

        $this->setAnonymousToken();

        $subject = $this->subjectManager->createSubject($task->getModel());
        $subject->setUp();
        $generator = $this->generatorManager->getGenerator($task->getGenerator());
        $workflow = $this->workflowRegistry->get($subject, $task->getModel());

        $path = new Path();
        $path->add(null, null, [$workflow->getDefinition()->getInitialPlace()]);

        try {
            foreach ($generator->getAvailableTransitions($workflow, $subject, $task->getMetaData()) as $transitionName) {
                try {
                    if (!$generator->applyTransition($workflow, $subject, $transitionName)) {
                        throw new Exception(sprintf("Generator '%s' generated transition '%s' that can not be applied", $task->getGenerator(), $transitionName));
                    }
                } catch (Throwable $throwable) {
                    throw $throwable;
                } finally {
                    $data = $subject->getStoredData();
                    $places = array_keys(array_filter($workflow->getMarking($subject)->getPlaces()));
                    $path->add($transitionName, $data, $places);
                }
            }
        } catch (Throwable $throwable) {
            $message = new CreateBugMessage(
                $this->defaultBugTitle,
                Path::serialize($path),
                $path->countPlaces(),
                $throwable->getMessage(),
                $task->getId(),
                'new'
            );
            $this->messageBus->dispatch($message);
        } finally {
            $subject->tearDown();

            $this->messageBus->dispatch(new UpdateTaskStatusMessage($taskId, 'completed'));
        }
    }
1058624
def register_workflow(connection, domain, workflow):
    
    args = get_workflow_registration_parameter(workflow)

    try:
        connection.register_workflow_type(domain=domain, **args)
    except ClientError as err:
        if err.response['Error']['Code'] == 'TypeAlreadyExistsFault':
            return False  # Ignore this error
        raise

    return True
279775
protected function init(EntryToObjectsService $entryToObjectsService, WorkflowService $workflowService)
    {
        $this->setEntryToObjectsService($entryToObjectsService);
        $this->setWorkflowService($workflowService);
    }
443169
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$input->getOption('delete') && !$input->getOption('info')) {
            throw new \InvalidArgumentException('You must specify whether you want to --delete or --info the specified workflow.');
        }

        $workflowService = $this->getWorkflowService();
        $workflowNameOrPath = $input->getArgument('workflow');

        if ($input->getOption('info')) {
            $output->writeln('');

            $workflow = $workflowService->getWorkflow($workflowNameOrPath);
            if ($workflow == null) {
                throw new \InvalidArgumentException(sprintf('The workflow "%s" does not exist in the database table.', $workflowNameOrPath));
            }

            switch ($workflow->status) {
                case Migration::STATUS_DONE:
                    $status = '<info>executed</info>';
                    break;
                case Migration::STATUS_STARTED:
                    $status = '<comment>execution started</comment>';
                    break;
                case Migration::STATUS_TODO:
                    // bold to-migrate!
                    $status = '<error>not executed</error>';
                    break;
                case Migration::STATUS_SKIPPED:
                    $status = '<comment>skipped</comment>';
                    break;
                case Migration::STATUS_PARTIALLY_DONE:
                    $status = '<comment>partially executed</comment>';
                    break;
                case Migration::STATUS_SUSPENDED:
                    $status = '<comment>suspended</comment>';
                    break;
                case Migration::STATUS_FAILED:
                    $status = '<error>failed</error>';
                    break;
            }

            $output->writeln('<info>Workflow: ' . $workflow->name . '</info>');
            $output->writeln('Status: ' . $status);
            $output->writeln('Executed on: <info>' . ($workflow->executionDate != null ? date("Y-m-d H:i:s", $workflow->executionDate) : '--'). '</info>');
            $output->writeln('Execution notes: <info>' . $workflow->executionError . '</info>');
            $output->writeln('Signal: <info>' . $workflow->signalName . '</info>');

            if ($workflow->status == Migration::STATUS_SUSPENDED) {
                /// @todo decode the suspension context: date, step, ...
            }

            $output->writeln('Definition path: <info>' . $workflow->path . '</info>');
            $output->writeln('Definition md5: <info>' . $workflow->md5 . '</info>');

            if ($workflow->path != '') {
                // q: what if we have a loader which does not work with is_file? We could probably remove this check...
                if (is_file($workflow->path)) {
                    try {
                        $workflowDefinitionCollection = $workflowService->getWorkflowsDefinitions(array($workflow->path));
                        if (count($workflowDefinitionCollection)) {
                            $workflowDefinition = reset($workflowDefinitionCollection);
                            $workflowDefinition = $workflowService->parseWorkflowDefinition($workflowDefinition);

                            if ($workflowDefinition->status != MigrationDefinition::STATUS_PARSED) {
                                $output->writeln('Definition error: <error>' . $workflowDefinition->parsingError . '</error>');
                            }

                            if (md5($workflowDefinition->rawDefinition) != $workflow->md5) {
                                $output->writeln('Notes: <comment>The workflow definition file has now a different checksum</comment>');
                            }

                            $output->writeln('Switch User: <info>' . (($workflowDefinition->runAs === false) ? '-' : $workflowDefinition->runAs) . '</info>');
                            $output->writeln('Use transaction: <info>' . ($workflowDefinition->useTransaction ? 'Y' : 'N') . '</info>');

                        } else {
                            $output->writeln('Definition error: <error>The workflow definition file can not be loaded</error>');
                        }
                    } catch (\Exception $e) {
                        /// @todo one day we should be able to limit the kind of exceptions we have to catch here...
                        $output->writeln('Definition parsing error: <error>' . $e->getMessage() . '</error>');
                    }
                } else {
                    $output->writeln('Definition error: <error>The workflow definition file can not be found any more</error>');
                }
            }

            $output->writeln('');
            return;
        }

        // ask user for confirmation to make changes
        if ($input->isInteractive() && !$input->getOption('no-interaction')) {
            $dialog = $this->getHelperSet()->get('dialog');
            if (!$dialog->askConfirmation(
                $output,
                '<question>Careful, the database will be modified. Do you want to continue Y/N ?</question>',
                false
            )
            ) {
                $output->writeln('<error>Workflow change cancelled!</error>');
                return 0;
            }
        }

        if ($input->getOption('delete')) {
            $workflow = $workflowService->getWorkflow($workflowNameOrPath);
            if ($workflow == null) {
                throw new \InvalidArgumentException(sprintf('The workflow "%s" does not exist in the database table.', $workflowNameOrPath));
            }

            $workflowService->deleteWorkflow($workflow);

            return;
        }
    }
400625
public function createWorkflowManager(WorkflowManagerEvent $event)
    {
        $workflowManager = $event->getWorkflowManager();
        $originalTypeResolver = $workflowManager->getResolver();
        $chainTypeResolver = $this->getChainTypeResolver();
        $resolver = $chainTypeResolver->add($originalTypeResolver, 0);

        $workflowTypeResolverEvent = new WorkflowTypeResolverEvent();
        $workflowTypeResolverEvent->setName(WorkflowTypeResolverEvent::INJECT_WORKFLOW_TYPE_RESOLVER);
        $workflowTypeResolverEvent->setWorkflowManager($workflowManager);
        $workflowTypeResolverEvent->setChainTypeResolver($chainTypeResolver);
        $workflowTypeResolverEvent->setTarget($this);
        $this->getEventManager()->trigger($workflowTypeResolverEvent);

        $workflowManager->setTypeResolver($resolver);
    }
502967
static void addDeployOperationStep(final CompositeOperationBuilder builder, final DeploymentDescription deployment) {
        final String name = deployment.getName();

        final Set<String> serverGroups = deployment.getServerGroups();
        // If the server groups are empty this is a standalone deployment
        if (serverGroups.isEmpty()) {
            final ModelNode address = createAddress(DEPLOYMENT, name);
            builder.addStep(createOperation(DEPLOYMENT_DEPLOY_OPERATION, address));
        } else {
            for (String serverGroup : serverGroups) {
                final ModelNode address = createAddress(SERVER_GROUP, serverGroup, DEPLOYMENT, name);
                builder.addStep(createOperation(DEPLOYMENT_DEPLOY_OPERATION, address));
            }
        }
    }