[fdo-commits] r629 - in trunk/Utilities/SchemaMgr: . Inc/Sm/Ph
Inc/Sm/Ph/Rd Nls Src/Sm/Ph Src/Sm/Ph/Mt Src/Sm/Ph/Rd
svn_fdo at osgeo.org
svn_fdo at osgeo.org
Tue Jan 16 09:24:39 EST 2007
Author: brentrobinson
Date: 2007-01-16 09:24:39 -0500 (Tue, 16 Jan 2007)
New Revision: 629
Added:
trunk/Utilities/SchemaMgr/Inc/Sm/Ph/CharacterSet.h
trunk/Utilities/SchemaMgr/Inc/Sm/Ph/Collation.h
trunk/Utilities/SchemaMgr/Inc/Sm/Ph/Rd/CharacterSetReader.h
trunk/Utilities/SchemaMgr/Inc/Sm/Ph/Rd/CollationReader.h
trunk/Utilities/SchemaMgr/Src/Sm/Ph/CharacterSet.cpp
trunk/Utilities/SchemaMgr/Src/Sm/Ph/Collation.cpp
trunk/Utilities/SchemaMgr/Src/Sm/Ph/Rd/CharacterSetReader.cpp
trunk/Utilities/SchemaMgr/Src/Sm/Ph/Rd/CollationReader.cpp
Modified:
trunk/Utilities/SchemaMgr/Inc/Sm/Ph/Database.h
trunk/Utilities/SchemaMgr/Nls/SmMessage.mc
trunk/Utilities/SchemaMgr/Physical.vcproj
trunk/Utilities/SchemaMgr/Src/Sm/Ph/Database.cpp
trunk/Utilities/SchemaMgr/Src/Sm/Ph/Makefile.am
trunk/Utilities/SchemaMgr/Src/Sm/Ph/Mt/SchemaReader.cpp
trunk/Utilities/SchemaMgr/Src/Sm/Ph/Rd/Makefile.am
Log:
Merged from 3.2.x branch (UTF8 connection character set for MySQL).
Copied: trunk/Utilities/SchemaMgr/Inc/Sm/Ph/CharacterSet.h (from rev 623, branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/Ph/CharacterSet.h)
Copied: trunk/Utilities/SchemaMgr/Inc/Sm/Ph/Collation.h (from rev 623, branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/Ph/Collation.h)
Modified: trunk/Utilities/SchemaMgr/Inc/Sm/Ph/Database.h
===================================================================
--- trunk/Utilities/SchemaMgr/Inc/Sm/Ph/Database.h 2007-01-12 22:38:53 UTC (rev 628)
+++ trunk/Utilities/SchemaMgr/Inc/Sm/Ph/Database.h 2007-01-16 14:24:39 UTC (rev 629)
@@ -23,6 +23,8 @@
#endif
#include <Sm/Ph/OwnerCollection.h>
+#include <Sm/Ph/CharacterSet.h>
+#include <Sm/Ph/Collation.h>
class FdoSmPhMgr;
class FdoSmPhRdOwnerReader;
@@ -70,6 +72,28 @@
/// Create a new owner.
virtual FdoSmPhOwnerP CreateOwner(FdoStringP owner, bool hasMetaSchema = true );
+ /// Get character set by name.
+
+ /// Get a read-only pointer, NULL if character set not in database
+ const FdoSmPhCharacterSet* RefCharacterSet(FdoStringP characterSetName) const;
+
+ /// Get a read-write smart pointer, NULL if character set not in database
+ virtual FdoSmPhCharacterSetP FindCharacterSet(FdoStringP characterSetName);
+
+ /// Get a read-write smart pointer, throws FdoSchemaException if character set not in database
+ FdoSmPhCharacterSetP GetCharacterSet(FdoStringP characterSetName);
+
+ /// Get collation set by name.
+
+ /// Get a read-only pointer, NULL if collation not in database
+ const FdoSmPhCollation* RefCollation(FdoStringP collationName) const;
+
+ /// Get a read-write smart pointer, NULL if collation not in database
+ virtual FdoSmPhCollationP FindCollation(FdoStringP collationName);
+
+ /// Get a read-write smart pointer, throws FdoSchemaException if collation not in database
+ FdoSmPhCollationP GetCollation(FdoStringP collationName);
+
/// Deactivate the current owner leaving no owner current.
/// Does nothing by default. Providers that can support this
/// functionality can override.
@@ -78,11 +102,27 @@
/// Remove an owner from the cache
void DiscardOwner( FdoSmPhOwner* owner );
- /// Create a reader to get all owner objects for this database.
- /// TODO: add flag to cache owners
- virtual FdoPtr<FdoSmPhRdOwnerReader> CreateOwnerReader( FdoStringP owner = L"") const = 0;
+ /// Create a reader to get owner objects for this database.
+ virtual FdoPtr<FdoSmPhRdOwnerReader> CreateOwnerReader(
+ FdoStringP owner = L""
+ // When specified, get this particular owner if present in database
+ // When L"", get all owners for this database.
+ ) const = 0;
+ /// Create a reader to get character sets for this database.
+ virtual FdoPtr<FdoSmPhRdCharacterSetReader> CreateCharacterSetReader(
+ FdoStringP characterSetName = L""
+ // When specified, get this particular character set if present in database
+ // When L"", get all character sets for this database.
+ ) const;
+ /// Create a reader to get collations for this database.
+ virtual FdoPtr<FdoSmPhRdCollationReader> CreateCollationReader(
+ FdoStringP collationName = L""
+ // When specified, get this particular collation if present in database
+ // When L"", get all collation for this database.
+ ) const;
+
/// Gather all errors for this element and child elements into a chain of exceptions.
/// Adds each error as an exception, to the given exception chain and returns
/// the chain.
@@ -106,6 +146,12 @@
/// Returns the owner (datastore) cache.
FdoSmPhOwnersP GetOwners();
+ /// Returns the character set cache.
+ FdoSmPhCharacterSetsP GetCharacterSets();
+
+ /// Returns the collation cache.
+ FdoSmPhCollationsP GetCollations();
+
/// Instantiate an owner (can be new or existing).
virtual FdoSmPhOwnerP NewOwner(
FdoStringP owner,
@@ -113,12 +159,34 @@
FdoSchemaElementState elementState = FdoSchemaElementState_Added
) = 0;
+ // Instantiate a character set.
+ // Implementing Character Sets is optional so this function always returns NULL.
+ // Providers that implement character sets must override this function.
+ virtual FdoSmPhCharacterSetP NewCharacterSet(
+ FdoStringP characterSetName,
+ FdoSmPhRdCharacterSetReader* reader
+ );
+
+ // Instantiate a collation.
+ // Implementing Collation is optional so this function always returns NULL.
+ // Providers that implement collations must override this function.
+ virtual FdoSmPhCollationP NewCollation(
+ FdoStringP collationName,
+ FdoSmPhRdCollationReader* reader
+ );
+
/// Commit modifications to owners.
virtual void CommitChildren( bool isBeforeParent );
private:
/// Owner cache for this database.
FdoSmPhOwnersP mOwners;
+
+ /// Character Set cache for this database.
+ FdoSmPhCharacterSetsP mCharacterSets;
+
+ /// Collation cache for this database.
+ FdoSmPhCollationsP mCollations;
};
typedef FdoPtr<FdoSmPhDatabase> FdoSmPhDatabaseP;
Copied: trunk/Utilities/SchemaMgr/Inc/Sm/Ph/Rd/CharacterSetReader.h (from rev 623, branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/Ph/Rd/CharacterSetReader.h)
Copied: trunk/Utilities/SchemaMgr/Inc/Sm/Ph/Rd/CollationReader.h (from rev 623, branches/3.2.x/Utilities/SchemaMgr/Inc/Sm/Ph/Rd/CollationReader.h)
Modified: trunk/Utilities/SchemaMgr/Nls/SmMessage.mc
===================================================================
--- trunk/Utilities/SchemaMgr/Nls/SmMessage.mc 2007-01-12 22:38:53 UTC (rev 628)
+++ trunk/Utilities/SchemaMgr/Nls/SmMessage.mc 2007-01-16 14:24:39 UTC (rev 629)
@@ -116,6 +116,11 @@
Language=English
Cannot modify primary key name for existing table %1$ls.
.
+MessageId=2226
+SymbolicName=FDOSM_21
+Language=English
+Character Set '%1$ls' does not exist or is inaccessible from current connection.
+.
MessageId=2227
SymbolicName=FDOSM_22
Language=English
@@ -146,6 +151,11 @@
Language=English
Unique Constraint property '%1$ls' is not a data property in class '%2$ls'
.
+MessageId=2233
+SymbolicName=FDOSM_28
+Language=English
+Collation '%1$ls' does not exist or is inaccessible from current connection.
+.
MessageId=2327
SymbolicName=FDOSM_122
Language=English
Modified: trunk/Utilities/SchemaMgr/Physical.vcproj
===================================================================
--- trunk/Utilities/SchemaMgr/Physical.vcproj 2007-01-12 22:38:53 UTC (rev 628)
+++ trunk/Utilities/SchemaMgr/Physical.vcproj 2007-01-16 14:24:39 UTC (rev 629)
@@ -171,6 +171,10 @@
>
</File>
<File
+ RelativePath=".\Src\Sm\Ph\CharacterSet.cpp"
+ >
+ </File>
+ <File
RelativePath="Src\Sm\Ph\ClassPropertyReader.cpp"
>
</File>
@@ -191,6 +195,10 @@
>
</File>
<File
+ RelativePath=".\Src\Sm\Ph\Collation.cpp"
+ >
+ </File>
+ <File
RelativePath="Src\Sm\Ph\Column.cpp"
>
</File>
@@ -211,11 +219,11 @@
>
</File>
<File
- RelativePath=".\Src\Sm\Ph\ColumnList.cpp"
+ RelativePath=".\src\Sm\Ph\ColumnList.cpp"
>
</File>
<File
- RelativePath=".\src\Sm\Ph\ColumnList.cpp"
+ RelativePath=".\Src\Sm\Ph\ColumnList.cpp"
>
</File>
<File
@@ -438,6 +446,10 @@
</FileConfiguration>
</File>
<File
+ RelativePath=".\Src\Sm\Ph\Rd\CharacterSetReader.cpp"
+ >
+ </File>
+ <File
RelativePath="Src\Sm\Ph\Rd\ClassReader.cpp"
>
<FileConfiguration
@@ -458,6 +470,10 @@
</FileConfiguration>
</File>
<File
+ RelativePath=".\Src\Sm\Ph\Rd\CollationReader.cpp"
+ >
+ </File>
+ <File
RelativePath="Src\Sm\Ph\Rd\ColumnReader.cpp"
>
</File>
@@ -959,6 +975,10 @@
>
</File>
<File
+ RelativePath=".\Inc\Sm\Ph\CharacterSet.h"
+ >
+ </File>
+ <File
RelativePath=".\Inc\Sm\Ph\CheckConstraint.h"
>
</File>
@@ -991,6 +1011,10 @@
>
</File>
<File
+ RelativePath=".\Inc\Sm\Ph\Collation.h"
+ >
+ </File>
+ <File
RelativePath="Inc\Sm\Ph\ColType.h"
>
</File>
@@ -1326,10 +1350,18 @@
>
</File>
<File
+ RelativePath=".\Inc\Sm\Ph\Rd\CharacterSetReader.h"
+ >
+ </File>
+ <File
RelativePath="Inc\Sm\Ph\Rd\ClassReader.h"
>
</File>
<File
+ RelativePath=".\Inc\Sm\Ph\Rd\CollationReader.h"
+ >
+ </File>
+ <File
RelativePath="Inc\Sm\Ph\Rd\ColumnReader.h"
>
</File>
Copied: trunk/Utilities/SchemaMgr/Src/Sm/Ph/CharacterSet.cpp (from rev 623, branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/CharacterSet.cpp)
Copied: trunk/Utilities/SchemaMgr/Src/Sm/Ph/Collation.cpp (from rev 623, branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/Collation.cpp)
Modified: trunk/Utilities/SchemaMgr/Src/Sm/Ph/Database.cpp
===================================================================
--- trunk/Utilities/SchemaMgr/Src/Sm/Ph/Database.cpp 2007-01-12 22:38:53 UTC (rev 628)
+++ trunk/Utilities/SchemaMgr/Src/Sm/Ph/Database.cpp 2007-01-16 14:24:39 UTC (rev 629)
@@ -20,6 +20,8 @@
#include <Sm/Ph/Database.h>
#include <Sm/Error.h>
#include <Sm/Ph/Rd/OwnerReader.h>
+#include <Sm/Ph/Rd/CharacterSetReader.h>
+#include <Sm/Ph/Rd/CollationReader.h>
FdoSmPhDatabase::FdoSmPhDatabase(
FdoStringP name,
@@ -83,6 +85,96 @@
return(pOwner);
}
+const FdoSmPhCharacterSet* FdoSmPhDatabase::RefCharacterSet(FdoStringP characterSetName) const
+{
+ return (FdoSmPhCharacterSet*) ((FdoSmPhDatabase*) this)->FindCharacterSet(characterSetName);
+}
+
+FdoSmPhCharacterSetP FdoSmPhDatabase::FindCharacterSet(FdoStringP characterSetName)
+{
+ FdoSmPhCharacterSetsP characterSets = GetCharacterSets();
+
+ // Look up the character set in the cache.
+ FdoSmPhCharacterSetP characterSet = characterSets->FindItem(characterSetName);
+
+ if ( !characterSet ) {
+ // Not in cache so read it in.
+ FdoPtr<FdoSmPhRdCharacterSetReader> reader = CreateCharacterSetReader( characterSetName );
+
+ if ( reader && reader->ReadNext() )
+ {
+ characterSet = NewCharacterSet(reader->GetString(L"",L"character_set_name"), reader);
+ }
+
+ if ( characterSet )
+ // Character set found, add it the the cache.
+ characterSets->Add( characterSet );
+ }
+
+ return( characterSet );
+}
+
+FdoSmPhCharacterSetP FdoSmPhDatabase::GetCharacterSet(FdoStringP characterSetName)
+{
+ FdoSmPhCharacterSetP characterSet = FindCharacterSet( characterSetName);
+
+ if ( !characterSet ) {
+ throw FdoSchemaException::Create(
+ FdoSmError::NLSGetMessage(
+ FDO_NLSID(FDOSM_21),
+ (FdoString*) characterSetName
+ )
+ );
+ }
+
+ return( characterSet );
+}
+
+const FdoSmPhCollation* FdoSmPhDatabase::RefCollation(FdoStringP collationName) const
+{
+ return (FdoSmPhCollation*) ((FdoSmPhDatabase*) this)->FindCollation(collationName);
+}
+
+FdoSmPhCollationP FdoSmPhDatabase::FindCollation(FdoStringP collationName)
+{
+ FdoSmPhCollationsP collations = GetCollations();
+
+ // Look up the collation in the cache.
+ FdoSmPhCollationP collation = collations->FindItem(collationName);
+
+ if ( !collation ) {
+ // Not in cache so read it in.
+ FdoPtr<FdoSmPhRdCollationReader> reader = CreateCollationReader( collationName );
+
+ if ( reader && reader->ReadNext() )
+ {
+ collation = NewCollation(reader->GetString(L"",L"collation_name"), reader);
+ }
+
+ if ( collation )
+ // Collation found, add it the the cache.
+ collations->Add( collation );
+ }
+
+ return( collation );
+}
+
+FdoSmPhCollationP FdoSmPhDatabase::GetCollation(FdoStringP collationName)
+{
+ FdoSmPhCollationP collation = FindCollation( collationName);
+
+ if ( !collation ) {
+ throw FdoSchemaException::Create(
+ FdoSmError::NLSGetMessage(
+ FDO_NLSID(FDOSM_28),
+ (FdoString*) collationName
+ )
+ );
+ }
+
+ return( collation );
+}
+
FdoSmPhOwnerP FdoSmPhDatabase::CreateOwner(FdoStringP owner, bool hasMetaSchema)
{
FdoStringP name = GetName();
@@ -124,6 +216,16 @@
}
}
+FdoPtr<FdoSmPhRdCharacterSetReader> FdoSmPhDatabase::CreateCharacterSetReader( FdoStringP characterSetName ) const
+{
+ return (FdoSmPhRdCharacterSetReader*) NULL;
+}
+
+FdoPtr<FdoSmPhRdCollationReader> FdoSmPhDatabase::CreateCollationReader( FdoStringP collationName ) const
+{
+ return (FdoSmPhRdCollationReader*) NULL;
+}
+
FdoSchemaExceptionP FdoSmPhDatabase::Errors2Exception(FdoSchemaException* pFirstException ) const
{
// Tack on errors for this element
@@ -162,6 +264,42 @@
return mOwners;
}
+FdoSmPhCharacterSetsP FdoSmPhDatabase::GetCharacterSets()
+{
+ if ( !mCharacterSets ) {
+ // Character Set cache not initialized so initialize it.
+ mCharacterSets = new FdoSmPhCharacterSetCollection();
+ }
+
+ return mCharacterSets;
+}
+
+FdoSmPhCollationsP FdoSmPhDatabase::GetCollations()
+{
+ if ( !mCollations ) {
+ // Collation cache not initialized so initialize it.
+ mCollations = new FdoSmPhCollationCollection();
+ }
+
+ return mCollations;
+}
+
+FdoSmPhCharacterSetP FdoSmPhDatabase::NewCharacterSet(
+ FdoStringP characterSetName,
+ FdoSmPhRdCharacterSetReader* reader
+)
+{
+ return (FdoSmPhCharacterSet*) NULL;
+}
+
+FdoSmPhCollationP FdoSmPhDatabase::NewCollation(
+ FdoStringP collationName,
+ FdoSmPhRdCollationReader* reader
+)
+{
+ return (FdoSmPhCollation*) NULL;
+}
+
void FdoSmPhDatabase::CommitChildren( bool isBeforeParent )
{
int i;
Modified: trunk/Utilities/SchemaMgr/Src/Sm/Ph/Makefile.am
===================================================================
--- trunk/Utilities/SchemaMgr/Src/Sm/Ph/Makefile.am 2007-01-12 22:38:53 UTC (rev 628)
+++ trunk/Utilities/SchemaMgr/Src/Sm/Ph/Makefile.am 2007-01-16 14:24:39 UTC (rev 629)
@@ -24,6 +24,7 @@
libSmPhysical_la_SOURCES = \
AssociationReader.cpp \
AssociationWriter.cpp \
+ CharacterSet.cpp \
ClassPropertyReader.cpp \
ClassPropertySADReader.cpp \
ClassReader.cpp \
@@ -31,6 +32,7 @@
ClassSOReader.cpp \
ClassSOWriter.cpp \
ClassWriter.cpp \
+ Collation.cpp \
Column.cpp \
ColumnChar.cpp \
ColumnDate.cpp \
Modified: trunk/Utilities/SchemaMgr/Src/Sm/Ph/Mt/SchemaReader.cpp
===================================================================
--- trunk/Utilities/SchemaMgr/Src/Sm/Ph/Mt/SchemaReader.cpp 2007-01-12 22:38:53 UTC (rev 628)
+++ trunk/Utilities/SchemaMgr/Src/Sm/Ph/Mt/SchemaReader.cpp 2007-01-16 14:24:39 UTC (rev 629)
@@ -35,8 +35,8 @@
if ( dsInfo ) {
// Generate the where clause for retrieving datastore information
whereClause = FdoStringP::Format(
- L"where upper(schemaname) = upper('%ls')",
- owner->GetName()
+ L"where upper(schemaname) = '%ls'",
+ (FdoString*) FdoStringP(owner->GetName()).Upper()
);
}
else {
Copied: trunk/Utilities/SchemaMgr/Src/Sm/Ph/Rd/CharacterSetReader.cpp (from rev 623, branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/Rd/CharacterSetReader.cpp)
Copied: trunk/Utilities/SchemaMgr/Src/Sm/Ph/Rd/CollationReader.cpp (from rev 623, branches/3.2.x/Utilities/SchemaMgr/Src/Sm/Ph/Rd/CollationReader.cpp)
Modified: trunk/Utilities/SchemaMgr/Src/Sm/Ph/Rd/Makefile.am
===================================================================
--- trunk/Utilities/SchemaMgr/Src/Sm/Ph/Rd/Makefile.am 2007-01-12 22:38:53 UTC (rev 628)
+++ trunk/Utilities/SchemaMgr/Src/Sm/Ph/Rd/Makefile.am 2007-01-16 14:24:39 UTC (rev 629)
@@ -21,7 +21,9 @@
libSmPhRd_la_SOURCES = \
AssociationReader.cpp \
+ CharacterSetReader.cpp \
ClassReader.cpp \
+ CollationReader.cpp \
ColumnReader.cpp \
ConstraintReader.cpp \
CoordSysReader.cpp \
More information about the fdo-commits
mailing list