use of com.google.refine.extension.database.DatabaseConfiguration in project OpenRefine by OpenRefine.
the class MariaDBConnectionManagerTest method beforeTest.
@BeforeTest
@Parameters({ "mariadbDbName", "mariadbDbHost", "mariadbDbPort", "mariadbDbUser", "mariadbDbPassword", "mariaTestTable" })
public void beforeTest(@Optional(DEFAULT_MARIADB_NAME) String mariaDbName, @Optional(DEFAULT_MARIADB_HOST) String mariaDbHost, @Optional(DEFAULT_MARIADB_PORT) String mariaDbPort, @Optional(DEFAULT_MARIADB_USER) String mariaDbUser, @Optional(DEFAULT_MARIADB_PASSWORD) String mariaDbPassword, @Optional(DEFAULT_TEST_TABLE) String mariaDbTestTable) {
MockitoAnnotations.initMocks(this);
testDbConfig = new DatabaseConfiguration();
testDbConfig.setDatabaseHost(mariaDbHost);
testDbConfig.setDatabaseName(mariaDbName);
testDbConfig.setDatabasePassword(mariaDbPassword);
testDbConfig.setDatabasePort(Integer.parseInt(mariaDbPort));
testDbConfig.setDatabaseType(MariaDBDatabaseService.DB_NAME);
testDbConfig.setDatabaseUser(mariaDbUser);
testDbConfig.setUseSSL(false);
// testTable = mariaDbTestTable;
// DBExtensionTestUtils.initTestData(testDbConfig);
DatabaseService.DBType.registerDatabase(MariaDBDatabaseService.DB_NAME, MariaDBDatabaseService.getInstance());
}
use of com.google.refine.extension.database.DatabaseConfiguration in project OpenRefine by OpenRefine.
the class MySQLConnectionManagerTest method beforeTest.
@BeforeTest
@Parameters({ "mySqlDbName", "mySqlDbHost", "mySqlDbPort", "mySqlDbUser", "mySqlDbPassword", "mySqlTestTable" })
public void beforeTest(@Optional(DEFAULT_MYSQL_DB_NAME) String mySqlDbName, @Optional(DEFAULT_MYSQL_HOST) String mySqlDbHost, @Optional(DEFAULT_MYSQL_PORT) String mySqlDbPort, @Optional(DEFAULT_MYSQL_USER) String mySqlDbUser, @Optional(DEFAULT_MYSQL_PASSWORD) String mySqlDbPassword, @Optional(DEFAULT_TEST_TABLE) String mySqlTestTable) {
MockitoAnnotations.initMocks(this);
testDbConfig = new DatabaseConfiguration();
testDbConfig.setDatabaseHost(mySqlDbHost);
testDbConfig.setDatabaseName(mySqlDbName);
testDbConfig.setDatabasePassword(mySqlDbPassword);
testDbConfig.setDatabasePort(Integer.parseInt(mySqlDbPort));
testDbConfig.setDatabaseType(MySQLDatabaseService.DB_NAME);
testDbConfig.setDatabaseUser(mySqlDbUser);
testDbConfig.setUseSSL(false);
// testTable = mySqlTestTable;
// DBExtensionTestUtils.initTestData(testDbConfig);
DatabaseService.DBType.registerDatabase(MySQLDatabaseService.DB_NAME, MySQLDatabaseService.getInstance());
}
use of com.google.refine.extension.database.DatabaseConfiguration in project OpenRefine by OpenRefine.
the class SQLiteConnectionManagerTest method beforeTest.
@BeforeTest
@Parameters({ "sqliteDbName", "sqliteTestTable" })
public void beforeTest(@Optional(DEFAULT_SQLITE_DB_NAME) String sqliteDbName, @Optional(DEFAULT_TEST_TABLE) String sqliteTestTable) throws DatabaseServiceException, SQLException {
MockitoAnnotations.initMocks(this);
testDbConfig = new DatabaseConfiguration();
testDbConfig.setDatabaseName(sqliteDbName);
testDbConfig.setDatabaseType(SQLiteDatabaseService.DB_NAME);
DatabaseService.DBType.registerDatabase(SQLiteDatabaseService.DB_NAME, SQLiteDatabaseService.getInstance());
}
use of com.google.refine.extension.database.DatabaseConfiguration in project OpenRefine by OpenRefine.
the class DatabaseCommand method getJdbcConfiguration.
/**
* @param request
* @return
*/
protected DatabaseConfiguration getJdbcConfiguration(HttpServletRequest request) {
DatabaseConfiguration jdbcConfig = new DatabaseConfiguration();
jdbcConfig.setConnectionName(request.getParameter("connectionName"));
jdbcConfig.setDatabaseType(request.getParameter("databaseType"));
jdbcConfig.setDatabaseHost(request.getParameter("databaseServer"));
String dbPort = request.getParameter("databasePort");
if (dbPort != null) {
try {
jdbcConfig.setDatabasePort(Integer.parseInt(dbPort));
} catch (NumberFormatException nfe) {
}
}
jdbcConfig.setDatabaseUser(request.getParameter("databaseUser"));
jdbcConfig.setDatabasePassword(request.getParameter("databasePassword"));
jdbcConfig.setDatabaseName(request.getParameter("initialDatabase"));
jdbcConfig.setDatabaseSchema(request.getParameter("initialSchema"));
if (logger.isDebugEnabled()) {
logger.debug("JDBC Configuration: {}", jdbcConfig);
}
return jdbcConfig;
}
use of com.google.refine.extension.database.DatabaseConfiguration in project OpenRefine by OpenRefine.
the class SavedConnectionCommand method doGet.
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (logger.isDebugEnabled()) {
logger.debug("SavedConnectionCommand::Get::connectionName::{}", request.getParameter("connectionName"));
}
String connectionName = request.getParameter("connectionName");
try {
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Type", "application/json");
if (connectionName == null || connectionName.isEmpty()) {
writeSavedConnectionResponse(response);
} else {
DatabaseConfiguration savedConnection = DatabaseUtils.getSavedConnection(connectionName);
writeSavedConnectionResponse(response, savedConnection);
}
} catch (Exception e) {
logger.error("Exception while loading settings {}", e);
}
}
Aggregations