mirror of https://github.com/MISP/MISP
chg: [workflowBlueprint] Clean-up and new method export formats
parent
8a98815b75
commit
95e98c27bb
|
@ -39,7 +39,7 @@ class WorkflowBlueprintsController extends AppController
|
|||
'beforeSave' => function(array $blueprint) {
|
||||
$blueprint['WorkflowBlueprint']['default'] = false;
|
||||
return $blueprint;
|
||||
}
|
||||
},
|
||||
];
|
||||
$this->CRUD->add($params);
|
||||
if ($this->IndexFilter->isRest()) {
|
||||
|
@ -55,7 +55,7 @@ class WorkflowBlueprintsController extends AppController
|
|||
'beforeSave' => function (array $blueprint) {
|
||||
$blueprint['WorkflowBlueprint']['default'] = false;
|
||||
return $blueprint;
|
||||
}
|
||||
},
|
||||
];
|
||||
$this->CRUD->edit($id, $params);
|
||||
if ($this->IndexFilter->isRest()) {
|
||||
|
@ -80,6 +80,16 @@ class WorkflowBlueprintsController extends AppController
|
|||
|
||||
public function view($id)
|
||||
{
|
||||
$filters = $this->IndexFilter->harvestParameters(['format']);
|
||||
if (!empty($filters['format'])) {
|
||||
if ($filters['format'] == 'dot') {
|
||||
$dot = $this->WorkflowBlueprint->getDotNotation($id);
|
||||
return $this->RestResponse->viewData($dot, $this->response->type());
|
||||
} else if ($filters['format'] == 'mermaid') {
|
||||
$mermaid = $this->WorkflowBlueprint->getMermaid($id);
|
||||
return $this->RestResponse->viewData($mermaid, $this->response->type());
|
||||
}
|
||||
}
|
||||
$this->CRUD->view($id, [
|
||||
]);
|
||||
if ($this->IndexFilter->isRest()) {
|
||||
|
|
|
@ -310,8 +310,8 @@ class WorkflowsController extends AppController
|
|||
|
||||
private function __applyDataFromSavedWorkflow($newWorkflow, $savedWorkflow)
|
||||
{
|
||||
if (!isset($newReport['Workflow'])) {
|
||||
$newReport = ['Workflow' => $newWorkflow];
|
||||
if (!isset($newWorkflow['Workflow'])) {
|
||||
$newWorkflow = ['Workflow' => $newWorkflow];
|
||||
}
|
||||
$ignoreFieldList = ['id', 'uuid'];
|
||||
foreach (Workflow::CAPTURE_FIELDS_EDIT as $field) {
|
||||
|
|
|
@ -74,14 +74,12 @@ class BackgroundJobsTool
|
|||
CMD_EVENT = 'event',
|
||||
CMD_SERVER = 'server',
|
||||
CMD_ADMIN = 'admin',
|
||||
CMD_MODULE = 'module',
|
||||
CMD_WORKFLOW = 'workflow';
|
||||
|
||||
const ALLOWED_COMMANDS = [
|
||||
self::CMD_EVENT,
|
||||
self::CMD_SERVER,
|
||||
self::CMD_ADMIN,
|
||||
self::CMD_MODULE,
|
||||
self::CMD_WORKFLOW,
|
||||
];
|
||||
|
||||
|
@ -89,7 +87,6 @@ class BackgroundJobsTool
|
|||
self::CMD_EVENT => 'EventShell',
|
||||
self::CMD_SERVER => 'ServerShell',
|
||||
self::CMD_ADMIN => 'AdminShell',
|
||||
self::CMD_MODULE => 'ModuleShell',
|
||||
self::CMD_WORKFLOW => 'WorkflowShell',
|
||||
];
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ class WorkflowBlueprint extends AppModel
|
|||
}
|
||||
$results[$k]['WorkflowBlueprint']['data'] = JsonTool::decode($result['WorkflowBlueprint']['data']);
|
||||
if (!empty($results[$k]['WorkflowBlueprint']['data'])) {
|
||||
$results[$k]['WorkflowBlueprint']['mermaid'] = $this->getMermaid($results[$k]['WorkflowBlueprint']['data']);
|
||||
$results[$k]['WorkflowBlueprint']['mermaid'] = $this->getMermaidForData($results[$k]['WorkflowBlueprint']['data']);
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
|
@ -112,9 +112,9 @@ class WorkflowBlueprint extends AppModel
|
|||
if (empty($blueprints_from_repo)) {
|
||||
throw new NotFoundException(__('Default blueprints could not be loaded or `%s` folder is empty', self::REPOSITORY_PATH));
|
||||
}
|
||||
$existing_blueprints = $this->find('all', array(
|
||||
$existing_blueprints = $this->find('all', [
|
||||
'recursive' => -1
|
||||
));
|
||||
]);
|
||||
$existing_blueprints_by_uuid = Hash::combine($existing_blueprints, '{n}.WorkflowBlueprint.uuid', '{n}.WorkflowBlueprint');
|
||||
foreach ($blueprints_from_repo as $blueprint_from_repo) {
|
||||
$blueprint_from_repo = $blueprint_from_repo['WorkflowBlueprint'];
|
||||
|
@ -134,10 +134,32 @@ class WorkflowBlueprint extends AppModel
|
|||
}
|
||||
}
|
||||
|
||||
public function getMermaid($workflowBlueprintData)
|
||||
public function getMermaidForData($workflowBlueprintData)
|
||||
{
|
||||
App::uses('MermaidFlowchartTool', 'Tools');
|
||||
$mermaid = MermaidFlowchartTool::mermaid($workflowBlueprintData);
|
||||
return $mermaid;
|
||||
}
|
||||
|
||||
public function getDotNotation($id)
|
||||
{
|
||||
App::uses('GraphvizDOTTool', 'Tools');
|
||||
$blueprint = $this->find('first', [
|
||||
'conditions' => ['id' => $id],
|
||||
'recursive' => -1,
|
||||
]);
|
||||
$dot = GraphvizDOTTool::dot($blueprint['WorkflowBlueprint']['data']);
|
||||
return $dot;
|
||||
}
|
||||
|
||||
public function getMermaid($id)
|
||||
{
|
||||
App::uses('MermaidFlowchartTool', 'Tools');
|
||||
$blueprint = $this->find('first', [
|
||||
'conditions' => ['id' => $id],
|
||||
'recursive' => -1,
|
||||
]);
|
||||
$mermaid = MermaidFlowchartTool::mermaid($blueprint['WorkflowBlueprint']['data']);
|
||||
return $mermaid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
echo $this->element(
|
||||
'genericElements/SingleViews/single_view',
|
||||
[
|
||||
'title' => 'Workflow view',
|
||||
'title' => 'Workflow blueprint view',
|
||||
'data' => $data,
|
||||
'fields' => [
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue