[fdo-commits] r666 - in trunk/Utilities: SchemaMgr/Src/Sm/Lp TestCommon/Inc

svn_fdo at osgeo.org svn_fdo at osgeo.org
Wed Jan 24 17:12:58 EST 2007


Author: danstoica
Date: 2007-01-24 17:12:58 -0500 (Wed, 24 Jan 2007)
New Revision: 666

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

Modified: trunk/Utilities/SchemaMgr/Src/Sm/Lp/SchemaCollection.cpp
===================================================================
--- trunk/Utilities/SchemaMgr/Src/Sm/Lp/SchemaCollection.cpp	2007-01-24 21:58:41 UTC (rev 665)
+++ trunk/Utilities/SchemaMgr/Src/Sm/Lp/SchemaCollection.cpp	2007-01-24 22:12:58 UTC (rev 666)
@@ -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: trunk/Utilities/TestCommon/Inc/TestCommonConstraints.h
===================================================================
--- trunk/Utilities/TestCommon/Inc/TestCommonConstraints.h	2007-01-24 21:58:41 UTC (rev 665)
+++ trunk/Utilities/TestCommon/Inc/TestCommonConstraints.h	2007-01-24 22:12:58 UTC (rev 666)
@@ -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