[fdo-commits] r193 - in branches/3.2.x/Providers/SDF/Src: Message Provider

svn_fdo at osgeo.org svn_fdo at osgeo.org
Mon Jan 22 12:47:53 EST 2007


Author: badreddinekaroui
Date: 2007-01-22 12:47:53 -0500 (Mon, 22 Jan 2007)
New Revision: 193

Modified:
   branches/3.2.x/Providers/SDF/Src/Message/SDFMessage.mc
   branches/3.2.x/Providers/SDF/Src/Provider/SdfDelete.cpp
   branches/3.2.x/Providers/SDF/Src/Provider/SdfInsert.cpp
   branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp
   branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.h
   branches/3.2.x/Providers/SDF/Src/Provider/SdfSelect.cpp
   branches/3.2.x/Providers/SDF/Src/Provider/SdfUpdate.cpp
Log:
This update fixes 3 issues:
1- The SDF provider filter capability does not does not advertise that it supports the spatial inside, this code change throws an exception if the inside operator is used.
2- A dynamic cast failed on Linux and caused a Rtree based filter optimization to be skipped. This change replaces the dynamic cast with a hard cast and explicit FDO type checking. i.e it the Fdo object type is as expected, we use hard cast.
3- The SDF filter is not being validated at execution time and exception of not found property are being thrown when accessing the reader. A new validator is added and called by select,update and delete when the execute method is called. Also added a better message for the case of a class not found.

Modified: branches/3.2.x/Providers/SDF/Src/Message/SDFMessage.mc
===================================================================
--- branches/3.2.x/Providers/SDF/Src/Message/SDFMessage.mc	2007-01-18 15:46:12 UTC (rev 192)
+++ branches/3.2.x/Providers/SDF/Src/Message/SDFMessage.mc	2007-01-22 17:47:53 UTC (rev 193)
@@ -1,5 +1,5 @@
 ;//
-;//Copyright (C) 2004-2006  Autodesk, Inc.
+;//Copyright (C) 2004-2007  Autodesk, Inc.
 ;//
 ;//This library is free software; you can redistribute it and/or
 ;//modify it under the terms of version 2.1 of the GNU Lesser
@@ -486,3 +486,13 @@
 Language=English
 Schema is not set - cannot set the class name.
 .
+MessageId=97
+SymbolicName=SDFPROVIDER_97_PROPERTY_NOTFOUND
+Language=English
+Property '%1$ls' is not found in class '%2$ls'.
+.
+MessageId=98
+SymbolicName=SDFPROVIDER_98_SPATIAL_OP_NOTSUPPORTED
+Language=English
+Spatial operation not supported
+.

Modified: branches/3.2.x/Providers/SDF/Src/Provider/SdfDelete.cpp
===================================================================
--- branches/3.2.x/Providers/SDF/Src/Provider/SdfDelete.cpp	2007-01-18 15:46:12 UTC (rev 192)
+++ branches/3.2.x/Providers/SDF/Src/Provider/SdfDelete.cpp	2007-01-22 17:47:53 UTC (rev 193)
@@ -1,6 +1,6 @@
 // 
 //  
-//  Copyright (C) 2004-2006  Autodesk, Inc.
+//  Copyright (C) 2004-2007  Autodesk, Inc.
 //  
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -70,7 +70,11 @@
 
     //get feature class
     FdoPtr<FdoClassDefinition> clas = FdoPtr<FdoClassCollection>(
-        m_connection->GetSchema()->GetClasses())->GetItem(m_className->GetName());
+        m_connection->GetSchema()->GetClasses())->FindItem(m_className->GetName());
+    if( clas == NULL )
+        throw FdoException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_75_CLASS_NOTFOUND), m_className->GetName()));
+    if( m_filter != NULL )
+        SdfQueryOptimizer::ValidateFilter( clas, m_filter );
 
 	m_connection->FlushAll( clas, true );
 

Modified: branches/3.2.x/Providers/SDF/Src/Provider/SdfInsert.cpp
===================================================================
--- branches/3.2.x/Providers/SDF/Src/Provider/SdfInsert.cpp	2007-01-18 15:46:12 UTC (rev 192)
+++ branches/3.2.x/Providers/SDF/Src/Provider/SdfInsert.cpp	2007-01-22 17:47:53 UTC (rev 193)
@@ -1,6 +1,6 @@
 // 
 //  
-//  Copyright (C) 2004-2006  Autodesk, Inc.
+//  Copyright (C) 2004-2007  Autodesk, Inc.
 //  
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -168,7 +168,9 @@
 
     FdoPtr<FdoClassCollection> classes = schema->GetClasses();
 
-    FdoPtr<FdoClassDefinition> clas = classes->GetItem(m_ClassName->GetName());
+    FdoPtr<FdoClassDefinition> clas = classes->FindItem(m_ClassName->GetName());
+    if( clas == NULL )
+        throw FdoException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_75_CLASS_NOTFOUND), m_ClassName->GetName()));
 
 	if( clas->GetIsAbstract() )
 		throw FdoCommandException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_71_ABSTRACT_CLASS)));

Modified: branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp
===================================================================
--- branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp	2007-01-18 15:46:12 UTC (rev 192)
+++ branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.cpp	2007-01-22 17:47:53 UTC (rev 193)
@@ -1,6 +1,6 @@
 // 
 //  
-//  Copyright (C) 2004-2006  Autodesk, Inc.
+//  Copyright (C) 2004-2007  Autodesk, Inc.
 //  
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -281,20 +281,18 @@
     //information to get a particular feature record number out of the 
     //identity property collection
     m_retvals.push_back(NULL);
-
+ 
     if (filter.GetOperation() != FdoComparisonOperations_EqualTo)
         return;
 
     FdoPtr<FdoExpression> left = filter.GetLeftExpression();
     FdoPtr<FdoExpression> right = filter.GetRightExpression();
-
     
     //This could be optimized by a struct similar to the
     //PropertyIndex used for the full property collection
     FdoIdentifier* ident = dynamic_cast<FdoIdentifier*>(left.p);
     FdoDataValue* val = dynamic_cast<FdoDataValue*>(right.p);
 
-
     if (ident && val)
     {
         //look for the identifier in the ID property collection
@@ -330,7 +328,7 @@
     //pushing NULL on return stack means no features are excluded for this 
     //condition
     m_retvals.push_back(NULL);
-
+    
 }
 
 void SdfQueryOptimizer::ProcessNullCondition(FdoNullCondition& filter)
@@ -341,6 +339,7 @@
     //pushing NULL on return stack means no features are excluded for this 
     //condition
     m_retvals.push_back(NULL);
+
 }
 
 void SdfQueryOptimizer::ProcessSpatialCondition(FdoSpatialCondition& filter)
@@ -479,12 +478,18 @@
                             filter.GetPropertyName(), filter.GetOperation(), gv));
                     }
                 }
-                break;
+                break;                
+
             default:
                 m_filters.push_back(FDO_SAFE_ADDREF(&filter));
                 break;
             }
         }
+        else if ( filter.GetOperation() == FdoSpatialOperations_Inside )
+        {
+            // The capability says so and can't change the capability yet! It's actually supported by the common code
+            throw FdoCommandException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_98_SPATIAL_OP_NOTSUPPORTED)));
+        }
         else
         {
             //pushing NULL on return stack means no features are spatially excluded for this 
@@ -656,7 +661,9 @@
     //TODO
     //Check if all this is fast with the new faster FDO geometry
 
-    FdoIPolygon* box = dynamic_cast<FdoIPolygon*>(fgfgeom.p);
+    FdoIPolygon* box = NULL;
+    if( fgfgeom->GetDerivedType() == FdoGeometryType_Polygon )
+        box = (FdoIPolygon*)(fgfgeom.p);
 
     //it has to be a polygon
     if (box == NULL)
@@ -833,3 +840,144 @@
     return false;
 }
 
+
+void SdfQueryOptimizer::ValidateFilter( FdoClassDefinition *cls, FdoFilter *filter )
+{
+    class SdfFilterValidator : public virtual FdoIExpressionProcessor, public virtual FdoIFilterProcessor
+    {
+    private:
+        FdoClassDefinition* m_class;
+
+    protected:
+
+        void HandleExpr( FdoExpression *exp )
+        {
+            exp->Process( this );
+        }
+        void HandleFilter( FdoFilter *filter )
+        {
+            filter->Process( this );
+        }
+    public:
+
+        SdfFilterValidator( FdoClassDefinition *cls )
+        {
+            m_class = cls;
+        }
+
+        virtual void Dispose() { delete this; }
+
+         /// <summary>Increase the reference count.</summary>
+        /// <returns>Returns the new reference count (value for debugging use only).</returns>
+        FdoInt32 AddRef()
+        {
+            // NOTE: due to multiple inheritance, there is an ambiguity in which AddRef() method to call.
+            //  Calling BOTH AddRef() methods leads to instances of this class being prematurely released.
+            return FdoIFilterProcessor::AddRef();
+        }
+
+        /// <summary>Decrease the reference count.</summary>
+        /// <returns>Returns the new reference count (value for debugging use only).</returns>
+        FdoInt32 Release ()
+        {
+            // NOTE: due to multiple inheritance, there is an ambiguity in which Release() method to call.
+            //  Calling BOTH Release() methods leads to instances of this class being prematurely released.
+            return FdoIFilterProcessor::Release();
+        }
+
+        virtual void ProcessBinaryExpression(FdoBinaryExpression& expr)
+        {
+            HandleExpr( FdoPtr<FdoExpression>(expr.GetLeftExpression()) );
+            HandleExpr( FdoPtr<FdoExpression>(expr.GetRightExpression()) );
+        }
+        virtual void ProcessBooleanValue(FdoBooleanValue& expr) {  }
+        virtual void ProcessByteValue(FdoByteValue& expr){   }
+        virtual void ProcessDateTimeValue(FdoDateTimeValue& expr){   }
+        virtual void ProcessDoubleValue(FdoDoubleValue& expr){   }
+        virtual void ProcessDecimalValue(FdoDecimalValue& expr){   }
+        virtual void ProcessInt16Value(FdoInt16Value& expr){  }
+        virtual void ProcessInt32Value(FdoInt32Value& expr){  }
+        virtual void ProcessInt64Value(FdoInt64Value& expr){  }
+        virtual void ProcessSingleValue(FdoSingleValue& expr){  }
+        virtual void ProcessStringValue(FdoStringValue& expr){  }
+        virtual void ProcessBLOBValue(FdoBLOBValue& expr){   }
+        virtual void ProcessCLOBValue(FdoCLOBValue& expr){  }
+        virtual void ProcessFunction(FdoFunction& expr)
+        {
+            FdoPtr<FdoExpressionCollection>col = expr.GetArguments();
+            for(int i=0; i<col->GetCount(); i++)
+                HandleExpr( FdoPtr<FdoExpression>(col->GetItem( i ) ) );
+        }
+        virtual void ProcessGeometryValue(FdoGeometryValue& expr){  }
+        virtual void ProcessParameter(FdoParameter& expr){  }
+        virtual void ProcessUnaryExpression(FdoUnaryExpression& expr)
+        {
+            HandleExpr( FdoPtr<FdoExpression>(expr.GetExpression()) );
+        }
+        virtual void ProcessBinaryLogicalOperator(FdoBinaryLogicalOperator& filter)
+        {
+            HandleFilter( FdoPtr<FdoFilter>(filter.GetLeftOperand()) );
+            HandleFilter( FdoPtr<FdoFilter>(filter.GetRightOperand()) );
+        }
+        virtual void ProcessComparisonCondition(FdoComparisonCondition& filter)
+        {
+            HandleExpr( FdoPtr<FdoExpression>(filter.GetLeftExpression()) );
+            HandleExpr( FdoPtr<FdoExpression>(filter.GetRightExpression()) );
+        }
+        virtual void ProcessDistanceCondition(FdoDistanceCondition& filter){  }
+
+        virtual void ProcessInCondition(FdoInCondition& filter)
+        {
+            ProcessIdentifier( *(FdoPtr<FdoIdentifier>(filter.GetPropertyName())) );
+        }
+        virtual void ProcessNullCondition(FdoNullCondition& filter)
+        {
+            ProcessIdentifier( *(FdoPtr<FdoIdentifier>(filter.GetPropertyName())) );
+        }
+        virtual void ProcessSpatialCondition(FdoSpatialCondition& filter){  }
+
+        virtual void ProcessUnaryLogicalOperator(FdoUnaryLogicalOperator& filter)
+        {
+            HandleFilter( FdoPtr<FdoFilter>(filter.GetOperand()) );
+        }
+
+        virtual void ProcessIdentifier(FdoIdentifier& expr)
+        {
+             // This is used to validate the property names referenced in the filter.
+            FdoPtr<FdoPropertyDefinitionCollection>props = m_class->GetProperties();
+            FdoPtr<FdoReadOnlyPropertyDefinitionCollection>basePops = m_class->GetBaseProperties();
+            FdoPtr<FdoPropertyDefinition> prop;
+
+            int length;
+            // If any of the identifiers is a decorated name of the form <obj proper>.<property>, then this is
+            // an association or object proeperty; assume it exist for now.
+            if( expr.GetScope( length ) && length > 0 )
+                return;
+
+            prop = props->FindItem( expr.GetName() );
+            if( prop != NULL )
+                return;
+
+            try
+            {
+                prop = basePops->GetItem( expr.GetName() );
+                if( prop != NULL )
+                    return;
+            }
+            catch(FdoException *exp )
+            {
+                exp->Release();
+            }
+
+            throw FdoException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_97_PROPERTY_NOTFOUND), expr.GetName(), m_class->GetName() ));
+        }
+
+        virtual void ProcessComputedIdentifier(FdoComputedIdentifier& expr)
+        {
+            HandleExpr( FdoPtr<FdoExpression>(expr.GetExpression()) );
+        }
+    };
+
+    SdfFilterValidator  validator(cls);
+    filter->Process( &validator ); 
+}

Modified: branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.h
===================================================================
--- branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.h	2007-01-18 15:46:12 UTC (rev 192)
+++ branches/3.2.x/Providers/SDF/Src/Provider/SdfQueryOptimizer.h	2007-01-22 17:47:53 UTC (rev 193)
@@ -1,5 +1,5 @@
 // 
-//  Copyright (C) 2004-2006  Autodesk, Inc.
+//  Copyright (C) 2004-2007  Autodesk, Inc.
 //  
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -117,6 +117,7 @@
 
     SDF_API virtual void ProcessGeometryValue(FdoGeometryValue& expr);
 
+    static void ValidateFilter( FdoClassDefinition *cls, FdoFilter *filter );
 
 public:
 

Modified: branches/3.2.x/Providers/SDF/Src/Provider/SdfSelect.cpp
===================================================================
--- branches/3.2.x/Providers/SDF/Src/Provider/SdfSelect.cpp	2007-01-18 15:46:12 UTC (rev 192)
+++ branches/3.2.x/Providers/SDF/Src/Provider/SdfSelect.cpp	2007-01-22 17:47:53 UTC (rev 193)
@@ -1,6 +1,6 @@
 // 
 //  
-//  Copyright (C) 2004-2006  Autodesk, Inc.
+//  Copyright (C) 2004-2007  Autodesk, Inc.
 //  
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -112,7 +112,12 @@
 
     //get feature class
     FdoPtr<FdoClassDefinition> clas = FdoPtr<FdoClassCollection>(
-        m_connection->GetSchema()->GetClasses())->GetItem(m_className->GetName());
+        m_connection->GetSchema()->GetClasses())->FindItem(m_className->GetName());
+    if( clas == NULL )
+        throw FdoException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_75_CLASS_NOTFOUND), m_className->GetName()));
+    
+    if( m_filter != NULL )
+        SdfQueryOptimizer::ValidateFilter( clas, m_filter );
 
     //get the R-Tree for this feature class... 
     SdfRTree* rt = m_connection->GetRTree(clas);

Modified: branches/3.2.x/Providers/SDF/Src/Provider/SdfUpdate.cpp
===================================================================
--- branches/3.2.x/Providers/SDF/Src/Provider/SdfUpdate.cpp	2007-01-18 15:46:12 UTC (rev 192)
+++ branches/3.2.x/Providers/SDF/Src/Provider/SdfUpdate.cpp	2007-01-22 17:47:53 UTC (rev 193)
@@ -1,6 +1,6 @@
 // 
 //  
-//  Copyright (C) 2004-2006  Autodesk, Inc.
+//  Copyright (C) 2004-2007  Autodesk, Inc.
 //  
 //  This library is free software; you can redistribute it and/or
 //  modify it under the terms of version 2.1 of the GNU Lesser
@@ -80,8 +80,13 @@
             
     //get feature class
     FdoPtr<FdoClassDefinition> clas = FdoPtr<FdoClassCollection>(
-        m_connection->GetSchema()->GetClasses())->GetItem(m_className->GetName());
+        m_connection->GetSchema()->GetClasses())->FindItem(m_className->GetName());
+    if( clas == NULL )
+        throw FdoException::Create(NlsMsgGetMain(FDO_NLSID(SDFPROVIDER_75_CLASS_NOTFOUND), m_className->GetName()));
 
+    if( m_filter != NULL )
+        SdfQueryOptimizer::ValidateFilter( clas, m_filter );
+
 	m_connection->FlushAll( clas, true );
 
     



More information about the fdo-commits mailing list