[fdo-commits] r95 - trunk/Providers/WFS/Src/Provider

svn_fdo at osgeo.org svn_fdo at osgeo.org
Wed Jan 24 17:15:27 EST 2007


Author: romicadascalescu
Date: 2007-01-24 17:15:27 -0500 (Wed, 24 Jan 2007)
New Revision: 95

Modified:
   trunk/Providers/WFS/Src/Provider/FdoWfsDelegate.cpp
   trunk/Providers/WFS/Src/Provider/FdoWfsDelegate.h
   trunk/Providers/WFS/Src/Provider/FdoWfsGetFeature.cpp
   trunk/Providers/WFS/Src/Provider/FdoWfsGetFeature.h
   trunk/Providers/WFS/Src/Provider/FdoWfsSelectCommand.cpp
Log:
WFS: Request fails if schema name prefix is not included in request

Modified: trunk/Providers/WFS/Src/Provider/FdoWfsDelegate.cpp
===================================================================
--- trunk/Providers/WFS/Src/Provider/FdoWfsDelegate.cpp	2007-01-24 22:14:59 UTC (rev 94)
+++ trunk/Providers/WFS/Src/Provider/FdoWfsDelegate.cpp	2007-01-24 22:15:27 UTC (rev 95)
@@ -81,23 +81,54 @@
                                               FdoString* srsName,
                                               FdoStringCollection* propertiesToSelect,
                                               FdoString* from,
-                                              FdoFilter* where)
+                                              FdoFilter* where,
+                                              FdoString* schemaName)
 {
     FdoPtr<FdoWfsGetFeature> request = FdoWfsGetFeature::Create(targetNamespace, 
                                                                 srsName, 
                                                                 propertiesToSelect, 
                                                                 from, 
-                                                                where);
+                                                                where,
+                                                                schemaName);
     FdoPtr<FdoOwsResponse> response;
+    FdoException* exc1 = NULL;
     try
     {
         response = Invoke(request);
     }
     catch(FdoException* exc) // some servers request to have the class name in the front of properties, so we will try to place them
     {
-        exc->Release();
+        exc1 = exc;
         request->EncodeWithClassName(true);
-        response = Invoke(request); // if second time we will get an exception then is something wrong.
+        try
+        {
+            response = Invoke(request);
+        }
+        catch(FdoException* exc2) // rare cases
+        {
+            exc2->Release();
+            request->SetSchemaName(L""); // remove schema name
+            request->EncodeWithClassName(false);
+            try
+            {
+                response = Invoke(request);
+            }
+            catch(FdoException* exc3)
+            {
+                exc3->Release();
+                request->EncodeWithClassName(true);
+                try
+                {
+                    response = Invoke(request);
+                }
+                catch(FdoException* exc4)
+                {
+                    exc4->Release();
+                    throw exc1;
+                }
+            }
+        }
+        exc1->Release();
     }
     FdoPtr<FdoIoStream> stream = response->GetStream();
 

Modified: trunk/Providers/WFS/Src/Provider/FdoWfsDelegate.h
===================================================================
--- trunk/Providers/WFS/Src/Provider/FdoWfsDelegate.h	2007-01-24 22:14:59 UTC (rev 94)
+++ trunk/Providers/WFS/Src/Provider/FdoWfsDelegate.h	2007-01-24 22:15:27 UTC (rev 95)
@@ -44,7 +44,8 @@
                                     FdoString* targetNamespace, FdoString* srsName,
                                     FdoStringCollection* propertiesToSelect,
                                     FdoString* from,
-                                    FdoFilter* where);
+                                    FdoFilter* where,
+                                    FdoString* schemaName);
 
 };
 

Modified: trunk/Providers/WFS/Src/Provider/FdoWfsGetFeature.cpp
===================================================================
--- trunk/Providers/WFS/Src/Provider/FdoWfsGetFeature.cpp	2007-01-24 22:14:59 UTC (rev 94)
+++ trunk/Providers/WFS/Src/Provider/FdoWfsGetFeature.cpp	2007-01-24 22:15:27 UTC (rev 95)
@@ -25,12 +25,13 @@
 //#define DEBUG_LIMIT_FEATURES
 
 FdoWfsGetFeature::FdoWfsGetFeature(FdoString* targetNamespace, FdoString* srsName, 
-                                   FdoStringCollection* propertiesToSelect,
+                                    FdoStringCollection* propertiesToSelect,
                                     FdoString* from,
-                                    FdoFilter* where) : FdoOwsRequest(FdoWfsGlobals::WFS, FdoWfsGlobals::GetFeature),
+                                    FdoFilter* where,
+                                    FdoString* schemaName) : FdoOwsRequest(FdoWfsGlobals::WFS, FdoWfsGlobals::GetFeature),
                                     m_targetNamespace(targetNamespace), m_srsName(srsName),
                                     m_propertiesToSelect(propertiesToSelect),
-                                    m_from(from), m_where(where)
+                                    m_from(from), m_where(where), m_schemaName(schemaName)
 {
     m_encodeWithClassName = false;
     SetVersion(FdoWfsGlobals::WfsVersion);
@@ -43,10 +44,9 @@
 }
 
 FdoWfsGetFeature* FdoWfsGetFeature::Create(FdoString* targetNamespace, FdoString* srsName, FdoStringCollection* propertiesToSelect,
-                            FdoString* from,
-                            FdoFilter* where)
+                            FdoString* from, FdoFilter* where, FdoString* schemaName)
 {
-    return new FdoWfsGetFeature(targetNamespace, srsName, propertiesToSelect, from, where);
+    return new FdoWfsGetFeature(targetNamespace, srsName, propertiesToSelect, from, where, schemaName);
 }
 
 FdoStringP FdoWfsGetFeature::EncodeKVP()
@@ -63,7 +63,10 @@
     ret += FdoWfsGlobals::And;
     ret += FdoWfsGlobals::TYPENAME;
     ret += FdoWfsGlobals::Equal;
-    ret += m_from;
+    if (m_schemaName.GetLength() != 0)
+        ret += m_schemaName + L":" + m_from;
+    else
+        ret += m_from;
     // PROPERTYNAME, optional
     FdoInt32 numProps = 0;
     if (m_propertiesToSelect != NULL)

Modified: trunk/Providers/WFS/Src/Provider/FdoWfsGetFeature.h
===================================================================
--- trunk/Providers/WFS/Src/Provider/FdoWfsGetFeature.h	2007-01-24 22:14:59 UTC (rev 94)
+++ trunk/Providers/WFS/Src/Provider/FdoWfsGetFeature.h	2007-01-24 22:15:27 UTC (rev 95)
@@ -33,13 +33,15 @@
     FdoStringP m_targetNamespace;
     FdoStringP m_srsName;
     bool m_encodeWithClassName;
+    FdoStringP m_schemaName;
 
 protected:
     FdoWfsGetFeature() {};
     FdoWfsGetFeature(FdoString* targetNamespace, FdoString* srsName,
                                 FdoStringCollection* propertiesToSelect,
                                 FdoString* from,
-                                FdoFilter* where);
+                                FdoFilter* where,
+                                FdoString* schemaName);
     virtual ~FdoWfsGetFeature();
     virtual void Dispose() { delete this; }
 
@@ -47,12 +49,14 @@
     static FdoWfsGetFeature* Create(FdoString* targetNamespace, FdoString* srsName,
                                 FdoStringCollection* propertiesToSelect,
                                 FdoString* from,
-                                FdoFilter* where);
+                                FdoFilter* where,
+                                FdoString* schemaName);
 
     virtual FdoStringP EncodeKVP();
     virtual FdoStringP EncodeXml();
 
     virtual void EncodeWithClassName(bool bVal) {m_encodeWithClassName = bVal;};
+    virtual void SetSchemaName(FdoStringP schemaName) {m_schemaName = schemaName;}
 };
 
 typedef FdoPtr<FdoWfsGetFeature> FdoWfsGetFeatureP;

Modified: trunk/Providers/WFS/Src/Provider/FdoWfsSelectCommand.cpp
===================================================================
--- trunk/Providers/WFS/Src/Provider/FdoWfsSelectCommand.cpp	2007-01-24 22:14:59 UTC (rev 94)
+++ trunk/Providers/WFS/Src/Provider/FdoWfsSelectCommand.cpp	2007-01-24 22:15:27 UTC (rev 95)
@@ -100,6 +100,7 @@
 	// that is , FDO class name --> GML global element name
 	// and that global element name actually represents the valid WFS feature type
 	// that is recognized by WFS servers.
+	FdoString* schemaFeatureName = NULL;
 	FdoString* featureTypeName = NULL;
 	FdoString* targetNamespace = L"";
 	FdoPtr<FdoFeatureSchemaCollection> schemas = mConnection->GetSchemas();
@@ -123,6 +124,7 @@
 						    // we found it
                             elementClass = elementMapping->GetClassMapping();
 						    featureTypeName = elementMapping->GetName();
+                            schemaFeatureName = schema->GetName();
 						    targetNamespace = mapping->GetTargetNamespace();
 						    break;
 					    }
@@ -138,31 +140,15 @@
 	// and at the same time find out the srs name that this feature type uses
 	FdoString* srsName = L"EPSG:4326";
 	if (featureTypeName != NULL) {
-		FdoPtr<FdoWfsServiceMetadata> metadata = mConnection->GetServiceMetadata();
-		FdoPtr<FdoWfsFeatureTypeList> typeList = metadata->GetFeatureTypeList();
-		FdoPtr<FdoWfsFeatureTypeCollection> types = typeList->GetFeatureTypes();
-		FdoInt32 count = types->GetCount();
-        std::wstring lhs = featureTypeName;
-		for (int i = 0; i < count; i++)
-        {
-			FdoPtr<FdoWfsFeatureType> featureType = types->GetItem(i);
-            std::wstring rhs = featureType->GetName();
-            std::wstring::size_type idxSep = rhs.find(L':');
-            bool foundit = false;
-            if (idxSep != std::wstring::npos){
-                std::wstring::size_type szComp = rhs.size() - (idxSep+1);
-                if(lhs.size() == szComp && !rhs.compare(idxSep+1, szComp < lhs.size() ? lhs.size() : szComp, lhs))
-                    foundit = true;
-            }
-            else {
-                if (rhs == featureTypeName)
-                    foundit = true;
-            }
-            if (foundit){
-			    srsName = featureType->GetSRS();
-                break;
-            }
-		}
+        FdoPtr<FdoWfsServiceMetadata> metadata = mConnection->GetServiceMetadata();
+        FdoPtr<FdoWfsFeatureTypeList> typeList = metadata->GetFeatureTypeList();
+        FdoPtr<FdoWfsFeatureTypeCollection> featTypes = typeList->GetFeatureTypes();
+        FdoPtr<FdoWfsFeatureType> featureType = featTypes->FindItem (mClassName->GetName());
+        if (featureType == NULL) {
+            featureType = featTypes->FindItem (mClassName->GetText());
+            if (featureType != NULL)
+            srsName = featureType->GetSRS();
+        }
 	}
 
 	if (featureTypeName == NULL || srsName == NULL) { // no match found
@@ -253,7 +239,7 @@
 
 	// yeah, all the parameters that WfsDeleget::GetFeature needs are ready
 	FdoPtr<FdoWfsDelegate> delegate = mConnection->GetWfsDelegate();
-	FdoPtr<FdoIFeatureReader> ret = delegate->GetFeature(schemas, mappings, targetNamespace, srsName, props, featureTypeName, mFilter);	
+	FdoPtr<FdoIFeatureReader> ret = delegate->GetFeature(schemas, mappings, targetNamespace, srsName, props, featureTypeName, mFilter, schemaFeatureName);
 
 	FdoWfsFeatureReader* reader = dynamic_cast<FdoWfsFeatureReader *>(ret.p);
 	if (reader)



More information about the fdo-commits mailing list