Search in sources :

Example 16 with DatabaseConfiguration

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());
}
Also used : DatabaseConfiguration(com.google.refine.extension.database.DatabaseConfiguration) Parameters(org.testng.annotations.Parameters) BeforeTest(org.testng.annotations.BeforeTest)

Example 17 with DatabaseConfiguration

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());
}
Also used : DatabaseConfiguration(com.google.refine.extension.database.DatabaseConfiguration) Parameters(org.testng.annotations.Parameters) BeforeTest(org.testng.annotations.BeforeTest)

Example 18 with DatabaseConfiguration

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());
}
Also used : DatabaseConfiguration(com.google.refine.extension.database.DatabaseConfiguration)

Example 19 with DatabaseConfiguration

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;
}
Also used : DatabaseConfiguration(com.google.refine.extension.database.DatabaseConfiguration)

Example 20 with DatabaseConfiguration

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);
    }
}
Also used : DatabaseConfiguration(com.google.refine.extension.database.DatabaseConfiguration) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Aggregations

DatabaseConfiguration (com.google.refine.extension.database.DatabaseConfiguration)22 BeforeTest (org.testng.annotations.BeforeTest)11 Parameters (org.testng.annotations.Parameters)11 IOException (java.io.IOException)8 ServletException (javax.servlet.ServletException)8 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)5 Writer (java.io.Writer)5 DatabaseServiceException (com.google.refine.extension.database.DatabaseServiceException)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 DatabaseInfo (com.google.refine.extension.database.model.DatabaseInfo)3