[mapguide-commits] r4266 - in trunk/MgDev/Common: MapGuideCommon/MapLayer PlatformBase/MapLayer

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun Sep 27 02:53:44 EDT 2009


Author: leaf
Date: 2009-09-27 02:53:43 -0400 (Sun, 27 Sep 2009)
New Revision: 4266

Modified:
   trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.cpp
   trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.h
   trunk/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp
Log:
Ticket #1109: MgLayerBase bypass its subclasses
https://trac.osgeo.org/mapguide/ticket/1109
Submit on behalf of Christine Bao.

Modified: trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.cpp
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.cpp	2009-09-26 22:31:04 UTC (rev 4265)
+++ trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.cpp	2009-09-27 06:53:43 UTC (rev 4266)
@@ -26,6 +26,7 @@
 MgLayer::MgLayer()
     : MgLayerBase()
 {
+    m_initIdProps = true;
 }
 
 //////////////////////////////////////////////////////////////
@@ -34,6 +35,7 @@
 MgLayer::MgLayer(MgResourceIdentifier* layerDefinition, MgResourceService* resourceService)
     : MgLayerBase(layerDefinition, resourceService)
 {
+    m_initIdProps = true;
     GetLayerInfoFromDefinition(resourceService);
 }
 
@@ -43,6 +45,7 @@
 MgLayer::MgLayer(MgResourceIdentifier* layerDefinition, MgResourceService* resourceService, bool initIdProps)
     : MgLayerBase(layerDefinition, resourceService)
 {
+    m_initIdProps = initIdProps;
     if (initIdProps)
     {
         GetLayerInfoFromDefinition(resourceService);
@@ -55,7 +58,8 @@
 MgLayer::MgLayer(MgResourceIdentifier* layerDefinition, MgResourceService* resourceService, bool initIdProps, bool initLayerDefinition)
     : MgLayerBase(layerDefinition, resourceService, initLayerDefinition)
 {
-    if (initIdProps)
+    m_initIdProps = initIdProps;
+    if (initIdProps && initLayerDefinition)
     {
         GetLayerInfoFromDefinition(resourceService);
     }
@@ -96,47 +100,51 @@
 //
 void MgLayer::GetLayerInfoFromDefinition(MgResourceService* resourceService)
 {
-    MG_TRY()
+    MgLayerBase::GetLayerInfoFromDefinition(resourceService);
 
-    // Generate Id field information for feature sources
-    m_idProps.clear();
-    if (!m_featureName.empty())
+    if(m_initIdProps && resourceService != NULL)
     {
-        // If we cannot pull the identity properties, silently ignore it.
-        try
+        MG_TRY()
+
+        // Generate Id field information for feature sources
+        m_idProps.clear();
+        if (!m_featureName.empty())
         {
-            //TODO: Pull site connection directly from resource service
-            Ptr<MgUserInformation> userInfo = resourceService->GetUserInfo();
-            Ptr<MgSiteConnection> conn = new MgSiteConnection();
-            conn->Open(userInfo);
+            // If we cannot pull the identity properties, silently ignore it.
+            try
+            {
+                //TODO: Pull site connection directly from resource service
+                Ptr<MgUserInformation> userInfo = resourceService->GetUserInfo();
+                Ptr<MgSiteConnection> conn = new MgSiteConnection();
+                conn->Open(userInfo);
 
-            Ptr<MgFeatureService> featureService = dynamic_cast<MgFeatureService*>(conn->CreateService(MgServiceType::FeatureService));
-            Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(m_featureSourceId);
+                Ptr<MgFeatureService> featureService = dynamic_cast<MgFeatureService*>(conn->CreateService(MgServiceType::FeatureService));
+                Ptr<MgResourceIdentifier> resId = new MgResourceIdentifier(m_featureSourceId);
 
-            // If the class name is fully qualified (prefixed with a schema name),
-            // then use it to determine the schema name.
-            STRING className;
-            STRING schemaName;
-            ParseFeatureName(featureService, className, schemaName);
+                // If the class name is fully qualified (prefixed with a schema name),
+                // then use it to determine the schema name.
+                STRING className;
+                STRING schemaName;
+                ParseFeatureName(featureService, className, schemaName);
 
-            // Get the identity properties
-            Ptr<MgStringCollection> classNames = new MgStringCollection();
-            classNames->Add(className);
-            Ptr<MgClassDefinitionCollection> classDefs = featureService->GetIdentityProperties(resId, schemaName, classNames);
-            if (NULL != classDefs.p && classDefs->GetCount() == 1)
+                // Get the identity properties
+                Ptr<MgStringCollection> classNames = new MgStringCollection();
+                classNames->Add(className);
+                Ptr<MgClassDefinitionCollection> classDefs = featureService->GetIdentityProperties(resId, schemaName, classNames);
+                if (NULL != classDefs.p && classDefs->GetCount() == 1)
+                {
+                    Ptr<MgClassDefinition> classDef = classDefs->GetItem(0);
+                    PopulateIdentityProperties(classDef);
+                }
+            }
+            catch (MgException* e)
             {
-                Ptr<MgClassDefinition> classDef = classDefs->GetItem(0);
-                PopulateIdentityProperties(classDef);
+                e->Release();
+                // Do nothing here.  A failure to pull selection id's is not critical at this point
             }
         }
-        catch (MgException* e)
-        {
-            e->Release();
-            // Do nothing here.  A failure to pull selection id's is not critical at this point
-        }
+        MG_CATCH_AND_THROW(L"MgLayer.GetLayerInfoFromDefinition")
     }
-
-    MG_CATCH_AND_THROW(L"MgLayer.GetLayerInfoFromDefinition")
 }
 
 //////////////////////////////////////////////////////////////

Modified: trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.h
===================================================================
--- trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.h	2009-09-26 22:31:04 UTC (rev 4265)
+++ trunk/MgDev/Common/MapGuideCommon/MapLayer/Layer.h	2009-09-27 06:53:43 UTC (rev 4266)
@@ -307,6 +307,8 @@
 
     MgMapBase* GetMap();
 
+    bool m_initIdProps;
+
 CLASS_ID:
     static const INT32 m_cls_id = MapGuide_MapLayer_Layer;
 

Modified: trunk/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp	2009-09-26 22:31:04 UTC (rev 4265)
+++ trunk/MgDev/Common/PlatformBase/MapLayer/LayerBase.cpp	2009-09-27 06:53:43 UTC (rev 4266)
@@ -300,7 +300,7 @@
     m_name = m_definition->GetName();
 
     m_forceReadFromServer = true;
-    MgLayerBase::GetLayerInfoFromDefinition(resourceService);
+    GetLayerInfoFromDefinition(resourceService);
     m_forceReadFromServer = false;
 
     if(m_layers != NULL)
@@ -330,7 +330,7 @@
 
     m_resourceContent = resourceContent;
 
-    MgLayerBase::GetLayerInfoFromDefinition(NULL);
+    GetLayerInfoFromDefinition(NULL);
 
     if(m_layers != NULL)
         m_layers->GetMap()->OnLayerDefinitionChanged(this);



More information about the mapguide-commits mailing list