use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class DSWDatasourceServiceImpl method checkSqlQueriesSupported.
/**
* Method is designed to check whether sql queries can be executed via connection with a {@core connName}.
* For now we can't allow sql queries for connections, that are based on Pentaho Data Services.
* See BISERVER-13225 for more info.
*
* @param connName
* name of connection, to be examined for sql queries support
* @throws ConnectionServiceException
* if an error occurs while receiving connection with {@code connectionName}
* @throws SqlQueriesNotSupportedException
* if query is not supported for a connection with a {@code connectionName}
*/
void checkSqlQueriesSupported(String connName) throws ConnectionServiceException, SqlQueriesNotSupportedException {
IDatabaseConnection conn = connService.getConnectionByName(connName);
IDatabaseType dbType = conn.getDatabaseType();
if (dbType.getName().equals(DB_TYPE_ID_PENTAHO_DATA_SERVICE)) {
throw new SqlQueriesNotSupportedException(Messages.getErrorString("DatasourceServiceImpl.ERROR_0024_SQL_QUERIES_NOT_SUPPORTED_FOR_PENTAHO_DATA_SERVICE"));
}
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class InMemoryConnectionServiceImpl method updateConnection.
public boolean updateConnection(IDatabaseConnection connection) throws ConnectionServiceException {
IDatabaseConnection conn = getConnectionByName(connection.getName());
if (conn != null) {
// conn.setDriverClass(connection.getDriverClass());
conn.setAccessType(connection.getAccessType());
conn.setPassword(connection.getPassword());
conn.setUsername(connection.getUsername());
return true;
} else {
logger.error(Messages.getErrorString("ConnectionServiceInMemoryDelegate.ERROR_0005_UNABLE_TO_UPDATE_CONNECTION", connection.getName(), null));
throw new ConnectionServiceException(Messages.getErrorString("ConnectionServiceInMemoryDelegate.ERROR_0005_UNABLE_TO_UPDATE_CONNECTION", connection.getName(), null));
}
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class WizardConnectionController method handleDialogAccept.
@Bindable
public void handleDialogAccept() {
// first, test the connection
RequestBuilder testConnectionBuilder = new RequestBuilder(RequestBuilder.PUT, ConnectionController.getServiceURL("test"));
testConnectionBuilder.setHeader("Content-Type", "application/json");
try {
// AutoBean<IDatabaseConnection> bean = AutoBeanUtils.getAutoBean(currentConnection);
AutoBean<IDatabaseConnection> bean = createIDatabaseConnectionBean(currentConnection);
testConnectionBuilder.sendRequest(AutoBeanCodex.encode(bean).getPayload(), new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
saveConnectionConfirmationDialog.show();
}
@Override
public void onResponseReceived(Request request, Response response) {
try {
if (response.getStatusCode() == Response.SC_OK) {
// test is ok, now check if we are renaming
renameCheck();
} else {
// confirm if we should continu saving this invalid connection.
saveConnectionConfirmationDialog.show();
}
} catch (Exception e) {
displayErrorMessage(e);
}
}
});
} catch (RequestException e) {
displayErrorMessage(e);
}
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class WizardConnectionController method addConnection.
@Bindable
public void addConnection() {
RequestBuilder addConnectionBuilder = new RequestBuilder(RequestBuilder.POST, ConnectionController.getServiceURL("add"));
addConnectionBuilder.setHeader("Content-Type", "application/json");
try {
// AutoBean<IDatabaseConnection> bean = AutoBeanUtils.getAutoBean(currentConnection);
AutoBean<IDatabaseConnection> bean = createIDatabaseConnectionBean(currentConnection);
addConnectionBuilder.sendRequest(AutoBeanCodex.encode(bean).getPayload(), new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
displayErrorMessage(exception);
}
@Override
public void onResponseReceived(Request request, Response response) {
try {
if (response.getStatusCode() == Response.SC_OK) {
IDatabaseConnection conn = AutobeanUtilities.connectionBeanToImpl(currentConnection);
datasourceModel.getGuiStateModel().addConnection(conn);
datasourceModel.setSelectedRelationalConnection(conn);
} else {
openErrorDialog(MessageHandler.getString("ERROR"), // $NON-NLS-1$
MessageHandler.getString(// $NON-NLS-1$
"ConnectionController.ERROR_0001_UNABLE_TO_ADD_CONNECTION"));
}
} catch (Exception e) {
displayErrorMessage(e);
}
}
});
} catch (RequestException e) {
displayErrorMessage(e);
}
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class WizardConnectionController method showEditConnectionDialog.
@Bindable
public void showEditConnectionDialog() {
datasourceModel.setEditing(true);
if (databaseDialog != null) {
IDatabaseConnection connection = datasourceModel.getSelectedRelationalConnection();
previousConnectionName = connection.getName();
existingConnectionName = previousConnectionName;
DatabaseConnection editConnection = new DatabaseConnection();
copyDatabaseConnectionProperties(connection, editConnection);
databaseDialog.setDatabaseConnection(editConnection);
databaseDialog.show();
} else {
databaseDialog = new GwtDatabaseDialog(databaseTypeHelper, GWT.getModuleBaseURL() + "dataaccess-databasedialog.xul", // $NON-NLS-1$
connectionSetter);
}
}
Aggregations