[mapguide-commits] r6075 - trunk/MgDev/Server/src/Services/Feature
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Tue Aug 16 02:39:36 EDT 2011
Author: hubu
Date: 2011-08-15 23:39:36 -0700 (Mon, 15 Aug 2011)
New Revision: 6075
Modified:
trunk/MgDev/Server/src/Services/Feature/FeatureDistribution.cpp
trunk/MgDev/Server/src/Services/Feature/FeatureGeometricFunctions.cpp
trunk/MgDev/Server/src/Services/Feature/FeatureNumericFunctions.cpp
trunk/MgDev/Server/src/Services/Feature/FeatureStringFunctions.cpp
Log:
Submit on behalf of Spark Liu: Fix for ticket 1782 - Customized function such as "EXTENT" can't be run on SQL Server Spatial
When coming to customized function such as "EXTENT", MapGuide server will try to calculate by itself instead of using FDO provider. So it will request the actual property instead of the expression into FDO. When getting properties from reader, it first check if the return column number is only 1, and use the first column as return column.
However, there is no guarantee in FDO interface that the return reader only contains the requesting column. For example, SQL Server spatial adds PK column as well, and many code may have been written depending on that.
So to make the code robust, if there are more than one columns returned, we should parse the expression when we gets the reader and only use the column we need.
The fix only happens when the original codes fail, so it will not affect original logic.
Modified: trunk/MgDev/Server/src/Services/Feature/FeatureDistribution.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/FeatureDistribution.cpp 2011-08-16 03:31:11 UTC (rev 6074)
+++ trunk/MgDev/Server/src/Services/Feature/FeatureDistribution.cpp 2011-08-16 06:39:36 UTC (rev 6075)
@@ -41,10 +41,33 @@
MgFeatureDistribution* MgFeatureDistribution::CreateDistributionFunction(MgReader* reader, FdoFunction* customFunction, CREFSTRING propertyAlias)
{
STRING propName;
-
Ptr<MgFeatureDistribution> featDist;
- INT32 propType = MgServerFeatureUtil::GetPropertyDefinition(reader, propName);
+ INT32 propType;
+ if(1 == reader->GetPropertyCount())
+ {
+ propType = MgServerFeatureUtil::GetPropertyDefinition(reader, propName);
+ }
+ else
+ {
+ // Only get the property needed
+ FdoPtr<FdoExpressionCollection> exprCol = customFunction->GetArguments();
+ FdoInt32 cnt = exprCol->GetCount();
+ FdoPtr<FdoExpression> expr;
+ if(cnt == 1)
+ {
+ expr = exprCol->GetItem(0);
+ FdoIdentifier* propIdentifier = dynamic_cast<FdoIdentifier*>(expr.p);
+ CHECKNULL(propIdentifier, L"MgFeatureDistribution.CreateDistributionFunction");
+ propName = propIdentifier->GetName();
+ propType = reader->GetPropertyType(propName);
+ }
+ else
+ {
+ // Throw original exception
+ propType = MgServerFeatureUtil::GetPropertyDefinition(reader, propName);
+ }
+ }
switch(propType)
{
Modified: trunk/MgDev/Server/src/Services/Feature/FeatureGeometricFunctions.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/FeatureGeometricFunctions.cpp 2011-08-16 03:31:11 UTC (rev 6074)
+++ trunk/MgDev/Server/src/Services/Feature/FeatureGeometricFunctions.cpp 2011-08-16 06:39:36 UTC (rev 6075)
@@ -41,10 +41,33 @@
void MgFeatureGeometricFunctions::Initialize(MgReader* reader, FdoFunction* customFunction, CREFSTRING propertyAlias)
{
- CHECKNULL((MgReader*)reader, L"MgFeatureDistribution.Initialize");
- CHECKNULL((FdoFunction*)customFunction, L"MgFeatureDistribution.Initialize");
+ CHECKNULL((MgReader*)reader, L"MgFeatureGeometricFunctions.Initialize");
+ CHECKNULL((FdoFunction*)customFunction, L"MgFeatureGeometricFunctions.Initialize");
- m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName);
+ if(1 == reader->GetPropertyCount())
+ {
+ m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName);
+ }
+ else
+ {
+ // Only get the property needed
+ FdoPtr<FdoExpressionCollection> exprCol = customFunction->GetArguments();
+ FdoInt32 cnt = exprCol->GetCount();
+ FdoPtr<FdoExpression> expr;
+ if(cnt == 1)
+ {
+ expr = exprCol->GetItem(0);
+ FdoIdentifier* propName = dynamic_cast<FdoIdentifier*>(expr.p);
+ CHECKNULL(propName, L"MgFeatureGeometricFunctions.Initialize");
+ m_propertyName = propName->GetName();
+ m_type = reader->GetPropertyType(m_propertyName);
+ }
+ else
+ {
+ // Throw original exception
+ m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName);
+ }
+ }
// TODO: Should we really check this, may be we can ignore ??
// because we can only come to here if property type is numeric
Modified: trunk/MgDev/Server/src/Services/Feature/FeatureNumericFunctions.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/FeatureNumericFunctions.cpp 2011-08-16 03:31:11 UTC (rev 6074)
+++ trunk/MgDev/Server/src/Services/Feature/FeatureNumericFunctions.cpp 2011-08-16 06:39:36 UTC (rev 6075)
@@ -50,10 +50,33 @@
void MgFeatureNumericFunctions::Initialize(MgReader* reader, FdoFunction* customFunction, CREFSTRING propertyAlias)
{
- CHECKNULL((MgReader*)reader, L"MgFeatureDistribution.Initialize");
- CHECKNULL((FdoFunction*)customFunction, L"MgFeatureDistribution.Initialize");
+ CHECKNULL((MgReader*)reader, L"MgFeatureNumericFunctions.Initialize");
+ CHECKNULL((FdoFunction*)customFunction, L"MgFeatureNumericFunctions.Initialize");
- m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName);
+ if(1 == reader->GetPropertyCount())
+ {
+ m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName);
+ }
+ else
+ {
+ // Only get the property needed
+ FdoPtr<FdoExpressionCollection> exprCol = customFunction->GetArguments();
+ FdoInt32 cnt = exprCol->GetCount();
+ FdoPtr<FdoExpression> expr;
+ if(cnt == 1)
+ {
+ expr = exprCol->GetItem(0);
+ FdoIdentifier* propName = dynamic_cast<FdoIdentifier*>(expr.p);
+ CHECKNULL(propName, L"MgFeatureNumericFunctions.Initialize");
+ m_propertyName = propName->GetName();
+ m_type = reader->GetPropertyType(m_propertyName);
+ }
+ else
+ {
+ // Throw original exception
+ m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName);
+ }
+ }
// TODO: Should we really check this, may be we can ignore ??
// because we can only come to here if property type is numeric
Modified: trunk/MgDev/Server/src/Services/Feature/FeatureStringFunctions.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/FeatureStringFunctions.cpp 2011-08-16 03:31:11 UTC (rev 6074)
+++ trunk/MgDev/Server/src/Services/Feature/FeatureStringFunctions.cpp 2011-08-16 06:39:36 UTC (rev 6075)
@@ -39,10 +39,33 @@
void MgFeatureStringFunctions::Initialize(MgReader* reader, FdoFunction* customFunction, CREFSTRING propertyAlias)
{
- CHECKNULL((MgReader*)reader, L"MgFeatureDistribution.Initialize");
- CHECKNULL((FdoFunction*)customFunction, L"MgFeatureDistribution.Initialize");
+ CHECKNULL((MgReader*)reader, L"MgFeatureStringFunctions.Initialize");
+ CHECKNULL((FdoFunction*)customFunction, L"MgFeatureStringFunctions.Initialize");
- m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName);
+ if(1 == reader->GetPropertyCount())
+ {
+ m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName);
+ }
+ else
+ {
+ // Only get the property needed
+ FdoPtr<FdoExpressionCollection> exprCol = customFunction->GetArguments();
+ FdoInt32 cnt = exprCol->GetCount();
+ FdoPtr<FdoExpression> expr;
+ if(cnt == 1)
+ {
+ expr = exprCol->GetItem(0);
+ FdoIdentifier* propName = dynamic_cast<FdoIdentifier*>(expr.p);
+ CHECKNULL(propName, L"MgFeatureStringFunctions.Initialize");
+ m_propertyName = propName->GetName();
+ m_type = reader->GetPropertyType(m_propertyName);
+ }
+ else
+ {
+ // Throw original exception
+ m_type = MgServerFeatureUtil::GetPropertyDefinition(reader, m_propertyName);
+ }
+ }
// TODO: Should we really check this, may be we can ignore ??
// because we can only come to here if property type is numeric
More information about the mapguide-commits
mailing list