[fdo-commits] r2623 - in trunk/Providers/GenericRdbms/Src: ODBC/SchemaMgr ODBC/SchemaMgr/Ph ODBC/SchemaMgr/Ph/Rd UnitTest/Odbc

svn_fdo at osgeo.org svn_fdo at osgeo.org
Fri Mar 2 17:35:23 EST 2007


Author: gavincramer
Date: 2007-03-02 17:35:23 -0500 (Fri, 02 Mar 2007)
New Revision: 2623

Added:
   trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/OraBaseObjectReader.cpp
   trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/OraBaseObjectReader.h
Modified:
   trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/OdbcSchemaMgr.vcproj
   trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/DbObject.cpp
   trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/DbObject.h
   trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Owner.cpp
   trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Owner.h
   trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/Makefile.am
   trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp
   trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp
   trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.h
Log:
Ticket #24: ODBC: Support base table fetching of Views for Oracle

Modified: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/OdbcSchemaMgr.vcproj
===================================================================
--- trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/OdbcSchemaMgr.vcproj	2007-03-02 21:39:23 UTC (rev 2622)
+++ trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/OdbcSchemaMgr.vcproj	2007-03-02 22:35:23 UTC (rev 2623)
@@ -340,6 +340,14 @@
 						>
 					</File>
 					<File
+						RelativePath=".\Ph\Rd\OraBaseObjectReader.cpp"
+						>
+					</File>
+					<File
+						RelativePath=".\Ph\Rd\OraBaseObjectReader.h"
+						>
+					</File>
+					<File
 						RelativePath=".\Ph\Rd\OraColumnReader.cpp"
 						>
 					</File>

Modified: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/DbObject.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/DbObject.cpp	2007-03-02 21:39:23 UTC (rev 2622)
+++ trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/DbObject.cpp	2007-03-02 22:35:23 UTC (rev 2623)
@@ -22,6 +22,7 @@
 #include "Rd/ColumnReader.h"
 #include "Rd/OraColumnReader.h"
 #include "Rd/DbObjectReader.h"
+#include "Rd/OraBaseObjectReader.h"
 #include "Sm/Ph/Rd/DbObjectReader.h"
 #include "Rd/PkeyReader.h"
 #include "ColumnChar.h"
@@ -267,6 +268,25 @@
         return new FdoSmPhRdOdbcColumnReader( GetManager(), FDO_SAFE_ADDREF(this) );
 }
 
+FdoPtr<FdoSmPhRdBaseObjectReader> FdoSmPhOdbcDbObject::CreateBaseObjectReader() const
+{
+    // Need to case away constness of 'this' to get correct version of GetManager.
+    FdoSmPhOdbcMgrP mgr = ((FdoSmPhOdbcDbObject *)this)->GetManager()->SmartCast<FdoSmPhOdbcMgr>();
+    rdbi_vndr_info_def info;
+	rdbi_vndr_info( mgr->GetRdbiContext(), &info );
+
+    if( info.dbversion == RDBI_DBVERSION_ODBC_ORACLE )
+    {
+        FdoSmPhOdbcDbObject* pDbObject = (FdoSmPhOdbcDbObject*) this;
+
+        return new FdoSmPhRdOdbcOraBaseObjectReader( FDO_SAFE_ADDREF(pDbObject) );
+    }
+    else
+    {
+        return (FdoSmPhRdBaseObjectReader*) NULL;
+    }
+}
+
 FdoPtr<FdoSmPhRdPkeyReader> FdoSmPhOdbcDbObject::CreatePkeyReader() const
 {
     FdoSmPhOdbcDbObject* pDbObject = (FdoSmPhOdbcDbObject*) this;

Modified: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/DbObject.h
===================================================================
--- trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/DbObject.h	2007-03-02 21:39:23 UTC (rev 2622)
+++ trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/DbObject.h	2007-03-02 22:35:23 UTC (rev 2623)
@@ -20,6 +20,7 @@
 
 #include <Sm/Ph/DbObject.h>
 #include <Sm/Ph/Rd/ColumnReader.h>
+#include <Sm/Ph/Rd/BaseObjectReader.h>
 
 // Odbc Provider implementation of a Database object.
 class FdoSmPhOdbcDbObject : virtual public FdoSmPhDbObject
@@ -180,6 +181,8 @@
     // Column reader creator implementation.
     virtual FdoPtr<FdoSmPhRdColumnReader> CreateColumnReader();
 
+    virtual FdoPtr<FdoSmPhRdBaseObjectReader> CreateBaseObjectReader() const;
+
     virtual FdoPtr<FdoSmPhRdPkeyReader> CreatePkeyReader() const;
 
 protected:

Modified: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Owner.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Owner.cpp	2007-03-02 21:39:23 UTC (rev 2622)
+++ trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Owner.cpp	2007-03-02 22:35:23 UTC (rev 2623)
@@ -23,6 +23,7 @@
 #include "Mgr.h"
 #include "Rd/DbObjectReader.h"
 #include "Rd/OraDbObjectReader.h"
+#include "Rd/OraBaseObjectReader.h"
 #include "Rd/OraPkeyReader.h"
 #include "Rd/ConstraintReader.h"
 #include "Inc/Rdbi/proto.h"
@@ -95,6 +96,20 @@
        return new FdoSmPhRdOdbcDbObjectReader( FDO_SAFE_ADDREF(pOwner), dbObject );
 }
 
+FdoPtr<FdoSmPhRdBaseObjectReader> FdoSmPhOdbcOwner::CreateBaseObjectReader() const
+{
+    FdoSmPhOdbcOwner* pOwner = (FdoSmPhOdbcOwner*) this;
+    FdoSmPhOdbcMgrP mgr = pOwner->GetManager()->SmartCast<FdoSmPhOdbcMgr>();
+    rdbi_vndr_info_def info;
+	rdbi_vndr_info( mgr->GetRdbiContext(), &info );
+    
+    // The Oracle primary key reader use bulk load to load all the primary keys.
+    if( info.dbversion == RDBI_DBVERSION_ODBC_ORACLE )
+        return new FdoSmPhRdOdbcOraBaseObjectReader( FDO_SAFE_ADDREF(pOwner) );
+    else
+        return (FdoSmPhRdBaseObjectReader *)NULL;
+}
+
 FdoPtr<FdoSmPhRdPkeyReader> FdoSmPhOdbcOwner::CreatePkeyReader() const
 {
     FdoSmPhOdbcOwner* pOwner = (FdoSmPhOdbcOwner*) this;
@@ -247,6 +262,7 @@
 												GetName());
 	return (FdoString*) schemaCond;
 }
+
 void FdoSmPhOdbcOwner::CreateMetaClass()
 {
 	FdoSmPhOdbcMgrP mgr = GetManager()->SmartCast<FdoSmPhOdbcMgr>();

Modified: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Owner.h
===================================================================
--- trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Owner.h	2007-03-02 21:39:23 UTC (rev 2622)
+++ trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Owner.h	2007-03-02 22:35:23 UTC (rev 2623)
@@ -20,6 +20,7 @@
 
 #include "../../../SchemaMgr/Ph/Owner.h"
 #include <Sm/Ph/Rd/DbObjectReader.h>
+#include <Sm/Ph/Rd/BaseObjectReader.h>
 #include <Sm/Ph/Rd/ConstraintReader.h>
 
 // Odbc Provider implementation of an Owner.
@@ -55,6 +56,8 @@
 
 	virtual FdoPtr<FdoSmPhRdConstraintReader> CreateConstraintReader( FdoStringP tableName, FdoStringP constraintType) const;
 
+    virtual FdoPtr<FdoSmPhRdBaseObjectReader> CreateBaseObjectReader() const;
+
     virtual FdoPtr<FdoSmPhRdPkeyReader> CreatePkeyReader() const;
 
    	void SetOptions();

Modified: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/Makefile.am
===================================================================
--- trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/Makefile.am	2007-03-02 21:39:23 UTC (rev 2622)
+++ trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/Makefile.am	2007-03-02 22:35:23 UTC (rev 2623)
@@ -23,6 +23,7 @@
 ColumnReader.cpp \
 ConstraintReader.cpp \
 DbObjectReader.cpp \
+OraBaseObjectReader.cpp \
 FkeyReader.cpp \
 IndexReader.cpp \
 OraColumnReader.cpp \
@@ -36,6 +37,7 @@
   ColumnReader.h \
   ConstraintReader.h \
   DbObjectReader.h \
+  OraBaseObjectReader.h \
   FkeyReader.h \
   IndexReader.h \
   OraColumnReader.h \

Added: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/OraBaseObjectReader.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/OraBaseObjectReader.cpp	                        (rev 0)
+++ trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/OraBaseObjectReader.cpp	2007-03-02 22:35:23 UTC (rev 2623)
@@ -0,0 +1,178 @@
+/*
+ * (C) Copyright 2007 by Autodesk, Inc. All Rights Reserved.
+ *
+ * By using this code, you are agreeing to the terms and conditions of
+ * the License Agreement included in the documentation for this code.
+ *
+ * AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE
+ * CORRECTNESS OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE
+ * IT. AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY
+ * DISCLAIMS ANY LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL
+ * DAMAGES FOR ERRORS, OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
+ *
+ * Use, duplication, or disclosure by the U.S. Government is subject
+ * to restrictions set forth in FAR 52.227-19 (Commercial Computer
+ * Software Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+ * (Rights in Technical Data and Computer Software), as applicable.
+ *
+ */
+
+#include "stdafx.h"
+#include "OraBaseObjectReader.h"
+#include "../../../../SchemaMgr/Ph/Rd/QueryReader.h"
+#include "../Mgr.h"
+#include "../Database.h"
+#include "../Owner.h"
+#include <Sm/Ph/Rd/DbObjectBinds.h>
+
+FdoSmPhRdOdbcOraBaseObjectReader::FdoSmPhRdOdbcOraBaseObjectReader(
+    FdoSmPhOwnerP owner
+) :
+    FdoSmPhRdBaseObjectReader((FdoSmPhReader*) NULL, owner)
+{
+    FdoStringsP objectNames = FdoStringCollection::Create();
+    SetSubReader(MakeQueryReader(owner,objectNames));
+}
+
+FdoSmPhRdOdbcOraBaseObjectReader::FdoSmPhRdOdbcOraBaseObjectReader(
+    FdoSmPhDbObjectP    dbObject
+) :
+    FdoSmPhRdBaseObjectReader((FdoSmPhReader*) NULL, dbObject)
+{
+    FdoSmPhOwnerP owner = FDO_SAFE_ADDREF((FdoSmPhOwner*)(FdoSmPhDbElement*)dbObject->GetParent());
+    FdoStringsP objectNames = FdoStringCollection::Create();
+    objectNames->Add(dbObject->GetName());
+    SetSubReader(MakeQueryReader(owner,objectNames));
+}
+
+FdoSmPhRdOdbcOraBaseObjectReader::FdoSmPhRdOdbcOraBaseObjectReader(
+    FdoSmPhOwnerP owner,
+    FdoStringsP objectNames
+) :
+    FdoSmPhRdBaseObjectReader((FdoSmPhReader*) NULL, owner)
+{
+    SetSubReader(MakeQueryReader(owner,objectNames));
+}
+
+FdoSmPhRdOdbcOraBaseObjectReader::FdoSmPhRdOdbcOraBaseObjectReader(
+    FdoSmPhOwnerP owner,
+    FdoSmPhRdTableJoinP join
+) :
+    FdoSmPhRdBaseObjectReader((FdoSmPhReader*) NULL, owner)
+{
+    FdoStringsP objectNames = FdoStringCollection::Create();
+    SetSubReader(MakeQueryReader(owner,objectNames,join));
+}
+
+FdoSmPhRdOdbcOraBaseObjectReader::~FdoSmPhRdOdbcOraBaseObjectReader(void)
+{
+	EndSelect();
+}
+
+FdoSmPhReaderP FdoSmPhRdOdbcOraBaseObjectReader::MakeQueryReader(
+    FdoSmPhOwnerP owner,
+    FdoStringsP objectNames,
+    FdoSmPhRdTableJoinP join
+)
+{
+    bool                 dblink_set = true;
+    FdoStringP           sqlString;
+    FdoStringP           owmViewString;
+    FdoStringP           ownerName = owner->GetName();
+    FdoStringP           dblinkName = owner->GetParent()->GetName();
+    FdoSmPhMgrP          mgr = owner->GetManager();
+	bool				 object_set = objectNames->GetCount() > 0;
+
+    if (dblinkName.GetLength() == 0 )
+        dblink_set = false;
+
+	FdoStringP readerName = L"OdbcOraBaseObjectReader";
+    // Differentiate reader name based on Multiple Objects (MO) versus Single Objects (SO).
+    // Different names will be used for reader pooling when calling SetStaticReader().
+	if ( object_set )
+		readerName += FdoStringP::Format(L"_%ls", (objectNames->GetCount() > 1) ? L"MO" : L"SO");
+
+	if ( dblinkName.GetLength() > 0 )
+		readerName += FdoStringP::Format(L"_%ls", (FdoString*)dblinkName );
+
+    FdoSmPhReaderP reader = mgr->GetStaticReader ( readerName );
+
+    if ( !reader ) {
+        // Create binds for owner and optional object names
+
+        FdoSmPhRdDbObjectBindsP binds = new FdoSmPhRdDbObjectBinds(
+            mgr,
+            L"D.owner",
+            L"owner_name",
+            L"D.name",
+            L"name",
+            ownerName,
+            objectNames
+        );
+
+
+        // Generate sql statement if not already done
+
+        // If joining to another table, generated from sub-clause for table.
+        FdoStringP joinFrom;
+        if ( join != NULL ) 
+            joinFrom = FdoStringP::Format( L"  , %ls\n", (FdoString*) join->GetFrom() );
+
+        // Get where clause for owner and object name binds.
+        FdoStringP qualification = binds->GetSQL();
+		
+        if ( join != NULL ) {
+            // If joining to another table, add generated join clause.
+            qualification += FdoStringP::Format( L"  and (%ls)\n", (FdoString*) join->GetWhere(L"O.object_name") );
+        }
+
+        sqlString = FdoStringP::Format(
+              L"select %ls D.name, D.referenced_name as base_name,\n"
+              L" D.referenced_owner as base_owner, D.referenced_link_name as base_database\n"
+              L" from all_dependencies%ls%ls D\n"
+              L"%ls"
+              L" where\n"
+              L" %ls"
+              L" and D.type in('TABLE', 'VIEW', 'SYNONYM')\n"
+              L" and D.referenced_type in('TABLE', 'VIEW', 'SYNONYM')\n"
+              L" order by D.name asc",
+               join ? L"distinct" : L"",
+               dblink_set ? L"@" : L"",
+               dblink_set ? (FdoString*) dblinkName : L"",
+               (FdoString*) joinFrom,
+               (FdoString*) qualification
+        );
+
+        FdoSmPhRowsP rows = MakeRows( mgr );
+        FdoSmPhRowP row = rows->GetItem(0);
+
+        reader = new FdoSmPhRdGrdQueryReader(row, sqlString, mgr, binds->GetBinds() );
+
+		if (reader && !join)
+			mgr->SetStaticReader ( readerName, reader );
+    }
+    else {
+        // Re-executing so update bind variables first.
+        FdoSmPhRdGrdQueryReader* pReader = (FdoSmPhRdGrdQueryReader*)(FdoSmPhReader*) reader;
+		pReader->EndSelect();
+
+		FdoSmPhRowP bindRows = pReader->GetBinds();
+		if ( bindRows )
+			FdoSmPhRdDbObjectBindsP binds = new FdoSmPhRdDbObjectBinds(
+				mgr,
+                L"D.owner",
+                L"owner_name",
+                L"D.name",
+                L"name",
+                ownerName,
+                objectNames,
+				bindRows,
+				true
+			);
+
+        pReader->Execute();
+    }
+
+    return reader;
+}
+


Property changes on: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/OraBaseObjectReader.cpp
___________________________________________________________________
Name: svn:eol-style
   + native

Added: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/OraBaseObjectReader.h
===================================================================
--- trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/OraBaseObjectReader.h	                        (rev 0)
+++ trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/OraBaseObjectReader.h	2007-03-02 22:35:23 UTC (rev 2623)
@@ -0,0 +1,79 @@
+#ifndef FDOSMPHRDODBCORABASEOBJECTREADER_H
+#define FDOSMPHRDODBCORABASEOBJECTREADER_H        1
+/*
+ * (C) Copyright 2007 by Autodesk, Inc. All Rights Reserved.
+ *
+ * By using this code, you are agreeing to the terms and conditions of
+ * the License Agreement included in the documentation for this code.
+ *
+ * AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE
+ * CORRECTNESS OF THIS CODE OR ANY DERIVATIVE WORKS WHICH INCORPORATE
+ * IT. AUTODESK PROVIDES THE CODE ON AN "AS-IS" BASIS AND EXPLICITLY
+ * DISCLAIMS ANY LIABILITY, INCLUDING CONSEQUENTIAL AND INCIDENTAL
+ * DAMAGES FOR ERRORS, OMISSIONS, AND OTHER PROBLEMS IN THE CODE.
+ *
+ * Use, duplication, or disclosure by the U.S. Government is subject
+ * to restrictions set forth in FAR 52.227-19 (Commercial Computer
+ * Software Restricted Rights) and DFAR 252.227-7013(c)(1)(ii)
+ * (Rights in Technical Data and Computer Software), as applicable.
+ *
+ */
+#include <Sm/Ph/Rd/BaseObjectReader.h>
+#include <Sm/Ph/Rd/TableJoin.h>
+
+// This class is used by the Physical Schema object to query the
+// database for schema information.
+//
+// To perform the query, the caller creates this object with a
+// GQL statement, which is parsed and executed. The caller then
+// can call ReadNext() to get each row returned by the query and
+// the various Get functions to get the row data.
+//
+// The query is initially positioned before the first row, so
+// ReadNext must be called before data can be retrieved.
+
+class FdoSmPhRdOdbcOraBaseObjectReader : public FdoSmPhRdBaseObjectReader
+{
+public:
+    // Create and execute a query
+    //
+    // Parameters:
+    //      sStatement: GQL statement to execute
+    //      physicalSchema: holds the connection for the Danube database to query.
+    FdoSmPhRdOdbcOraBaseObjectReader(
+        FdoSmPhOwnerP owner
+    );
+
+    FdoSmPhRdOdbcOraBaseObjectReader(
+        FdoSmPhDbObjectP    dbObject
+    );
+
+    FdoSmPhRdOdbcOraBaseObjectReader(
+        FdoSmPhOwnerP owner,
+        FdoStringsP objectNames
+    );
+
+    FdoSmPhRdOdbcOraBaseObjectReader(
+        FdoSmPhOwnerP owner,
+        FdoSmPhRdTableJoinP join
+    );
+
+    // Deactivates the query.
+    ~FdoSmPhRdOdbcOraBaseObjectReader(void);
+
+protected:
+    // unused constructor needed only to build on Linux
+    FdoSmPhRdOdbcOraBaseObjectReader() {}
+
+    FdoSmPhReaderP MakeQueryReader(
+        FdoSmPhOwnerP owner,
+        FdoStringsP objectNames,
+        FdoSmPhRdTableJoinP join = (FdoSmPhRdTableJoin*) NULL
+    );
+
+private:
+};
+
+typedef FdoPtr<FdoSmPhRdOdbcOraBaseObjectReader> FdoSmPhRdOdbcOraBaseObjectReaderP;
+
+#endif


Property changes on: trunk/Providers/GenericRdbms/Src/ODBC/SchemaMgr/Ph/Rd/OraBaseObjectReader.h
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp	2007-03-02 21:39:23 UTC (rev 2622)
+++ trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcBaseSetup.cpp	2007-03-02 22:35:23 UTC (rev 2623)
@@ -272,6 +272,8 @@
 	L"( featid1, name, x, y )",
 	L" values ",
 	L"( 2, 'His''Name', 20, 25 );",
+    L""
+    L"create view view1 ( featid1, name, x, y ) as select featid1, name, x, y from table1", 
     L"",
     NULL
 };
@@ -312,6 +314,8 @@
 	L"( featid1, name, x, y )",
 	L" values ",
 	L"( 2, 'His''Name', 20, 25 );",
+    L""
+    L"create view view1 ( featid1, name, x, y ) as select featid1, name, x, y from table1", 
     L"",
     NULL
 };

Modified: trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp
===================================================================
--- trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp	2007-03-02 21:39:23 UTC (rev 2622)
+++ trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.cpp	2007-03-02 22:35:23 UTC (rev 2623)
@@ -168,9 +168,16 @@
                 {
                     FdoPtr<FdoDataPropertyDefinition> idPropDef = idPropDefs->GetItem(i);
                     printf("    Found identity property '%ls'.\n", idPropDef->GetName());
+                    CPPUNIT_ASSERT_MESSAGE("Expected identity property named FEATID1", 0==wcscmp(L"FEATID1", idPropDef->GetName()));
                 }
                 printf("  Found total %d identity properties.\n", numIdProps);
-                CPPUNIT_ASSERT_MESSAGE("Expected no identity properties", 0==numIdProps);
+#ifdef _WIN32
+                CPPUNIT_ASSERT_MESSAGE("Expected 1 identity property", 1==numIdProps);
+#else
+                // Cannot currently use Oracle metadata views from Easysoft driver.
+                // TODO: revisit with Oracle native driver on Linux.
+                CPPUNIT_ASSERT_MESSAGE("Expected 0 identity properties", 0==numIdProps);
+#endif
             }
 
             // read through all the features
@@ -235,8 +242,108 @@
     }
 }
 
+void OdbcMySqlFdoSelectTest::View1Test()
+{
+    if( mConnection != NULL )
+    {
+        try
+        {
+            FdoPtr<FdoISelect> selectCmd = (FdoISelect*)mConnection->CreateCommand(FdoCommandType_Select);
+
+            selectCmd->SetFeatureClassName(L"view1");
+
+            FdoPtr<FdoIFeatureReader> reader = selectCmd->Execute();
+
+            FdoPtr<FdoClassDefinition> classDef = reader->GetClassDefinition();
+            CPPUNIT_ASSERT_MESSAGE("Class should not have IsComputed=true", !classDef->GetIsComputed());
+            FdoFeatureSchemaP pSchema =  classDef->GetFeatureSchema(); 
+            FdoPtr<FdoDataPropertyDefinitionCollection> idPropDefs = classDef->GetIdentityProperties();
+            FdoInt32 numIdProps = 0;
+            if (idPropDefs != NULL)
+            {
+                numIdProps = idPropDefs->GetCount();
+                for (FdoInt32 i=0;  i < numIdProps;  i++)
+                {
+                    FdoPtr<FdoDataPropertyDefinition> idPropDef = idPropDefs->GetItem(i);
+                    printf("    Found identity property '%ls'.\n", idPropDef->GetName());
+                    CPPUNIT_ASSERT_MESSAGE("Expected identity property named featid1", 0==wcscmp(L"featid1", idPropDef->GetName()));
+                }
+                printf("  Found total %d identity properties.\n", numIdProps);
+                CPPUNIT_ASSERT_MESSAGE("Expected 1 identity property", 1==numIdProps);
+            }
+
+            // read through all the features
+            int numFeatures = 0;
+            while (reader->ReadNext())
+            {
+                numFeatures++;
+                UnitTestUtil::ProcessFeature(reader);
+            }
+
+            printf("   %i feature(s) read\n", numFeatures);
+
+            // close the reader
+            reader->Close();
+        }
+        catch (FdoException* e)
+        {
+            TestCommonFail (e);
+        }
+    }
+}
+
 #ifdef _WIN32
 
+void OdbcSqlServerFdoSelectTest::View1Test()
+{
+    if( mConnection != NULL )
+    {
+        try
+        {
+            FdoPtr<FdoISelect> selectCmd = (FdoISelect*)mConnection->CreateCommand(FdoCommandType_Select);
+
+            selectCmd->SetFeatureClassName(L"view1");
+
+            FdoPtr<FdoIFeatureReader> reader = selectCmd->Execute();
+
+            FdoPtr<FdoClassDefinition> classDef = reader->GetClassDefinition();
+            CPPUNIT_ASSERT_MESSAGE("Class should not have IsComputed=true", !classDef->GetIsComputed());
+            FdoFeatureSchemaP pSchema =  classDef->GetFeatureSchema(); 
+            FdoPtr<FdoDataPropertyDefinitionCollection> idPropDefs = classDef->GetIdentityProperties();
+            FdoInt32 numIdProps = 0;
+            if (idPropDefs != NULL)
+            {
+                numIdProps = idPropDefs->GetCount();
+                for (FdoInt32 i=0;  i < numIdProps;  i++)
+                {
+                    FdoPtr<FdoDataPropertyDefinition> idPropDef = idPropDefs->GetItem(i);
+                    printf("    Found identity property '%ls'.\n", idPropDef->GetName());
+                    CPPUNIT_ASSERT_MESSAGE("Expected identity property named featid1", 0==wcscmp(L"featid1", idPropDef->GetName()));
+                }
+                printf("  Found total %d identity properties.\n", numIdProps);
+                CPPUNIT_ASSERT_MESSAGE("Expected 1 identity property", 1==numIdProps);
+            }
+
+            // read through all the features
+            int numFeatures = 0;
+            while (reader->ReadNext())
+            {
+                numFeatures++;
+                UnitTestUtil::ProcessFeature(reader);
+            }
+
+            printf("   %i feature(s) read\n", numFeatures);
+
+            // close the reader
+            reader->Close();
+        }
+        catch (FdoException* e)
+        {
+            TestCommonFail (e);
+        }
+    }
+}
+
 void OdbcAccessFdoSelectTest::Table1Test()
 {
     if( mConnection != NULL )

Modified: trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.h
===================================================================
--- trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.h	2007-03-02 21:39:23 UTC (rev 2622)
+++ trunk/Providers/GenericRdbms/Src/UnitTest/Odbc/OdbcFdoSelectTest.h	2007-03-02 22:35:23 UTC (rev 2623)
@@ -94,6 +94,7 @@
 {
     CPPUNIT_TEST_SUB_SUITE (OdbcMySqlFdoSelectTest, OdbcFdoSelectTest);
     CPPUNIT_TEST (ConfigFileTest);
+    CPPUNIT_TEST (View1Test);
     CPPUNIT_TEST_SUITE_END ();
 
 public:
@@ -113,12 +114,15 @@
     virtual void _secondComputedIdTest() {
         TestCommonFeatureCommands::secondComputedIdTest(mConnection, L"acdb3dpolyline", L"featid");
     }
+
+    virtual void View1Test();
 };
 
 #ifdef _WIN32
 class OdbcSqlServerFdoSelectTest : public OdbcFdoSelectTest
 {
     CPPUNIT_TEST_SUB_SUITE (OdbcSqlServerFdoSelectTest, OdbcFdoSelectTest);
+    CPPUNIT_TEST (View1Test);
     CPPUNIT_TEST_SUITE_END ();
 
     virtual void concurrent_select() {};    // Need to set up "testClass" class to run this.
@@ -134,6 +138,8 @@
         TestCommonFeatureCommands::secondComputedIdTest(mConnection, L"acdb3dpolyline", L"featid");
     }
     virtual int numPropertiesInPolylineClass() { return 17; };
+
+    virtual void View1Test();
 };
 
 class OdbcAccessFdoSelectTest : public OdbcFdoSelectTest



More information about the fdo-commits mailing list