use of org.pentaho.platform.dataaccess.datasource.IDatasourceInfo in project data-access by pentaho.
the class DatasourceAdminDialogController method removeDatasourceAccept.
@Bindable
public void removeDatasourceAccept() {
final IDatasourceInfo dsInfo = datasourceAdminDialogModel.getSelectedDatasource();
manager.remove(dsInfo, new XulServiceCallback<Boolean>() {
@Override
public void success(Boolean isOk) {
if (isOk) {
refreshDatasourceList();
editDatasourceMenuItem.setDisabled(true);
} else {
Window.alert(messageBundle.getString("datasourceAdminDialogController.COULD_NOT_REMOVE") + ": " + dsInfo.getId());
}
}
@Override
public void error(String message, Throwable error) {
Window.alert(messageBundle.getString("datasourceAdminDialogController.ERROR_REMOVING") + ": " + dsInfo.getId() + "." + messageBundle.getString("ERROR") + "=" + error.getLocalizedMessage());
}
});
removeDatasourceConfirmationDialog.hide();
}
use of org.pentaho.platform.dataaccess.datasource.IDatasourceInfo in project data-access by pentaho.
the class MainWizardController method finish.
@Bindable
public // TODO: migrate to CSV datasource
void finish() {
if (finishButton.isDisabled()) {
return;
}
finishButton.setDisabled(true);
final String datasourceName = this.wizardModel.getDatasourceName();
// Validating whether the datasource name contains any illegal characters
if (isDatasourceNameValid(datasourceName)) {
UIDatasourceServiceManager manager = UIDatasourceServiceManager.getInstance();
manager.getIds(new XulServiceCallback<List<IDatasourceInfo>>() {
@Override
public void success(List<IDatasourceInfo> datasourceInfos) {
finishButton.setDisabled(false);
boolean isEditing = wizardModel.isEditing();
List<String> datasourceNames = new ArrayList<String>();
for (IDatasourceInfo datasourceInfo : datasourceInfos) {
if (datasourceInfo.getType().equals("Data Source Wizard") || datasourceInfo.getType().equals("Analysis")) {
datasourceNames.add(datasourceInfo.getName());
}
}
if (datasourceNames.contains(datasourceName) && !isEditing) {
showWarningDialog();
} else {
setFinished();
}
}
@Override
public void error(String s, Throwable throwable) {
finishButton.setDisabled(false);
throwable.printStackTrace();
MessageHandler.getInstance().showErrorDialog(throwable.getMessage());
}
});
} else {
finishButton.setDisabled(false);
MessageHandler.getInstance().showErrorDialog("Error", // $NON-NLS-1$
MessageHandler.getString("DatasourceEditor.ERROR_0005_INVALID_DATASOURCE_NAME", NameUtils.reservedCharListForDisplay(" ")), // $NON-NLS-1$
true);
}
}
use of org.pentaho.platform.dataaccess.datasource.IDatasourceInfo in project data-access by pentaho.
the class DatasourceSelectionDialogController method internalInit.
private void internalInit() {
try {
// $NON-NLS-1$
datasourceListbox = (XulListbox) safeGetElementById(document, "datasourceListbox");
// $NON-NLS-1$
datasourceSelectionDialog = (XulDialog) safeGetElementById(document, "datasourceSelectionDialog");
removeDatasourceConfirmationDialog = (XulDialog) safeGetElementById(document, // $NON-NLS-1$
"removeDatasourceConfirmationDialog");
XulButton acceptButton = null;
try {
// $NON-NLS-1$
acceptButton = (XulButton) safeGetElementById(document, "datasourceSelectionDialog_accept");
} catch (Exception e) {
// this might not be available
}
// $NON-NLS-1$
addDatasourceButton = (XulButton) safeGetElementById(document, "addDatasource");
// $NON-NLS-1$
editDatasourceButton = (XulButton) safeGetElementById(document, "editDatasource");
// $NON-NLS-1$
removeDatasourceButton = (XulButton) safeGetElementById(document, "removeDatasource");
manager = UIDatasourceServiceManager.getInstance();
manager.getIds(new XulServiceCallback<List<IDatasourceInfo>>() {
@Override
public void success(List<IDatasourceInfo> infoList) {
DatasourceSelectionDialogController.this.datasourceInfos = infoList;
}
@Override
public void error(String message, Throwable error) {
}
});
bf.setBindingType(Binding.Type.ONE_WAY);
bf.createBinding(DatasourceSelectionDialogController.this.datasourceSelectionDialogModel, "logicalModelSummaries", datasourceListbox, // $NON-NLS-1$ //$NON-NLS-2$
"elements");
bf.setBindingType(Binding.Type.ONE_WAY);
// $NON-NLS-1$
bf.createBinding(// $NON-NLS-1$
datasourceListbox, // $NON-NLS-1$
"selectedIndex", DatasourceSelectionDialogController.this.datasourceSelectionDialogModel, // $NON-NLS-1$
"selectedIndex");
// setup binding to disable accept button until user selects a datasource
bf.setBindingType(Binding.Type.ONE_WAY);
if (acceptButton != null) {
BindingConvertor<Integer, Boolean> acceptButtonConvertor = new BindingConvertor<Integer, Boolean>() {
@Override
public Boolean sourceToTarget(final Integer value) {
return value > -1;
}
@Override
public Integer targetToSource(final Boolean value) {
throw new UnsupportedOperationException();
}
};
bf.createBinding(DatasourceSelectionDialogController.this.datasourceSelectionDialogModel, "selectedIndex", // $NON-NLS-1$
acceptButton, "!disabled", // $NON-NLS-1$
acceptButtonConvertor);
}
// setup binding to disable remove datasource button until user selects a datasource
bf.setBindingType(Binding.Type.ONE_WAY);
BindingConvertor<Integer, Boolean> removeDatasourceButtonConvertor = new BindingConvertor<Integer, Boolean>() {
@Override
public Boolean sourceToTarget(final Integer value) {
boolean active = false;
if (value > -1) {
LogicalModelSummary summary = (LogicalModelSummary) datasourceListbox.getSelectedItem();
if (datasourceInfos.size() > 0) {
for (int i = 0; i < datasourceInfos.size(); i++) {
IDatasourceInfo datasourceInfo = datasourceInfos.get(i);
if (datasourceInfo.getId().equals(summary.getDomainId())) {
active = datasourceInfo.isEditable();
break;
}
}
}
}
return active && administrator;
}
@Override
public Integer targetToSource(final Boolean value) {
throw new UnsupportedOperationException();
}
};
removeDatasourceButtonBinding = bf.createBinding(DatasourceSelectionDialogController.this.datasourceSelectionDialogModel, "selectedIndex", // $NON-NLS-1$
removeDatasourceButton, "!disabled", // $NON-NLS-1$
removeDatasourceButtonConvertor);
BindingConvertor<Integer, Boolean> editDatasourceButtonConvertor = new BindingConvertor<Integer, Boolean>() {
@Override
public Boolean sourceToTarget(final Integer value) {
boolean active = false;
if (value > -1) {
LogicalModelSummary summary = (LogicalModelSummary) datasourceListbox.getSelectedItem();
if (datasourceInfos.size() > 0) {
for (int i = 0; i < datasourceInfos.size(); i++) {
IDatasourceInfo datasourceInfo = datasourceInfos.get(i);
if (datasourceInfo.getId().equals(summary.getDomainId())) {
active = datasourceInfo.isEditable();
break;
}
}
}
}
return active && administrator;
}
@Override
public Integer targetToSource(final Boolean value) {
throw new UnsupportedOperationException();
}
};
editDatasourceButtonBinding = bf.createBinding(DatasourceSelectionDialogController.this.datasourceSelectionDialogModel, "selectedIndex", // $NON-NLS-1$
editDatasourceButton, "!disabled", // $NON-NLS-1$
editDatasourceButtonConvertor);
datasourceListbox.setSelectedIndex(-1);
// workaround for bug in some XulListbox implementations (doesn't fire event on setSelectedIndex call)
DatasourceSelectionDialogController.this.datasourceSelectionDialogModel.setSelectedIndex(-1);
} catch (Exception e) {
e.printStackTrace();
// $NON-NLS-1$
showMessagebox("Error", e.getLocalizedMessage());
}
}
use of org.pentaho.platform.dataaccess.datasource.IDatasourceInfo in project data-access by pentaho.
the class JSUIDatasourceService method getIds.
@Override
public final void getIds(XulServiceCallback<List<IDatasourceInfo>> callback) {
List<IDatasourceInfo> datasourceInfoList = new ArrayList<IDatasourceInfo>();
JsArray<JavaScriptObject> infos = getDelegateIds(this.datasourceServiceObject);
for (int i = 0; i < infos.length(); i++) {
JSDatasourceInfo info = new JSDatasourceInfo(infos.get(i));
datasourceInfoList.add(new DatasourceInfo(info.getName(), info.getName(), info.getType(), info.isEditable(), info.isRemovable(), info.isImportable(), info.isExportable()));
}
callback.success(datasourceInfoList);
}
use of org.pentaho.platform.dataaccess.datasource.IDatasourceInfo in project data-access by pentaho.
the class JdbcDatasourceService method getIds.
@Override
public void getIds(final XulServiceCallback<List<IDatasourceInfo>> callback) {
RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, getMetadataBaseURL() + "getDatasourcePermissions");
requestBuilder.setHeader("Content-Type", "application/json");
try {
requestBuilder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
callback.error(exception.getMessage(), exception);
}
public void onResponseReceived(Request request, Response response) {
if (response.getText().equals("EDIT")) {
String cacheBuster = "?ts=" + new java.util.Date().getTime();
RequestBuilder listConnectionBuilder = new RequestBuilder(RequestBuilder.GET, getBaseURL() + "list" + cacheBuster);
listConnectionBuilder.setHeader("Content-Type", "application/json");
try {
listConnectionBuilder.sendRequest(null, new RequestCallback() {
@Override
public void onError(Request request, Throwable exception) {
callback.error(exception.getMessage(), exception);
}
@Override
public void onResponseReceived(Request request, Response response) {
AutoBean<IDatabaseConnectionList> bean = AutoBeanCodex.decode(connectionAutoBeanFactory, IDatabaseConnectionList.class, response.getText());
List<IDatabaseConnection> connections = bean.as().getDatabaseConnections();
List<IDatasourceInfo> datasourceInfos = new ArrayList<IDatasourceInfo>();
for (IDatabaseConnection connection : connections) {
// check attributes to make sure we only return "standard" connections which can be managed
Map<String, String> attributes = connection.getAttributes();
if (attributes.containsKey(ATTRIBUTE_STANDARD_CONNECTION)) {
if (attributes.get(ATTRIBUTE_STANDARD_CONNECTION).equals(Boolean.FALSE.toString())) {
continue;
}
}
datasourceInfos.add(new DatasourceInfo(connection.getName(), connection.getName(), TYPE, editable, removable, importable, exportable));
}
callback.success(datasourceInfos);
}
});
} catch (RequestException e) {
callback.error(e.getMessage(), e);
}
}
}
});
} catch (RequestException e) {
callback.error(e.getMessage(), e);
}
}
Aggregations