use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class ConnectionController method createIDatabaseConnectionBean.
protected AutoBean<IDatabaseConnection> createIDatabaseConnectionBean(IDatabaseConnection connection) {
AutoBean<IDatabaseConnection> bean = connectionAutoBeanFactory.iDatabaseConnection();
IDatabaseConnection connectionBean = bean.as();
copyDatabaseConnectionProperties(connection, connectionBean);
return AutoBeanUtils.getAutoBean(connectionBean);
}
use of org.pentaho.database.model.IDatabaseConnection 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.IDatabaseConnection in project data-access by pentaho.
the class ConnectionService method getConnectionIdByNameWithResponse.
/**
* Returns a response with id of a database connection
*
* @param name
* String representing the name of the database to search
* @return Response based on the string value of the connection id
*
* @throws ConnectionServiceException
*/
@GET
@Path("/getid")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response getConnectionIdByNameWithResponse(@QueryParam("name") String name) throws ConnectionServiceException {
IDatabaseConnection conn = null;
Response response;
try {
conn = connectionService.getConnectionByName(name);
if (conn != null) {
response = Response.ok().entity(conn.getId()).build();
} else {
response = Response.notModified().build();
}
} catch (Exception ex) {
response = Response.serverError().entity(ex.getMessage()).build();
}
return response;
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class ConnectionService method getConnectionByNameWithResponse.
/**
* this is a method to return a response object with an error message use getEntity(Connection.class) and getStatus()
* to determine success
*/
@GET
@Path("/getresponse")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response getConnectionByNameWithResponse(@QueryParam("name") String name) throws ConnectionServiceException {
IDatabaseConnection conn = null;
Response response;
try {
conn = connectionService.getConnectionByName(name);
sanitizer.unsanitizeConnectionParameters(conn);
hidePassword(conn);
response = Response.ok().entity(conn).build();
} catch (Exception ex) {
response = Response.serverError().entity(ex.getMessage()).build();
}
return response;
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class ConnectionService method getConnectionByName.
/**
* Returns the list of database connections
*
* @param name
* String representing the name of the database to return
* @return Database connection by name
*
* @throws ConnectionServiceException
*/
@GET
@Path("/get")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public IDatabaseConnection getConnectionByName(@QueryParam("name") String name) throws ConnectionServiceException {
IDatabaseConnection conn = connectionService.getConnectionByName(name);
hidePassword(conn);
return conn;
}
Aggregations