icingadb-web/library/Icingadb/Model/CommentHistory.php

93 lines
2.8 KiB
PHP
Raw Normal View History

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
2019-11-04 19:07:30 -05:00
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use Icinga\Module\Icingadb\Model\Behavior\Timestamp;
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.
*/
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',
'removed_by',
2019-11-03 16:01:07 -05:00
'comment',
'entry_type',
'is_persistent',
'expire_time',
'remove_time',
'has_been_removed'
];
}
public function getMetaData()
{
return [
'environment_id' => t('Comment Environment Id (History)'),
'endpoint_id' => t('Comment Endpoint Id (History)'),
'object_type' => t('Comment Object Type (History)'),
'host_id' => t('Comment Host Id (History)'),
'service_id' => t('Comment Service Id (History)'),
'entry_time' => t('Comment Entry Time (History)'),
'author' => t('Comment Author (History)'),
'removed_by' => t('Comment Removed By (History)'),
'comment' => t('Comment Comment (History)'),
'entry_type' => t('Comment Entry Type (History)'),
'is_persistent' => t('Comment Is Persistent (History)'),
'expire_time' => t('Comment Expire Time (History)'),
'remove_time' => t('Comment Remove Time (History)'),
'has_been_removed' => t('Comment Has Been Removed (History)')
];
}
2019-11-03 16:01:07 -05:00
public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new BoolCast([
'is_persistent',
'has_been_removed'
]));
$behaviors->add(new Timestamp([
'entry_time',
'expire_time',
'remove_time'
]));
}
public function createRelations(Relations $relations)
{
$relations->belongsTo('endpoint', Endpoint::class);
$relations->belongsTo('environment', Environment::class);
$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
}
}