[mapguide-commits] r5999 - trunk/MgDev/Server/src/Services/Feature

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Jul 26 02:02:15 EDT 2011


Author: hubu
Date: 2011-07-25 23:02:15 -0700 (Mon, 25 Jul 2011)
New Revision: 5999

Modified:
   trunk/MgDev/Server/src/Services/Feature/ServerFeatureUtil.cpp
Log:
On behalf of Spark Liu:
Fix for ticket 1756: ServerFeatureService.DescribeSchemaAsXml will throw exception when geometry property is inherited from base class

When the geometry property is inherited from base class (which means no extra geometry property defined in child class), ServerFeatureService.DescribeSchemaAsXml will throw exception.
This is because when trying to change MgClassDefinition back to FdoClassDefinition, it always try to get geometry property from the property collection in child class instead of base class.

Modified: trunk/MgDev/Server/src/Services/Feature/ServerFeatureUtil.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/ServerFeatureUtil.cpp	2011-07-25 11:15:02 UTC (rev 5998)
+++ trunk/MgDev/Server/src/Services/Feature/ServerFeatureUtil.cpp	2011-07-26 06:02:15 UTC (rev 5999)
@@ -2461,9 +2461,28 @@
 
     if (!geomName.empty())
     {
-        FdoPtr<FdoGeometricPropertyDefinition> defaultGeom = (FdoGeometricPropertyDefinition*)fdoPropDefCol->GetItem(geomName.c_str());
-        FdoPtr<FdoFeatureClass> ffClass = FDO_SAFE_ADDREF((FdoFeatureClass*)((FdoClassDefinition*)fdoClassDef));
-        ffClass->SetGeometryProperty(defaultGeom);
+        FdoPtr<FdoGeometricPropertyDefinition> defaultGeom = (FdoGeometricPropertyDefinition*)fdoPropDefCol->FindItem(geomName.c_str());
+        if(defaultGeom.p == NULL)
+        {
+            FdoPtr<FdoReadOnlyPropertyDefinitionCollection> fdoBasePropDefCol = fdoClassDef->GetBaseProperties();
+            if(fdoBasePropDefCol.p != NULL)
+            {
+                for(FdoInt32 ix = 0; ix < fdoBasePropDefCol->GetCount(); ix++)
+                {
+                    FdoPtr<FdoPropertyDefinition> propCandidate = fdoBasePropDefCol->GetItem(ix);
+                    if(wcscmp(propCandidate->GetName(), geomName.c_str()) == 0)
+                    {
+                        defaultGeom = (FdoGeometricPropertyDefinition*) propCandidate.Detach();
+                        break;
+                    }
+                }
+            }
+        }
+        if(defaultGeom.p != NULL)
+        {
+            FdoPtr<FdoFeatureClass> ffClass = FDO_SAFE_ADDREF((FdoFeatureClass*)((FdoClassDefinition*)fdoClassDef));
+            ffClass->SetGeometryProperty(defaultGeom);
+        }
     }
 
     MG_FEATURE_SERVICE_CATCH_AND_THROW(L"MgServerFeatureUtil.GetFdoClassDefinition")



More information about the mapguide-commits mailing list