[mapguide-commits] r4939 - in trunk/MgDev/Common: Foundation/Data PlatformBase/Data PlatformBase/Services Schema

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Sun Jun 13 05:17:36 EDT 2010


Author: brucedechant
Date: 2010-06-10 22:53:45 +0000 (Thu, 10 Jun 2010)
New Revision: 4939

Modified:
   trunk/MgDev/Common/Foundation/Data/StringProperty.cpp
   trunk/MgDev/Common/PlatformBase/Data/BlobProperty.cpp
   trunk/MgDev/Common/PlatformBase/Data/BooleanProperty.cpp
   trunk/MgDev/Common/PlatformBase/Data/ByteProperty.cpp
   trunk/MgDev/Common/PlatformBase/Data/ClobProperty.cpp
   trunk/MgDev/Common/PlatformBase/Data/DateTimeProperty.cpp
   trunk/MgDev/Common/PlatformBase/Data/DoubleProperty.cpp
   trunk/MgDev/Common/PlatformBase/Data/Int16Property.cpp
   trunk/MgDev/Common/PlatformBase/Data/Int32Property.cpp
   trunk/MgDev/Common/PlatformBase/Data/Int64Property.cpp
   trunk/MgDev/Common/PlatformBase/Data/SingleProperty.cpp
   trunk/MgDev/Common/PlatformBase/Services/FeatureProperty.cpp
   trunk/MgDev/Common/PlatformBase/Services/GeometryProperty.cpp
   trunk/MgDev/Common/PlatformBase/Services/RasterProperty.cpp
   trunk/MgDev/Common/Schema/BatchPropertyCollection-1.0.0.xsd
Log:
Fix for trac ticket #708 - Exceptions thrown on SELECTFEATURES instead of being handled gracefully

Notes:
- Submitted on behalf of Jackie Ng
- I had to fix the patch before integrating it as it did not compile. It was using string and STRING with the + operator which does not work. I also had to replace the tabs with spaces.
- Updated to handle NULL values properly


Modified: trunk/MgDev/Common/Foundation/Data/StringProperty.cpp
===================================================================
--- trunk/MgDev/Common/Foundation/Data/StringProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/Foundation/Data/StringProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -127,7 +127,14 @@
         {
             str += "<Type>string</Type>";
         }
-        str += "<Value>" + MgUtil::WideCharToMultiByte(MgUtil::ReplaceEscapeCharInXml(this->GetValue())) + "</Value>";
+
+        if (!this->IsNull())
+        {
+            str += "<Value>"; 
+            str += MgUtil::WideCharToMultiByte(MgUtil::ReplaceEscapeCharInXml(this->GetValue())); 
+            str += "</Value>";
+        }
+
         str += "</" + rootElmName + ">";
     }
     else

Modified: trunk/MgDev/Common/PlatformBase/Data/BlobProperty.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Data/BlobProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Data/BlobProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -132,13 +132,13 @@
         str += "<Type>blob</Type>";
     }
 
-    str += "<Value>";
-    if (m_value != NULL)
+    if (m_value != NULL || !this->IsNull())
     {
+        str += "<Value>";
         Ptr<MgByteReader> reader = this->GetValue();
         str += MgUtil::GetStringFromReader(reader);
+        str += "</Value>";
     }
-    str += "</Value>";
 
     str += "</" + rootElmName + ">";
 }

Modified: trunk/MgDev/Common/PlatformBase/Data/BooleanProperty.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Data/BooleanProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Data/BooleanProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -118,15 +118,16 @@
         str += "<Type>boolean</Type>";
     }
 
-    str += "<Value>";
+    if (!this->IsNull())
+    {
+        str += "<Value>";
+        if( this->GetValue())
+            str += "true" ;
+        else
+            str += "false" ;
+        str += "</Value>";
+    }
 
-    if( this->GetValue())
-        str += "true" ;
-    else
-        str += "false" ;
-
-    str += "</Value>";
-
     str += "</" + rootElmName + ">";
 }
 

Modified: trunk/MgDev/Common/PlatformBase/Data/ByteProperty.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Data/ByteProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Data/ByteProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -124,9 +124,13 @@
     {
         str += "<Type>byte</Type>";
     }
-    str += "<Value>";
-    str += MgUtil::Char2Hex(this->GetValue());
-    str += "</Value>";
+    
+    if (!this->IsNull())
+    {
+        str += "<Value>";
+        str += MgUtil::Char2Hex(this->GetValue());
+        str += "</Value>";
+    }
 
     str += "</" + rootElmName + ">";
 }

Modified: trunk/MgDev/Common/PlatformBase/Data/ClobProperty.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Data/ClobProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Data/ClobProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -131,13 +131,13 @@
         str += "<Type>clob</Type>";
     }
 
-    str += "<Value>";
-    if (m_value != NULL)
+    if (m_value != NULL || !this->IsNull())
     {
+        str += "<Value>";
         Ptr<MgByteReader> reader = this->GetValue();
         str += MgUtil::GetStringFromReader(reader);
+        str += "</Value>";
     }
-    str += "</Value>";
 
     str += "</" + rootElmName + ">";
 }

Modified: trunk/MgDev/Common/PlatformBase/Data/DateTimeProperty.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Data/DateTimeProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Data/DateTimeProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -118,15 +118,18 @@
         str += "<Type>datetime</Type>";
     }
 
-    str += "<Value>";
-    char buf[128]; buf[0] = 0;
-    Ptr<MgDateTime> dtPtr = this->GetValue();
-    if (dtPtr != NULL)
+    if (!this->IsNull())
     {
-        STRING dateStr = dtPtr->ToString();
-        str += MgUtil::WideCharToMultiByte(dateStr);
+        str += "<Value>";
+        char buf[128]; buf[0] = 0;
+        Ptr<MgDateTime> dtPtr = this->GetValue();
+        if (dtPtr != NULL)
+        {
+            STRING dateStr = dtPtr->ToString();
+            str += MgUtil::WideCharToMultiByte(dateStr);
+        }
+        str += "</Value>";
     }
-    str += "</Value>";
 
     str += "</" + rootElmName + ">";
 }

Modified: trunk/MgDev/Common/PlatformBase/Data/DoubleProperty.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Data/DoubleProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Data/DoubleProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -130,7 +130,12 @@
     string doubleStr = "";
     MgUtil::DoubleToString(m_value, doubleStr);
 
-    str += "<Value>" + doubleStr + "</Value>";
+    if (!this->IsNull()) 
+    {
+        str += "<Value>";
+        str += doubleStr; 
+        str += "</Value>";
+    }
 
     str += "</" + rootElmName + ">";
 }

Modified: trunk/MgDev/Common/PlatformBase/Data/Int16Property.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Data/Int16Property.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Data/Int16Property.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -122,17 +122,20 @@
         str += "<Type>int16</Type>";
     }
 
-    str += "<Value>";
+    if (!this->IsNull())
+    {
+        str += "<Value>";
+        char buf[128]; buf[0] = 0;
+        #ifdef _WIN32
+        itoa(this->GetValue(), buf, 10);
+        #else
+        snprintf(buf, 128, "%d", this->GetValue());
+        #endif
 
-    char buf[128]; buf[0] = 0;
-    #ifdef _WIN32
-    itoa(this->GetValue(), buf, 10);
-    #else
-    snprintf(buf, 128, "%d", this->GetValue());
-    #endif
+        str += std::string(buf);
+        str += "</Value>";
+    }
 
-    str += std::string(buf) + "</Value>";
-
     str += "</" + rootElmName + ">";
 }
 

Modified: trunk/MgDev/Common/PlatformBase/Data/Int32Property.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Data/Int32Property.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Data/Int32Property.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -121,17 +121,20 @@
         str += "<Type>int32</Type>";
     }
 
-    str += "<Value>";
+    if (!this->IsNull())
+    {
+        str += "<Value>";
+        char buf[128]; buf[0] = 0;
+        #ifdef _WIN32
+        itoa(this->GetValue(), buf, 10);
+        #else
+        snprintf(buf, 128, "%li", this->GetValue());
+        #endif
 
-    char buf[128]; buf[0] = 0;
-    #ifdef _WIN32
-    itoa(this->GetValue(), buf, 10);
-    #else
-    snprintf(buf, 128, "%li", this->GetValue());
-    #endif
+        str += std::string(buf);
+        str += "</Value>";
+    }
 
-    str += std::string(buf) + "</Value>";
-
     str += "</" + rootElmName + ">";
 }
 

Modified: trunk/MgDev/Common/PlatformBase/Data/Int64Property.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Data/Int64Property.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Data/Int64Property.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -112,13 +112,16 @@
         str += "<Type>int64</Type>";
     }
 
-    str += "<Value>";
+    if (!this->IsNull())
+    {
+        str += "<Value>";
+        std::string tmp = "";
+        MgUtil::Int64ToString(this->GetValue(), tmp);
 
-    std::string tmp = "";
-    MgUtil::Int64ToString(this->GetValue(), tmp);
+        str += tmp; 
+        str += "</Value>";
+    }
 
-    str += tmp + "</Value>";
-
     str += "</" + rootElmName + ">";
 }
 

Modified: trunk/MgDev/Common/PlatformBase/Data/SingleProperty.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Data/SingleProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Data/SingleProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -125,7 +125,12 @@
     string singleStr = "";
     MgUtil::DoubleToString(m_value, singleStr);
 
-    str += "<Value>" + singleStr + "</Value>";
+    if (!this->IsNull())
+    {
+        str += "<Value>";
+        str += singleStr;
+        str += "</Value>";
+    }
 
     str += "</" + rootElmName + ">";
 }

Modified: trunk/MgDev/Common/PlatformBase/Services/FeatureProperty.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/FeatureProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Services/FeatureProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -114,23 +114,26 @@
     {
         str += "<Type>feature</Type>";
     }
-    str += "<Value>";
 
-    std::string featureXml;
+    if (!this->IsNull())
+    {
+        str += "<Value>";
+        std::string featureXml;
 
-    Ptr<MgByteReader> reader = m_value->ToXml();
-    MgByteSink sink(reader);
-    sink.ToStringUtf8(featureXml);
+        Ptr<MgByteReader> reader = m_value->ToXml();
+        MgByteSink sink(reader);
+        sink.ToStringUtf8(featureXml);
 
-    size_t idx = featureXml.find("?>");
-    if (idx >= 0)
-    {
-        featureXml = featureXml.substr(idx+2);
+        size_t idx = featureXml.find("?>");
+        if (idx >= 0)
+        {
+            featureXml = featureXml.substr(idx+2);
+        }
+
+        str += featureXml;
+        str += "</Value>";
     }
 
-    str += featureXml;
-    str += "</Value>";
-
     str += "</" + rootElmName + ">";
 }
 

Modified: trunk/MgDev/Common/PlatformBase/Services/GeometryProperty.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/GeometryProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Services/GeometryProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -118,31 +118,43 @@
     {
         str += "<Type>geometry</Type>";
     }
-    str += "<Value>";
 
-    Ptr<MgByteReader> byteReader = this->GetValue();
-
-    if (byteReader != NULL)
+    if (!this->IsNull())
     {
-        MgAgfReaderWriter agfReader;
-        Ptr<MgGeometry> geom = agfReader.Read(byteReader);
+        string valueXml = "";
+        try 
+        {
+            valueXml += "<Value>";
+            Ptr<MgByteReader> byteReader = this->GetValue();
 
-        // geom->ToXml(str); // TODO: we need this method
-        STRING awktStr = L"";
-        if (geom != NULL)
-        {
-            awktStr = geom->ToAwkt(false);
-            assert(!awktStr.empty());
+            if (byteReader != NULL)
+            {
+                MgAgfReaderWriter agfReader;
+                Ptr<MgGeometry> geom = agfReader.Read(byteReader);
+
+                // geom->ToXml(str); // TODO: we need this method
+                STRING awktStr = L"";
+                if (geom != NULL)
+                {
+                    awktStr = geom->ToAwkt(false);
+                    assert(!awktStr.empty());
+                }
+
+                if (!awktStr.empty())
+                {
+                    valueXml += MgUtil::WideCharToMultiByte(awktStr);
+                }
+            }
+            valueXml += "</Value>";
         }
-
-        if (!awktStr.empty())
+        catch(MgException* ex) //Can happen if the geometry is invalid
         {
-            str += MgUtil::WideCharToMultiByte(awktStr);
+            SAFE_RELEASE(ex);
+            valueXml = ""; //Treat an invalid geometry as a NULL geometry
         }
+        str += valueXml;
     }
 
-    str += "</Value>";
-
     str += "</" + rootElmName + ">";
 }
 

Modified: trunk/MgDev/Common/PlatformBase/Services/RasterProperty.cpp
===================================================================
--- trunk/MgDev/Common/PlatformBase/Services/RasterProperty.cpp	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/PlatformBase/Services/RasterProperty.cpp	2010-06-10 22:53:45 UTC (rev 4939)
@@ -126,9 +126,14 @@
     {
         str += "<Type>raster</Type>";
     }
-    str += "<Value>";
-//  Ptr<MgByteReader> reader = this->GetValue();
-    str += /* MgUtil::GetStringFromReader(reader) +*/  "</Value></Property>";
+
+    if (!this->IsNull())
+    {
+        str += "<Value>";
+    //  Ptr<MgByteReader> reader = this->GetValue();
+        str += /* MgUtil::GetStringFromReader(reader) +*/ "</Value>";
+    }
+    str += "</Property>";
 }
 
 //////////////////////////////////////////////////////////////////

Modified: trunk/MgDev/Common/Schema/BatchPropertyCollection-1.0.0.xsd
===================================================================
--- trunk/MgDev/Common/Schema/BatchPropertyCollection-1.0.0.xsd	2010-06-09 03:36:20 UTC (rev 4938)
+++ trunk/MgDev/Common/Schema/BatchPropertyCollection-1.0.0.xsd	2010-06-10 22:53:45 UTC (rev 4939)
@@ -17,7 +17,7 @@
                   <xs:sequence>
                     <xs:element name="Name" type="xs:string"/>
                     <xs:element name="Type" type="xs:string"/>
-                    <xs:element name="Value" type="xs:string"/>
+                    <xs:element name="Value" type="xs:string" minOccurs="0" maxOccurs="1" />
                   </xs:sequence>
                 </xs:complexType>
               </xs:element>



More information about the mapguide-commits mailing list