Move the ClearConfigTables function into the DbConnection class.

Refs #5565
This commit is contained in:
Gunnar Beutner 2014-01-28 11:09:13 +01:00
parent 6c724d2797
commit 3a23f0110b
6 changed files with 40 additions and 72 deletions

View File

@ -233,40 +233,6 @@ void IdoMysqlConnection::Reconnect(void)
UpdateAllObjects();
}
void IdoMysqlConnection::ClearConfigTables(void)
{
/* TODO make hardcoded table names modular */
ClearConfigTable("commands");
ClearConfigTable("comments");
ClearConfigTable("contact_addresses");
ClearConfigTable("contact_notificationcommands");
ClearConfigTable("contactgroup_members");
ClearConfigTable("contactgroups");
ClearConfigTable("contacts");
ClearConfigTable("contactstatus");
ClearConfigTable("customvariables");
ClearConfigTable("customvariablestatus");
ClearConfigTable("host_contactgroups");
ClearConfigTable("host_contacts");
ClearConfigTable("host_parenthosts");
ClearConfigTable("hostdependencies");
ClearConfigTable("hostgroup_members");
ClearConfigTable("hostgroups");
ClearConfigTable("hosts");
ClearConfigTable("hoststatus");
ClearConfigTable("programstatus");
ClearConfigTable("scheduleddowntime");
ClearConfigTable("service_contactgroups");
ClearConfigTable("service_contacts");
ClearConfigTable("servicedependencies");
ClearConfigTable("servicegroup_members");
ClearConfigTable("servicegroups");
ClearConfigTable("services");
ClearConfigTable("servicestatus");
ClearConfigTable("timeperiod_timeranges");
ClearConfigTable("timeperiods");
}
void IdoMysqlConnection::ClearConfigTable(const String& table)
{
Query("DELETE FROM " + GetTablePrefix() + table + " WHERE instance_id = " + Convert::ToString(static_cast<long>(m_InstanceID)));

View File

@ -83,8 +83,7 @@ private:
void InternalExecuteQuery(const DbQuery& query);
void InternalCleanUpExecuteQuery(const String& table, const String& time_key, double time_value);
void ClearConfigTables(void);
void ClearConfigTable(const String& table);
virtual void ClearConfigTable(const String& table);
void ExceptionHandler(boost::exception_ptr exp);
};

View File

@ -236,40 +236,6 @@ void IdoPgsqlConnection::Reconnect(void)
UpdateAllObjects();
}
void IdoPgsqlConnection::ClearConfigTables(void)
{
/* TODO make hardcoded table names modular */
ClearConfigTable("commands");
ClearConfigTable("comments");
ClearConfigTable("contact_addresses");
ClearConfigTable("contact_notificationcommands");
ClearConfigTable("contactgroup_members");
ClearConfigTable("contactgroups");
ClearConfigTable("contacts");
ClearConfigTable("contactstatus");
ClearConfigTable("customvariables");
ClearConfigTable("customvariablestatus");
ClearConfigTable("host_contactgroups");
ClearConfigTable("host_contacts");
ClearConfigTable("host_parenthosts");
ClearConfigTable("hostdependencies");
ClearConfigTable("hostgroup_members");
ClearConfigTable("hostgroups");
ClearConfigTable("hosts");
ClearConfigTable("hoststatus");
ClearConfigTable("programstatus");
ClearConfigTable("scheduleddowntime");
ClearConfigTable("service_contactgroups");
ClearConfigTable("service_contacts");
ClearConfigTable("servicedependencies");
ClearConfigTable("servicegroup_members");
ClearConfigTable("servicegroups");
ClearConfigTable("services");
ClearConfigTable("servicestatus");
ClearConfigTable("timeperiod_timeranges");
ClearConfigTable("timeperiods");
}
void IdoPgsqlConnection::ClearConfigTable(const String& table)
{
Query("DELETE FROM " + GetTablePrefix() + table + " WHERE instance_id = " + Convert::ToString(static_cast<long>(m_InstanceID)));

View File

@ -81,8 +81,7 @@ private:
void InternalExecuteQuery(const DbQuery& query);
void InternalCleanUpExecuteQuery(const String& table, const String& time_key, double time_value);
void ClearConfigTables(void);
void ClearConfigTable(const String& table);
virtual void ClearConfigTable(const String& table);
void ExceptionHandler(boost::exception_ptr exp);
};

View File

@ -292,3 +292,37 @@ void DbConnection::UpdateAllObjects(void)
}
}
}
void DbConnection::ClearConfigTables(void)
{
/* TODO make hardcoded table names modular */
ClearConfigTable("commands");
ClearConfigTable("comments");
ClearConfigTable("contact_addresses");
ClearConfigTable("contact_notificationcommands");
ClearConfigTable("contactgroup_members");
ClearConfigTable("contactgroups");
ClearConfigTable("contacts");
ClearConfigTable("contactstatus");
ClearConfigTable("customvariables");
ClearConfigTable("customvariablestatus");
ClearConfigTable("host_contactgroups");
ClearConfigTable("host_contacts");
ClearConfigTable("host_parenthosts");
ClearConfigTable("hostdependencies");
ClearConfigTable("hostgroup_members");
ClearConfigTable("hostgroups");
ClearConfigTable("hosts");
ClearConfigTable("hoststatus");
ClearConfigTable("programstatus");
ClearConfigTable("scheduleddowntime");
ClearConfigTable("service_contactgroups");
ClearConfigTable("service_contacts");
ClearConfigTable("servicedependencies");
ClearConfigTable("servicegroup_members");
ClearConfigTable("servicegroups");
ClearConfigTable("services");
ClearConfigTable("servicestatus");
ClearConfigTable("timeperiod_timeranges");
ClearConfigTable("timeperiods");
}

View File

@ -72,6 +72,8 @@ protected:
void UpdateAllObjects(void);
void ClearConfigTables(void);
private:
std::map<DbObject::Ptr, DbReference> m_ObjectIDs;
std::map<DbObject::Ptr, DbReference> m_InsertIDs;
@ -83,6 +85,8 @@ private:
void CleanUpHandler(void);
virtual void ClearConfigTable(const String& table) = 0;
static Timer::Ptr m_ProgramStatusTimer;
static void InsertRuntimeVariable(const String& key, const Value& value);