2019-11-03 16:01:07 -05:00
|
|
|
<?php
|
|
|
|
|
|
2020-03-13 03:38:01 -04:00
|
|
|
/* Icinga DB Web | (c) 2020 Icinga GmbH | GPLv2 */
|
|
|
|
|
|
2019-11-04 19:07:30 -05:00
|
|
|
namespace Icinga\Module\Icingadb\Model;
|
2019-11-03 16:01:07 -05:00
|
|
|
|
2024-01-23 02:43:02 -05:00
|
|
|
use DateTime;
|
2025-06-05 10:56:46 -04:00
|
|
|
use ipl\Orm\Behavior\BoolCast;
|
2022-05-19 10:28:45 -04:00
|
|
|
use ipl\Orm\Behavior\Binary;
|
2023-05-30 10:05:11 -04:00
|
|
|
use ipl\Orm\Behavior\MillisecondTimestamp;
|
2019-11-03 16:01:07 -05:00
|
|
|
use ipl\Orm\Behaviors;
|
|
|
|
|
use ipl\Orm\Model;
|
|
|
|
|
use ipl\Orm\Relations;
|
|
|
|
|
|
2020-03-10 04:26:28 -04:00
|
|
|
/**
|
|
|
|
|
* Model for table `comment_history`
|
|
|
|
|
*
|
|
|
|
|
* Please note that using this model will fetch history entries for decommissioned services. To avoid this,
|
|
|
|
|
* the query needs a `comment_history.service_id IS NULL OR comment_history_service.id IS NOT NULL` where.
|
2024-01-23 02:43:02 -05:00
|
|
|
*
|
|
|
|
|
* @property string $comment_id
|
|
|
|
|
* @property string $environment_id
|
|
|
|
|
* @property ?string $endpoint_id
|
|
|
|
|
* @property string $object_type
|
|
|
|
|
* @property string $host_id
|
|
|
|
|
* @property ?string $service_id
|
|
|
|
|
* @property DateTime $entry_time
|
|
|
|
|
* @property string $author
|
|
|
|
|
* @property ?string $removed_by
|
|
|
|
|
* @property string $comment
|
|
|
|
|
* @property string $entry_type
|
|
|
|
|
* @property bool $is_persistent
|
|
|
|
|
* @property bool $is_sticky
|
|
|
|
|
* @property ?DateTime $expire_time
|
|
|
|
|
* @property ?DateTime $remove_time
|
|
|
|
|
* @property bool $has_been_removed
|
2020-03-10 04:26:28 -04:00
|
|
|
*/
|
2019-11-03 16:01:07 -05:00
|
|
|
class CommentHistory extends Model
|
|
|
|
|
{
|
|
|
|
|
public function getTableName()
|
|
|
|
|
{
|
|
|
|
|
return 'comment_history';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getKeyName()
|
|
|
|
|
{
|
|
|
|
|
return 'comment_id';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getColumns()
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'environment_id',
|
|
|
|
|
'endpoint_id',
|
|
|
|
|
'object_type',
|
|
|
|
|
'host_id',
|
|
|
|
|
'service_id',
|
|
|
|
|
'entry_time',
|
|
|
|
|
'author',
|
2020-05-14 08:06:28 -04:00
|
|
|
'removed_by',
|
2019-11-03 16:01:07 -05:00
|
|
|
'comment',
|
|
|
|
|
'entry_type',
|
|
|
|
|
'is_persistent',
|
2021-06-11 10:28:10 -04:00
|
|
|
'is_sticky',
|
2019-11-03 16:01:07 -05:00
|
|
|
'expire_time',
|
|
|
|
|
'remove_time',
|
|
|
|
|
'has_been_removed'
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-08 09:34:01 -04:00
|
|
|
public function getColumnDefinitions()
|
2021-03-08 05:40:16 -05:00
|
|
|
{
|
|
|
|
|
return [
|
2022-07-11 11:31:53 -04:00
|
|
|
'environment_id' => t('Environment Id'),
|
|
|
|
|
'endpoint_id' => t('Endpoint Id'),
|
|
|
|
|
'object_type' => t('Object Type'),
|
|
|
|
|
'host_id' => t('Host Id'),
|
|
|
|
|
'service_id' => t('Service Id'),
|
|
|
|
|
'entry_time' => t('Comment Entry Time'),
|
|
|
|
|
'author' => t('Comment Author'),
|
|
|
|
|
'removed_by' => t('Comment Removed By'),
|
|
|
|
|
'comment' => t('Comment Text'),
|
|
|
|
|
'entry_type' => t('Comment Entry Type'),
|
|
|
|
|
'is_persistent' => t('Comment Is Persistent'),
|
|
|
|
|
'is_sticky' => t('Comment Is Sticky'),
|
|
|
|
|
'expire_time' => t('Comment Expire Time'),
|
|
|
|
|
'remove_time' => t('Comment Remove Time'),
|
|
|
|
|
'has_been_removed' => t('Comment Has Been Removed')
|
2021-03-08 05:40:16 -05:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-03 16:01:07 -05:00
|
|
|
public function createBehaviors(Behaviors $behaviors)
|
|
|
|
|
{
|
|
|
|
|
$behaviors->add(new BoolCast([
|
|
|
|
|
'is_persistent',
|
2021-06-11 10:28:10 -04:00
|
|
|
'is_sticky',
|
2019-11-03 16:01:07 -05:00
|
|
|
'has_been_removed'
|
|
|
|
|
]));
|
|
|
|
|
|
2023-05-30 10:05:11 -04:00
|
|
|
$behaviors->add(new MillisecondTimestamp([
|
2019-11-03 16:01:07 -05:00
|
|
|
'entry_time',
|
|
|
|
|
'expire_time',
|
|
|
|
|
'remove_time'
|
|
|
|
|
]));
|
2022-03-29 09:27:18 -04:00
|
|
|
|
|
|
|
|
$behaviors->add(new Binary([
|
|
|
|
|
'comment_id',
|
|
|
|
|
'environment_id',
|
|
|
|
|
'endpoint_id',
|
|
|
|
|
'host_id',
|
|
|
|
|
'service_id'
|
|
|
|
|
]));
|
2019-11-03 16:01:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function createRelations(Relations $relations)
|
|
|
|
|
{
|
|
|
|
|
$relations->belongsTo('endpoint', Endpoint::class);
|
|
|
|
|
$relations->belongsTo('environment', Environment::class);
|
2021-03-08 10:29:30 -05:00
|
|
|
$relations->belongsTo('history', History::class)
|
|
|
|
|
->setCandidateKey('comment_id')
|
|
|
|
|
->setForeignKey('comment_history_id');
|
2020-02-07 09:50:55 -05:00
|
|
|
$relations->belongsTo('host', Host::class);
|
2020-03-10 04:26:28 -04:00
|
|
|
$relations->belongsTo('service', Service::class)->setJoinType('LEFT');
|
2019-11-03 16:01:07 -05:00
|
|
|
}
|
|
|
|
|
}
|