Prints configuration for each defined application

@param array $applications
@param Workflow $workflow
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());
            }
        }
    }
1187705
public function processDocuments(array $documents, array $processingConfiguration) {
        foreach ($documents as $document) {
            $this->processDocument($document, $processingConfiguration);
        }
    }
1106963
static function runWorkflow( $workflowProcess )
    {
        $workflow = eZWorkflow::fetch( $workflowProcess->attribute( "workflow_id" ) );
        $workflowEvent = null;

        $workflowStatus = $workflowProcess->run( $workflow, $workflowEvent, $eventLog );

        $db = eZDB::instance();
        $db->begin();
        $workflowProcess->store();

        switch ( $workflowStatus )
        {
            case eZWorkflow::STATUS_FAILED:
            case eZWorkflow::STATUS_CANCELLED:
            case eZWorkflow::STATUS_NONE:
            case eZWorkflow::STATUS_BUSY:
            {
                $workflowProcess->removeThis();
                $db->commit();
                return array( 'Status' => eZTrigger::WORKFLOW_CANCELLED,
                              'Result' => null );
            } break;
            case eZWorkflow::STATUS_FETCH_TEMPLATE:
            case eZWorkflow::STATUS_FETCH_TEMPLATE_REPEAT:
            {
                $tpl = eZTemplate::factory();
                $result = array();
                foreach ( array_keys( $workflowProcess->Template['templateVars'] ) as $key )
                {
                    $value = $workflowProcess->Template['templateVars'][$key];
                    $tpl->setVariable( $key, $value );
                }
                $result['content'] = $tpl->fetch( $workflowProcess->Template['templateName'] );
                if ( isset( $workflowProcess->Template['path'] ) )
                    $result['path'] = $workflowProcess->Template['path'];

                    $db->commit();
                if ( $workflowStatus == eZWorkflow::STATUS_FETCH_TEMPLATE )
                {
                    $triggerStatus = eZTrigger::FETCH_TEMPLATE;
                }
                elseif ( $workflowStatus == eZWorkflow::STATUS_FETCH_TEMPLATE_REPEAT )
                {
                    $triggerStatus = eZTrigger::FETCH_TEMPLATE_REPEAT;
                }
                return array( 'Status' => $triggerStatus,
                              'WorkflowProcess' => $workflowProcess,
                              'Result' => $result );
            } break;
            case eZWorkflow::STATUS_REDIRECT:
            {
//                var_dump( $workflowProcess->RedirectUrl  );
                $db->commit();
                return array( 'Status' => eZTrigger::REDIRECT,
                              'WorkflowProcess' => $workflowProcess,
                              'Result' => $workflowProcess->RedirectUrl );

            } break;
            case eZWorkflow::STATUS_DEFERRED_TO_CRON:
            {

                $db->commit();
                return array( 'Status' => eZTrigger::STATUS_CRON_JOB,
                              'WorkflowProcess' => $workflowProcess,
                              'Result' => array( 'content' => 'Deffered to cron. Operation halted during execution. <br/>Refresh page to continue<br/><br/><b>Note: The halt is just a temporary test</b><br/>',
                                                 'path' => array( array( 'text' => 'Operation halt',
                                                                         'url' => false ) ) ) );
/*
                return array( 'Status' => eZTrigger::STATUS_CRON_JOB,
                              'Result' => $workflowProcess->attribute( 'id') );
*/
            } break;
            case eZWorkflow::STATUS_RESET:
            {
                $db->commit();
                return array( 'Status' => eZTrigger::WORKFLOW_RESET,
                              'WorkflowProcess' => $workflowProcess,
                              'Result' => array( 'content' => 'Workflow was reset',
                                                 'path' => array( array( 'text' => 'Operation halt',
                                                                         'url' => false ) ) ) );
            } break;
            case eZWorkflow::STATUS_DONE:
            {
                $workflowProcess->removeThis();
                $db->commit();
                return array( 'Status' => eZTrigger::WORKFLOW_DONE,
                              'Result' => null );
            }
        }

        $db->commit();
        return array( 'Status' => eZTrigger::WORKFLOW_CANCELLED,
                      'Result' => null );



    }
1248033
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if (!$this->workflowRegistry instanceof Registry) {
            throw new Exception('Can not generate path: No workflows were defined');
        }

        $this->setAnonymousToken();

        $model = $input->getArgument('model');
        $generatorName = $input->getOption('generator');
        $metaData = $input->getOption('meta-data');
        $generator = $this->generatorManager->getGenerator($generatorName);
        $subject = $this->subjectManager->createSubject($model);
        $subject->setTestingModel(true);
        $subject->setUp();
        $workflow = $this->workflowRegistry->get($subject, $model);

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

        try {
            foreach ($generator->getAvailableTransitions($workflow, $subject, $metaData) as $transitionName) {
                try {
                    if (!$generator->applyTransition($workflow, $subject, $transitionName)) {
                        throw new Exception(sprintf("Generator '%s' generated transition '%s' that can not be applied", $generatorName, $transitionName));
                    }
                } finally {
                    $data = $subject->getStoredData();
                    $places = array_keys(array_filter($workflow->getMarking($subject)->getPlaces()));
                    $path->add($transitionName, $data, $places);
                }
            }
        } finally {
            $subject->tearDown();
        }

        $output->writeln(json_encode(Path::serialize($path)));
    }
473891
public List<String> getRunningWorkflow(String workflowName, @Nullable Integer version) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowName), "Workflow name cannot be blank");

        WorkflowServicePb.GetRunningWorkflowsResponse workflows = stub.getRunningWorkflows(
                WorkflowServicePb.GetRunningWorkflowsRequest.newBuilder()
                        .setName(workflowName)
                        .setVersion(version == null ? 1 : version)
                        .build()
        );
        return workflows.getWorkflowIdsList();
    }
1289506
private function patchStateOperation(Page $page, array &$operations)
    {
        $stateOp = null;
        $isHiddenOp = null;
        foreach ($operations as $key => $operation) {
            $op = [
                'key' => $key,
                'op' => $operation
            ];
            if ('/state' === $operation['path']) {
                $stateOp = $op;
            } elseif ('/is_hidden' === $operation['path']) {
                $isHiddenOp = $op;
            }
        }

        if ($page->isOnline(true)) {
            $this->granted('PUBLISH', $page);
        }

        if (null !== $stateOp) {
            unset($operations[$stateOp['key']]);
            $states = explode('_', $stateOp['op']['value']);
            if (in_array($state = (int) array_shift($states), Page::$STATES)) {
                $page->setState($state | ($page->getState() & Page::STATE_HIDDEN ? Page::STATE_HIDDEN : 0));
            }

            if ($code = (int) array_shift($states)) {
                $workflowState = $this->getApplication()->getEntityManager()
                    ->getRepository('BackBee\Workflow\State')
                    ->findOneBy([
                        '_code'   => $code,
                        '_layout' => $page->getLayout(),
                    ])
                ;

                if (null !== $workflowState) {
                    $page->setWorkflowState($workflowState);
                }
            }
        }

        if (null !== $isHiddenOp) {
            unset($operations[$isHiddenOp['key']]);

            $isHidden = (boolean) $isHiddenOp['op']['value'];
            if ($isHidden && !($page->getState() & Page::STATE_HIDDEN)) {
                $page->setState($page->getState() | Page::STATE_HIDDEN);
            } elseif (!$isHidden && ($page->getState() & Page::STATE_HIDDEN)) {
                $page->setState($page->getState() ^ Page::STATE_HIDDEN);
            }
        }
    }
184974
public function setStates($objects, $processes, $onlySuccess)
    {
        $objects = ( ! is_array($objects) && ! $objects instanceof \ArrayAccess) ? array($objects) : $objects;

        if (0 === count($objects)) {
            return;
        }

        $ordersIndexedByWorkflowIdentifier = array();
        foreach ($objects as $object) {
            if (!$object instanceof ModelStateInterface) {
                throw new \InvalidArgumentException();
            }

            $ordersIndexedByWorkflowIdentifier[$object->getWorkflowIdentifier()] = $object;
        }

        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('ms')
            ->from('Lexik\Bundle\WorkflowBundle\Entity\ModelState', 'ms')
            ->andWhere($qb->expr()->in('ms.workflowIdentifier', array_keys($ordersIndexedByWorkflowIdentifier)))
            ->orderBy('ms.id');

        if (count($processes)) {
            $qb->andWhere($qb->expr()->in('ms.processName', $processes));
        }

        if ($onlySuccess) {
            $qb->andWhere('ms.successful = 1');
        }

        $states = $qb->getQuery()->getResult();

        foreach ($states as $state) {
            $ordersIndexedByWorkflowIdentifier[$state->getWorkflowIdentifier()]->addState($state);
        }
    }
644951
function (config, cb) {

        var o = {}, k;
        o.domain = this.baseConfig.domain;
        //o.execution = this.workflowId;

        for (k in config) {
            if (config.hasOwnProperty(k)) {
                o[k] = config[k];
            }
        }

        this.swfClient.getWorkflowExecutionHistory(o, cb);
    }
1359807
public function load(array $files) : void
    {
        $this->appConfig = $this->getCache()->getOrSet($this->env, function() use ($files){
            $config = $this->loadBaseConfig($files);
            return $this->loadInstalledComponentsConfig($config);
        });
    }
1213565
function WorkflowProcessBeginController($state, workorderService, wfmService, $stateParams) {
  var self = this;

  var workorderId = $stateParams.workorderId;
  workorderService.read(workorderId).then(function(workorder) {
    self.workorder = workorder;
    self.workflow = workorder.workflow;
    self.results = workorder.results;
    self.started = !wfmService.isNew(self.workorder);
    self.completed = wfmService.isCompleted(self.workorder);
  });

  self.getStepForResult = function(result) {
    return wfmService.getStepForResult(result, self.workorder);
  };

  self.begin = function() {
    wfmService.begin(self.workorder)
      .then(function() {
        $state.go('app.workflowProcess.steps', {
          workorderId: workorderId
        });
      })
      .catch(console.error.bind(console));
  };
}
224015
protected function configureModules(InputInterface $input, OutputInterface $output, array $modules)
    {
        $app = $this->getApplication();
        if ($app->getConfiguration()) {
            $app->addCommands(ModuleCommand::getCommands());
            if ($app->getBitrixStatus() != \Notamedia\ConsoleJedi\Application\Application::BITRIX_STATUS_COMPLETE) {
                throw new BitrixException('Bitrix core is not available');
            }
        } else {
            throw new BitrixException('No configuration loaded');
        }

        if (!is_array($modules)) {
            throw new \LogicException('Incorrect modules configuration');
        }

        if (!count($modules)) {
            return;
        }

        $bar = new ProgressBar($output, count($modules));
        $bar->setRedrawFrequency(1);
        $bar->setFormat('verbose');

        foreach ($modules as $moduleName) {
            $message = "\r" . '   module:load ' . $moduleName . ': ';

            try {
                if (isset($bar)) {
                    $bar->setMessage($message);
                    $bar->display();
                }

                (new Module($moduleName))->load()->register();

                $bar->clear();
                $output->writeln($message . '<info>ok</info>');
            } catch (ModuleInstallException $e) {
                $bar->clear();
                $output->writeln($e->getMessage(), OutputInterface::VERBOSITY_VERBOSE);
                $output->writeln($message . '<comment>not registered</comment> (install it in admin panel)');
            } catch (ModuleException $e) {
                $bar->clear();
                $output->writeln($e->getMessage(), OutputInterface::VERBOSITY_VERBOSE);
                $output->writeln($message . '<error>FAILED</error>');
            }
            $bar->advance();
        }
        $bar->finish();
        $bar->clear();
        $output->write("\r");
    }
758828
static function getWorkflowState($workflow_key) {
        $status = self::STATUS_COMPLETED;
        $created_after = "-20 years";
        $data = DataStore::retrieveMostCurrentWorkflowJobByAgeAndStatus($workflow_key, $status, $created_after);
        if ($data) {
            return $data["end_state"];
        } else {
            $workflow = DataStore::retrieveWorkflow($workflow_key);
            if (!$workflow) {
                throw new \Exception("Error retrieving workflow for key $workflow_key can't determine state.");
            }
            $data = $workflow->getData();
            return $data[self::CONF_INITIAL_STATE];
        }
    }
675537
public function getWorkflow($workflow)
    {
        if (!isset($this->workflows[$workflow])) {
            $this->loadWorkflow($workflow);
        }

        return $this->workflows[$workflow];
    }
994637
public function getWorkflowNames()
    {
        try {
            return $this->getConfiguration()->getWorkflowNames();
        } catch (FactoryException $e) {
            $errMsg = 'Ошибка при получение имен workflow';
            $this->getLog()->error($errMsg, [$e]);
        }

        return [];
    }
32076
function (config, cb) {

        var o = {}, k;

        for (k in this.baseConfig) {
            if (this.baseConfig.hasOwnProperty(k)) {
                o[k] = this.baseConfig[k];
            }
        }

        for (k in config) {
            if (config.hasOwnProperty(k)) {
                o[k] = config[k];
            }
        }

        if (!o.workflowId) {
            o.workflowId = String(Math.random()).substr(2);
        }

        this.workflowId = o.workflowId;

        this.swfClient.startWorkflowExecution(o, function (err, result) {
            cb(err, result ? result.runId : null);
        });
    }
1121874
@Service
    public Workflow getExecutionStatus(String workflowId, boolean includeTasks) {
        Workflow workflow = executionService.getExecutionStatus(workflowId, includeTasks);
        if (workflow == null) {
            throw new ApplicationException(ApplicationException.Code.NOT_FOUND,
                    String.format("Workflow with Id: %s not found.", workflowId));
        }
        return workflow;
    }
1096171
static function runFromKey($workflow_key) {
        $workflow_job_config = [];
        $start_time = microtime(true);
        /**
         * First doing a simple setup... does this work?
         * Nothing get saved at this point errors here is most likely to be
         * a runtime problem. Like locking errorous jobs or that a job is already running.
         */
        try {
            $workflow_config = self::getWorkflowConfig($workflow_key);
            $workflow_job_key = self::createWorkflowJobKey();
            $workflow_job_config = self::createJobConfig($workflow_config);
            $start_state = self::getWorkflowState($workflow_key);
            $workflow_job_config = self::startJob($workflow_job_key, $workflow_job_config, $start_state);
        } catch (\Exception $exception) {
            syslog(LOG_ERR, $exception->getMessage());
            $workflow_job_config["status"] = self::STATUS_ERROR;
            $workflow_job_config["message"] = "Got this error: " . $exception->getMessage();
            $workflow_job_config["runtime"] = microtime(true) - $start_time;
            return $workflow_job_config;
        }
        /**
         * Continues with a working setup and trying to do the config run.
         */
        try {
            ob_start();
            $end_state = self::runFromConfig($workflow_config, $start_state);
            $workflow_job_config["message"] = ob_get_clean();
            $workflow_job_config["runtime"] = microtime(true) - $start_time;
            if ($end_state) {
                return self::endJob($workflow_job_key, $workflow_job_config, $end_state);
            } else {
                return self::failJob($workflow_job_key, $workflow_job_config, "Job didn't emit an endstate.");
            }
        } catch (\Exception $exception) {
            $workflow_job_config["runtime"] = microtime(true) - $start_time;
            return self::failJob($workflow_job_key, $workflow_job_config, $exception->getMessage());
        }
    }