Fix missing insert IDs for service and contact groups.

This commit is contained in:
Gunnar Beutner 2013-08-05 16:04:01 +02:00
parent 17f1b98575
commit ddc8a9cd7e
4 changed files with 20 additions and 10 deletions

View File

@ -20,7 +20,6 @@
#include "ido/servicegroupdbobject.h"
#include "ido/dbtype.h"
#include "ido/dbvalue.h"
#include "icinga/servicegroup.h"
#include "base/objectlock.h"
#include "base/initialize.h"
#include <boost/foreach.hpp>
@ -36,7 +35,7 @@ ServiceGroupDbObject::ServiceGroupDbObject(const DbType::Ptr& type, const String
void ServiceGroupDbObject::StaticInitialize(void)
{
ServiceGroup::OnMembersChanged.connect(&ServiceGroupDbObject::MembersChangedHandler);
ServiceGroup::OnMembersChanged.connect(boost::bind(&ServiceGroupDbObject::MembersChangedHandler, ServiceGroup::Ptr()));
}
Dictionary::Ptr ServiceGroupDbObject::GetConfigFields(void) const
@ -56,10 +55,12 @@ Dictionary::Ptr ServiceGroupDbObject::GetStatusFields(void) const
void ServiceGroupDbObject::OnConfigUpdate(void)
{
MembersChangedHandler();
ServiceGroup::Ptr group = static_pointer_cast<ServiceGroup>(GetObject());
MembersChangedHandler(group);
}
void ServiceGroupDbObject::MembersChangedHandler(void)
void ServiceGroupDbObject::MembersChangedHandler(const ServiceGroup::Ptr& sgfilter)
{
DbQuery query1;
query1.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
@ -71,6 +72,9 @@ void ServiceGroupDbObject::MembersChangedHandler(void)
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("ServiceGroup")) {
ServiceGroup::Ptr sg = static_pointer_cast<ServiceGroup>(object);
if (sgfilter && sgfilter != sg)
continue;
BOOST_FOREACH(const Service::Ptr& service, sg->GetMembers()) {
DbQuery query2;
query2.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";

View File

@ -21,6 +21,7 @@
#define SERVICEGROUPDBOBJECT_H
#include "ido/dbobject.h"
#include "icinga/servicegroup.h"
#include "base/dynamicobject.h"
namespace icinga
@ -47,7 +48,7 @@ protected:
virtual void OnConfigUpdate(void);
private:
static void MembersChangedHandler(void);
static void MembersChangedHandler(const ServiceGroup::Ptr& sgfilter);
};
}

View File

@ -20,7 +20,6 @@
#include "ido/usergroupdbobject.h"
#include "ido/dbtype.h"
#include "ido/dbvalue.h"
#include "icinga/usergroup.h"
#include "base/objectlock.h"
#include "base/initialize.h"
#include "base/dynamictype.h"
@ -37,7 +36,7 @@ UserGroupDbObject::UserGroupDbObject(const DbType::Ptr& type, const String& name
void UserGroupDbObject::StaticInitialize(void)
{
UserGroup::OnMembersChanged.connect(&UserGroupDbObject::MembersChangedHandler);
UserGroup::OnMembersChanged.connect(boost::bind(&UserGroupDbObject::MembersChangedHandler, UserGroup::Ptr()));
}
Dictionary::Ptr UserGroupDbObject::GetConfigFields(void) const
@ -57,10 +56,12 @@ Dictionary::Ptr UserGroupDbObject::GetStatusFields(void) const
void UserGroupDbObject::OnConfigUpdate(void)
{
MembersChangedHandler();
UserGroup::Ptr group = static_pointer_cast<UserGroup>(GetObject());
MembersChangedHandler(group);
}
void UserGroupDbObject::MembersChangedHandler(void)
void UserGroupDbObject::MembersChangedHandler(const UserGroup::Ptr& ugfilter)
{
DbQuery query1;
query1.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";
@ -72,6 +73,9 @@ void UserGroupDbObject::MembersChangedHandler(void)
BOOST_FOREACH(const DynamicObject::Ptr& object, DynamicType::GetObjects("UserGroup")) {
UserGroup::Ptr ug = static_pointer_cast<UserGroup>(object);
if (ugfilter && ugfilter != ug)
continue;
BOOST_FOREACH(const User::Ptr& user, ug->GetMembers()) {
DbQuery query2;
query2.Table = DbType::GetByName("UserGroup")->GetTable() + "_members";

View File

@ -21,6 +21,7 @@
#define USERGROUPDBOBJECT_H
#include "ido/dbobject.h"
#include "icinga/usergroup.h"
#include "base/dynamicobject.h"
namespace icinga
@ -47,7 +48,7 @@ protected:
virtual void OnConfigUpdate(void);
private:
static void MembersChangedHandler(void);
static void MembersChangedHandler(const UserGroup::Ptr& ugfilter);
};
}