2 ** NetXMS - Network Management System
3 ** Copyright (C) 2003-2016 Victor Kirhenshtein
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 ** File: bizsvcroot.cpp
26 * Business service tree root class default constructor
28 BusinessServiceRoot::BusinessServiceRoot() : ServiceContainer()
30 m_id
= BUILTIN_OID_BUSINESSSERVICEROOT
;
31 _tcscpy(m_name
, _T("Business Services"));
32 m_guid
= uuid::generate();
33 m_status
= STATUS_NORMAL
;
37 * Business service root class destructor
39 BusinessServiceRoot::~BusinessServiceRoot()
44 * Save object to database
46 BOOL
BusinessServiceRoot::saveToDatabase(DB_HANDLE hdb
)
52 saveCommonProperties(hdb
);
54 // Update members list
55 _sntprintf(szQuery
, sizeof(szQuery
) / sizeof(TCHAR
), _T("DELETE FROM container_members WHERE container_id=%d"), m_id
);
56 DBQuery(hdb
, szQuery
);
58 for(int i
= 0; i
< m_childList
->size(); i
++)
60 _sntprintf(szQuery
, sizeof(szQuery
) / sizeof(TCHAR
), _T("INSERT INTO container_members (container_id,object_id) VALUES (%d,%d)"), m_id
, m_childList
->get(i
)->getId());
61 DBQuery(hdb
, szQuery
);
68 // Unlock object and clear modification flag
75 * Load properties from database
77 void BusinessServiceRoot::loadFromDatabase(DB_HANDLE hdb
)
79 loadCommonProperties(hdb
);
86 * This method is expected to be called only at startup, so we don't lock
88 void BusinessServiceRoot::linkChildObjects()
90 DB_HANDLE hdb
= DBConnectionPoolAcquireConnection();
93 _sntprintf(szQuery
, sizeof(szQuery
) / sizeof(TCHAR
), _T("SELECT object_id FROM container_members WHERE container_id=%d"), m_id
);
95 DB_RESULT hResult
= DBSelect(hdb
, szQuery
);
98 int count
= DBGetNumRows(hResult
);
99 for(int i
= 0; i
< count
; i
++)
101 UINT32 dwObjectId
= DBGetFieldULong(hResult
, i
, 0);
102 NetObj
*pObject
= FindObjectById(dwObjectId
);
106 nxlog_write(MSG_ROOT_INVALID_CHILD_ID
, EVENTLOG_WARNING_TYPE
, "ds", dwObjectId
, getObjectClassName());
108 DBFreeResult(hResult
);
110 DBConnectionPoolReleaseConnection(hdb
);