[fdo-commits] r838 - in branches/3.2.x/Utilities/SchemaMgr: Inc/Sm
Inc/Sm/Ph Src/Sm/Ph
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Thu Mar 15 11:25:37 EDT 2007
Author: brentrobinson
Date: 2007-03-15 11:25:37 -0400 (Thu, 15 Mar 2007)
New Revision: 838
Modified:
branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/Ph/BaseObject.h
branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/SchemaElement.h
branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/BaseObject.cpp
branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/DbObject.cpp
branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/Field.cpp
Log:
View Support: Prevent "item already in collection" message when view is based on 2 tables with same name but in different datatores.
Modified: branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/Ph/BaseObject.h
===================================================================
--- branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/Ph/BaseObject.h 2007-03-15 13:18:01 UTC (rev 837)
+++ branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/Ph/BaseObject.h 2007-03-15 15:25:37 UTC (rev 838)
@@ -55,12 +55,25 @@
const FdoSmPhDbObject* RefDbObject() const;
FdoPtr<FdoSmPhDbObject> GetDbObject();
+ /// Overridden to generate a unique name qualified by owner and database, since
+ /// a base object collection can contain objects from different owners and databases.
+ virtual FdoString* GetName() const;
+
+ /// Get the referenced object's unqualified name
+ FdoStringP GetObjectName() const;
+
/// Get the referenced object's owner name
FdoStringP GetOwnerName() const;
/// Get the referenced object's database name
FdoStringP GetDatabaseName() const;
+ // returns number of times this base is referenced by child.
+ FdoInt32 GetBaseRefCount() const;
+
+ // Increment number of times this base is referenced by child
+ void AddBaseRef();
+
protected:
/// unused constructor needed only to build on Linux
FdoSmPhBaseObject();
@@ -73,11 +86,13 @@
virtual bool Delete() {return true;}
private:
+ mutable FdoStringP mQName;
FdoStringP mOwnerName;
FdoStringP mDatabaseName;
FdoPtr<FdoSmPhDbObject> mDbObject;
+ FdoInt32 mBaseRefCount;
};
typedef FdoPtr<FdoSmPhBaseObject> FdoSmPhBaseObjectP;
Modified: branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/SchemaElement.h
===================================================================
--- branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/SchemaElement.h 2007-03-15 13:18:01 UTC (rev 837)
+++ branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/SchemaElement.h 2007-03-15 15:25:37 UTC (rev 838)
@@ -41,7 +41,7 @@
const FdoSmSchemaElement* GetParent() const;
/// Returns the name of the schema object.
- FdoString* GetName() const;
+ virtual FdoString* GetName() const;
/// Get the fully qualified name for this element.
/// This varies between element type so some types override this
Modified: branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/BaseObject.cpp
===================================================================
--- branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/BaseObject.cpp 2007-03-15 13:18:01 UTC (rev 837)
+++ branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/BaseObject.cpp 2007-03-15 15:25:37 UTC (rev 838)
@@ -28,7 +28,8 @@
) :
FdoSmPhDbElement(name, (FdoSmPhMgr*) NULL, parent, FdoSchemaElementState_Detached ),
mOwnerName(ownerName),
- mDatabaseName(databaseName)
+ mDatabaseName(databaseName),
+ mBaseRefCount(1)
{
if ( ownerName == L"" )
mOwnerName = parent->GetParent()->GetName();
@@ -41,7 +42,8 @@
FdoSmPhDbElement(dbObject->GetName(), (FdoSmPhMgr*) NULL, parent, FdoSchemaElementState_Detached ),
mOwnerName(dbObject->GetParent()->GetName()),
mDatabaseName(dbObject->GetParent()->GetParent()->GetName()),
- mDbObject(dbObject)
+ mDbObject(dbObject),
+ mBaseRefCount(1)
{
}
@@ -64,11 +66,29 @@
FdoSmPhDbObjectP FdoSmPhBaseObject::GetDbObject()
{
if ( (wcslen(GetName()) > 0) && (!mDbObject) )
- mDbObject = GetManager()->FindDbObject( GetName(), GetOwnerName(), GetDatabaseName() );
+ mDbObject = GetManager()->FindDbObject( FdoSmPhDbElement::GetName(), GetOwnerName(), GetDatabaseName() );
return mDbObject;
}
+FdoString* FdoSmPhBaseObject::GetName() const
+{
+ if ( mQName == L"" ) {
+ mQName = FdoStringP(L"\"") + GetOwnerName() + L"\".\"" + FdoSmPhDbElement::GetName() + L"\"";
+
+ if ( GetDatabaseName() != L"" ) {
+ mQName = FdoStringP(L"\"") + GetDatabaseName() + L"\"." + mQName;
+ }
+ }
+
+ return mQName;
+}
+
+FdoStringP FdoSmPhBaseObject::GetObjectName() const
+{
+ return FdoSmPhDbElement::GetName();
+}
+
FdoStringP FdoSmPhBaseObject::GetOwnerName() const
{
return mOwnerName;
@@ -79,3 +99,12 @@
return mDatabaseName;
}
+FdoInt32 FdoSmPhBaseObject::GetBaseRefCount() const
+{
+ return mBaseRefCount;
+}
+
+void FdoSmPhBaseObject::AddBaseRef()
+{
+ mBaseRefCount++;
+}
Modified: branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/DbObject.cpp
===================================================================
--- branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/DbObject.cpp 2007-03-15 13:18:01 UTC (rev 837)
+++ branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/DbObject.cpp 2007-03-15 15:25:37 UTC (rev 838)
@@ -169,7 +169,8 @@
if ( baseObjects->GetCount() == 1 ) {
FdoSmPhBaseObjectP baseObject = baseObjects->GetItem(0);
- rootObject = baseObject->GetDbObject();
+ if ( baseObject->GetBaseRefCount() < 2 )
+ rootObject = baseObject->GetDbObject();
}
return rootObject;
@@ -195,7 +196,8 @@
if ( baseObjects->GetCount() == 1 ) {
const FdoSmPhBaseObject* baseObject = baseObjects->RefItem(0);
- rootObjectName = baseObject->GetName();
+ if ( baseObject->GetBaseRefCount() < 2 )
+ rootObjectName = baseObject->GetObjectName();
}
return rootObjectName;
@@ -209,7 +211,8 @@
if ( baseObjects->GetCount() == 1 ) {
const FdoSmPhBaseObject* baseObject = baseObjects->RefItem(0);
- rootOwnerName = baseObject->GetOwnerName();
+ if ( baseObject->GetBaseRefCount() < 2 )
+ rootOwnerName = baseObject->GetOwnerName();
}
return rootOwnerName;
@@ -223,7 +226,8 @@
if ( baseObjects->GetCount() == 1 ) {
const FdoSmPhBaseObject* baseObject = baseObjects->RefItem(0);
- rootDatabaseName = baseObject->GetDatabaseName();
+ if ( baseObject->GetBaseRefCount() < 2 )
+ rootDatabaseName = baseObject->GetDatabaseName();
}
return rootDatabaseName;
@@ -1101,8 +1105,16 @@
{
while ( baseObjRdr->ReadNext() ) {
FdoSmPhBaseObjectP newBaseObject = NewBaseObject( baseObjRdr );
- if ( newBaseObject )
- mBaseObjects->Add( newBaseObject );
+
+ if ( newBaseObject ) {
+ FdoSmPhBaseObjectP currBaseObject = mBaseObjects->FindItem( newBaseObject->GetName() );
+ if ( currBaseObject )
+ // Base object already in collection, just add a base reference.
+ currBaseObject->AddBaseRef();
+ else
+ // Not in collection, add it.
+ mBaseObjects->Add( newBaseObject );
+ }
}
}
Modified: branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/Field.cpp
===================================================================
--- branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/Field.cpp 2007-03-15 13:18:01 UTC (rev 837)
+++ branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/Field.cpp 2007-03-15 15:25:37 UTC (rev 838)
@@ -158,8 +158,9 @@
{
FdoStringP colSyntax;
- if ( GetColumn() ) {
- colSyntax = GetColumn()->GetName();
+ FdoSmPhColumnP column = GetColumn();
+ if ( column && column->GetExists() ) {
+ colSyntax = column->GetName();
}
return colSyntax;
More information about the fdo-commits
mailing list