MCPcopy Create free account
hub / github.com/Icinga/icinga2 / InternalActivateObject

Method InternalActivateObject

lib/db_ido_pgsql/idopgsqlconnection.cpp:604–633  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

602}
603
604void IdoPgsqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj)
605{
606 AssertOnWorkQueue();
607
608 if (!GetConnected())
609 return;
610
611 DbReference dbref = GetObjectID(dbobj);
612 std::ostringstream qbuf;
613
614 if (!dbref.IsValid()) {
615 if (!dbobj->GetName2().IsEmpty()) {
616 qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES ("
617 << static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
618 << "'" << Escape(dbobj->GetName1()) << "', '" << Escape(dbobj->GetName2()) << "', 1)";
619 } else {
620 qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, is_active) VALUES ("
621 << static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", "
622 << "'" << Escape(dbobj->GetName1()) << "', 1)";
623 }
624
625 IncreasePendingQueries(1);
626 Query(qbuf.str());
627 SetObjectID(dbobj, GetSequenceValue(GetTablePrefix() + "objects", "object_id"));
628 } else {
629 qbuf << "UPDATE " + GetTablePrefix() + "objects SET is_active = 1 WHERE object_id = " << static_cast<long>(dbref);
630 IncreasePendingQueries(1);
631 Query(qbuf.str());
632 }
633}
634
635void IdoPgsqlConnection::DeactivateObject(const DbObject::Ptr& dbobj)
636{

Callers

nothing calls this directly

Calls 6

IsValidMethod · 0.80
GetName2Method · 0.80
GetTypeIDMethod · 0.80
GetName1Method · 0.80
IsEmptyMethod · 0.45
GetTypeMethod · 0.45

Tested by

no test coverage detected