Search in sources :

Example 1 with DatabaseType

use of org.pentaho.database.model.DatabaseType in project pentaho-platform by pentaho.

the class DatabaseHelperTest method createDatabaseConnection.

private DatabaseConnection createDatabaseConnection() {
    DatabaseConnection databaseConnection = new DatabaseConnection();
    databaseConnection.setDatabaseType(new DatabaseType());
    databaseConnection.setName("name");
    databaseConnection.setId("id");
    databaseConnection.setAccessType(DatabaseAccessType.CUSTOM);
    databaseConnection.setHostname("hostName");
    databaseConnection.setDatabaseName("databaseName");
    databaseConnection.setDatabasePort("8080");
    databaseConnection.setUsername("username");
    databaseConnection.setPassword("password");
    databaseConnection.setInformixServername("informixServername");
    databaseConnection.setDataTablespace("dataTablespace");
    databaseConnection.setIndexTablespace("indexTableSpace");
    databaseConnection.setConnectSql("connectSql");
    databaseConnection.setInitialPoolSize(1);
    databaseConnection.setMaximumPoolSize(1);
    databaseConnection.setUsingConnectionPool(true);
    databaseConnection.setForcingIdentifiersToLowerCase(true);
    databaseConnection.setForcingIdentifiersToUpperCase(true);
    databaseConnection.setQuoteAllFields(true);
    databaseConnection.setUsingDoubleDecimalAsSchemaTableSeparator(true);
    Map<String, String> attributeMap = new HashMap<String, String>();
    attributeMap.put("key", "value");
    databaseConnection.setAttributes(attributeMap);
    Map<String, String> connectionPoolingMap = new HashMap<String, String>();
    connectionPoolingMap.put("key", "value");
    databaseConnection.setConnectionPoolingProperties(connectionPoolingMap);
    Map<String, String> extraOptions = new HashMap<String, String>();
    extraOptions.put("key", "value");
    databaseConnection.setExtraOptions(extraOptions);
    Map<String, String> extraOptionsOrder = new HashMap<String, String>();
    extraOptions.put("key", "value");
    databaseConnection.setExtraOptionsOrder(extraOptions);
    return databaseConnection;
}
Also used : DatabaseType(org.pentaho.database.model.DatabaseType) HashMap(java.util.HashMap) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) DatabaseConnection(org.pentaho.database.model.DatabaseConnection)

Example 2 with DatabaseType

use of org.pentaho.database.model.DatabaseType in project data-access by pentaho.

the class AutobeanUtilitiesTest method testConnectionBeanToImpl.

@Test
public void testConnectionBeanToImpl() {
    DatabaseConnection dbConnection = new DatabaseConnection();
    dbConnection.setId("my id");
    dbConnection.setAccessType(DatabaseAccessType.NATIVE);
    DatabaseType dbType = new DatabaseType();
    List<DatabaseAccessType> accessTypes = new LinkedList<DatabaseAccessType>();
    accessTypes.add(DatabaseAccessType.NATIVE);
    dbType.setSupportedAccessTypes(accessTypes);
    dbConnection.setDatabaseType(dbType);
    Map<String, String> extraOptions = new HashMap<String, String>();
    extraOptions.put("opt", "value");
    dbConnection.setExtraOptions(extraOptions);
    dbConnection.setName("Best name");
    dbConnection.setHostname("localhost");
    dbConnection.setDatabaseName("foodmart");
    dbConnection.setDatabasePort("2233");
    dbConnection.setUsername("username");
    dbConnection.setPassword("password");
    dbConnection.setStreamingResults(true);
    dbConnection.setDataTablespace("tables");
    dbConnection.setIndexTablespace("indexes");
    dbConnection.setSQLServerInstance("INSTANCE_0");
    dbConnection.setUsingDoubleDecimalAsSchemaTableSeparator(true);
    dbConnection.setInformixServername("INFORM_1");
    dbConnection.addExtraOption("100", "option", "value");
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("attr1", "value");
    dbConnection.setAttributes(attributes);
    dbConnection.setChanged(true);
    dbConnection.setQuoteAllFields(true);
    dbConnection.setForcingIdentifiersToLowerCase(true);
    dbConnection.setForcingIdentifiersToUpperCase(true);
    dbConnection.setConnectSql("select * from 1");
    dbConnection.setUsingConnectionPool(true);
    dbConnection.setInitialPoolSize(3);
    dbConnection.setMaximumPoolSize(9);
    dbConnection.setPartitioned(true);
    Map<String, String> connectionPoolingProperties = new HashMap<String, String>();
    connectionPoolingProperties.put("pool", "abc");
    dbConnection.setConnectionPoolingProperties(connectionPoolingProperties);
    List<PartitionDatabaseMeta> partitioningInformation = new LinkedList<PartitionDatabaseMeta>();
    PartitionDatabaseMeta pdm = new PartitionDatabaseMeta();
    partitioningInformation.add(pdm);
    dbConnection.setPartitioningInformation(partitioningInformation);
    IDatabaseConnection conn = AutobeanUtilities.connectionBeanToImpl(dbConnection);
    assertEquals(conn.getId(), "my id");
    assertEquals(conn.getAccessType(), DatabaseAccessType.NATIVE);
    assertEquals(conn.getDatabaseType().getSupportedAccessTypes().size(), 1);
    assertEquals(conn.getExtraOptions().size(), 3);
    assertEquals(conn.getName(), "Best name");
    assertEquals(conn.getHostname(), "localhost");
    assertEquals(conn.getDatabaseName(), "foodmart");
    assertEquals(conn.getDatabasePort(), "2233");
    assertEquals(conn.getUsername(), "username");
    assertEquals(conn.getPassword(), "password");
    assertEquals(conn.isStreamingResults(), true);
    assertEquals(conn.getDataTablespace(), "tables");
    assertEquals(conn.getIndexTablespace(), "indexes");
    assertEquals(conn.getSQLServerInstance(), "INSTANCE_0");
    assertEquals(conn.isUsingDoubleDecimalAsSchemaTableSeparator(), true);
    assertEquals(conn.getInformixServername(), "INFORM_1");
    assertEquals(conn.getAttributes().size(), 1);
    assertEquals(conn.getChanged(), false);
    assertEquals(conn.isQuoteAllFields(), true);
    assertEquals(conn.isForcingIdentifiersToLowerCase(), true);
    assertEquals(conn.isForcingIdentifiersToUpperCase(), true);
    assertEquals(conn.getConnectSql(), "select * from 1");
    assertEquals(conn.isUsingConnectionPool(), true);
    assertEquals(conn.getInitialPoolSize(), 3);
    assertEquals(conn.getMaximumPoolSize(), 9);
    assertEquals(conn.isPartitioned(), true);
    assertEquals(conn.getConnectionPoolingProperties().size(), 1);
    assertEquals(conn.getPartitioningInformation().size(), 1);
}
Also used : DatabaseType(org.pentaho.database.model.DatabaseType) IDatabaseType(org.pentaho.database.model.IDatabaseType) DatabaseAccessType(org.pentaho.database.model.DatabaseAccessType) HashMap(java.util.HashMap) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) PartitionDatabaseMeta(org.pentaho.database.model.PartitionDatabaseMeta) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 3 with DatabaseType

use of org.pentaho.database.model.DatabaseType in project data-access by pentaho.

the class DatabaseConnectionConverterTest method testConvertToXml.

@Test
public void testConvertToXml() {
    DatabaseConnection dbConnection = new DatabaseConnection();
    dbConnection.setId("my id");
    dbConnection.setAccessType(DatabaseAccessType.NATIVE);
    List<DatabaseAccessType> accessTypes = new LinkedList<DatabaseAccessType>();
    accessTypes.add(DatabaseAccessType.NATIVE);
    DatabaseType dbType = new DatabaseType("name", "short name", accessTypes, 100500, "helpUri");
    dbConnection.setDatabaseType(dbType);
    Map<String, String> extraOptions = new HashMap<String, String>();
    extraOptions.put("opt", "value");
    dbConnection.setExtraOptions(extraOptions);
    dbConnection.setName("Best name");
    dbConnection.setHostname("localhost");
    dbConnection.setDatabaseName("foodmart");
    dbConnection.setDatabasePort("2233");
    dbConnection.setUsername("username");
    dbConnection.setPassword("password");
    dbConnection.setStreamingResults(true);
    dbConnection.setDataTablespace("tables");
    dbConnection.setIndexTablespace("indexes");
    dbConnection.setSQLServerInstance("INSTANCE_0");
    dbConnection.setUsingDoubleDecimalAsSchemaTableSeparator(true);
    dbConnection.setInformixServername("INFORM_1");
    dbConnection.addExtraOption("100", "option", "value");
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put("attr1", "value");
    dbConnection.setAttributes(attributes);
    dbConnection.setChanged(true);
    dbConnection.setQuoteAllFields(true);
    dbConnection.setForcingIdentifiersToLowerCase(true);
    dbConnection.setForcingIdentifiersToUpperCase(true);
    dbConnection.setConnectSql("select * from 1");
    dbConnection.setUsingConnectionPool(true);
    dbConnection.setInitialPoolSize(3);
    dbConnection.setMaximumPoolSize(9);
    dbConnection.setPartitioned(true);
    Map<String, String> connectionPoolingProperties = new HashMap<String, String>();
    connectionPoolingProperties.put("pool", "abc");
    dbConnection.setConnectionPoolingProperties(connectionPoolingProperties);
    List<PartitionDatabaseMeta> partitioningInformation = new LinkedList<PartitionDatabaseMeta>();
    PartitionDatabaseMeta pdm = new PartitionDatabaseMeta();
    partitioningInformation.add(pdm);
    dbConnection.setPartitioningInformation(partitioningInformation);
    List<IDatabaseType> databaseTypes = new LinkedList<IDatabaseType>();
    databaseTypes.add(dbType);
    DatabaseTypeHelper dbh = new DatabaseTypeHelper(databaseTypes);
    DatabaseConnectionConverter dbcc = new DatabaseConnectionConverter(dbh);
    String xmlCOnnection = dbcc.convertToXml(dbConnection);
}
Also used : DatabaseType(org.pentaho.database.model.DatabaseType) IDatabaseType(org.pentaho.database.model.IDatabaseType) HashMap(java.util.HashMap) PartitionDatabaseMeta(org.pentaho.database.model.PartitionDatabaseMeta) LinkedList(java.util.LinkedList) IDatabaseType(org.pentaho.database.model.IDatabaseType) DatabaseAccessType(org.pentaho.database.model.DatabaseAccessType) DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) Test(org.junit.Test)

Example 4 with DatabaseType

use of org.pentaho.database.model.DatabaseType in project data-access by pentaho.

the class AutobeanUtilities method dbTypeBeanToImpl.

/**
 * @param databaseType - A DatabaseType
 * @return IDatabaseType backed by an DatabaseType
 * <p/>
 * Conversion method for creating a Database Type from an Autobean implementation of IDatabaseType
 */
public static IDatabaseType dbTypeBeanToImpl(IDatabaseType databaseTypeBean) {
    DatabaseType databaseTypeImpl = new DatabaseType();
    databaseTypeImpl.setDefaultDatabasePort(databaseTypeBean.getDefaultDatabasePort());
    databaseTypeImpl.setExtraOptionsHelpUrl(databaseTypeBean.getExtraOptionsHelpUrl());
    databaseTypeImpl.setName(databaseTypeBean.getName());
    databaseTypeImpl.setShortName(databaseTypeBean.getShortName());
    databaseTypeImpl.setSupportedAccessTypes(listBeanToImpl(databaseTypeBean.getSupportedAccessTypes()));
    return databaseTypeImpl;
}
Also used : DatabaseType(org.pentaho.database.model.DatabaseType) IDatabaseType(org.pentaho.database.model.IDatabaseType)

Example 5 with DatabaseType

use of org.pentaho.database.model.DatabaseType in project data-access by pentaho.

the class ConnectionServiceImplIT method testTestConnection.

@Test
public void testTestConnection() throws ConnectionServiceException {
    DatabaseConnection connection = new DatabaseConnection();
    connection.setName(NON_EXIST_CONNECTION_NAME);
    connection.setAccessType(DatabaseAccessType.NATIVE);
    connection.setDatabaseType(new DatabaseType("H2", "H2", Arrays.asList(DatabaseAccessType.NATIVE), 0, null));
    assertTrue(connectionServiceImpl.testConnection(connection));
}
Also used : DatabaseType(org.pentaho.database.model.DatabaseType) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) Test(org.junit.Test)

Aggregations

DatabaseType (org.pentaho.database.model.DatabaseType)8 Test (org.junit.Test)6 DatabaseConnection (org.pentaho.database.model.DatabaseConnection)6 IDatabaseType (org.pentaho.database.model.IDatabaseType)6 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)5 HashMap (java.util.HashMap)3 LinkedList (java.util.LinkedList)3 DatabaseAccessType (org.pentaho.database.model.DatabaseAccessType)3 Mockito.anyString (org.mockito.Mockito.anyString)2 PartitionDatabaseMeta (org.pentaho.database.model.PartitionDatabaseMeta)2 DatabaseTypeHelper (org.pentaho.database.util.DatabaseTypeHelper)1