use of org.pentaho.platform.dataaccess.datasource.ui.service.UIDatasourceServiceManager in project data-access by pentaho.
the class GwtDatasourceEditorEntryPoint method onModuleLoad.
public void onModuleLoad() {
datasourceServiceManager = new DatasourceServiceManagerGwtImpl();
datasourceServiceManager.isAdmin(new XulServiceCallback<Boolean>() {
public void error(String message, Throwable error) {
}
public void success(Boolean retVal) {
isAdmin = retVal;
datasourceService = new DSWDatasourceServiceGwtImpl();
modelerService = new GwtModelerServiceImpl();
BogoPojo bogo = new BogoPojo();
modelerService.gwtWorkaround(bogo, new XulServiceCallback<BogoPojo>() {
public void success(BogoPojo retVal) {
}
public void error(String message, Throwable error) {
}
});
// only init the app if the user has permissions
// $NON-NLS-1$
final String url = GWT.getHostPageBaseURL() + "plugin/data-access/api/permissions/hasDataAccess";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
builder.setHeader("accept", "application/json");
builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
try {
builder.sendRequest(null, new RequestCallback() {
public void onError(Request request, Throwable exception) {
setupStandardNativeHooks(GwtDatasourceEditorEntryPoint.this);
initDashboardButtons(false);
}
public void onResponseReceived(Request request, Response response) {
hasPermissions = new Boolean(response.getText());
setupStandardNativeHooks(GwtDatasourceEditorEntryPoint.this);
if (hasPermissions) {
csvService = (ICsvDatasourceServiceAsync) GWT.create(ICsvDatasourceService.class);
setupPrivilegedNativeHooks(GwtDatasourceEditorEntryPoint.this);
loadOverlay("startup.dataaccess");
}
initDashboardButtons(hasPermissions);
}
});
} catch (RequestException e) {
// TODO Auto-generated catch block
}
}
});
XulServiceCallback<List<IDatabaseType>> callback = new XulServiceCallback<List<IDatabaseType>>() {
public void error(String message, Throwable error) {
error.printStackTrace();
}
public void success(List<IDatabaseType> retVal) {
databaseTypeHelper = new DatabaseTypeHelper(retVal);
databaseConnectionConverter = new DatabaseConnectionConverter(databaseTypeHelper);
}
};
dialectService.getDatabaseTypes(callback);
UIDatasourceServiceManager manager = UIDatasourceServiceManager.getInstance();
manager.registerService(new JdbcDatasourceService());
manager.registerService(new MondrianUIDatasourceService(datasourceServiceManager));
manager.registerService(new MetadataUIDatasourceService(datasourceServiceManager));
manager.registerService(new DSWUIDatasourceService(datasourceServiceManager));
manager.getIds(null);
}
use of org.pentaho.platform.dataaccess.datasource.ui.service.UIDatasourceServiceManager 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);
}
}
Aggregations