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',
'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;
}