chg: [analyst-data:event-report] Added support of analyst-data to event reports

notes
Sami Mokaddem 2024-01-30 10:13:58 +01:00
parent 5664a735e2
commit caf55c3eec
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
6 changed files with 53 additions and 0 deletions

View File

@ -61,6 +61,7 @@ class EventReportsController extends AppController
public function view($reportId, $ajax=false)
{
$this->EventReport->includeAnalystData = true;
$report = $this->EventReport->simpleFetchById($this->Auth->user(), $reportId);
if ($this->_isRest()) {
return $this->RestResponse->viewData($report, $this->response->type());
@ -175,6 +176,7 @@ class EventReportsController extends AppController
$filters = $this->IndexFilter->harvestParameters(['event_id', 'value', 'context', 'index_for_event', 'extended_event']);
$filters['embedded_view'] = $this->request->is('ajax');
$compiledConditions = $this->__generateIndexConditions($filters);
$this->EventReport->includeAnalystData = true;
if ($this->_isRest()) {
$reports = $this->EventReport->find('all', [
'recursive' => -1,
@ -515,6 +517,7 @@ class EventReportsController extends AppController
{
$distributionLevels = $this->EventReport->Event->Attribute->distributionLevels;
$this->set('distributionLevels', $distributionLevels);
$this->set('shortDist', $this->EventReport->Event->Attribute->shortDist);
$this->set('initialDistribution', $this->EventReport->Event->Attribute->defaultDistribution());
}

View File

@ -17,6 +17,7 @@ class EventReport extends AppModel
'change' => 'full'
),
'Regexp' => array('fields' => array('value')),
'AnalystDataParent',
);
public $validate = array(

View File

@ -0,0 +1,16 @@
<?php
$uuid = Hash::get($row, $field['data_path']);
if (empty($uuid) || empty($field['object_type'])) {
throw new MethodNotAllowedException(__('No UUID or object_type provided'), 500);
}
$notes = Hash::extract($row, $field['notes_data_path'] ?? 'Note');
$opinions = Hash::extract($row, $field['opinions_data_path'] ?? 'Opnion');
$relationships = Hash::extract($row, $field['relationships_data_path'] ?? 'Relationship');
echo $this->element('genericElements/shortUuidWithNotes', [
'uuid' => $uuid,
'object_type' => $field['object_type'],
'notes' => $notes,
'opinions' => $opinions,
'relationships' => $relationships,
]);

View File

@ -73,6 +73,17 @@
'class' => 'short',
'data_path' => 'EventReport.id',
),
array(
'name' => __('Context'),
'sort' => 'uuid',
'class' => 'short',
'data_path' => 'EventReport.uuid',
'notes_data_path' => 'Note',
'opinions_data_path' => 'Opinion',
'relationships_data_path' => 'Relationship',
'element' => 'shortUUIDWithNotes',
'object_type' => 'EventReport',
),
array(
'name' => __('Name'),
'class' => 'useCursorPointer',

View File

@ -52,6 +52,17 @@
'element' => 'links',
'url' => $baseurl . '/eventReports/view/%s'
),
array(
'name' => __('Context'),
'sort' => 'uuid',
'class' => 'short',
'data_path' => 'EventReport.uuid',
'notes_data_path' => 'Note',
'opinions_data_path' => 'Opinion',
'relationships_data_path' => 'Relationship',
'element' => 'shortUUIDWithNotes',
'object_type' => 'EventReport',
),
array(
'name' => __('Name'),
'data_path' => 'EventReport.name',

View File

@ -23,6 +23,17 @@
'key' => __('Last update'),
'html' => $this->Time->time($report['EventReport']['timestamp']),
);
$table_data[] = array(
'key' => __('Analyst Data'),
'element' => 'genericElements/shortUuidWithNotes',
'element_params' => [
'uuid' => $report['EventReport']['uuid'],
'object_type' => 'EventReport',
'notes' => $report['Note'] ?? [],
'opinions' => $report['Opinion'] ?? [],
'relationships' => $report['Relationship'] ?? [],
],
);
if ($report['EventReport']['deleted']) {
$table_data[] = array(
'key' => __('Deleted'),