def go_next(self): try: self.main.plan.migrationSource.selectedCatalogName, self.main.plan.migrationSource.selectedSchemataNames = self.schemata_to_migrate( ) except Exception as e: mforms.Utilities.show_error("Invalid Selection", str(e), "OK", "", "") return def find_selected_option( ): #TODO: When we finally drop py2.5 support substitute this with self.options.index(next(opt for opt in self.options if opt.get_active())) for idx, option_radio in enumerate(self.options): if option_radio.get_active(): return idx return None if self.doesSupportCatalogs: self.main.plan.state.applicationData["schemaMappingMethod"] = [ "drop_catalog", "drop_schema", "merge_schema" ][find_selected_option()] else: self.main.plan.state.applicationData[ "schemaMappingMethod"] = "drop_catalog" WizardPage.go_next(self)
def go_next(self): self.main.plan.state.objectCreationParams[ "KeepSchemata"] = self._keep_schema.get_active() self.main.plan.state.objectCreationParams[ "CreateInDB"] = self._create_db.get_active() if self._create_script.get_active(): path = self._create_script_file.get_string_value() if not path or not os.path.isdir(os.path.dirname(path)): mforms.Utilities.show_error( "Create Script File", "Create Script File option was enabled, but the provided path is invalid.\nPlease correct and retry.", "OK", "", "") return if os.path.isdir(path): mforms.Utilities.show_error( "Create Script File", "'%s' is a directory name. Please provide a file name for saving the script as and retry." % path, "OK", "", "") return if os.path.exists(path) and self._check_file_duplicate: if mforms.Utilities.show_error( "Create Script File", "The file '%s' provided for the SQL script already exists. Do you want to replace it?" % path, "Replace", "Cancel", "") == mforms.ResultCancel: return self.main.plan.state.objectCreationParams["CreateSQLFile"] = path elif "CreateSQLFile" in self.main.plan.state.objectCreationParams: del self.main.plan.state.objectCreationParams["CreateSQLFile"] WizardPage.go_next(self)
def go_next(self): self.main.plan.state.objectCreationParams["KeepSchemata"] = self._keep_schema.get_active() self.main.plan.state.objectCreationParams["CreateInDB"] = self._create_db.get_active() if self._create_script.get_active(): path = self._create_script_file.get_string_value() if not path or not os.path.isdir(os.path.dirname(path)): mforms.Utilities.show_error("Create Script File", "Create Script File option was enabled, but the provided path is invalid.\nPlease correct and retry.", "OK", "", "") return if os.path.isdir(path): mforms.Utilities.show_error("Create Script File", "'%s' is a directory name. Please provide a file name for saving the script as and retry." % path, "OK", "", "") return if os.path.exists(path) and self._check_file_duplicate: if mforms.Utilities.show_error("Create Script File", "The file '%s' provided for the SQL script already exists. Do you want to replace it?" % path, "Replace", "Cancel", "") == mforms.ResultCancel: return self.main.plan.state.objectCreationParams["CreateSQLFile"] = path elif self.main.plan.state.objectCreationParams.has_key("CreateSQLFile"): del self.main.plan.state.objectCreationParams["CreateSQLFile"] WizardPage.go_next(self)
def go_next(self): if self._error_tables: r = mforms.Utilities.show_warning("Table Creation Errors", "Some tables could not be created in the target database.\nWould you like to flag them to be skipped and copy the data for the remaining tables only?", "Skip Failed Tables", "Cancel", "") if r == mforms.ResultOk: for table in self._error_tables: table.commentedOut = 1 else: return WizardPage.go_next(self)
def go_next(self): i = self._worker_count.get_string_value() try: count = int(i) if count < 1: raise Exception("Bad value") except Exception: mforms.Utilities.show_error("Invalid Value", "Worker thread count must be a number larger than 0.", "OK", "", "") return self.main.plan.state.dataBulkTransferParams["workerCount"] = count #if self.dump_to_file.get_active(): # self.main.plan.state.dataBulkTransferParams["GenerateDumpScript"] = self.dump_to_file_entry.get_string_value() #else: # if "GenerateDumpScript" in self.main.plan.state.dataBulkTransferParams: # del self.main.plan.state.dataBulkTransferParams["GenerateDumpScript"] if self.copy_script_checkbox.get_active(): self.main.plan.state.dataBulkTransferParams["GenerateCopyScript"] = self.copy_script_entry.get_string_value() else: if self.main.plan.state.dataBulkTransferParams.has_key("GenerateCopyScript"): del self.main.plan.state.dataBulkTransferParams["GenerateCopyScript"] self.main.plan.state.dataBulkTransferParams["LiveDataCopy"] = 1 if self._copy_db.get_active() else 0 self.main.plan.state.dataBulkTransferParams["DebugTableCopy"] = 1 if self._debug_copy.get_active() else 0 self.main.plan.state.dataBulkTransferParams["TruncateTargetTables"] = 1 if self._truncate_db.get_active() else 0 for key in self.main.plan.state.dataBulkTransferParams.keys(): if key.endswith(":rangeKey"): del self.main.plan.state.dataBulkTransferParams[key] if key.endswith(":rangeStart"): del self.main.plan.state.dataBulkTransferParams[key] if key.endswith(":rangeEnd"): del self.main.plan.state.dataBulkTransferParams[key] if key.endswith(":rowCount"): del self.main.plan.state.dataBulkTransferParams[key] tables_to_copy = [] for row in range(self._tree.count()): n = self._tree.node_at_row(row) table = self._tables_by_id[n.get_tag()] count = n.get_string(1) if not count: tables_to_copy.append(table) else: try: count = int(count) if count > 0: # tables_to_copy.append(table) self.main.plan.state.dataBulkTransferParams["%s:rowCount" % table.__id__] = count except: grt.log_error("Invalid value in Migration DataCopy tree: %s"%count) self.main.plan.state.dataBulkTransferParams["tableList"] = tables_to_copy if self._copy_db.get_active() or self.copy_script_checkbox.get_active(): return WizardPage.go_next(self) else: self.main.go_next_page(2) return
def go_next(self): dic = self.main.plan.state.objectMigrationParams for item, name, getter in self._db_options: dic[name] = getter() WizardPage.go_next(self)
def go_next(self): if self.validate(): self.main.plan.migrationUpdate() WizardPage.go_next(self)
class SchemaMainView(WizardPage): def __init__(self, main): WizardPage.__init__(self, main, 'Schemas Selection') self._ui_created = False self.main.add_wizard_page(self, 'SourceTarget', 'Schemas Selection') optionspanel = mforms.newPanel(mforms.TitledBoxPanel) optionspanel.set_title('Schema Name Mapping Method') optionsbox = mforms.newBox(False) optionsbox.set_padding(8) optionsbox.set_spacing(8) label = mforms.newLabel( 'Choose how the reverse engineered schemas and objects should be mapped.\n' ) label.set_name('') optionsbox.add(label, False) options = [ 'Keep schemas as they are: Catalog.Schema.Table -> Schema.Table', 'Only one schema: Catalog.Schema.Table -> Catalog.Table', 'Only one schema, keep current schema names as a prefix: Catalog.Schema.Table -> Catalog.Schema_Table', ] rid = mforms.RadioButton.new_id() self.options = [] for opt in options: radio_button = mforms.newRadioButton(rid) radio_button.set_name('Option %i' % options.index(opt)) radio_button.set_text(opt) optionsbox.add(radio_button, False) self.options.append(radio_button) self.options[1].set_active(True) optionspanel.add(optionsbox) self._optionspanel = optionspanel #self._advanced_shown = False #self._optionspanel.show(False) self.content.add_end(optionspanel, False) def page_activated(self, advancing): WizardPage.page_activated(self, advancing) if advancing: self.doesSupportCatalogs = self.main.plan.migrationSource.rdbms.doesSupportCatalogs match_str = r"\%s\.\%s" % (self.main.plan.migrationSource. _db_module.quoteIdentifier('(.+)\\'), self.main.plan.migrationSource. _db_module.quoteIdentifier('(.+)\\')) if self.doesSupportCatalogs > 0: catalog_schemata_list = [ (catalog_name, schema_name) for catalog_name, schema_name in ( re.match(match_str, full_name).groups() for full_name in self.main.plan.migrationSource.schemaNames) ] self.catalog_schemata = {} for catalog_name, schema_name in catalog_schemata_list: self.catalog_schemata.setdefault(catalog_name, []).append(schema_name) self.catalog_schemata = self.catalog_schemata.items() self._optionspanel.show(True) #self.advanced_button.show(True) else: self.catalog_schemata = [ schema_name for catalog_name, schema_name in ( re.match(match_str, full_name).groups() for full_name in self.main.plan.migrationSource.schemaNames) ] self._optionspanel.show(False) #self.advanced_button.show(False) if self.schema_selector: self.content.remove(self.schema_selector) self.schema_selector = DatabaseSchemaSelector( self.catalog_schemata, tree_checked_callback=self.update_next_button) self.content.add(self.schema_selector, True, True) self.next_button.set_enabled(False) def create_ui(self): label = mforms.newLabel('Select the schemata you want to migrate:') label.set_name('Select Schema To Migrate') label.set_style(mforms.BoldStyle) self.content.add(label, False) self.schema_selector = None def should_skip(self): return self.main.plan.migrationSource.rdbms.doesSupportCatalogs < 0 and len( self.main.plan.migrationSource.schemaNames) == 1 def page_skipped(self): # called when the page is not activated, because should_skip returned True match_re = self.main.plan.migrationSource._db_module.quoteIdentifier( '(.+)\\') names = [ re.match(match_re, s).groups()[0] for s in self.main.plan.migrationSource.schemaNames ] self.main.plan.migrationSource.selectedCatalogName, self.main.plan.migrationSource.selectedSchemataNames = ( "def", names) self.main.plan.state.applicationData[ "schemaMappingMethod"] = "drop_catalog" def update_next_button(self, count): self.next_button.set_enabled(bool(count)) def schemata_to_migrate(self): selected = self.schema_selector.get_selected() if self.doesSupportCatalogs > 0: if len(selected) > 1: raise Exception( 'Cannot select multiple schemas from different catalogs') catalog = selected.keys()[0] return catalog, selected[catalog] else: return "def", selected #def go_advanced(self): # self._advanced_shown = not self._advanced_shown # self._optionspanel.show(self._advanced_shown) def go_next(self): try: self.main.plan.migrationSource.selectedCatalogName, self.main.plan.migrationSource.selectedSchemataNames = self.schemata_to_migrate( ) except Exception, e: mforms.Utilities.show_error("Invalid Selection", str(e), "OK", "", "") return def find_selected_option( ): #TODO: When we finally drop py2.5 support substitute this with self.options.index(next(opt for opt in self.options if opt.get_active())) for idx, option_radio in enumerate(self.options): if option_radio.get_active(): return idx return None if self.doesSupportCatalogs: self.main.plan.state.applicationData["schemaMappingMethod"] = [ "drop_catalog", "drop_schema", "merge_schema" ][find_selected_option()] else: self.main.plan.state.applicationData[ "schemaMappingMethod"] = "drop_catalog" WizardPage.go_next(self)
def go_next(self): i = self._worker_count.get_string_value() try: count = int(i) if count < 1: raise Exception("Bad value") except Exception: mforms.Utilities.show_error( "Invalid Value", "Worker thread count must be a number larger than 0.", "OK", "", "") return self.main.plan.state.dataBulkTransferParams["workerCount"] = count #if self.dump_to_file.get_active(): # self.main.plan.state.dataBulkTransferParams["GenerateDumpScript"] = self.dump_to_file_entry.get_string_value() #else: # if "GenerateDumpScript" in self.main.plan.state.dataBulkTransferParams: # del self.main.plan.state.dataBulkTransferParams["GenerateDumpScript"] if self.copy_script_radiobutton.get_active(): self.main.plan.state.dataBulkTransferParams[ "GenerateCopyScript"] = self.copy_script_entry.get_string_value( ) else: if self.main.plan.state.dataBulkTransferParams.has_key( "GenerateCopyScript"): del self.main.plan.state.dataBulkTransferParams[ "GenerateCopyScript"] if self.bulk_copy_script_radiobutton.get_active(): self.main.plan.state.dataBulkTransferParams[ "GenerateBulkCopyScript"] = self.bulk_copy_script_entry.get_string_value( ) else: if self.main.plan.state.dataBulkTransferParams.has_key( "GenerateBulkCopyScript"): del self.main.plan.state.dataBulkTransferParams[ "GenerateBulkCopyScript"] self.main.plan.state.dataBulkTransferParams[ "LiveDataCopy"] = 1 if self._copy_db.get_active() else 0 self.main.plan.state.dataBulkTransferParams[ "DebugTableCopy"] = 1 if self._debug_copy.get_active() else 0 self.main.plan.state.dataBulkTransferParams[ "DriverSendsDataAsUTF8"] = 1 if self._driver_sends_utf8.get_active( ) else 0 self.main.plan.state.dataBulkTransferParams[ "TruncateTargetTables"] = 1 if self._truncate_db.get_active( ) else 0 for key in self.main.plan.state.dataBulkTransferParams.keys(): if key.endswith(":rangeKey"): del self.main.plan.state.dataBulkTransferParams[key] if key.endswith(":rangeStart"): del self.main.plan.state.dataBulkTransferParams[key] if key.endswith(":rangeEnd"): del self.main.plan.state.dataBulkTransferParams[key] if key.endswith(":rowCount"): del self.main.plan.state.dataBulkTransferParams[key] tables_to_copy = [] for row in range(self._tree.count()): n = self._tree.node_at_row(row) table = self._tables_by_id[n.get_tag()] count = n.get_string(1) if not count: tables_to_copy.append(table) else: try: count = int(count) if count > 0: # tables_to_copy.append(table) self.main.plan.state.dataBulkTransferParams[ "%s:rowCount" % table.__id__] = count except: grt.log_error( "Invalid value in Migration DataCopy tree: %s" % count) self.main.plan.state.dataBulkTransferParams[ "tableList"] = tables_to_copy if self._copy_db.get_active( ) or self.copy_script_radiobutton.get_active( ) or self.bulk_copy_script_radiobutton.get_active(): return WizardPage.go_next(self) else: self.main.go_next_page(2) return
def go_next(self): if self.validate(): WizardPage.go_next(self)