use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class GwtDatasourceEditorEntryPoint method showEditDatabaseDialog.
public void showEditDatabaseDialog(final DialogListener dialogListener, final String databaseName) {
String cacheBuster = String.valueOf(new java.util.Date().getTime());
String url = ConnectionController.getServiceURL("get", new String[][] { { "name", databaseName }, { "ts", cacheBuster } });
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
builder.setHeader("Accept", "application/json");
try {
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
Window.alert(exception.toString());
}
@SuppressWarnings("deprecation")
public void onResponseReceived(Request request, Response response) {
IDatabaseConnection conn = null;
if (response.getStatusCode() == Response.SC_OK) {
AutoBean<IDatabaseConnection> bean = AutoBeanCodex.decode(connectionAutoBeanFactory, IDatabaseConnection.class, response.getText());
conn = bean.as();
}
ConnectionController connectionController = wizard.getConnectionController();
connectionController.init();
DatasourceModel datasourceModel = connectionController.getDatasourceModel();
if (datasourceModel == null) {
datasourceModel = new DatasourceModel();
}
datasourceModel.setSelectedRelationalConnection(conn);
// This is important for edit mode of datasource model
datasourceModel.setEditing(true);
connectionController.setDatasourceModel(datasourceModel);
connectionController.showEditConnectionDialog(dialogListener, conn);
}
});
} catch (Exception e) {
Window.alert("Cannot edit datasource");
}
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class AnalysisImportDialogController method handleParam.
protected boolean handleParam(StringBuilder name, StringBuilder value) {
if (name.length() == 0 && value.length() == 0) {
return false;
}
boolean hasParameters = false;
boolean connectionFound = false;
String paramName = name.toString();
// Unescape quotes is used, because value can contain " elements.
String paramValue = DataSourceInfoUtil.unescapeQuotes(value.toString());
if (paramName.equalsIgnoreCase("Datasource")) {
for (IDatabaseConnection connection : importDialogModel.getConnectionList()) {
if (connection.getName().equals(paramValue)) {
importDialogModel.setConnection(connection);
connectionFound = true;
}
}
// always add the Datasource so if the toggle is selected it displays -
// it may be JNDI and not in DSW
importDialogModel.addParameter(paramName, paramValue);
hasParameters = !connectionFound;
} else {
if (!paramName.equalsIgnoreCase("overwrite") && !paramName.equalsIgnoreCase("Provider")) {
importDialogModel.addParameter(paramName, paramValue);
// this is the default value so do not treat it as a param to flip to manual mode
if ((paramName.equalsIgnoreCase("EnableXmla") && paramValue.equalsIgnoreCase("true"))) {
hasParameters = false;
} else {
hasParameters = true;
}
}
}
name.setLength(0);
value.setLength(0);
return hasParameters;
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class AnalysisImportDialogModel method setConnection.
@Bindable
public void setConnection(IDatabaseConnection value) {
IDatabaseConnection previousValue = connection;
connection = value;
firePropertyChange("connection", previousValue, value);
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class ConnectionController method showEditConnectionDialog.
@SuppressWarnings("deprecation")
public void showEditConnectionDialog(DialogListener dialogListener) {
IDatabaseConnection connection = datasourceModel.getSelectedRelationalConnection();
showEditConnectionDialog(dialogListener, connection);
}
use of org.pentaho.database.model.IDatabaseConnection in project data-access by pentaho.
the class ConnectionController 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 = 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) {
datasourceModel.getGuiStateModel().addConnection(currentConnection);
datasourceModel.setSelectedRelationalConnection(currentConnection);
DialogListener dialogListener = connectionSetter.getOuterListener();
if (dialogListener != null) {
dialogListener.onDialogAccept(currentConnection);
}
} 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);
}
}
Aggregations