Monitoring\Object: fit new Query classes

refs #6418
This commit is contained in:
Thomas Gelf 2014-06-06 07:09:15 +00:00
parent c77e178bc7
commit 4f3596fcaf
1 changed files with 26 additions and 25 deletions

View File

@ -57,14 +57,14 @@ abstract class AbstractObject
'author' => 'comment_author', 'author' => 'comment_author',
'comment' => 'comment_data', 'comment' => 'comment_data',
'type' => 'comment_type', 'type' => 'comment_type',
))->getQuery(); ));
$query->where('comment_type', array('comment', 'ack')); $query->where('comment_type', array('comment', 'ack'));
$query->where('comment_objecttype', $this->type); $query->where('comment_objecttype', $this->type);
$query->where('comment_host', $this->host_name); $query->where('comment_host', $this->host_name);
if ($this->type === 'service') { if ($this->type === 'service') {
$query->where('comment_service', $this->service_description); $query->where('comment_service', $this->service_description);
} }
$this->comments = $query->fetchAll(); $this->comments = $query->getQuery()->fetchAll();
return $this; return $this;
} }
@ -88,7 +88,7 @@ abstract class AbstractObject
'entry_time' => 'downtime_entry_time', 'entry_time' => 'downtime_entry_time',
'host' => 'downtime_host', 'host' => 'downtime_host',
'service' => 'downtime_service' 'service' => 'downtime_service'
))->getQuery(); ));
$query->where('downtime_objecttype', $this->type); $query->where('downtime_objecttype', $this->type);
$query->where('downtime_host', $this->host_name); $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'); $query->order('downtime_is_in_effect', 'DESC')->order('downtime_scheduled_start', 'ASC');
$this->downtimes = $query->fetchAll(); $this->downtimes = $query->getQuery()->fetchAll();
return $this; return $this;
$this->downtimes = Downtime::fromRequest($this->request)->getQuery()->fetchAll(); $this->downtimes = Downtime::fromRequest($this->request)->getQuery()->fetchAll();
@ -106,15 +106,12 @@ abstract class AbstractObject
public function fetchHostgroups() public function fetchHostgroups()
{ {
$query = Hostgroup::fromRequest( $query = HostGroup::fromParams(array('backend' => null), array(
$this->request, 'hostgroup_name',
array( 'hostgroup_alias'
'hostgroup_name', ))->where('host_name', $this->host_name);
'hostgroup_alias'
)
)->getQuery();
$this->hostgroups = $query->fetchPairs(); $this->hostgroups = $query->getQuery()->fetchPairs();
return $this; return $this;
} }
@ -126,7 +123,7 @@ abstract class AbstractObject
'varname', 'varname',
'varvalue' 'varvalue'
) )
)->getQuery(); );
if ($this->type === 'host') { if ($this->type === 'host') {
$query->where('host_name', $this->host_name) $query->where('host_name', $this->host_name)
@ -137,7 +134,7 @@ abstract class AbstractObject
->where('service_description', $this->service_description); ->where('service_description', $this->service_description);
} }
$this->customvars = $query->fetchPairs(); $this->customvars = $query->getQuery()->fetchPairs();
return $this; return $this;
} }
@ -161,7 +158,7 @@ abstract class AbstractObject
'contact_alias', 'contact_alias',
'contact_email', 'contact_email',
'contact_pager', 'contact_pager',
))->getQuery(); ));
if ($this->type === 'service') { if ($this->type === 'service') {
$query->where('service_host_name', $this->host_name); $query->where('service_host_name', $this->host_name);
@ -170,7 +167,7 @@ abstract class AbstractObject
$query->where('host_name', $this->host_name); $query->where('host_name', $this->host_name);
} }
$this->contacts = $query->fetchAll(); $this->contacts = $query->getQuery()->fetchAll();
return $this; return $this;
} }
@ -182,9 +179,9 @@ abstract class AbstractObject
'servicegroup_name', 'servicegroup_name',
'servicegroup_alias', 'servicegroup_alias',
) )
)->getQuery(); );
$this->servicegroups = $query->fetchPairs(); $this->servicegroups = $query->getQuery()->fetchPairs();
return $this; return $this;
} }
@ -194,7 +191,7 @@ abstract class AbstractObject
$query = Contactgroup::fromParams(array('backend' => null), array( $query = Contactgroup::fromParams(array('backend' => null), array(
'contactgroup_name', 'contactgroup_name',
'contactgroup_alias' 'contactgroup_alias'
))->getQuery(); ));
if ($this->type === 'service') { if ($this->type === 'service') {
$query->where('service_host_name', $this->host_name); $query->where('service_host_name', $this->host_name);
@ -211,16 +208,14 @@ abstract class AbstractObject
) )
)->getQuery(); )->getQuery();
*/ */
$this->contactgroups = $query->fetchAll(); $this->contactgroups = $query->getQuery()->fetchAll();
return $this; return $this;
} }
public function fetchEventHistory() public function fetchEventHistory()
{ {
$query = EventHistory::fromRequest( $query = EventHistory::fromParams(array('backend' => null), array(
$this->request,
array(
'object_type', 'object_type',
'host_name', 'host_name',
'service_description', 'service_description',
@ -231,9 +226,15 @@ abstract class AbstractObject
'output', 'output',
'type' '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; return $this;
} }