def execImport(self): #Initiate the import process success = False matchCols = self.getSrcDestPairs() #Specify geometry column geomColumn=None if self.field("typeSpatial"): geomColumn = str(self.field("geomCol")) #Ensure that user has selected at least one column if it is a non-spatial table if len(matchCols) == 0: self.ErrorInfoMessage("Please select at least one source column.") return success try: if self.field("optOverwrite"): self.dataReader.featToDb(self.targetTab,matchCols,False,self,geomColumn) else: self.dataReader.featToDb(self.targetTab,matchCols,True,self,geomColumn) self.InfoMessage("All features have been imported successfully!") #Update directory info in the registry setVectorFileDir(str(self.field("srcFile"))) success = True except: self.ErrorInfoMessage(str(sys.exc_info()[1])) return success
def execExport(self): #Initiate the export process succeed = False targetFile = str(self.field("destFile")) writer = OGRWriter(targetFile) resultSet = self.filter_buildQuery() if resultSet is None: return succeed if resultSet.rowcount == 0: self.ErrorInfoMessage("There are no records to export") return succeed try: writer.db2Feat(self, self.srcTab, resultSet, self.selectedColumns(), self.geomColumn) self.InfoMessage( "Features in '%s' have been successfully exported!" % (self.srcTab)) #Update directory info in the registry setVectorFileDir(targetFile) succeed = True except: self.ErrorInfoMessage(str(sys.exc_info()[1])) return succeed
def execExport(self): #Initiate the export process succeed = False targetFile = str(self.field("destFile")) writer = OGRWriter(targetFile) resultSet = self.filter_buildQuery() if resultSet is None: return succeed if resultSet.rowcount == 0: self.ErrorInfoMessage("There are no records to export") return succeed try: writer.db2Feat(self,self.srcTab,resultSet,self.selectedColumns(),self.geomColumn) self.InfoMessage("Features in '%s' have been successfully exported!"%(self.srcTab)) #Update directory info in the registry setVectorFileDir(targetFile) succeed=True except: self.ErrorInfoMessage(str(sys.exc_info()[1])) return succeed
def execImport(self): #Initiate the import process success = False matchCols = self.getSrcDestPairs() #Specify geometry column geom_column = None if self.field("typeSpatial"): geom_column = self.field("geomCol") #Ensure that user has selected at least one column if it is a non-spatial table if len(matchCols) == 0: self.ErrorInfoMessage("Please select at least one source column.") return success value_translator_manager = self._trans_widget_mgr.translator_manager() try: if self.field("optOverwrite"): self.dataReader.featToDb( self.targetTab, matchCols, False, self, geom_column, translator_manager=value_translator_manager) else: self.dataReader.featToDb( self.targetTab, matchCols, True, self, geom_column, translator_manager=value_translator_manager) self.InfoMessage("All features have been imported successfully!") #Update directory info in the registry setVectorFileDir(self.field("srcFile")) success = True except: self.ErrorInfoMessage(unicode(sys.exc_info()[1])) return success
def execExport(self): #Initiate the export process succeed = False targetFile = str(self.field("destFile")) writer = OGRWriter(targetFile) resultSet = self.filter_buildQuery() if resultSet is None: return succeed if resultSet.rowcount == 0: msg = QApplication.translate( 'ExportData', u"There are no records to export.") self.ErrorInfoMessage(msg) return succeed try: writer.db2Feat( self, self.srcTab, resultSet, self.selectedColumns(), self.geomColumn ) ft = QApplication.translate('ExportData', 'Features in ') succ = QApplication.translate( 'ExportData', 'have been successfully exported!') self.InfoMessage(u'{}{} {}'.format(ft, self.srcTab, succ)) # Update directory info in the registry setVectorFileDir(targetFile) succeed = True except Exception as ex: self.ErrorInfoMessage(ex) return succeed
def execImport(self): #Initiate the import process success = False matchCols = self.getSrcDestPairs() #Specify geometry column geom_column=None if self.field("typeSpatial"): geom_column = self.field("geomCol") # Ensure that user has selected at least one column if it is a # non-spatial table if len(matchCols) == 0: self.ErrorInfoMessage("Please select at least one source column.") return success value_translator_manager = self._trans_widget_mgr.translator_manager() # try: if self.field("optOverwrite"): entity = self.curr_profile.entity_by_name(self.targetTab) dependencies = entity.dependencies() view_dep = dependencies['views'] entity_dep = [e.name for e in entity.children()] entities_dep_str = ', '.join(entity_dep) views_dep_str = ', '.join(view_dep) if len(entity_dep) > 0 or len(view_dep) > 0: del_msg = QApplication.translate( 'ImportData', "Overwriting existing records will permanently \n" "remove records from other tables linked to the \n" "records. The following tables will be affected." "\n{}\n{}" "\nClick Yes to proceed importing or No to cancel.". format(entities_dep_str, views_dep_str) ) del_result = QMessageBox.critical( self, QApplication.translate( "ImportData", "Overwrite Import Data Warning" ), del_msg, QMessageBox.Yes | QMessageBox.No ) if del_result == QMessageBox.Yes: self.dataReader.featToDb( self.targetTab, matchCols, False, self, geom_column, translator_manager=value_translator_manager ) # Update directory info in the registry setVectorFileDir(self.field("srcFile")) self.InfoMessage( "All features have been imported successfully!" ) success = True else: success = False else: self.dataReader.featToDb( self.targetTab, matchCols, True, self, geom_column, translator_manager=value_translator_manager ) self.InfoMessage( "All features have been imported successfully!" ) #Update directory info in the registry setVectorFileDir(self.field("srcFile")) success = True # except: # self.ErrorInfoMessage(unicode(sys.exc_info()[1])) return success
def execImport(self): #Initiate the import process success = False matchCols = self.getSrcDestPairs() #Specify geometry column geom_column=None if self.field("typeSpatial"): geom_column = self.field("geomCol") # Ensure that user has selected at least one column if it is a # non-spatial table if len(matchCols) == 0: self.ErrorInfoMessage("Please select at least one source column.") return success value_translator_manager = self._trans_widget_mgr.translator_manager() # try: if self.field("optOverwrite"): entity = self.curr_profile.entity_by_name(self.targetTab) dependencies = entity.dependencies() view_dep = dependencies['views'] entity_dep = [e.name for e in entity.children()] entities_dep_str = ', '.join(entity_dep) views_dep_str = ', '.join(view_dep) if len(entity_dep) > 0 or len(view_dep) > 0: del_msg = QApplication.translate( 'ImportData', "Overwriting existing records will permanently \n" "remove records from other tables linked to the \n" "records. The following tables will be affected." "\n{}\n{}" "\nClick Yes to proceed importing or No to cancel.". format(entities_dep_str, views_dep_str) ) del_result = QMessageBox.critical( self, QApplication.translate( "ImportData", "Overwrite Import Data Warning" ), del_msg, QMessageBox.Yes | QMessageBox.No ) if del_result == QMessageBox.Yes: self.dataReader.featToDb( self.targetTab, matchCols, False, self, geom_column, translator_manager=value_translator_manager ) # Update directory info in the registry setVectorFileDir(self.field("srcFile")) self.InfoMessage( "All features have been imported successfully!") else: success = False else: self.dataReader.featToDb( self.targetTab, matchCols, True, self, geom_column, translator_manager=value_translator_manager ) self.InfoMessage( "All features have been imported successfully!" ) #Update directory info in the registry setVectorFileDir(self.field("srcFile")) success = True # except: # self.ErrorInfoMessage(unicode(sys.exc_info()[1])) return success