From 4f3596fcafee420f97597140698443af685f22f8 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Fri, 6 Jun 2014 07:09:15 +0000 Subject: [PATCH] Monitoring\Object: fit new Query classes refs #6418 --- .../Monitoring/Object/AbstractObject.php | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Object/AbstractObject.php b/modules/monitoring/library/Monitoring/Object/AbstractObject.php index de01845a4..b20c6495b 100644 --- a/modules/monitoring/library/Monitoring/Object/AbstractObject.php +++ b/modules/monitoring/library/Monitoring/Object/AbstractObject.php @@ -57,14 +57,14 @@ abstract class AbstractObject 'author' => 'comment_author', 'comment' => 'comment_data', 'type' => 'comment_type', - ))->getQuery(); + )); $query->where('comment_type', array('comment', 'ack')); $query->where('comment_objecttype', $this->type); $query->where('comment_host', $this->host_name); if ($this->type === 'service') { $query->where('comment_service', $this->service_description); } - $this->comments = $query->fetchAll(); + $this->comments = $query->getQuery()->fetchAll(); return $this; } @@ -88,7 +88,7 @@ abstract class AbstractObject 'entry_time' => 'downtime_entry_time', 'host' => 'downtime_host', 'service' => 'downtime_service' - ))->getQuery(); + )); $query->where('downtime_objecttype', $this->type); $query->where('downtime_host', $this->host_name); @@ -97,7 +97,7 @@ abstract class AbstractObject } $query->order('downtime_is_in_effect', 'DESC')->order('downtime_scheduled_start', 'ASC'); - $this->downtimes = $query->fetchAll(); + $this->downtimes = $query->getQuery()->fetchAll(); return $this; $this->downtimes = Downtime::fromRequest($this->request)->getQuery()->fetchAll(); @@ -106,15 +106,12 @@ abstract class AbstractObject public function fetchHostgroups() { - $query = Hostgroup::fromRequest( - $this->request, - array( - 'hostgroup_name', - 'hostgroup_alias' - ) - )->getQuery(); + $query = HostGroup::fromParams(array('backend' => null), array( + 'hostgroup_name', + 'hostgroup_alias' + ))->where('host_name', $this->host_name); - $this->hostgroups = $query->fetchPairs(); + $this->hostgroups = $query->getQuery()->fetchPairs(); return $this; } @@ -126,7 +123,7 @@ abstract class AbstractObject 'varname', 'varvalue' ) - )->getQuery(); + ); if ($this->type === 'host') { $query->where('host_name', $this->host_name) @@ -137,7 +134,7 @@ abstract class AbstractObject ->where('service_description', $this->service_description); } - $this->customvars = $query->fetchPairs(); + $this->customvars = $query->getQuery()->fetchPairs(); return $this; } @@ -161,7 +158,7 @@ abstract class AbstractObject 'contact_alias', 'contact_email', 'contact_pager', - ))->getQuery(); + )); if ($this->type === 'service') { $query->where('service_host_name', $this->host_name); @@ -170,7 +167,7 @@ abstract class AbstractObject $query->where('host_name', $this->host_name); } - $this->contacts = $query->fetchAll(); + $this->contacts = $query->getQuery()->fetchAll(); return $this; } @@ -182,9 +179,9 @@ abstract class AbstractObject 'servicegroup_name', 'servicegroup_alias', ) - )->getQuery(); + ); - $this->servicegroups = $query->fetchPairs(); + $this->servicegroups = $query->getQuery()->fetchPairs(); return $this; } @@ -194,7 +191,7 @@ abstract class AbstractObject $query = Contactgroup::fromParams(array('backend' => null), array( 'contactgroup_name', 'contactgroup_alias' - ))->getQuery(); + )); if ($this->type === 'service') { $query->where('service_host_name', $this->host_name); @@ -211,16 +208,14 @@ abstract class AbstractObject ) )->getQuery(); */ - $this->contactgroups = $query->fetchAll(); + $this->contactgroups = $query->getQuery()->fetchAll(); return $this; } public function fetchEventHistory() { - $query = EventHistory::fromRequest( - $this->request, - array( + $query = EventHistory::fromParams(array('backend' => null), array( 'object_type', 'host_name', 'service_description', @@ -231,9 +226,15 @@ abstract class AbstractObject 'output', 'type' ) - )->sort('raw_timestamp', 'DESC')->getQuery(); + )->sort('raw_timestamp', 'DESC'); + if ($this->type === 'service') { + $query->where('service_host_name', $this->host_name); + $query->where('service_description', $this->service_description); + } else { + $query->where('host_name', $this->host_name); + } - $this->eventhistory = $query; + $this->eventhistory = $query->getQuery(); return $this; }