Changeset View
Changeset View
Standalone View
Standalone View
src/migration/mdb/src/keximdb/mdbmigrate.cpp
Show First 20 Lines • Show All 148 Lines • ▼ Show 20 Line(s) | |||||
149 | { | 149 | { | ||
150 | // Get the column meta-data | 150 | // Get the column meta-data | ||
151 | MdbTableDef *tableDef = getTableDef(originalName); | 151 | MdbTableDef *tableDef = getTableDef(originalName); | ||
152 | if (!tableDef) { | 152 | if (!tableDef) { | ||
153 | qWarning() << "couldn't find table" << originalName; | 153 | qWarning() << "couldn't find table" << originalName; | ||
154 | return false; | 154 | return false; | ||
155 | } | 155 | } | ||
156 | mdb_read_columns(tableDef); | 156 | mdb_read_columns(tableDef); | ||
157 | //qDebug() << "#cols = " << tableDef->num_cols; | 157 | //qDebug() << "#cols =" << tableDef->num_cols; | ||
158 | 158 | | |||
159 | /*! Convert column data to Kexi KDbTableSchema | 159 | /*! Convert column data to Kexi KDbTableSchema | ||
160 | Nice mix of terminology here, MDBTools has columns, Kexi has fields. */ | 160 | Nice mix of terminology here, MDBTools has columns, Kexi has fields. */ | ||
161 | for (unsigned int i = 0; i < tableDef->num_cols; i++) { | 161 | for (unsigned int i = 0; i < tableDef->num_cols; i++) { | ||
162 | MdbColumn *col = static_cast<MdbColumn*>(g_ptr_array_index(tableDef->columns, i)); | 162 | MdbColumn *col = static_cast<MdbColumn*>(g_ptr_array_index(tableDef->columns, i)); | ||
163 | 163 | | |||
164 | // Field name | 164 | // Field name | ||
165 | QString fldName = QString::fromUtf8(col->name); | 165 | QString fldName = QString::fromUtf8(col->name); | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | |||||
281 | 281 | | |||
282 | #ifdef KEXI_MIGRATION_MAX_ROWS_TO_IMPORT | 282 | #ifdef KEXI_MIGRATION_MAX_ROWS_TO_IMPORT | ||
283 | qulonglong rows = 0; | 283 | qulonglong rows = 0; | ||
284 | #endif | 284 | #endif | ||
285 | 285 | | |||
286 | bool ok = true; | 286 | bool ok = true; | ||
287 | while (mdb_fetch_row(tableDef)) { | 287 | while (mdb_fetch_row(tableDef)) { | ||
288 | QList<QVariant> vals; | 288 | QList<QVariant> vals; | ||
289 | // qDebug() << kdLoc << "Copying " << tableDef->num_cols << " cols"; | 289 | // qDebug() << kdLoc << "Copying" << tableDef->num_cols << "cols"; | ||
290 | for (unsigned int i = 0; i < tableDef->num_cols; i++) { | 290 | for (unsigned int i = 0; i < tableDef->num_cols; i++) { | ||
291 | MdbColumn *col = (MdbColumn*) g_ptr_array_index(tableDef->columns, i); | 291 | MdbColumn *col = (MdbColumn*) g_ptr_array_index(tableDef->columns, i); | ||
292 | 292 | | |||
293 | if (col->col_type == MDB_OLE && col->cur_value_len) { | 293 | if (col->col_type == MDB_OLE && col->cur_value_len) { | ||
294 | mdb_ole_read(m_mdb, col, columnData[i], MDB_BIND_SIZE); | 294 | mdb_ole_read(m_mdb, col, columnData[i], MDB_BIND_SIZE); | ||
295 | } | 295 | } | ||
296 | 296 | | |||
297 | //! @todo: How to import binary data? | 297 | //! @todo: How to import binary data? | ||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 385 | { | |||
403 | 403 | | |||
404 | if (!foundIdx) { | 404 | if (!foundIdx) { | ||
405 | mdb_free_indices(tableDef->indices); | 405 | mdb_free_indices(tableDef->indices); | ||
406 | return false; | 406 | return false; | ||
407 | } | 407 | } | ||
408 | 408 | | |||
409 | //! @todo: MDB index order (asc, desc) | 409 | //! @todo: MDB index order (asc, desc) | ||
410 | 410 | | |||
411 | qDebug() << "num_keys" << idx->num_keys; | 411 | //qDebug() << "num_keys" << idx->num_keys; | ||
412 | 412 | | |||
413 | //! Create the KdbIndexSchema ... | 413 | //! Create the KdbIndexSchema ... | ||
414 | QVector<int> key_col_num(idx->num_keys); | 414 | QVector<int> key_col_num(idx->num_keys); | ||
415 | 415 | | |||
416 | // MDBTools counts columns from 1 - subtract 1 where necessary | 416 | // MDBTools counts columns from 1 - subtract 1 where necessary | ||
417 | KDbIndexSchema* p_idx = new KDbIndexSchema; | 417 | KDbIndexSchema* p_idx = new KDbIndexSchema; | ||
418 | table->addIndex(p_idx); | 418 | table->addIndex(p_idx); | ||
419 | 419 | | |||
420 | bool ok = true; | 420 | bool ok = true; | ||
421 | for (unsigned int i = 0; i < idx->num_keys; i++) { | 421 | for (unsigned int i = 0; i < idx->num_keys; i++) { | ||
422 | key_col_num[i] = idx->key_col_num[i]; | 422 | key_col_num[i] = idx->key_col_num[i]; | ||
423 | qDebug() << "key" << i + 1 << " col " << key_col_num[i] | 423 | //qDebug() << "key" << i + 1 << "col" << key_col_num[i] | ||
424 | << table->field(idx->key_col_num[i] - 1)->name(); | 424 | // << table->field(idx->key_col_num[i] - 1)->name(); | ||
425 | if (!p_idx->addField(table->field(idx->key_col_num[i] - 1))) { | 425 | if (!p_idx->addField(table->field(idx->key_col_num[i] - 1))) { | ||
426 | delete p_idx; | 426 | delete p_idx; | ||
427 | ok = false; | 427 | ok = false; | ||
428 | break; | 428 | break; | ||
429 | } | 429 | } | ||
430 | } | 430 | } | ||
431 | 431 | | |||
432 | if (ok) { | 432 | if (ok) { | ||
Show All 30 Lines |