Search in sources :

Example 16 with DatabaseConnection

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

the class ConnectionServiceImplIT method testAddConnectionDublicate.

@Test(expected = ConnectionServiceException.class)
public void testAddConnectionDublicate() throws ConnectionServiceException {
    DatabaseConnection connection = new DatabaseConnection();
    connection.setName(DUBLICATE_CONNECTION_NAME);
    connectionServiceImpl.addConnection(connection);
}
Also used : DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) Test(org.junit.Test)

Example 17 with DatabaseConnection

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

the class ConnectionServiceImplIT method testUpdateConnectionNonExist.

@Test(expected = ConnectionServiceException.class)
public void testUpdateConnectionNonExist() throws ConnectionServiceException {
    DatabaseConnection connection = new DatabaseConnection();
    connection.setName(NON_EXIST_CONNECTION_NAME);
    connectionServiceImpl.updateConnection(connection);
}
Also used : DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) Test(org.junit.Test)

Example 18 with DatabaseConnection

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

the class ConnectionServiceImplIT method setUp.

@Before
public void setUp() throws DuplicateDatasourceException, DatasourceMgmtServiceException {
    DatabaseConnection connection = new DatabaseConnection();
    connection.setName(EXIST_CONNECTION_NAME);
    connection.setId(EXIST_CONNECTION_ID);
    connection.setPassword(PASSWORD);
    mgmtService.createDatasource(connection);
}
Also used : DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) Before(org.junit.Before)

Example 19 with DatabaseConnection

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

the class AgileMartDatasourceHelper method getAgileMartDatasource.

private IDatabaseConnection getAgileMartDatasource(Boolean useDefault, Properties agileMartDatasourceProperties) {
    IDatabaseConnection databaseConnection = new DatabaseConnection();
    IDatabaseDialectService databaseDialectService = PentahoSystem.get(IDatabaseDialectService.class);
    DatabaseTypeHelper databaseTypeHelper = new DatabaseTypeHelper(databaseDialectService.getDatabaseTypes());
    databaseConnection.setDatabaseType(databaseTypeHelper.getDatabaseTypeByShortName(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_DATABASETYPESHORTNAME_VALUE) : agileMartDatasourceProperties.getProperty(DATABASETYPESHORTNAME)));
    String accessType = useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_ACCESS_TYPE_VALUE) : agileMartDatasourceProperties.getProperty(ACCESS_TYPE);
    // This is a special case with some PDI connections
    if (accessType != null && accessType.contains("Native") || accessType.equals("NATIVE")) {
        accessType = DatabaseAccessType.NATIVE.getName();
    } else if (accessType != null && accessType.equals(", ")) {
        accessType = DatabaseAccessType.JNDI.getName();
    }
    databaseConnection.setAccessType(accessType != null ? DatabaseAccessType.getAccessTypeByName(accessType) : null);
    databaseConnection.setName(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_NAME_VALUE) : agileMartDatasourceProperties.getProperty(NAME));
    databaseConnection.setChanged(Boolean.getBoolean(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_CHANGED_VALUE) : agileMartDatasourceProperties.getProperty(CHANGED)));
    databaseConnection.setDatabaseName(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_DATABASENAME_VALUE) : agileMartDatasourceProperties.getProperty(DATABASENAME));
    databaseConnection.setDatabasePort(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_DATABASEPORT_VALUE) : agileMartDatasourceProperties.getProperty(DATABASEPORT));
    databaseConnection.setForcingIdentifiersToLowerCase(Boolean.getBoolean(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_FORCINGIDENTIFIERSTOLOWERCASE_VALUE) : agileMartDatasourceProperties.getProperty(FORCINGIDENTIFIERSTOLOWERCASE)));
    databaseConnection.setForcingIdentifiersToUpperCase(Boolean.getBoolean(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_FORCINGIDENTIFIERSTOUPPERCASE_VALUE) : agileMartDatasourceProperties.getProperty(FORCINGIDENTIFIERSTOUPPERCASE)));
    databaseConnection.setHostname(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_HOSTNAME_VALUE) : agileMartDatasourceProperties.getProperty(HOSTNAME));
    databaseConnection.setInitialPoolSize(Integer.valueOf(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_INITIALPOOLSIZE_VALUE) : agileMartDatasourceProperties.getProperty(INITIALPOOLSIZE)));
    databaseConnection.setMaximumPoolSize(Integer.valueOf(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_MAXIMUMPOOLSIZE_VALUE) : agileMartDatasourceProperties.getProperty(MAXIMUMPOOLSIZE)));
    databaseConnection.setPartitioned(Boolean.getBoolean(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_PARTITIONED_VALUE) : agileMartDatasourceProperties.getProperty(PARTITIONED)));
    databaseConnection.setPassword(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_PASSWORD_VALUE) : agileMartDatasourceProperties.getProperty(PASSWORD));
    databaseConnection.setUsername(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_USERNAME_VALUE) : agileMartDatasourceProperties.getProperty(USERNAME));
    databaseConnection.setUsingConnectionPool(Boolean.getBoolean(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_USECONNECTIONPOOL_VALUE) : agileMartDatasourceProperties.getProperty(USECONNECTIONPOOL)));
    databaseConnection.setUsingDoubleDecimalAsSchemaTableSeparator(Boolean.getBoolean(useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_USINGDOUBLEDECIMALASSCHEMATABLESEPERATOR_VALUE) : agileMartDatasourceProperties.getProperty(USINGDOUBLEDECIMALASSCHEMATABLESEPERATOR)));
    Map<String, String> attributes = new HashMap<String, String>();
    attributes.put(ATTRIBUTE_PORT_NUMBER, useDefault ? agileMartDatasourceProperties.getProperty(DEFAULT_DATABASEPORT_VALUE) : agileMartDatasourceProperties.getProperty(DATABASEPORT));
    attributes.put(ATTRIBUTE_STANDARD_CONNECTION, Boolean.FALSE.toString());
    attributes.put(ATTRIBUTE_AGILE_MART_CONNECTION, Boolean.TRUE.toString());
    databaseConnection.setAttributes(attributes);
    return databaseConnection;
}
Also used : DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) HashMap(java.util.HashMap) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) IDatabaseDialectService(org.pentaho.database.service.IDatabaseDialectService)

Example 20 with DatabaseConnection

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

the class ConnectionServiceConcrete method getConnectionByName.

public DatabaseConnection getConnectionByName(String name) throws ConnectionServiceException {
    DatabaseConnection connection = (DatabaseConnection) service.getConnectionByName(name);
    hidePassword(connection);
    return connection;
}
Also used : IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) DatabaseConnection(org.pentaho.database.model.DatabaseConnection)

Aggregations

DatabaseConnection (org.pentaho.database.model.DatabaseConnection)56 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)48 Test (org.junit.Test)36 HashMap (java.util.HashMap)10 IDatabaseDialectService (org.pentaho.database.service.IDatabaseDialectService)7 DatabaseType (org.pentaho.database.model.DatabaseType)6 DatabaseDialectService (org.pentaho.database.service.DatabaseDialectService)6 DatabaseTypeHelper (org.pentaho.database.util.DatabaseTypeHelper)6 ArrayList (java.util.ArrayList)5 Matchers.containsString (org.hamcrest.Matchers.containsString)5 IDatabaseType (org.pentaho.database.model.IDatabaseType)5 DBDatasourceServiceException (org.pentaho.platform.api.data.DBDatasourceServiceException)5 ConnectionServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.ConnectionServiceException)5 Response (javax.ws.rs.core.Response)4 List (java.util.List)3 LinkedList (java.util.LinkedList)2 Mockito.anyString (org.mockito.Mockito.anyString)2 DatabaseAccessType (org.pentaho.database.model.DatabaseAccessType)2 PartitionDatabaseMeta (org.pentaho.database.model.PartitionDatabaseMeta)2 Category (org.pentaho.metadata.model.Category)2