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);
}
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);
}
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);
}
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;
}
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;
}
Aggregations