Skip to content

Commit

Permalink
Add Binary behavior for binary columns
Browse files Browse the repository at this point in the history
  • Loading branch information
lippserd committed Apr 13, 2022
1 parent 88b4448 commit ce10eb6
Show file tree
Hide file tree
Showing 58 changed files with 647 additions and 6 deletions.
9 changes: 9 additions & 0 deletions library/Icingadb/Model/AcknowledgementHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use Icinga\Module\Icingadb\Model\Behavior\Timestamp;
use ipl\Orm\Behaviors;
Expand Down Expand Up @@ -78,6 +79,14 @@ public function createBehaviors(Behaviors $behaviors)
'clear_time',
'expire_time'
]));

$behaviors->add(new Binary([
'id',
'environment_id',
'endpoint_id',
'host_id',
'service_id',
]));
}

public function createRelations(Relations $relations)
Expand Down
6 changes: 6 additions & 0 deletions library/Icingadb/Model/ActionUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\ActionAndNoteUrl;
use Icinga\Module\Icingadb\Model\Behavior\Binary;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;
Expand Down Expand Up @@ -40,6 +41,11 @@ public function getMetaData()
public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new ActionAndNoteUrl(['action_url']));

$behaviors->add(new Binary([
'id',
'environment_id'
]));
}

public function createRelations(Relations $relations)
Expand Down
8 changes: 8 additions & 0 deletions library/Icingadb/Model/Behavior/Binary.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ public function toDb($value, $key, $_)
throw new \UnexpectedValueException(sprintf('Unexpected resource for %s', $key));
}

if ($value === '*') {
/**
* Support IS (NOT) NULL filter transformation.
* {@see \ipl\Sql\Compat\FilterProcessor::assemblePredicate()}
*/
return $value;
}

return sprintf('\\x%s', bin2hex($value));
}

Expand Down
9 changes: 9 additions & 0 deletions library/Icingadb/Model/Checkcommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
Expand Down Expand Up @@ -55,6 +56,14 @@ public function createBehaviors(Behaviors $behaviors)
'hostgroup' => 'host.hostgroup',
'servicegroup' => 'service.servicegroup'
]));

$behaviors->add(new Binary([
'id',
'zone_id',
'environment_id',
'name_checksum',
'properties_checksum'
]));
}

public function createRelations(Relations $relations)
Expand Down
12 changes: 12 additions & 0 deletions library/Icingadb/Model/CheckcommandArgument.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;

Expand Down Expand Up @@ -55,6 +57,16 @@ public function getMetaData()
];
}

public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new Binary([
'id',
'checkcommand_id',
'environment_id',
'properties_checksum'
]));
}

public function createRelations(Relations $relations)
{
$relations->belongsTo('environment', Environment::class);
Expand Down
12 changes: 12 additions & 0 deletions library/Icingadb/Model/CheckcommandCustomvar.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;

Expand All @@ -28,6 +30,16 @@ public function getColumns()
];
}

public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new Binary([
'id',
'checkcommand_id',
'customvar_id',
'environment_id'
]));
}

public function createRelations(Relations $relations)
{
$relations->belongsTo('environment', Environment::class);
Expand Down
12 changes: 12 additions & 0 deletions library/Icingadb/Model/CheckcommandEnvvar.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;

Expand Down Expand Up @@ -41,6 +43,16 @@ public function getMetaData()
];
}

public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new Binary([
'id',
'checkcommand_id',
'environment_id',
'properties_checksum'
]));
}

public function createRelations(Relations $relations)
{
$relations->belongsTo('environment', Environment::class);
Expand Down
11 changes: 11 additions & 0 deletions library/Icingadb/Model/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
use Icinga\Module\Icingadb\Model\Behavior\Timestamp;
Expand Down Expand Up @@ -91,6 +92,16 @@ public function createBehaviors(Behaviors $behaviors)
'hostgroup' => 'host.hostgroup',
'servicegroup' => 'service.servicegroup'
]));

$behaviors->add(new Binary([
'id',
'environment_id',
'host_id',
'service_id',
'name_checksum',
'properties_checksum',
'zone_id'
]));
}

public function createRelations(Relations $relations)
Expand Down
9 changes: 9 additions & 0 deletions library/Icingadb/Model/CommentHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use Icinga\Module\Icingadb\Model\Behavior\Timestamp;
use ipl\Orm\Behaviors;
Expand Down Expand Up @@ -83,6 +84,14 @@ public function createBehaviors(Behaviors $behaviors)
'expire_time',
'remove_time'
]));

$behaviors->add(new Binary([
'comment_id',
'environment_id',
'endpoint_id',
'host_id',
'service_id'
]));
}

public function createRelations(Relations $relations)
Expand Down
11 changes: 11 additions & 0 deletions library/Icingadb/Model/Customvar.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;

Expand Down Expand Up @@ -31,6 +33,15 @@ public function getColumns()
];
}

public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new Binary([
'id',
'environment_id',
'name_checksum'
]));
}

public function createRelations(Relations $relations)
{
$relations->belongsTo('environment', Environment::class);
Expand Down
18 changes: 13 additions & 5 deletions library/Icingadb/Model/CustomvarFlat.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use Icinga\Module\Icingadb\Model\Behavior\FlattenedObjectVars;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
Expand Down Expand Up @@ -33,6 +34,18 @@ public function getColumns()
];
}

public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new FlattenedObjectVars());

$behaviors->add(new Binary([
'id',
'environment_id',
'customvar_id',
'flatname_checksum'
]));
}

public function createRelations(Relations $relations)
{
$relations->belongsTo('environment', Environment::class);
Expand Down Expand Up @@ -73,11 +86,6 @@ public function createRelations(Relations $relations)
->setCandidateKey('customvar_id');
}

public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new FlattenedObjectVars());
}

/**
* Restore flattened custom variables to their previous structure
*
Expand Down
16 changes: 16 additions & 0 deletions library/Icingadb/Model/Downtime.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use Icinga\Module\Icingadb\Model\Behavior\IdKey;
use Icinga\Module\Icingadb\Model\Behavior\ReRoute;
Expand Down Expand Up @@ -95,10 +96,12 @@ public function getDefaultSort()
public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new IdKey());

$behaviors->add(new BoolCast([
'is_flexible',
'is_in_effect'
]));

$behaviors->add(new Timestamp([
'entry_time',
'scheduled_start_time',
Expand All @@ -109,10 +112,23 @@ public function createBehaviors(Behaviors $behaviors)
'end_time',
'duration'
]));

$behaviors->add(new ReRoute([
'hostgroup' => 'host.hostgroup',
'servicegroup' => 'service.servicegroup'
]));

$behaviors->add(new Binary([
'id',
'environment_id',
'triggered_by_id',
'parent_id',
'host_id',
'service_id',
'name_checksum',
'properties_checksum',
'zone_id'
]));
}

public function createRelations(Relations $relations)
Expand Down
11 changes: 11 additions & 0 deletions library/Icingadb/Model/DowntimeHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use Icinga\Module\Icingadb\Model\Behavior\BoolCast;
use Icinga\Module\Icingadb\Model\Behavior\Timestamp;
use ipl\Orm\Behaviors;
Expand Down Expand Up @@ -97,6 +98,16 @@ public function createBehaviors(Behaviors $behaviors)
'trigger_time',
'cancel_time'
]));

$behaviors->add(new Binary([
'downtime_id',
'environment_id',
'endpoint_id',
'triggered_by_id',
'parent_id',
'host_id',
'service_id'
]));
}

public function createRelations(Relations $relations)
Expand Down
13 changes: 13 additions & 0 deletions library/Icingadb/Model/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;

Expand Down Expand Up @@ -43,6 +45,17 @@ public function getMetaData()
];
}

public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new Binary([
'id',
'environment_id',
'name_checksum',
'properties_checksum',
'zone_id'
]));
}

public function createRelations(Relations $relations)
{
$relations->belongsTo('environment', Environment::class);
Expand Down
9 changes: 9 additions & 0 deletions library/Icingadb/Model/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Icinga\Module\Icingadb\Model;

use Icinga\Module\Icingadb\Model\Behavior\Binary;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Orm\Relations;

Expand Down Expand Up @@ -33,6 +35,13 @@ public function getMetaData()
];
}

public function createBehaviors(Behaviors $behaviors)
{
$behaviors->add(new Binary([
'id'
]));
}

public function createRelations(Relations $relations)
{
$relations->hasMany('acknowledgement_history', AcknowledgementHistory::class);
Expand Down
Loading

0 comments on commit ce10eb6

Please sign in to comment.