[fdo-commits] r665 - in branches/3.2.x/Utilities: SchemaMgr/Src/Sm/Lp TestCommon/Inc

svn_fdo at osgeo.org svn_fdo at osgeo.org
Wed Jan 24 16:58:42 EST 2007


Author: danstoica
Date: 2007-01-24 16:58:41 -0500 (Wed, 24 Jan 2007)
New Revision: 665

Modified:
   branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Lp/SchemaCollection.cpp
   branches/3.2.x/Utilities/TestCommon/Inc/TestCommonConstraints.h
Log:
Date constraints described as strings fix


Modified: branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Lp/SchemaCollection.cpp
===================================================================
--- branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Lp/SchemaCollection.cpp	2007-01-24 21:40:31 UTC (rev 664)
+++ branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Lp/SchemaCollection.cpp	2007-01-24 21:58:41 UTC (rev 665)
@@ -925,7 +925,7 @@
 	FdoPtr<FdoDataValue>	ret = val;
 
 	// Fast return if nothing to do
-	if ( val == NULL || propType == FdoDataType_DateTime )
+	if ( val == NULL )
 		return ret;
 
 	FdoDataType	constrType = val->GetDataType();
@@ -1023,6 +1023,39 @@
 
             break;
 
+		case FdoDataType_String:
+
+            switch (propType) {
+            case FdoDataType_DateTime:
+				{
+					newData = val;	// In case the conversion fail, return the same.
+
+					FdoStringP	valString = ((FdoStringValue*)(FdoDataValue*)val)->GetString();
+					const char	*timeStr = (const char *)valString;
+
+					if( timeStr != NULL && *timeStr != '\0' )
+					{
+						char		*fmt = valString.Contains(L":") ? "%4d-%02d-%02d %02d:%02d:%02d" : "%4d-%02d-%02d-%02d-%02d-%02d";
+						int			year, month, day, hour, minute, seconds;
+
+						year = month = day = hour = minute = seconds = 0;
+
+						int count = sscanf(timeStr, fmt, &year, &month, &day, &hour, &minute, &seconds);     
+
+						// Check the number of successfully read items
+						if ( count >= 3 )
+							newData = FdoDateTimeValue::Create(FdoDateTime((FdoInt16)year, (FdoInt8)month, (FdoInt8)day, 
+																		  (FdoInt8)hour, (FdoInt8)minute, (float)seconds));
+					}
+				}
+				break;
+			// Other cases...
+
+			default:
+				;
+			}
+
+			break;
         }
 
         ret = newData;

Modified: branches/3.2.x/Utilities/TestCommon/Inc/TestCommonConstraints.h
===================================================================
--- branches/3.2.x/Utilities/TestCommon/Inc/TestCommonConstraints.h	2007-01-24 21:40:31 UTC (rev 664)
+++ branches/3.2.x/Utilities/TestCommon/Inc/TestCommonConstraints.h	2007-01-24 21:58:41 UTC (rev 665)
@@ -202,20 +202,18 @@
 		    FdoPtr<FdoDataValue>	val = pList->GetItem(j);
 		    bool					valMatched = false;
 
-            // Some providers' DescribeSchema implementations set the constraint
-            // values for date properties to string. Temporarily skip this check
-            // for these providers until this bug is fixed. 
-            if ( val->GetDataType() == FdoDataType_DateTime ) {
-                for ( int k = 0; k < masterCount && !valMatched; k++ ) {
-			        valMatched = ( wcscmp(val->ToString(), pMaster[k]) == 0 );
-		        }	
+            if ( val->GetDataType() != FdoDataType_DateTime ) 
+                CPPUNIT_ASSERT_MESSAGE( "Wrong type for datetime constraint returned", false);
 
-                CPPUNIT_ASSERT_MESSAGE( 
-                    (const char*) FdoStringP::Format( L"Wrong List Value %ls", pPropName ),
-                    valMatched
-                );
-            }
+            for ( int k = 0; k < masterCount && !valMatched; k++ ) {
+		        valMatched = ( wcscmp(val->ToString(), pMaster[k]) == 0 );
+	        }	
 
+            CPPUNIT_ASSERT_MESSAGE( 
+                (const char*) FdoStringP::Format( L"Wrong List Value %ls", pPropName ),
+                valMatched
+            );
+
 		    DBG(printf("%ls,", val->ToString()));
 	    }
 	    DBG(printf("))\n"));



More information about the fdo-commits mailing list