public function startAppAction()
 {
     $workflows = $this->workflowFinder->findAll();
     $viewModel = new ViewModel(['workflows' => $workflows, 'processes' => array_values(Func::map($this->systemConfig->getProcessDefinitions(), function ($definition, $message) {
         return $this->convertToClientProcess($message, $definition, $this->systemConfig->getAllAvailableProcessingTypes());
     })), 'connectors' => array_values(Func::map($this->systemConfig->getConnectors(), function ($connector, $id) {
         $connector['id'] = $id;
         if (!isset($connector['metadata']) || empty($connector['metadata'])) {
             //Force empty object
             $connector['metadata'] = new \stdClass();
         }
         return $connector;
     })), 'available_processing_types' => $this->getProcessingTypesForClient(), 'available_manipulation_scripts' => $this->scriptLocation->getScriptNames(), 'locations' => $this->locationTranslator->getLocations(), 'available_process_types' => [['value' => \Prooph\Processing\Processor\Definition::PROCESS_LINEAR_MESSAGING, 'label' => $this->i18nTranslator->translate('Linear Process')], ['value' => \Prooph\Processing\Processor\Definition::PROCESS_PARALLEL_FOR_EACH, 'label' => $this->i18nTranslator->translate('Foreach Process')]], 'available_task_types' => [['value' => \Prooph\Processing\Processor\Definition::TASK_COLLECT_DATA, 'label' => $this->i18nTranslator->translate('Collect Data')], ['value' => \Prooph\Processing\Processor\Definition::TASK_PROCESS_DATA, 'label' => $this->i18nTranslator->translate('Process Data')], ['value' => \Prooph\Processing\Processor\Definition::TASK_MANIPULATE_PAYLOAD, 'label' => $this->i18nTranslator->translate('Run Manipulation Script')]], 'available_messages' => [['value' => 'collect-data', 'label' => $this->i18nTranslator->translate('Collect Data Message')], ['value' => 'data-collected', 'label' => $this->i18nTranslator->translate('Data Collected Message')], ['value' => 'process-data', 'label' => $this->i18nTranslator->translate('Process Data Message')]]]);
     $viewModel->setTemplate('prooph.link.process-manager/process-manager/app');
     $this->layout()->setVariable('includeRiotJs', true);
     return $viewModel;
 }
Exemplo n.º 2
0
 public function detailsAction()
 {
     $processId = ProcessId::fromString($this->params('process_id'));
     $process = $this->processLogger->getLoggedProcess($processId);
     if (is_null($process)) {
         return $this->notFoundAction();
     }
     $process['events'] = $this->convertToClientProcessEvents($this->processStreamReader->getStreamOfProcess($processId));
     if (!isset($process['start_message']) || !isset($this->systemConfig->getProcessDefinitions()[$process['start_message']])) {
         return $this->incompleteAction($process);
     }
     $definition = $this->convertToClientProcess($process['start_message'], $this->systemConfig->getProcessDefinitions()[$process['start_message']], $this->systemConfig->getAllAvailableProcessingTypes());
     $process = array_merge($process, $definition);
     $this->populateTaskEvents($process);
     $view = new ViewModel(['process' => $process, 'available_processing_types' => $this->getProcessingTypesForClient(), 'available_task_types' => \Prooph\Processing\Processor\Definition::getAllTaskTypes(), 'available_manipulation_scripts' => $this->scriptLocation->getScriptNames(), 'locations' => $this->locationTranslator->getLocations(), 'connectors' => array_values(Func::map($this->systemConfig->getConnectors(), function ($connector, $id) {
         $connector['id'] = $id;
         return $connector;
     }))]);
     $view->setTemplate('prooph/link/monitor/process-view/process-details-app');
     $this->layout()->setVariable('includeRiotJs', true);
     return $view;
 }
Exemplo n.º 3
0
 /**
  * @param WorkflowMessage $workflowMessage
  * @throws \InvalidArgumentException
  */
 private function processData(WorkflowMessage $workflowMessage)
 {
     $metadata = $workflowMessage->metadata();
     if (isset($metadata[self::META_LOCATION]) && !isset($metadata[self::META_PATH])) {
         $metadata[self::META_PATH] = $this->locationTranslator->getPathFor($metadata[self::META_LOCATION]);
     }
     if (!isset($metadata[self::META_FILENAME_TEMPLATE])) {
         throw new \InvalidArgumentException("Missing filename_pattern in metadata");
     }
     if (!isset($metadata[self::META_FILE_TYPE])) {
         throw new \InvalidArgumentException("Missing file_type in metadata");
     }
     if (!isset($metadata[self::META_PATH])) {
         throw new \InvalidArgumentException("Missing path in metadata");
     }
     $metadata[self::META_PATH] = $this->sanitizePath($metadata[self::META_PATH]);
     if (!is_dir($metadata[self::META_PATH])) {
         throw new \InvalidArgumentException(sprintf('Directory %s is invalid', $metadata[self::META_PATH]));
     }
     if (!is_writable($metadata[self::META_PATH])) {
         throw new \InvalidArgumentException(sprintf('Directory %s is not writable', $metadata[self::META_PATH]));
     }
     $type = $workflowMessage->payload()->toType();
     $fileTypeAdapter = $this->fileTypeAdapters->get($metadata[self::META_FILE_TYPE]);
     if ($type->description()->nativeType() === NativeType::COLLECTION && isset($metadata[self::META_WRITE_MULTI_FILES]) && $metadata[self::META_WRITE_MULTI_FILES]) {
         foreach ($type as $index => $item) {
             $this->writeTypeToFile($item, $metadata, $fileTypeAdapter, $index);
         }
     } else {
         $this->writeTypeToFile($type, $metadata, $fileTypeAdapter);
     }
     return $workflowMessage->answerWithDataProcessingCompleted($metadata);
 }