[fdo-commits] r642 - trunk/Utilities/SchemaMgr/Src/Sm/Lp

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


Author: barbarazoladek
Date: 2007-01-22 12:45:12 -0500 (Mon, 22 Jan 2007)
New Revision: 642

Modified:
   trunk/Utilities/SchemaMgr/Src/Sm/Lp/DataPropertyDefinition.cpp
Log:
column not set to autoincrement in non-feature class

Modified: trunk/Utilities/SchemaMgr/Src/Sm/Lp/DataPropertyDefinition.cpp
===================================================================
--- trunk/Utilities/SchemaMgr/Src/Sm/Lp/DataPropertyDefinition.cpp	2007-01-19 21:57:49 UTC (rev 641)
+++ trunk/Utilities/SchemaMgr/Src/Sm/Lp/DataPropertyDefinition.cpp	2007-01-22 17:45:12 UTC (rev 642)
@@ -18,6 +18,7 @@
 
 #include "stdafx.h"
 #include <Sm/Lp/ClassDefinition.h>
+#include <Sm/Lp/ObjectPropertyClass.h>
 #include <Sm/Lp/DataPropertyDefinition.h>
 #include <Sm/Lp/DataTypeMapper.h>
 #include <Sm/Lp/Schema.h>
@@ -424,7 +425,42 @@
 )
 {
     FdoSmPhColumnP column;
+	bool featClass = false;
+	FdoSmLpClassDefinition* parentClass = (FdoSmLpClassDefinition*)(RefParentClass());
 
+	if (parentClass && parentClass->GetClassType() == FdoClassType_FeatureClass)
+		featClass = true;
+
+	// check for object property class
+	const FdoSmLpObjectPropertyClass *objectPropertyClass = dynamic_cast<const FdoSmLpObjectPropertyClass *> (parentClass);
+	
+	if (objectPropertyClass)
+		featClass = true;
+
+	if (GetIsAutoGenerated() && !featClass)
+	{
+		// Check if there is already column defined as autoincrement.
+		// If there is one, the new one cannot be set as autoincerement.
+		FdoSmPhColumnsP pColumns = dbObject->GetColumns();
+		bool found = false;
+		for (int i=0; i<pColumns->GetCount() && !found; i++)
+		{
+			FdoSmPhColumnP pColumn = pColumns->GetItem(i);
+			if (pColumn->GetAutoincrement() == true)
+			{
+				mIsAutoGenerated = false;
+				found = true;
+			}
+		}			
+	}
+	// TO DO: Auto-generated column must be not NUll, 
+	// but the below fix does not aways work.
+	/*if (GetIsAutoGenerated() && nullable)
+	{
+		nullable = false;
+		SetNullable(nullable);
+	}*/
+
     // Create the appropriate physical column type based on the FDO data type.
 	switch ( GetDataType() ) {
 	case FdoDataType_Boolean:
@@ -481,7 +517,7 @@
 		column = dbObject->CreateColumnInt16(
             columnName,
             nullable,
-			GetIsAutoGenerated() && GetIsFeatId(),
+			featClass ? (GetIsAutoGenerated() && GetIsFeatId()) : GetIsAutoGenerated(),
             rootColumnName
         );
 		break;
@@ -490,7 +526,7 @@
 		column = dbObject->CreateColumnInt32(
             columnName,
             nullable,
-			GetIsAutoGenerated() && GetIsFeatId(),
+			featClass ? (GetIsAutoGenerated() && GetIsFeatId()) : GetIsAutoGenerated(),
             rootColumnName
         );
 		break;
@@ -499,7 +535,7 @@
 		column = dbObject->CreateColumnInt64(
 			columnName,
 			nullable,
-			GetIsAutoGenerated() && GetIsFeatId(),
+			featClass ? (GetIsAutoGenerated() && GetIsFeatId()) : GetIsAutoGenerated(),
 			rootColumnName
 		);		
 		break;



More information about the fdo-commits mailing list