kexi

KexiMigration::KexiMigrate Class Referenceabstract

#include <keximigrate.h>

Inheritance diagram for KexiMigration::KexiMigrate:
KexiDB::Object KexiMigration::TxtMigrate

Signals

void progressPercent (int percent)

Public Member Functions

KexiMigration::Data * data () const
void setData (KexiMigration::Data *migrateData)
bool checkIfDestinationDatabaseOverwritingNeedsAccepting (Kexi::ObjectStatus *result, bool &acceptingNeeded)
bool isSourceAndDestinationDataSourceTheSame () const
bool performImport (Kexi::ObjectStatus *result=0)
bool performExport (Kexi::ObjectStatus *result=0)
bool progressSupported ()
virtual int versionMajor () const =0
virtual int versionMinor () const =0
virtual TQVariant propertyValue (const TQCString &propName)
void setPropertyValue (const TQCString &propName, const TQVariant &value)
TQString propertyCaption (const TQCString &propName) const
TQValueList< TQCString > propertyNames () const
virtual bool isValid ()
Public Member Functions inherited from KexiDB::Object
bool error () const
const TQString & errorMsg () const
int errorNum () const
int previousServerResult () const
TQString previousServerResultName () const
void debugError ()
virtual void clearError ()
virtual TQString serverErrorMsg ()
virtual int serverResult ()
virtual TQString serverResultName ()
TQString msgTitle () const
const TQString recentSQLString () const

Protected Member Functions

 KexiMigrate (TQObject *parent, const char *name, const TQStringList &args=TQStringList())
virtual bool drv_connect ()=0
virtual bool drv_disconnect ()=0
virtual bool drv_tableNames (TQStringList &tablenames)=0
virtual bool drv_readTableSchema (const TQString &originalName, KexiDB::TableSchema &tableSchema)=0
virtual bool drv_queryMaxNumber (const TQString &tableName, const TQString &columnName, int &result)
virtual tristate drv_queryStringListFromSQL (const TQString &sqlStatement, uint columnNumber, TQStringList &stringList, int numRecords=-1)
virtual tristate drv_querySingleStringFromSQL (const TQString &sqlStatement, uint columnNumber, TQString &string)
virtual tristate drv_fetchRecordFromSQL (const TQString &sqlStatement, KexiDB::RowData &data, bool &firstRecord)
virtual bool drv_copyTable (const TQString &srcTable, KexiDB::Connection *destConn, KexiDB::TableSchema *dstTable)=0
virtual bool drv_progressSupported ()
virtual bool drv_getTableSize (const TQString &, TQ_ULLONG &)
void updateProgress (TQ_ULLONG step=1ULL)
KexiDB::Field::Type userType (const TQString &fname)
virtual TQString drv_escapeIdentifier (const TQString &str) const
Protected Member Functions inherited from KexiDB::Object
 Object (MessageHandler *handler=0)
virtual void setError (int code=ERR_OTHER, const TQString &msg=TQString())
virtual void setError (const TQString &msg)
virtual void setError (const TQString &title, const TQString &msg)
void setError (KexiDB::Object *obj, const TQString &prependMessage=TQString())
virtual void setError (KexiDB::Object *obj, int code, const TQString &prependMessage=TQString())
virtual int askQuestion (const TQString &message, KMessageBox::DialogType dlgType, KMessageBox::ButtonCode defaultResult, const KGuiItem &buttonYes=KStdGuiItem::yes(), const KGuiItem &buttonNo=KStdGuiItem::no(), const TQString &dontShowAskAgainName=TQString(), int options=KMessageBox::Notify, MessageHandler *msgHandler=0)
virtual void drv_clearServerResult ()

Protected Attributes

KexiMigration::Data * m_migrateData
TQMap< TQCString, TQVariant > m_properties
TQMap< TQCString, TQString > m_propertyCaptions
TQGuardedPtr< KexiDB::Driver > m_kexiDBDriver
Protected Attributes inherited from KexiDB::Object
TQString m_sql
TQString m_errorSql
int m_serverResult
TQString m_serverResultName
TQString m_serverErrorMsg
TQString m_errMsg

Friends

class MigrateManager

Detailed Description

Imports non-native databases into Kexi projects.

A generic API for importing schema and data from an existing database into a new Kexi project. Can be also used for importing native Kexi databases.

Basic idea is this:

  1. User selects an existing DB and new project (file or server based)
  2. User specifies whether to import structure and data or structure only.
  3. Import tool connects to db
  4. Checks if it is already a kexi project (not implemented yet)
  5. If not, then read structure and construct new project
  6. Ask user what to do if column type is not supported

See kexi/doc/dev/kexi_import.txt for more info.

Definition at line 78 of file keximigrate.h.

Constructor & Destructor Documentation

◆ ~KexiMigrate()

KexiMigrate::~KexiMigrate ( )
virtual

Definition at line 59 of file keximigrate.cpp.

◆ KexiMigrate()

KexiMigrate::KexiMigrate ( TQObject * parent,
const char * name,
const TQStringList & args = TQStringList() )
protected

Used by MigrateManager.

Definition at line 36 of file keximigrate.cpp.

Member Function Documentation

◆ checkIfDestinationDatabaseOverwritingNeedsAccepting()

bool KexiMigrate::checkIfDestinationDatabaseOverwritingNeedsAccepting ( Kexi::ObjectStatus * result,
bool & acceptingNeeded )

Checks whether the destination database exists. For file-based dest. projects, we've already asked about overwriting existing project but for server-based projects it's better to ask user. This method should be called before performImport() or performExport().

Returns
true if no connection-related errors occurred. acceptingNeeded is set to true if destination database exists. In this case you should ask about accepting database overwriting. Used in ImportWizard::import().

Definition at line 64 of file keximigrate.cpp.

◆ data()

KexiMigration::Data * KexiMigration::KexiMigrate::data ( ) const
inline
Todo
Remove this! KexiMigrate should be usable for multiple concurrent migrations!

Definition at line 87 of file keximigrate.h.

◆ drv_connect()

virtual bool KexiMigration::KexiMigrate::drv_connect ( )
protectedpure virtual

Connect to source database (driver specific).

◆ drv_copyTable()

virtual bool KexiMigration::KexiMigrate::drv_copyTable ( const TQString & srcTable,
KexiDB::Connection * destConn,
KexiDB::TableSchema * dstTable )
protectedpure virtual

Copy a table from source DB to target DB (driver specific)

  • create copies of KexiDB tables
  • create copies of non-KexiDB tables

◆ drv_disconnect()

virtual bool KexiMigration::KexiMigrate::drv_disconnect ( )
protectedpure virtual

Disconnect from source database (driver specific).

◆ drv_escapeIdentifier()

virtual TQString KexiMigration::KexiMigrate::drv_escapeIdentifier ( const TQString & str) const
inlineprotectedvirtual

Definition at line 245 of file keximigrate.h.

◆ drv_fetchRecordFromSQL()

virtual tristate KexiMigration::KexiMigrate::drv_fetchRecordFromSQL ( const TQString & sqlStatement,
KexiDB::RowData & data,
bool & firstRecord )
inlineprotectedvirtual

Fetches single record from result obtained by running sqlStatement. firstRecord should be first initialized to true, so the method can run the query at first call and then set it will set firstRecord to false, so subsequent calls will only fetch records. On success the result is stored in data and true is returned, data is resized to appropriate size. cancelled is returned on EOF.

Todo
SQL-dependent!

Definition at line 206 of file keximigrate.h.

◆ drv_getTableSize()

virtual bool KexiMigration::KexiMigrate::drv_getTableSize ( const TQString & ,
TQ_ULLONG &  )
inlineprotectedvirtual
Returns
the size of a table to be imported, or 0 if not supported Finds the size of the named table, in order to provide feedback on migration progress.

The units of the return type are deliberately unspecified. Migration drivers may return the number of records in the table, or the size in bytes, etc. Units should be chosen in order that the driver can return the size in the fastest way possible (e.g. migration from CSV files should use file size to avoid counting the number of rows, and migration from MDB files should return the number of rows as this is stored within the file).

Obviously, the driver should use the same units when reporting migration progress.

Returns
size of the specified table

Definition at line 236 of file keximigrate.h.

◆ drv_progressSupported()

virtual bool KexiMigration::KexiMigrate::drv_progressSupported ( )
inlineprotectedvirtual

Definition at line 217 of file keximigrate.h.

◆ drv_queryMaxNumber()

bool KexiMigrate::drv_queryMaxNumber ( const TQString & tableName,
const TQString & columnName,
int & result )
protectedvirtual

Fetches maximum number from table tableName, column columnName into result. On success true is returned. If there is no records in the table, result is set to 0 and true is returned.

  • Note 1: implement only if the database can already contain kexidb__* tables (so e.g. keximdb driver doea not need this).
  • Note 2: default implementation uses drv_querySingleStringFromSQL() with "SELECT MAX(columName) FROM tableName" statement, assuming SQL-compliant backend.

Definition at line 585 of file keximigrate.cpp.

◆ drv_querySingleStringFromSQL()

tristate KexiMigrate::drv_querySingleStringFromSQL ( const TQString & sqlStatement,
uint columnNumber,
TQString & string )
protectedvirtual

Fetches single string at column columnNumber from result obtained by running sqlStatement. On success the result is stored in string and true is returned.

Returns
cancelled if there are no records available. This implementation uses drv_queryStringListFromSQL() with numRecords == 1.
Todo
SQL-dependent!

Definition at line 605 of file keximigrate.cpp.

◆ drv_queryStringListFromSQL()

virtual tristate KexiMigration::KexiMigrate::drv_queryStringListFromSQL ( const TQString & sqlStatement,
uint columnNumber,
TQStringList & stringList,
int numRecords = -1 )
inlineprotectedvirtual

Fetches single string at column columnNumber for each record from result obtained by running sqlStatement. numRecords can be specified to limit number of records read. If numRecords is -1, all records are loaded. On success the result is stored in stringList and true is returned.

Returns
cancelled if there are no records available.
  • Note: implement only if the database can already contain kexidb__* tables (so e.g. keximdb driver does not need this).
Todo
SQL-dependent!

Definition at line 182 of file keximigrate.h.

◆ drv_readTableSchema()

virtual bool KexiMigration::KexiMigrate::drv_readTableSchema ( const TQString & originalName,
KexiDB::TableSchema & tableSchema )
protectedpure virtual

Read schema for a given table (driver specific).

◆ drv_tableNames()

virtual bool KexiMigration::KexiMigrate::drv_tableNames ( TQStringList & tablenames)
protectedpure virtual

Get table names in source database (driver specific).

◆ isSourceAndDestinationDataSourceTheSame()

bool KexiMigrate::isSourceAndDestinationDataSourceTheSame ( ) const

Checks if the source- and the destination databases are identical.

Returns
true if they are identical else false.

Definition at line 99 of file keximigrate.cpp.

◆ isValid()

bool KexiMigrate::isValid ( )
virtual
Returns
true is driver is valid. Checks if KexiMigrate::versionMajor() and KexiMigrate::versionMinor() are matching. You can reimplement this but always call KexiMigrate::isValid() implementation.

Definition at line 570 of file keximigrate.cpp.

◆ performExport()

bool KexiMigrate::performExport ( Kexi::ObjectStatus * result = 0)

Perform an export operation.

Todo
performExport

Definition at line 423 of file keximigrate.cpp.

◆ performImport()

bool KexiMigrate::performImport ( Kexi::ObjectStatus * result = 0)

Perform an import operation.

Todo
to reuse Connection::setupTableSchema()'s statement somehow...
Todo
check detailed "copy forms/blobs/tables" flags here when we add them
Todo
what if these two tables are not compatible with tables created in destination db because newer db format was used?
Todo
copy kexi__db contents!

Definition at line 116 of file keximigrate.cpp.

◆ progressSupported()

bool KexiMigration::KexiMigrate::progressSupported ( )
inline

Returns true if the migration driver supports progress updates.

Definition at line 116 of file keximigrate.h.

◆ propertyCaption()

TQString KexiMigrate::propertyCaption ( const TQCString & propName) const
Todo
This is copied from KexiDB::Driver. One day it will be merged with KexiDB.
Returns
translated property caption for propeName. If there's no such property defined for driver, empty string value is returned.

Definition at line 553 of file keximigrate.cpp.

◆ propertyNames()

TQValueList< TQCString > KexiMigrate::propertyNames ( ) const
Todo
This is copied from KexiDB::Driver. One day it will be merged with KexiDB.
Returns
a list of property names available for this driver.

Definition at line 563 of file keximigrate.cpp.

◆ propertyValue()

TQVariant KexiMigrate::propertyValue ( const TQCString & propName)
virtual
Todo
This is copied from KexiDB::Driver. One day it will be merged with KexiDB.
Returns
property value for propeName available for this driver. If there's no such property defined for driver, Null TQVariant value is returned.

Definition at line 548 of file keximigrate.cpp.

◆ setData()

void KexiMigrate::setData ( KexiMigration::Data * migrateData)

Data Setup. Requires two connection objects, a name and a bool.

Todo
Remove this! KexiMigrate should be usable for multiple concurrent migrations!

Definition at line 52 of file keximigrate.cpp.

◆ setPropertyValue()

void KexiMigrate::setPropertyValue ( const TQCString & propName,
const TQVariant & value )
Todo
This is copied from KexiDB::Driver. One day it will be merged with KexiDB.

Definition at line 558 of file keximigrate.cpp.

◆ updateProgress()

void KexiMigrate::updateProgress ( TQ_ULLONG step = 1ULL)
protected

Definition at line 478 of file keximigrate.cpp.

◆ userType()

KexiDB::Field::Type KexiMigrate::userType ( const TQString & fname)
protected

Prompt user to select a field type for unrecognized fields.

Todo
user should be asked ONCE using a convenient wizard's page, not a popup dialog
Todo
use TQMap<TQCString, KexiDB::Field::Type> here!

Definition at line 492 of file keximigrate.cpp.

◆ MigrateManager

friend class MigrateManager
friend

Definition at line 294 of file keximigrate.h.

Member Data Documentation

◆ m_kexiDBDriver

TQGuardedPtr<KexiDB::Driver> KexiMigration::KexiMigrate::m_kexiDBDriver
protected

KexiDB driver. For instance, it is used for escaping identifiers.

Definition at line 266 of file keximigrate.h.

◆ m_migrateData

KexiMigration::Data* KexiMigration::KexiMigrate::m_migrateData
protected

Migrate Options.

Todo
Remove this! KexiMigrate should be usable for multiple concurrent migrations!

Definition at line 250 of file keximigrate.h.

◆ m_properties

TQMap<TQCString,TQVariant> KexiMigration::KexiMigrate::m_properties
protected

Driver properties dictionary (indexed by name), useful for presenting properties to the user. Set available properties here in driver implementation.

Definition at line 258 of file keximigrate.h.

◆ m_propertyCaptions

TQMap<TQCString,TQString> KexiMigration::KexiMigrate::m_propertyCaptions
protected

i18n'd captions for properties. You do not need to set predefined properties' caption in driver implementation -it's done automatically.

Definition at line 263 of file keximigrate.h.


The documentation for this class was generated from the following files: