use of com.google.web.bindery.autobean.shared.AutoBean 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 com.google.web.bindery.autobean.shared.AutoBean in project data-access by pentaho.
the class AnalysisImportDialogController method reloadConnections.
private void reloadConnections() {
String cacheBuster = "?ts=" + new java.util.Date().getTime();
RequestBuilder listConnectionBuilder = new RequestBuilder(RequestBuilder.GET, getBaseURL() + "list" + cacheBuster);
listConnectionBuilder.setHeader("Content-Type", "application/json");
listConnectionBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
listConnectionBuilder.sendRequest(null, new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
exception.printStackTrace();
MessageHandler.getInstance().showErrorDialog(exception.getMessage());
}
@Override
public void onResponseReceived(Request request, Response response) {
AutoBean<IDatabaseConnectionList> bean = AutoBeanCodex.decode(connectionAutoBeanFactory, IDatabaseConnectionList.class, response.getText());
List<IDatabaseConnection> databaseConnections = bean.as().getDatabaseConnections();
List<IDatabaseConnection> standardDatabaseConnections = new ArrayList();
// take anything except connections where STANDARD_CONNECTION == false
for (IDatabaseConnection databaseConnection : databaseConnections) {
if ((databaseConnection.getAttributes() == null) || (databaseConnection.getAttributes().get(ATTRIBUTE_STANDARD_CONNECTION) == null) || (databaseConnection.getAttributes().get(ATTRIBUTE_STANDARD_CONNECTION) == Boolean.TRUE.toString())) {
standardDatabaseConnections.add(databaseConnection);
}
}
importDialogModel.setConnectionList(standardDatabaseConnections);
}
});
} catch (RequestException e) {
MessageHandler.getInstance().showErrorDialog(MessageHandler.getString("ERROR"), "DatasourceEditor.ERROR_0004_CONNECTION_SERVICE_NULL");
}
}
use of com.google.web.bindery.autobean.shared.AutoBean in project data-access by pentaho.
the class ConnectionController method reloadConnections.
public void reloadConnections() {
String cacheBuster = String.valueOf(new java.util.Date().getTime());
String[][] params = new String[][] { { "ts", cacheBuster } };
RequestBuilder listConnectionBuilder = new RequestBuilder(RequestBuilder.GET, getServiceURL("list", params));
listConnectionBuilder.setHeader("Content-Type", "application/json");
try {
listConnectionBuilder.sendRequest(null, new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
MessageHandler.getInstance().showErrorDialog(MessageHandler.getString("ERROR"), MessageHandler.getString("DatasourceEditor.ERROR_0002_UNABLE_TO_SHOW_DIALOG", exception.getLocalizedMessage()));
}
@Override
public void onResponseReceived(Request request, Response response) {
AutoBean<IDatabaseConnectionList> bean = AutoBeanCodex.decode(connectionAutoBeanFactory, IDatabaseConnectionList.class, response.getText());
List<IDatabaseConnection> connectionBeanList = bean.as().getDatabaseConnections();
List<IDatabaseConnection> connectionImplList = new ArrayList<IDatabaseConnection>();
for (IDatabaseConnection connectionBean : connectionBeanList) {
try {
// take anything except connections where STANDARD_CONNECTION == false
if ((connectionBean.getAttributes() == null) || (connectionBean.getAttributes().get(ATTRIBUTE_STANDARD_CONNECTION) == null) || (connectionBean.getAttributes().get(ATTRIBUTE_STANDARD_CONNECTION) == Boolean.TRUE.toString())) {
connectionImplList.add(AutobeanUtilities.connectionBeanToImpl(connectionBean));
}
} catch (Exception e) {
// skip invalid connections that couldn't be converted to IDatabaseConnection
}
}
if (datasourceModel != null) {
datasourceModel.getGuiStateModel().setConnections(connectionImplList);
}
}
});
} catch (RequestException e) {
MessageHandler.getInstance().showErrorDialog(MessageHandler.getString("ERROR"), "DatasourceEditor.ERROR_0004_CONNECTION_SERVICE_NULL");
}
}
Aggregations