old map tables removed; added field "submapId" to all objects
authorVictor Kirhenshtein <victor@netxms.org>
Wed, 8 Jun 2011 16:12:22 +0000 (16:12 +0000)
committerVictor Kirhenshtein <victor@netxms.org>
Wed, 8 Jun 2011 16:12:22 +0000 (16:12 +0000)
22 files changed:
doc/internal/db_format_change.txt
include/netxmsdb.h
include/nms_cscp.h
sql/Makefile.am
sql/Makefile.msvc.w32
sql/Makefile.w32
sql/dbinit.in
sql/maps.in [deleted file]
sql/schema.in
src/java/netxms-base/src/main/java/org/netxms/base/NXCPCodes.java
src/java/netxms-client/src/main/java/org/netxms/client/objects/GenericObject.java
src/server/core/Makefile.am
src/server/core/main.cpp
src/server/core/map.cpp [deleted file]
src/server/core/netobj.cpp
src/server/core/nxcore.vcproj
src/server/core/session.cpp
src/server/include/Makefile.am
src/server/include/nms_core.h
src/server/include/nms_objects.h
src/server/include/nxcore_maps.h [deleted file]
src/server/tools/nxdbmgr/upgrade.cpp

index a77b21b..3af3d1b 100644 (file)
@@ -1,4 +1,37 @@
 ***************
+* 231 ==> 232 *
+***************
+
+- Field "submap_id" added to table "object_properties"
+- Tables "maps", "map_access_lists", "submaps", "submap_object_positions", "submap_links" dropped
+
+
+***************
+* 230 ==> 231 *
+***************
+
+- Field "bridge_base_addr" added to table "nodes"
+
+
+***************
+* 229 ==> 230 *
+***************
+
+- Fields "bg_latitude", "bg_longitude", "bg_zoom" added to table "network_maps"
+- Fields "horizontal_span", "vertical_span", "horizontal_alignment", "vertical_alignment"
+  removed from table "dashboard_elements"
+- Field "layout_data" added to table "dashboard_elements"
+- Dashboards layout infornmation converted to XML and stored in single comlumn
+
+
+***************
+* 228 ==> 229 *
+***************
+
+- Added tables "dashboards" and "dashboard_elements"
+
+
+***************
 * 227 ==> 228 *
 ***************
 
index 7d8d7d2..fb0889f 100644 (file)
@@ -23,6 +23,6 @@
 #ifndef _netxmsdb_h
 #define _netxmsdb_h
 
-#define DB_FORMAT_VERSION   231
+#define DB_FORMAT_VERSION   232
 
 #endif
index d1926e3..bf5efe1 100644 (file)
@@ -867,6 +867,7 @@ typedef struct
 #define VID_BACKGROUND_LONGITUDE    ((DWORD)386)
 #define VID_BACKGROUND_ZOOM         ((DWORD)387)
 #define VID_BRIDGE_BASE_ADDRESS     ((DWORD)388)
+#define VID_SUBMAP_ID               ((DWORD)389)
 
 // Map elements list base
 #define VID_ELEMENT_LIST_BASE       ((DWORD)0x10000000)
index c2fade0..5413afe 100644 (file)
@@ -18,7 +18,7 @@ sql_DATA = dbinit_mysql.sql \
            dbschema_db2.sql
 
 ROOT_FILE = dbinit.in
-SOURCE = $(ROOT_FILE) database.in schema.in metadata.in setup.in events.in policy.in objtools.in scripts.in maps.in images.in
+SOURCE = $(ROOT_FILE) database.in schema.in metadata.in setup.in events.in policy.in objtools.in scripts.in images.in
 HEADER_FILES = ../include/netxmsdb.h ../include/nxevent.h ../src/server/include/nms_locks.h
 COMMAND = $(CPP) -x c -P -Wundef -D_NETXMS_DB_SCHEMA_ -I@top_srcdir@/include -I@top_srcdir@/src/server/include
 SQUEEZE = perl -n -e "if (! /^[\s\t\n]*$$/) { print; }"
index 55c3fde..e9af4fd 100644 (file)
@@ -7,7 +7,7 @@ CPP = cl
 sql_SCRIPTS = dbinit_mysql.sql dbinit_pgsql.sql dbinit_mssql.sql dbinit_oracle.sql dbinit_sqlite.sql
 
 ROOT_FILE = dbinit.in
-SOURCE = $(ROOT_FILE) database.in schema.in setup.in events.in policy.in objtools.in scripts.in maps.in images.in
+SOURCE = $(ROOT_FILE) database.in schema.in setup.in events.in policy.in objtools.in scripts.in images.in
 HEADERS = ../include/netxmsdb.h ../include/nxevent.h ../src/server/include/nms_locks.h
 COMMAND = $(CPP) /EP /D_NETXMS_DB_SCHEMA_ /I../include /I../src/server/include
 #SQUEEZE = perl -e "while (<>) { if (! /^[\s\t\n]*$$/) { print; } }"
index 79a3534..b69e943 100644 (file)
@@ -16,7 +16,7 @@ sql_SCRIPTS = dbinit_mysql.sql \
               dbschema_sqlite.sql
 
 ROOT_FILE = dbinit.in
-SOURCE = $(ROOT_FILE) database.in schema.in metadata.in setup.in events.in maps.in policy.in objtools.in scripts.in maps.in images.in
+SOURCE = $(ROOT_FILE) database.in schema.in metadata.in setup.in events.in policy.in objtools.in scripts.in images.in
 HEADERS = ../include/netxmsdb.h ../include/nxevent.h ../src/server/include/nms_locks.h
 COMMAND = $(CPP) -P -Wundef -D_NETXMS_DB_SCHEMA_ -I../include -I../src/server/include
 SQUEEZE = perl -e "while (<>) { if (! /^[\s\t\n]*$$/) { print; } }"
index 4850932..c0cd0c7 100644 (file)
@@ -31,7 +31,6 @@ BEGIN TRANSACTION;
 #include "traps.in"
 #include "objtools.in"
 #include "scripts.in"
-#include "maps.in"
 #include "images.in"
 #endif
 
diff --git a/sql/maps.in b/sql/maps.in
deleted file mode 100644 (file)
index bda6658..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/*
-** Default network maps
-** ex: syntax=sql
-*/
-
-INSERT INTO maps (map_id,map_name,description,root_object_id)
-       VALUES (1,'Default','Default network map',1);
-INSERT INTO map_access_lists (map_id,user_id,access_rights) VALUES (1,-2147483648,1);
index 17bcd59..78ef76d 100644 (file)
@@ -156,6 +156,7 @@ CREATE TABLE object_properties
        latitude varchar(20),
        longitude varchar(20),
        image varchar(36) not null,
+       submap_id integer not null,
        PRIMARY KEY(object_id)
 ) TABLE_TYPE;
 
@@ -963,78 +964,6 @@ CREATE INDEX idx_snmp_trap_log_tt ON snmp_trap_log(trap_timestamp);
 
 
 /*
-** Network maps
-*/
-
-CREATE TABLE maps
-(
-       map_id integer not null,
-       map_name varchar(255) not null,
-       description SQL_TEXT not null,
-       root_object_id integer not null,
-       PRIMARY KEY(map_id)
-) TABLE_TYPE;
-
-
-/*
-** Map ACLs
-*/
-
-CREATE TABLE map_access_lists
-(
-       map_id integer not null,
-       user_id integer not null,
-       access_rights integer not null,
-       PRIMARY KEY(map_id,user_id)
-) TABLE_TYPE;
-
-
-/*
-** Submaps of network maps
-*/
-
-CREATE TABLE submaps
-(
-       map_id integer not null,
-       submap_id integer not null,     // Equal to object id
-       attributes integer not null,    
-       PRIMARY KEY(map_id,submap_id)
-) TABLE_TYPE;
-
-
-/*
-** Object positioning on submap
-*/
-
-CREATE TABLE submap_object_positions
-(
-       map_id integer not null,
-       submap_id integer not null,
-       object_id integer not null,
-       x integer not null,
-       y integer not null,
-       PRIMARY KEY(map_id,submap_id,object_id)
-) TABLE_TYPE;
-
-
-/*
-** Object links on submap
-*/
-
-CREATE TABLE submap_links
-(
-       map_id integer not null,
-       submap_id integer not null,
-       object_id1 integer not null,
-       object_id2 integer not null,
-       link_type integer not null,
-       port1 varchar(255) not null,
-       port2 varchar(255) not null,
-       PRIMARY KEY(map_id,submap_id,object_id1,object_id2)
-) TABLE_TYPE;
-
-
-/*
 ** Agent configurations
 */
 
index 3eb2a01..2a1b6e8 100644 (file)
@@ -671,6 +671,7 @@ public final class NXCPCodes
        public static final long VID_BACKGROUND_LONGITUDE    = 386;\r
        public static final long VID_BACKGROUND_ZOOM         = 387;\r
        public static final long VID_BRIDGE_BASE_ADDRESS     = 388;\r
+       public static final long VID_SUBMAP_ID               = 389;\r
 \r
        public static final long VID_ACL_USER_BASE            = 0x00001000L;\r
        public static final long VID_ACL_USER_LAST            = 0x00001FFFL;\r
index fa9f966..5e1e14f 100644 (file)
@@ -88,6 +88,7 @@ public class GenericObject
        private String comments;
        private GeoLocation geolocation;
        private UUID image;
+       private long submapId;
        private HashSet<Long> parents = new HashSet<Long>(0);
        private HashSet<Long> childs = new HashSet<Long>(0);
        private HashSet<Long> trustedNodes = new HashSet<Long>(0);
@@ -143,6 +144,7 @@ public class GenericObject
                comments = msg.getVariableAsString(NXCPCodes.VID_COMMENTS);
                geolocation = new GeoLocation(msg);
                image = msg.getVariableAsUUID(NXCPCodes.VID_IMAGE);
+               submapId = msg.getVariableAsInt64(NXCPCodes.VID_SUBMAP_ID);
                if (image == null)
                        image = NXCommon.EMPTY_GUID;
                
@@ -518,4 +520,12 @@ public class GenericObject
        {
                return image;
        }
+
+       /**
+        * @return the submapId
+        */
+       public long getSubmapId()
+       {
+               return submapId;
+       }
 }
index b9e63ed..f6a580a 100644 (file)
@@ -13,7 +13,7 @@ libnxcore_la_SOURCES = acl.cpp agent.cpp agent_policy.cpp actions.cpp \
                        events.cpp evproc.cpp fdb.cpp hk.cpp id.cpp import.cpp \
                        index.cpp interface.cpp isc.cpp job.cpp jobmgr.cpp jobqueue.cpp \
                        layer2.cpp lln.cpp lldp.cpp locks.cpp logfilter.cpp \
-                       loghandle.cpp logs.cpp main.cpp map.cpp modules.cpp \
+                       loghandle.cpp logs.cpp main.cpp modules.cpp \
                        ndd.cpp ndp.cpp netinfo.cpp netmap.cpp netobj.cpp \
                        netsrv.cpp node.cpp np.cpp nxsl_classes.cpp nxslext.cpp \
                        objects.cpp objtools.cpp package.cpp poll.cpp \
index 934626b..8c15cdb 100644 (file)
@@ -677,7 +677,6 @@ retry_db_lock:
        ObjectsInit();
        if (!LoadObjects())
                return FALSE;
-       LoadMaps();
        DbgPrintf(1, _T("Objects loaded and initialized"));
        
        // Initialize situations
diff --git a/src/server/core/map.cpp b/src/server/core/map.cpp
deleted file mode 100644 (file)
index e9eea41..0000000
+++ /dev/null
@@ -1,681 +0,0 @@
-/* 
-** NetXMS - Network Management System
-** Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Victor Kirhenshtein
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** File: map.cpp
-**
-**/
-
-#include "nxcore.h"
-
-
-//
-// Static data
-//
-
-static DWORD m_dwNumMaps = 0;
-static nxMapSrv **m_ppMapList = NULL;
-static MUTEX m_mutexMapList = INVALID_MUTEX_HANDLE;
-
-
-//
-// Submap creation function for ...Srv classes
-//
-
-static nxSubmap *CreateSubmapSrv(DWORD dwObjectId, nxMap *pMap)
-{
-   return new nxSubmapSrv(dwObjectId, pMap->MapId());
-}
-
-
-//
-// Constructor for new empty nxSubmapSrv object
-//
-
-nxSubmapSrv::nxSubmapSrv(DWORD dwObjectId, DWORD dwMapId)
-            :nxSubmap(dwObjectId)
-{
-   m_dwMapId = dwMapId;
-}
-
-
-//
-// Constructor for creating submap object from database
-// Expected field order:
-//     submap_id,attributes
-//
-
-nxSubmapSrv::nxSubmapSrv(DB_RESULT hData, int nRow, DWORD dwMapId)
-{
-   DB_RESULT hResult;
-   DWORD i;
-   TCHAR szQuery[1024];
-
-   CommonInit();
-   m_dwMapId = dwMapId;
-   m_dwId = DBGetFieldULong(hData, nRow, 0);
-   m_dwAttr = DBGetFieldULong(hData, nRow, 1);
-   
-   // Load object positions
-   _sntprintf(szQuery, 1024, _T("SELECT object_id,x,y FROM submap_object_positions WHERE map_id=%d AND submap_id=%d"),
-              m_dwMapId, m_dwId);
-   hResult = DBSelect(g_hCoreDB, szQuery);
-   if (hResult != NULL)
-   {
-      m_dwNumObjects = DBGetNumRows(hResult);
-      if (m_dwNumObjects > 0)
-      {
-         m_pObjectList = (MAP_OBJECT *)malloc(sizeof(MAP_OBJECT) * m_dwNumObjects);
-         for(i = 0; i < m_dwNumObjects; i++)
-         {
-            m_pObjectList[i].dwId = DBGetFieldULong(hResult, i, 0);
-            m_pObjectList[i].x = DBGetFieldLong(hResult, i, 1);
-            m_pObjectList[i].y = DBGetFieldLong(hResult, i, 2);
-            m_pObjectList[i].dwState = 0;
-         }
-      }
-      DBFreeResult(hResult);
-   }
-
-   // Load links between objects
-   _sntprintf(szQuery, 1024, _T("SELECT object_id1,object_id2,link_type,port1,port2 FROM submap_links WHERE map_id=%d AND submap_id=%d"),
-              m_dwMapId, m_dwId);
-   hResult = DBSelect(g_hCoreDB, szQuery);
-   if (hResult != NULL)
-   {
-      m_dwNumLinks = DBGetNumRows(hResult);
-      if (m_dwNumLinks > 0)
-      {
-         m_pLinkList = (OBJLINK *)malloc(sizeof(OBJLINK) * m_dwNumLinks);
-         for(i = 0; i < m_dwNumLinks; i++)
-         {
-            m_pLinkList[i].dwId1 = DBGetFieldULong(hResult, i, 0);
-            m_pLinkList[i].dwId2 = DBGetFieldULong(hResult, i, 1);
-            m_pLinkList[i].nType = DBGetFieldLong(hResult, i, 2);
-                               DBGetField(hResult, i, 3, m_pLinkList[i].szPort1, MAX_CONNECTOR_NAME);
-                               DecodeSQLString(m_pLinkList[i].szPort1);
-                               DBGetField(hResult, i, 4, m_pLinkList[i].szPort2, MAX_CONNECTOR_NAME);
-                               DecodeSQLString(m_pLinkList[i].szPort2);
-         }
-      }
-      DBFreeResult(hResult);
-   }
-}
-
-
-//
-// Save submap to database
-// Will return appropriate RCC, ready for sending to client
-// Intended to be called only from nxMapSrv::SaveToDB()
-//
-
-DWORD nxSubmapSrv::SaveToDB(void)
-{
-   TCHAR szQuery[2048], *pszEscPort1, *pszEscPort2;
-   DB_RESULT hResult;
-   BOOL bExist;
-   DWORD i, dwResult = RCC_DB_FAILURE;
-
-   // Check if submap record exist in database
-   _sntprintf(szQuery, 256, _T("SELECT submap_id FROM submaps WHERE map_id=%d AND submap_id=%d"),
-              m_dwMapId, m_dwId);
-   hResult = DBSelect(g_hCoreDB, szQuery);
-   if (hResult == NULL)
-      goto exit_save;
-
-   bExist = (DBGetNumRows(hResult) > 0);
-   DBFreeResult(hResult);
-
-   if (bExist)
-   {
-      _sntprintf(szQuery, 256, _T("UPDATE submaps SET attributes=%d WHERE map_id=%d AND submap_id=%d"),
-                 m_dwAttr, m_dwMapId, m_dwId);
-   }
-   else
-   {
-      _sntprintf(szQuery, 256, _T("INSERT INTO submaps (map_id,submap_id,attributes) VALUES (%d,%d,%d)"),
-                 m_dwMapId, m_dwId, m_dwAttr);
-   }
-   if (!DBQuery(g_hCoreDB, szQuery))
-      goto exit_save;
-
-   // Save object positions
-   // INSERT is used because old records was deleted by nxMapSrv::SaveToDB()
-   for(i = 0; i < m_dwNumObjects; i++)
-   {
-      _sntprintf(szQuery, 256, _T("INSERT INTO submap_object_positions (map_id,submap_id,object_id,x,y) VALUES (%d,%d,%d,%d,%d)"),
-                 m_dwMapId, m_dwId, m_pObjectList[i].dwId, m_pObjectList[i].x,
-                 m_pObjectList[i].y);
-      if (!DBQuery(g_hCoreDB, szQuery))
-         goto exit_save;
-   }
-
-   // Save links between objects
-   // INSERT is used because old records was deleted by nxMapSrv::SaveToDB()
-   for(i = 0; i < m_dwNumLinks; i++)
-   {
-               pszEscPort1 = EncodeSQLString(m_pLinkList[i].szPort1);
-               pszEscPort2 = EncodeSQLString(m_pLinkList[i].szPort2);
-      _sntprintf(szQuery, 2048, _T("INSERT INTO submap_links (map_id,submap_id,object_id1,object_id2,link_type,port1,port2) VALUES (%d,%d,%d,%d,%d,'%s','%s')"),
-                 m_dwMapId, m_dwId, m_pLinkList[i].dwId1, m_pLinkList[i].dwId2,
-                 m_pLinkList[i].nType, pszEscPort1, pszEscPort2);
-               free(pszEscPort1);
-               free(pszEscPort2);
-      if (!DBQuery(g_hCoreDB, szQuery))
-         goto exit_save;
-   }
-
-   dwResult = RCC_SUCCESS;
-
-exit_save:
-   return dwResult;
-}
-
-
-//
-// Delete submap from database
-//
-
-BOOL nxSubmapSrv::DeleteFromDB()
-{
-       TCHAR query[256];
-       BOOL success;
-
-       _sntprintf(query, 256, _T("DELETE FROM submaps WHERE map_id=%d AND submap_id=%d"), m_dwMapId, m_dwId);
-       success = DBQuery(g_hCoreDB, query);
-
-       if (success)
-       {
-               _sntprintf(query, 256, _T("DELETE FROM submap_object_positions WHERE map_id=%d AND submap_id=%d"), m_dwMapId, m_dwId);
-               success = DBQuery(g_hCoreDB, query);
-       }
-
-       if (success)
-       {
-               _sntprintf(query, 256, _T("DELETE FROM submap_links WHERE map_id=%d AND submap_id=%d"), m_dwMapId, m_dwId);
-               success = DBQuery(g_hCoreDB, query);
-       }
-
-       return success;
-}
-
-
-//
-// Constructor for creating map object from scratch
-//
-
-nxMapSrv::nxMapSrv(DWORD dwMapId, DWORD dwObjectId, const TCHAR *pszName, const TCHAR *pszDescription)
-         : nxMap(dwMapId, dwObjectId, pszName, pszDescription)
-{
-       m_nRefCount = 0;
-       m_pfCreateSubmap = CreateSubmapSrv;
-}
-
-
-//
-// Constructor for creaing map object from database
-// Expected field order:
-//     map_id,map_name,description,root_object_id
-//
-
-nxMapSrv::nxMapSrv(DB_RESULT hData, int nRow)
-         : nxMap()
-{
-   DB_RESULT hResult;
-   DWORD i;
-   TCHAR szQuery[1024];
-
-       m_nRefCount = 0;
-       m_pfCreateSubmap = CreateSubmapSrv;
-
-   m_dwMapId = DBGetFieldULong(hData, nRow, 0);
-   m_pszName = DBGetField(hData, nRow, 1, NULL, 0);
-   DecodeSQLString(m_pszName);
-   m_pszDescription = DBGetField(hData, nRow, 2, NULL, 0);
-   DecodeSQLString(m_pszDescription);
-   m_dwObjectId = DBGetFieldULong(hData, nRow, 3);
-
-   // Load ACL
-   _sntprintf(szQuery, 1024, _T("SELECT user_id,access_rights FROM map_access_lists WHERE map_id=%d"), m_dwMapId);
-   hResult = DBSelect(g_hCoreDB, szQuery);
-   if (hResult != NULL)
-   {
-      m_dwACLSize = DBGetNumRows(hResult);
-      if (m_dwACLSize > 0)
-      {
-         m_pACL = (MAP_ACL_ENTRY *)malloc(sizeof(MAP_ACL_ENTRY) * m_dwACLSize);
-         for(i = 0; i < m_dwACLSize; i++)
-         {
-            m_pACL[i].dwUserId = DBGetFieldULong(hResult, i, 0);
-            m_pACL[i].dwAccess = DBGetFieldULong(hResult, i, 1);
-         }
-      }
-      DBFreeResult(hResult);
-   }
-
-   // Load submaps
-   _sntprintf(szQuery, 1024, _T("SELECT submap_id,attributes FROM submaps WHERE map_id=%d"), m_dwMapId);
-   hResult = DBSelect(g_hCoreDB, szQuery);
-   if (hResult != NULL)
-   {
-      m_dwNumSubmaps = DBGetNumRows(hResult);
-      if (m_dwNumSubmaps > 0)
-      {
-         m_ppSubmaps = (nxSubmap **)malloc(sizeof(nxSubmap *) * m_dwNumSubmaps);
-         for(i = 0; i < m_dwNumSubmaps; i++)
-            m_ppSubmaps[i] = new nxSubmapSrv(hResult, i, m_dwMapId);
-      }
-      DBFreeResult(hResult);
-   }
-}
-
-
-//
-// Save map to database
-// Will return appropriate RCC, ready for sending to client
-//
-
-DWORD nxMapSrv::SaveToDB(void)
-{
-   DWORD i, dwNumRows, dwId, dwResult = RCC_DB_FAILURE;
-   DB_RESULT hResult;
-   TCHAR szQuery[1024], *pszEscName, *pszEscDescr;
-   BOOL bExist;
-
-   Lock();
-       DBBegin(g_hCoreDB);
-
-   // Check if map record exist in database
-   _sntprintf(szQuery, 256, _T("SELECT map_id FROM maps WHERE map_id=%d"), m_dwMapId);
-   hResult = DBSelect(g_hCoreDB, szQuery);
-   if (hResult == NULL)
-      goto exit_save;
-
-   bExist = (DBGetNumRows(hResult) > 0);
-   DBFreeResult(hResult);
-
-   pszEscName = EncodeSQLString(m_pszName);
-   pszEscDescr = EncodeSQLString(m_pszDescription);
-   if (bExist)
-   {
-      _sntprintf(szQuery, 1024, _T("UPDATE maps SET map_name='%s',description='%s',root_object_id=%d WHERE map_id=%d"),
-                 pszEscName, pszEscDescr, m_dwObjectId, m_dwMapId);
-   }
-   else
-   {
-      _sntprintf(szQuery, 1024, _T("INSERT INTO maps (map_id,map_name,description,root_object_id) VALUES (%d,'%s','%s',%d)"),
-                 m_dwMapId, pszEscName, pszEscDescr, m_dwObjectId);
-   }
-   free(pszEscName);
-   free(pszEscDescr);
-   if (!DBQuery(g_hCoreDB, szQuery))
-      goto exit_save;
-
-   // Save ACL
-   _sntprintf(szQuery, 256, _T("DELETE FROM map_access_lists WHERE map_id=%d"), m_dwMapId);
-   if (!DBQuery(g_hCoreDB, szQuery))
-      goto exit_save;
-
-   for(i = 0; i < m_dwACLSize; i++)
-   {
-      _sntprintf(szQuery, 1024, _T("INSERT INTO map_access_lists (map_id,user_id,access_rights) VALUES (%d,%d,%d)"),
-                 m_dwMapId, m_pACL[i].dwUserId, m_pACL[i].dwAccess);
-      if (!DBQuery(g_hCoreDB, szQuery))
-         goto exit_save;
-   }
-
-   // Delete non-existing submaps
-   _sntprintf(szQuery, 1024, _T("SELECT submap_id FROM submaps WHERE map_id=%d"), m_dwMapId);
-   hResult = DBSelect(g_hCoreDB, szQuery);
-   if (hResult == NULL)
-      goto exit_save;
-   dwNumRows = DBGetNumRows(hResult);
-   for(i = 0; i < dwNumRows; i++)
-   {
-      dwId = DBGetFieldULong(hResult, i, 0);
-      if (!IsSubmapExist(dwId, FALSE))
-      {
-         _sntprintf(szQuery, 1024, _T("DELETE FROM submaps WHERE map_id=%d AND submap_id=%d"),
-                    m_dwMapId, dwId);
-         DBQuery(g_hCoreDB, szQuery);
-      }
-   }
-   DBFreeResult(hResult);
-
-   // Save submaps
-   _sntprintf(szQuery, 1024, _T("DELETE FROM submap_object_positions WHERE map_id=%d"), m_dwMapId);
-   DBQuery(g_hCoreDB, szQuery);
-
-   _sntprintf(szQuery, 1024, _T("DELETE FROM submap_links WHERE map_id=%d"), m_dwMapId);
-   DBQuery(g_hCoreDB, szQuery);
-
-   dwResult = RCC_SUCCESS;
-   for(i = 0; (i < m_dwNumSubmaps) && (dwResult == RCC_SUCCESS); i++)
-      dwResult = ((nxSubmapSrv *)m_ppSubmaps[i])->SaveToDB();
-
-exit_save:
-   Unlock();
-
-       if (dwResult == RCC_SUCCESS)
-               DBCommit(g_hCoreDB);
-       else
-               DBRollback(g_hCoreDB);
-
-   return dwResult;
-}
-
-
-//
-// Delete map from database
-//
-
-BOOL nxMapSrv::DeleteFromDB()
-{
-       TCHAR query[256];
-       BOOL success;
-       DWORD i;
-
-       if (!DBBegin(g_hCoreDB))
-               return FALSE;
-
-   for(i = 0, success = TRUE; (i < m_dwNumSubmaps) && success; i++)
-      success = ((nxSubmapSrv *)m_ppSubmaps[i])->DeleteFromDB();
-
-       if (success)
-       {
-               _sntprintf(query, 256, _T("DELETE FROM maps WHERE map_id=%d"), m_dwMapId);
-               success = DBQuery(g_hCoreDB, query);
-       }
-
-       if (success)
-       {
-               _sntprintf(query, 256, _T("DELETE FROM map_access_lists WHERE map_id=%d"), m_dwMapId);
-               success = DBQuery(g_hCoreDB, query);
-       }
-
-       if (success)
-               DBCommit(g_hCoreDB);
-       else
-               DBRollback(g_hCoreDB);
-       return success;
-}
-
-
-//
-// Check user's access level
-//
-
-BOOL nxMapSrv::CheckUserRights(DWORD dwUserId, DWORD dwDesiredAccess)
-{
-   DWORD i, dwRights;
-   BOOL bRet = FALSE, bFound = FALSE;
-
-   if (dwUserId == 0)
-      return TRUE;   // Superuser always has all rights
-
-   Lock();
-
-   // Check direct user assignment first
-   for(i = 0; i < m_dwACLSize; i++)
-   {
-      if (m_pACL[i].dwUserId == dwUserId)
-      {
-         bRet = ((m_pACL[i].dwAccess & dwDesiredAccess) == dwDesiredAccess)? TRUE : FALSE;
-         bFound = TRUE;
-         break;
-      }
-   }
-
-   // Check rights assignment through the group
-   if (!bFound)
-   {
-      dwRights = 0;
-      for(i = 0; i < m_dwACLSize; i++)
-      {
-         if (m_pACL[i].dwUserId & GROUP_FLAG)
-         {
-            if (CheckUserMembership(dwUserId, m_pACL[i].dwUserId))
-            {
-               dwRights |= m_pACL[i].dwAccess;
-            }
-         }
-      }
-      bRet = ((dwRights & dwDesiredAccess) == dwDesiredAccess)? TRUE : FALSE;
-   }
-
-       // Check user rights via root object rights
-       if (!bRet)
-       {
-               NetObj *object = FindObjectById(m_dwObjectId);
-               if (object != NULL)
-               {
-             dwRights = 0;
-
-                       if (object->CheckAccessRights(dwUserId, OBJECT_ACCESS_READ))
-                               dwRights |= MAP_ACCESS_READ;
-
-                       if (object->CheckAccessRights(dwUserId, OBJECT_ACCESS_MODIFY))
-                               dwRights |= MAP_ACCESS_WRITE;
-
-                       bRet = ((dwRights & dwDesiredAccess) == dwDesiredAccess)? TRUE : FALSE;
-               }
-       }
-
-   Unlock();
-   return bRet;
-}
-
-
-//
-// Load all maps on startup
-//
-
-void LoadMaps(void)
-{
-   DB_RESULT hResult;
-   DWORD i;
-
-   hResult = DBSelect(g_hCoreDB, _T("SELECT map_id,map_name,description,root_object_id FROM maps"));
-   if (hResult != NULL)
-   {
-      m_dwNumMaps = DBGetNumRows(hResult);
-      if (m_dwNumMaps > 0)
-      {
-         m_ppMapList = (nxMapSrv **)malloc(sizeof(nxMapSrv *) * m_dwNumMaps);
-         for(i = 0; i < m_dwNumMaps; i++)
-            m_ppMapList[i] = new nxMapSrv(hResult, i);
-      }
-      DBFreeResult(hResult);
-   }
-   m_mutexMapList = MutexCreate();
-}
-
-
-//
-// Resolve map name to ID
-// Will return RCC_SUCCESS on success or appropriate RCC on failure
-//
-
-DWORD GetMapIdFromName(TCHAR *pszName, DWORD *pdwMapId)
-{
-   DWORD i, dwResult = RCC_INTERNAL_ERROR;
-
-   if (MutexLock(m_mutexMapList, g_dwLockTimeout))
-   {
-      for(i = 0; i < m_dwNumMaps; i++)
-      {
-         if (!_tcsicmp(pszName, m_ppMapList[i]->Name()))
-         {
-            *pdwMapId = m_ppMapList[i]->MapId();
-            dwResult = RCC_SUCCESS;
-            break;
-         }
-
-         // Map with given name not found
-         *pdwMapId = 0;
-         dwResult = RCC_UNKNOWN_MAP_NAME;
-      }
-      MutexUnlock(m_mutexMapList);
-   }
-   return dwResult;
-}
-
-
-//
-// Lock access to maps
-//
-
-BOOL LockMaps(void)
-{
-   return MutexLock(m_mutexMapList, g_dwLockTimeout);
-}
-
-
-//
-// Unlock access to maps
-//
-
-void UnlockMaps(void)
-{
-   MutexUnlock(m_mutexMapList);
-}
-
-
-//
-// Find map by ID (assuming that map list already locked)
-//
-
-nxMapSrv *FindMapByID(DWORD dwMapId)
-{
-   DWORD i;
-
-   for(i = 0; i < m_dwNumMaps; i++)
-      if (m_ppMapList[i]->MapId() == dwMapId)
-         return m_ppMapList[i];
-   return NULL;
-}
-
-
-//
-// Create NXCP message with map list
-//
-
-void CreateMapListMessage(CSCPMessage &msg, DWORD dwUserId)
-{
-       DWORD i, id, count;
-
-       if (!LockMaps())
-       {
-               msg.SetVariable(VID_RCC, RCC_INTERNAL_ERROR);
-               return;
-       }
-
-   for(i = 0, id = VID_MAP_LIST_BASE, count = 0; i < m_dwNumMaps; i++)
-       {
-               if (m_ppMapList[i]->CheckUserRights(dwUserId, MAP_ACCESS_READ))
-               {
-                       msg.SetVariable(id++, m_ppMapList[i]->MapId());
-                       msg.SetVariable(id++, m_ppMapList[i]->ObjectId());
-                       msg.SetVariable(id++, (DWORD)MAP_ACCESS_READ);
-                       msg.SetVariable(id++, m_ppMapList[i]->Name());
-         id += 6;  // Reserved ids for future use
-                       count++;
-               }
-       }
-
-       UnlockMaps();
-       msg.SetVariable(VID_NUM_MAPS, count);
-       msg.SetVariable(VID_RCC, RCC_SUCCESS);
-}
-
-
-//
-// Create new map
-//
-
-DWORD CreateNewMap(DWORD rootObj, const TCHAR *name, DWORD *newId)
-{
-       DWORD id, rcc;
-       nxMapSrv *map;
-
-       id = CreateUniqueId(IDG_MAP);
-
-       map = new nxMapSrv(id, rootObj, name, _T(""));
-       rcc = map->SaveToDB();
-       if (rcc == RCC_SUCCESS)
-       {
-               LockMaps();
-               m_dwNumMaps++;
-               m_ppMapList = (nxMapSrv **)realloc(m_ppMapList, sizeof(nxMapSrv *) * m_dwNumMaps);
-               m_ppMapList[m_dwNumMaps - 1] = map;
-               UnlockMaps();
-               *newId = id;
-       }
-       else
-       {
-               delete map;
-       }
-       return rcc;
-}
-
-
-//
-// Delete map
-//
-
-DWORD DeleteMap(DWORD mapId)
-{
-   DWORD i, rcc = RCC_INVALID_MAP_ID;
-       int count;
-
-       LockMaps();
-   for(i = 0; i < m_dwNumMaps; i++)
-      if (m_ppMapList[i]->MapId() == mapId)
-               {
-                       m_ppMapList[i]->IncRefCount();
-                       for(count = 20; (m_ppMapList[i]->GetRefCount() > 1) && (count > 0); count--)
-                       {
-                               DbgPrintf(6, _T("DeleteMap(%d): Waiting for map unlock, current reference count %d"), mapId, m_ppMapList[i]->GetRefCount());
-                               UnlockMaps();
-                               ThreadSleep(100);
-                               LockMaps();
-                       }
-                       if (m_ppMapList[i]->GetRefCount() == 1)
-                       {
-                               DbgPrintf(5, _T("DeleteMap(%d): calling DeleteFromDB()"), mapId);
-                               if (m_ppMapList[i]->DeleteFromDB())
-                               {
-                                       delete m_ppMapList[i];
-                                       m_dwNumMaps--;
-                                       memmove(&m_ppMapList[i], &m_ppMapList[i + 1], (m_dwNumMaps - i) * sizeof(nxMapSrv *));
-                                       rcc = RCC_SUCCESS;
-                               }
-                               else
-                               {
-                                       rcc = RCC_DB_FAILURE;
-                               }
-                       }
-                       else
-                       {
-                               rcc = RCC_RESOURCE_BUSY;
-                       }
-                       break;
-               }
-       UnlockMaps();
-       DbgPrintf(4, _T("DeleteMap(%d): RCC=%d"), mapId, rcc);
-   return rcc;
-}
index d69f217..cb85c67 100644 (file)
@@ -66,6 +66,7 @@ NetObj::NetObj()
       m_iStatusThresholds[i] = 80 - i * 20;
    }
        uuid_clear(m_image);
+       m_submapId = 0;
 }
 
 
@@ -143,7 +144,7 @@ BOOL NetObj::loadCommonProperties()
                              _T("status_prop_alg,status_fixed_val,status_shift,")
                              _T("status_translation,status_single_threshold,")
                              _T("status_thresholds,comments,is_system,")
-                                                                         _T("location_type,latitude,longitude,guid,image FROM object_properties ")
+                                                                         _T("location_type,latitude,longitude,guid,image,submap_id FROM object_properties ")
                              _T("WHERE object_id=%d"), m_dwId);
    hResult = DBSelect(g_hCoreDB, szQuery);
    if (hResult != NULL)
@@ -182,6 +183,7 @@ BOOL NetObj::loadCommonProperties()
 
                        DBGetFieldGUID(hResult, 0, 17, m_guid);
                        DBGetFieldGUID(hResult, 0, 18, m_image);
+                       m_submapId = DBGetFieldULong(hResult, 0, 19);
 
          bResult = TRUE;
       }
@@ -261,7 +263,7 @@ BOOL NetObj::saveCommonProperties(DB_HANDLE hdb)
                     _T("status_fixed_val=%d,status_shift=%d,status_translation='%s',")
                     _T("status_single_threshold=%d,status_thresholds='%s',")
                     _T("comments=%s,is_system=%d,location_type=%d,latitude='%f',")
-                                                 _T("longitude='%f',guid='%s',image='%s' WHERE object_id=%d"),
+                                                 _T("longitude='%f',guid='%s',image='%s',submap_id=%d WHERE object_id=%d"),
                     (const TCHAR *)DBPrepareString(g_hCoreDB, m_szName), m_iStatus, m_bIsDeleted,
                     m_bInheritAccessRights, m_dwTimeStamp, m_iStatusCalcAlg,
                     m_iStatusPropAlg, m_iFixedStatus, m_iStatusShift,
@@ -269,7 +271,8 @@ BOOL NetObj::saveCommonProperties(DB_HANDLE hdb)
                                                  (const TCHAR *)DBPrepareString(g_hCoreDB, CHECK_NULL_EX(m_pszComments)),
                                                  m_bIsSystem, m_geoLocation.getType(),
                                                  m_geoLocation.getLatitude(), m_geoLocation.getLongitude(),
-                                                 uuid_to_string(m_guid, guid), uuid_to_string(m_image, image), m_dwId);
+                                                 uuid_to_string(m_guid, guid), uuid_to_string(m_image, image),
+                                                 (int)m_submapId, m_dwId);
       }
       else
       {
@@ -278,8 +281,8 @@ BOOL NetObj::saveCommonProperties(DB_HANDLE hdb)
                     _T("inherit_access_rights,last_modified,status_calc_alg,")
                     _T("status_prop_alg,status_fixed_val,status_shift,status_translation,")
                     _T("status_single_threshold,status_thresholds,comments,is_system,")
-                                                 _T("location_type,latitude,longitude,guid,image) ")
-                    _T("VALUES (%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,'%s',%d,'%s',%s,%d,%d,'%f','%f','%s','%s')"),
+                                                 _T("location_type,latitude,longitude,guid,image,submap_id) ")
+                    _T("VALUES (%d,%s,%d,%d,%d,%d,%d,%d,%d,%d,'%s',%d,'%s',%s,%d,%d,'%f','%f','%s','%s',%d)"),
                     m_dwId, (const TCHAR *)DBPrepareString(g_hCoreDB, m_szName), m_iStatus, m_bIsDeleted,
                     m_bInheritAccessRights, m_dwTimeStamp, m_iStatusCalcAlg,
                     m_iStatusPropAlg, m_iFixedStatus, m_iStatusShift,
@@ -287,7 +290,8 @@ BOOL NetObj::saveCommonProperties(DB_HANDLE hdb)
                     (const TCHAR *)DBPrepareString(g_hCoreDB, CHECK_NULL_EX(m_pszComments)),
                                                  m_bIsSystem, m_geoLocation.getType(),
                                                  m_geoLocation.getLatitude(), m_geoLocation.getLongitude(),
-                                                 uuid_to_string(m_guid, guid), uuid_to_string(m_image, image));
+                                                 uuid_to_string(m_guid, guid), uuid_to_string(m_image, image),
+                                                 m_submapId);
       }
       DBFreeResult(hResult);
       bResult = DBQuery(hdb, szQuery);
@@ -791,6 +795,7 @@ void NetObj::CreateMessage(CSCPMessage *pMsg)
    pMsg->SetVariable(VID_STATUS_THRESHOLD_4, (WORD)m_iStatusThresholds[3]);
    pMsg->SetVariable(VID_COMMENTS, CHECK_NULL_EX(m_pszComments));
        pMsg->SetVariable(VID_IMAGE, m_image, UUID_LENGTH);
+       pMsg->SetVariable(VID_SUBMAP_ID, m_submapId);
        pMsg->SetVariable(VID_NUM_TRUSTED_NODES, m_dwNumTrustedNodes);
        if (m_dwNumTrustedNodes > 0)
                pMsg->SetVariableToInt32Array(VID_TRUSTED_NODES, m_dwNumTrustedNodes, m_pdwTrustedNodes);
@@ -921,6 +926,11 @@ DWORD NetObj::ModifyFromMessage(CSCPMessage *pRequest, BOOL bAlreadyLocked)
                m_geoLocation = GeoLocation(*pRequest);
        }
 
+       if (pRequest->IsVariableExist(VID_SUBMAP_ID))
+       {
+               m_submapId = pRequest->GetVariableLong(VID_SUBMAP_ID);
+       }
+
    Modify();
    UnlockData();
 
index 013ea15..1ad6d2a 100644 (file)
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\map.cpp"\r
-                               >\r
-                       </File>\r
-                       <File\r
                                RelativePath=".\modules.cpp"\r
                                >\r
                        </File>\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath="..\include\nxcore_maps.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
                                RelativePath="..\include\nxcore_situations.h"\r
                                >\r
                        </File>\r
index 9f208f1..9ea9aef 100644 (file)
@@ -1030,36 +1030,6 @@ void ClientSession::processingThread()
          case CMD_START_SNMP_WALK:
             StartSnmpWalk(pMsg);
             break;
-                       case CMD_GET_MAP_LIST:
-                               SendMapList(pMsg->GetId());
-                               break;
-         case CMD_RESOLVE_MAP_NAME:
-            ResolveMapName(pMsg);
-            break;
-         case CMD_CREATE_MAP:
-            CreateMap(pMsg);
-            break;
-         case CMD_RENAME_MAP:
-            RenameMap(pMsg);
-            break;
-         case CMD_SAVE_MAP:
-            SaveMap(pMsg);
-            break;
-                       case CMD_DELETE_MAP:
-                               DeleteMap(pMsg);
-                               break;
-         case CMD_SUBMAP_DATA:
-            ProcessSubmapData(pMsg);
-            break;
-         case CMD_LOAD_MAP:
-            LoadMap(pMsg);
-            break;
-         case CMD_UPLOAD_SUBMAP_BK_IMAGE:
-            RecvSubmapBkImage(pMsg);
-            break;
-         case CMD_GET_SUBMAP_BK_IMAGE:
-            SendSubmapBkImage(pMsg);
-            break;
          case CMD_RESOLVE_DCI_NAMES:
             ResolveDCINames(pMsg);
             break;
@@ -7388,417 +7358,6 @@ void ClientSession::StartSnmpWalk(CSCPMessage *pRequest)
 
 
 //
-// Send map list
-//
-
-void ClientSession::SendMapList(DWORD dwRqId)
-{
-   CSCPMessage msg;
-
-   msg.SetCode(CMD_REQUEST_COMPLETED);
-   msg.SetId(dwRqId);
-
-       CreateMapListMessage(msg, m_dwUserId);
-
-   sendMessage(&msg);
-}
-
-
-//
-// Resolve map name to ID
-//
-
-void ClientSession::ResolveMapName(CSCPMessage *pRequest)
-{
-   CSCPMessage msg;
-   TCHAR szName[MAX_DB_STRING];
-   DWORD dwMapId;
-
-   msg.SetCode(CMD_REQUEST_COMPLETED);
-   msg.SetId(pRequest->GetId());
-
-   pRequest->GetVariableStr(VID_NAME, szName, MAX_DB_STRING);
-   msg.SetVariable(VID_RCC, GetMapIdFromName(szName, &dwMapId));
-   msg.SetVariable(VID_MAP_ID, dwMapId);
-
-   sendMessage(&msg);
-}
-
-
-//
-// Save map
-//
-
-void ClientSession::SaveMap(CSCPMessage *pRequest)
-{
-   CSCPMessage msg;
-   DWORD dwMapId;
-
-   msg.SetCode(CMD_REQUEST_COMPLETED);
-   msg.SetId(pRequest->GetId());
-
-   if (!(m_dwFlags & CSF_RECEIVING_MAP_DATA))
-   {
-      dwMapId = pRequest->GetVariableLong(VID_MAP_ID);
-      LockMaps();
-      m_pActiveMap = FindMapByID(dwMapId);
-      if (m_pActiveMap != NULL)
-      {
-         if (m_pActiveMap->CheckUserRights(m_dwUserId, MAP_ACCESS_WRITE))
-         {
-            m_pActiveMap->IncRefCount();
-            m_pActiveMap->Lock();
-            m_pActiveMap->ModifyFromMessage(pRequest);
-            m_pActiveMap->Unlock();
-            msg.SetVariable(VID_RCC, RCC_SUCCESS);
-            m_dwFlags |= CSF_RECEIVING_MAP_DATA;
-            m_dwMapSaveRqId = pRequest->GetId();
-         }
-         else
-         {
-            msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
-         }
-      }
-      else
-      {
-         msg.SetVariable(VID_RCC, RCC_INVALID_MAP_ID);
-      }
-      UnlockMaps();
-   }
-   else
-   {
-      msg.SetVariable(VID_RCC, RCC_OPERATION_IN_PROGRESS);
-   }
-
-   sendMessage(&msg);
-}
-
-
-//
-// Process incoming submap data
-//
-
-void ClientSession::ProcessSubmapData(CSCPMessage *pRequest)
-{
-   CSCPMessage msg;
-   DWORD dwId, dwResult;
-   nxSubmapSrv *pSubmap;
-   BOOL bSend = FALSE;
-
-   msg.SetCode(CMD_REQUEST_COMPLETED);
-   msg.SetId(pRequest->GetId());
-
-   if ((m_dwFlags & CSF_RECEIVING_MAP_DATA) &&
-       (m_dwMapSaveRqId == pRequest->GetId()))
-   {
-      dwId = pRequest->GetVariableLong(VID_OBJECT_ID);
-      pSubmap = (nxSubmapSrv *)m_pActiveMap->GetSubmap(dwId);
-      if (pSubmap != NULL)
-      {
-         pSubmap->ModifyFromMessage(pRequest);
-      }
-      if (pRequest->IsEndOfSequence())
-      {
-         dwResult = m_pActiveMap->SaveToDB();
-         m_pActiveMap->DecRefCount();
-         m_dwFlags &= ~CSF_RECEIVING_MAP_DATA;
-         msg.SetVariable(VID_RCC, dwResult);
-         bSend = TRUE;
-      }
-   }
-   else
-   {
-      msg.SetVariable(VID_RCC, RCC_OUT_OF_STATE_REQUEST);
-      bSend = TRUE;
-   }
-
-   if (bSend)
-      sendMessage(&msg);
-}
-
-
-//
-// Create map
-//
-
-void ClientSession::CreateMap(CSCPMessage *pRequest)
-{
-   CSCPMessage msg;
-   TCHAR szName[MAX_DB_STRING];
-   DWORD dwMapId, dwResult, dwRootObj;
-
-   msg.SetCode(CMD_REQUEST_COMPLETED);
-   msg.SetId(pRequest->GetId());
-
-       if (m_dwSystemAccess & SYSTEM_ACCESS_MANAGE_MAPS)
-       {
-               pRequest->GetVariableStr(VID_NAME, szName, MAX_DB_STRING);
-               if (IsValidObjectName(szName, TRUE))
-               {
-                       dwRootObj = pRequest->GetVariableLong(VID_OBJECT_ID);
-                       dwResult = CreateNewMap(dwRootObj, szName, &dwMapId);
-                       msg.SetVariable(VID_RCC, dwResult);
-                       if (dwResult == RCC_SUCCESS)
-                               msg.SetVariable(VID_MAP_ID, dwMapId);
-               }
-               else
-               {
-             msg.SetVariable(VID_RCC, RCC_INVALID_OBJECT_NAME);
-               }
-       }
-       else
-       {
-      msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
-       }
-
-   sendMessage(&msg);
-}
-
-
-//
-// Rename map
-//
-
-void ClientSession::RenameMap(CSCPMessage *pRequest)
-{
-   CSCPMessage msg;
-   DWORD dwMapId;
-   nxMapSrv *pMap;
-       TCHAR szName[MAX_DB_STRING];
-
-   msg.SetCode(CMD_REQUEST_COMPLETED);
-   msg.SetId(pRequest->GetId());
-
-       if (m_dwSystemAccess & SYSTEM_ACCESS_MANAGE_MAPS)
-       {
-               dwMapId = pRequest->GetVariableLong(VID_MAP_ID);
-               LockMaps();
-               pMap = FindMapByID(dwMapId);
-               if (pMap != NULL)
-               {
-                       pRequest->GetVariableStr(VID_NAME, szName, MAX_DB_STRING);
-                       pMap->SetName(szName);
-                       pMap->SaveToDB();
-                       msg.SetVariable(VID_RCC, RCC_SUCCESS);
-               }
-               else
-               {
-                       msg.SetVariable(VID_RCC, RCC_INVALID_MAP_ID);
-               }
-               UnlockMaps();
-       }
-       else
-       {
-               msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
-       }
-
-   sendMessage(&msg);
-}
-
-
-//
-// Save map
-//
-
-void ClientSession::DeleteMap(CSCPMessage *pRequest)
-{
-   CSCPMessage msg;
-   DWORD dwMapId;
-
-   msg.SetCode(CMD_REQUEST_COMPLETED);
-   msg.SetId(pRequest->GetId());
-
-       if (m_dwSystemAccess & SYSTEM_ACCESS_MANAGE_MAPS)
-       {
-               dwMapId = pRequest->GetVariableLong(VID_MAP_ID);
-               DebugPrintf(4, _T("Requesting map deletion (mapId=%d)"), dwMapId);
-               msg.SetVariable(VID_RCC, ::DeleteMap(dwMapId));
-       }
-       else
-       {
-               msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
-       }
-
-   sendMessage(&msg);
-}
-
-
-//
-// Load map
-//
-
-void ClientSession::LoadMap(CSCPMessage *pRequest)
-{
-   CSCPMessage msg;
-   DWORD i, dwMapId;
-   nxMapSrv *pMap;
-   nxSubmap *pSubmap;
-
-   msg.SetCode(CMD_REQUEST_COMPLETED);
-   msg.SetId(pRequest->GetId());
-
-   dwMapId = pRequest->GetVariableLong(VID_MAP_ID);
-   LockMaps();
-   pMap = FindMapByID(dwMapId);
-   if (pMap != NULL)
-   {
-      if (pMap->CheckUserRights(m_dwUserId, MAP_ACCESS_READ))
-      {
-         msg.SetVariable(VID_RCC, RCC_SUCCESS);
-         pMap->CreateMessage(&msg);
-
-         for(i = 0; i < pMap->GetSubmapCount(); i++)
-         {
-            sendMessage(&msg);
-            msg.SetCode(CMD_SUBMAP_DATA);
-            msg.DeleteAllVariables();
-            pSubmap = pMap->GetSubmapByIndex(i);
-            if (pSubmap != NULL)
-               pSubmap->CreateMessage(&msg);
-         }
-         msg.SetEndOfSequence();
-      }
-      else
-      {
-         msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
-      }
-   }
-   else
-   {
-      msg.SetVariable(VID_RCC, RCC_INVALID_MAP_ID);
-   }
-   UnlockMaps();
-
-   sendMessage(&msg);
-}
-
-
-//
-// Send submap's background image to client
-//
-
-void ClientSession::SendSubmapBkImage(CSCPMessage *pRequest)
-{
-   CSCPMessage msg;
-   DWORD dwMapId, dwSubmapId;
-   TCHAR szBuffer[MAX_PATH];
-   nxMapSrv *pMap;
-   BOOL bSuccess = FALSE;
-
-   msg.SetCode(CMD_REQUEST_COMPLETED);
-   msg.SetId(pRequest->GetId());
-
-   dwMapId = pRequest->GetVariableLong(VID_MAP_ID);
-   dwSubmapId = pRequest->GetVariableLong(VID_OBJECT_ID);
-
-   LockMaps();
-
-   pMap = FindMapByID(dwMapId);
-   if (pMap != NULL)
-   {
-      if (pMap->CheckUserRights(m_dwUserId, MAP_ACCESS_READ))
-      {
-         _sntprintf(szBuffer, MAX_PATH, 
-                    _T("%s") DDIR_BACKGROUNDS FS_PATH_SEPARATOR _T("%08X.%08X"),
-                    g_szDataDir, dwMapId, dwSubmapId);
-         if (_taccess(szBuffer, 4) == 0)
-         {
-            msg.SetVariable(VID_RCC, RCC_SUCCESS);
-            bSuccess = TRUE;
-         }
-         else
-         {
-            msg.SetVariable(VID_RCC, RCC_IO_ERROR);
-         }
-      }
-      else
-      {
-         msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
-      }
-   }
-   else
-   {
-      msg.SetVariable(VID_RCC, RCC_INVALID_MAP_ID);
-   }
-
-   UnlockMaps();
-
-   // Send response message
-   sendMessage(&msg);
-
-   // Send bitmap file
-   if (bSuccess)
-   {
-               sendFile(szBuffer, pRequest->GetId());
-   }
-}
-
-
-//
-// Receive submap's background image from client
-//
-
-void ClientSession::RecvSubmapBkImage(CSCPMessage *pRequest)
-{
-   CSCPMessage msg;
-   DWORD dwMapId, dwSubmapId;
-   nxMapSrv *pMap;
-
-   msg.SetCode(CMD_REQUEST_COMPLETED);
-   msg.SetId(pRequest->GetId());
-
-   dwMapId = pRequest->GetVariableLong(VID_MAP_ID);
-   dwSubmapId = pRequest->GetVariableLong(VID_OBJECT_ID);
-
-   LockMaps();
-
-   pMap = FindMapByID(dwMapId);
-   if (pMap != NULL)
-   {
-      if (pMap->CheckUserRights(m_dwUserId, MAP_ACCESS_WRITE))
-      {
-         // Prepare for file receive
-         if (m_hCurrFile == -1)
-         {
-            _sntprintf(m_szCurrFileName, MAX_PATH, 
-                       _T("%s") DDIR_BACKGROUNDS FS_PATH_SEPARATOR _T("%08X.%08X"),
-                       g_szDataDir, dwMapId, dwSubmapId);
-            m_hCurrFile = _topen(m_szCurrFileName, O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, S_IRUSR | S_IWUSR);
-            if (m_hCurrFile != -1)
-            {
-               m_dwFileRqId = pRequest->GetId();
-               m_dwUploadCommand = CMD_UPLOAD_SUBMAP_BK_IMAGE;
-               m_dwUploadData = 0;
-               msg.SetVariable(VID_RCC, RCC_SUCCESS);
-            }
-            else
-            {
-               msg.SetVariable(VID_RCC, RCC_IO_ERROR);
-            }
-         }
-         else
-         {
-            msg.SetVariable(VID_RCC, RCC_RESOURCE_BUSY);
-         }
-      }
-      else
-      {
-         msg.SetVariable(VID_RCC, RCC_ACCESS_DENIED);
-      }
-   }
-   else
-   {
-      msg.SetVariable(VID_RCC, RCC_INVALID_MAP_ID);
-   }
-
-   UnlockMaps();
-
-   // Send response message
-   sendMessage(&msg);
-}
-
-
-//
 // Resolve single DCI name
 //
 
index e78057c..dcf5e12 100644 (file)
@@ -23,7 +23,6 @@ EXTRA_DIST = \
        nms_users.h \
        nxcore_jobs.h \
        nxcore_logs.h \
-       nxcore_maps.h \
        nxcore_situations.h \
        nxmodule.h \
        nxsrvapi.h \
index 936ef6c..8f2743f 100644 (file)
@@ -102,7 +102,6 @@ typedef __console_ctx * CONSOLE_CTX;
 #include "nms_pkg.h"
 #include "nms_topo.h"
 #include "nms_script.h"
-#include "nxcore_maps.h"
 #include "nxcore_situations.h"
 #include "nxcore_jobs.h"
 #include "nxcore_logs.h"
@@ -370,8 +369,6 @@ private:
    DWORD m_dwEncryptionResult;
    CONDITION m_condEncryptionSetup;
    DWORD m_dwActiveChannels;     // Active data channels
-   DWORD m_dwMapSaveRqId;        // ID of currently active map saving request
-   nxMapSrv *m_pActiveMap;       // Map currenly being saved
        CONSOLE_CTX m_console;                  // Server console context
 
    static THREAD_RESULT THREAD_CALL ReadThreadStarter(void *);
@@ -497,16 +494,6 @@ private:
    void KillSession(CSCPMessage *pRequest);
    void SendTrapLog(CSCPMessage *pRequest);
    void StartSnmpWalk(CSCPMessage *pRequest);
-   void SendMapList(DWORD dwRqId);
-   void ResolveMapName(CSCPMessage *pRequest);
-   void SaveMap(CSCPMessage *pRequest);
-   void DeleteMap(CSCPMessage *pRequest);
-   void ProcessSubmapData(CSCPMessage *pRequest);
-   void CreateMap(CSCPMessage *pRequest);
-   void RenameMap(CSCPMessage *pRequest);
-   void LoadMap(CSCPMessage *pRequest);
-   void SendSubmapBkImage(CSCPMessage *pRequest);
-   void RecvSubmapBkImage(CSCPMessage *pRequest);
    void ResolveDCINames(CSCPMessage *pRequest);
    DWORD ResolveDCIName(DWORD dwNode, DWORD dwItem, TCHAR **ppszName);
    void SendConfigForAgent(CSCPMessage *pRequest);
index 9db8bf6..4ed7775 100644 (file)
@@ -239,6 +239,7 @@ protected:
    DWORD m_dwIpAddr;          // Every object should have an IP address
        GeoLocation m_geoLocation;
    ClientSession *m_pPollRequestor;
+       DWORD m_submapId;                               // Map object which should be open on drill-down request
 
    DWORD m_dwChildCount;      // Number of child objects
    NetObj **m_pChildList;     // Array of pointers to child objects
diff --git a/src/server/include/nxcore_maps.h b/src/server/include/nxcore_maps.h
deleted file mode 100644 (file)
index 687b314..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/* 
-** NetXMS - Network Management System
-** Copyright (C) 2003-2009 Victor Kirhenshtein
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**
-** File: nxcore_maps.h
-**
-**/
-
-#ifndef _nxcore_maps_h_
-#define _nxcore_maps_h_
-
-#include <netxms_maps.h>
-
-
-//
-// Server-side submap class
-//
-
-class nxSubmapSrv : public nxSubmap
-{
-protected:
-   DWORD m_dwMapId;     // ID of parent map
-
-public:
-   nxSubmapSrv(DB_RESULT hResult, int nRow, DWORD dwMapId);
-   nxSubmapSrv(DWORD dwObjectId, DWORD dwMapId);
-
-   DWORD SaveToDB();
-       BOOL DeleteFromDB();
-};
-
-
-//
-// Server-side map class
-//
-
-class nxMapSrv : public nxMap
-{
-protected:
-   int m_nRefCount;
-
-public:
-   nxMapSrv(DB_RESULT hResult, int nRow);
-   nxMapSrv(DWORD dwMapId, DWORD dwObjectId, const TCHAR *pszName, const TCHAR *pszDescription);
-
-   DWORD SaveToDB();
-       BOOL DeleteFromDB();
-   BOOL CheckUserRights(DWORD dwUserId, DWORD dwDesiredAccess);
-
-   void IncRefCount() { Lock(); m_nRefCount++; Unlock(); }
-   void DecRefCount() { Lock(); if (m_nRefCount > 0) m_nRefCount--; Unlock(); }
-   int GetRefCount() { int nRef; Lock(); nRef = m_nRefCount; Unlock(); return nRef; }
-};
-
-
-//
-// Functions
-//
-
-void CreateMapListMessage(CSCPMessage &msg, DWORD dwUserId);
-DWORD CreateNewMap(DWORD rootObj, const TCHAR *name, DWORD *newId);
-void LoadMaps(void);
-DWORD GetMapIdFromName(TCHAR *pszName, DWORD *pdwMapId);
-BOOL LockMaps(void);
-void UnlockMaps(void);
-nxMapSrv *FindMapByID(DWORD dwMapId);
-DWORD DeleteMap(DWORD mapId);
-
-
-//
-// Webmaps functions
-//
-
-DWORD CreateWebMap(const TCHAR *name, const TCHAR *props, DWORD *id);
-DWORD DeleteWebMap(DWORD id);
-DWORD UpdateWebMapData(DWORD mapId, const TCHAR *data);
-DWORD UpdateWebMapProperties(DWORD mapId, const TCHAR *name, const TCHAR *props);
-
-
-#endif   /* _nxcore_maps_h_ */
index f6453e0..fb15104 100644 (file)
@@ -256,6 +256,29 @@ static BOOL SetColumnNullable(const TCHAR *table, const TCHAR *column, const TCH
 
 
 //
+// Upgrade from V231 to V232
+//
+
+static BOOL H_UpgradeFromV231(int currVersion, int newVersion)
+{
+       static TCHAR batch[] = 
+               _T("ALTER TABLE object_properties ADD submap_id integer\n")
+               _T("UPDATE object_properties SET submap_id=0\n")
+               _T("DROP TABLE maps\n")
+               _T("DROP TABLE map_access_lists\n")
+               _T("DROP TABLE submaps\n")
+               _T("DROP TABLE submap_object_positions\n")
+               _T("DROP TABLE submap_links\n")
+               _T("<END>");
+
+       CHK_EXEC(SQLBatch(batch));
+
+       CHK_EXEC(SQLQuery(_T("UPDATE metadata SET var_value='232' WHERE var_name='SchemaVersion'")));
+   return TRUE;
+}
+
+
+//
 // Upgrade from V230 to V231
 //
 
@@ -5323,6 +5346,7 @@ static struct
        { 228, 229, H_UpgradeFromV228 },
        { 229, 230, H_UpgradeFromV229 },
        { 230, 231, H_UpgradeFromV230 },
+       { 231, 232, H_UpgradeFromV231 },
    { 0, NULL }
 };
 
@@ -5331,7 +5355,7 @@ static struct
 // Upgrade database to new version
 //
 
-void UpgradeDatabase(void)
+void UpgradeDatabase()
 {
    DB_RESULT hResult;
    LONG i, iVersion = 0;