@Override public DriverFunction addingService(ServiceReference<DriverFunction> reference) { DriverFunction service = bundleContext.getService(reference); driverFunctionContainer.addDriverFunction(service); return service; }
@Override public void removedService(ServiceReference<DriverFunction> reference, DriverFunction service) { driverFunctionContainer.removeDriverFunction(service); } }
@Override public void run(ProgressMonitor pm) { long deb = System.currentTimeMillis(); try(Connection connection = dataManager.getDataSource().getConnection()) { ProgressMonitor filePm = pm.startTask(files.size()); boolean isH2 = JDBCUtilities.isH2DataBase(connection.getMetaData()); for(File file : files) { String ext = FilenameUtils.getExtension(file.getName()); DriverFunction driverFunction = driverFunctionContainer.getImportDriverFromExt(ext, driverType); if(driverFunction != null) { TableLocation tableName = new TableLocation("","",dataManager.findUniqueTableName( TableLocation.capsIdentifier(FileUtils.getNameFromURI(file.toURI()), isH2))); driverFunction.importFile(connection, tableName.toString() ,file, new H2GISProgressMonitor(filePm)); } else { LOGGER.error(I18N.tr("No driver found for {0} extension", ext)); } } } catch (SQLException ex) { LOGGER.error(I18N.tr("Cannot import the file"), ex); // Print additional information while((ex = ex.getNextException()) != null) { LOGGER.error(ex.getLocalizedMessage()); } } catch (IOException ex) { LOGGER.error(I18N.tr("Cannot import the file"), ex); } LOGGER.info(I18N.tr("Importation done in {0} sec", (System.currentTimeMillis() - deb) / 1000d)); catalog.refreshSourceList(); } }