use of org.pentaho.platform.dataaccess.datasource.IDatasourceInfo in project data-access by pentaho.
the class XMLToDatasourceInfoConverter method getDatasourceInfoList.
private List<IDatasourceInfo> getDatasourceInfoList(Element element) {
List<IDatasourceInfo> datasourceInfoList = new ArrayList<IDatasourceInfo>();
NodeList nodeList = element.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Element ele = (Element) nodeList.item(i);
boolean editable = Boolean.parseBoolean(getNodeValueByTagName(ele, "editable"));
boolean removable = Boolean.parseBoolean(getNodeValueByTagName(ele, "removable"));
boolean importable = Boolean.parseBoolean(getNodeValueByTagName(ele, "importable"));
boolean exportable = Boolean.parseBoolean(getNodeValueByTagName(ele, "exportable"));
IDatasourceInfo info = new DatasourceInfo(getName(ele), getId(ele), getType(ele), editable, removable, importable, exportable);
datasourceInfoList.add(info);
}
return datasourceInfoList;
}
use of org.pentaho.platform.dataaccess.datasource.IDatasourceInfo in project data-access by pentaho.
the class DatasourceAdminDialogController method export.
@Bindable
public void export() {
IDatasourceInfo dsInfo = datasourceAdminDialogModel.getSelectedDatasource();
if (dsInfo == null) {
showErrorDialog("datasourceAdminErrorDialog.SELECT_DATASOURCE", "datasourceAdminErrorDialog.SELECT_DATASOURCE_EXPORT");
return;
}
if (JdbcDatasourceService.TYPE.equals(dsInfo.getType())) {
showErrorDialog("datasourceAdminErrorDialog.CANNOT_EXPORT_HEADER", "datasourceAdminErrorDialog.CANNOT_EXPORT_TEXT");
return;
}
manager.exportDatasource(dsInfo);
}
use of org.pentaho.platform.dataaccess.datasource.IDatasourceInfo in project data-access by pentaho.
the class DatasourceAdminDialogController method getDatasourceTypes.
private void getDatasourceTypes() {
List<String> datasourceTypes = manager.getTypes();
// Clear out the current component list
List<XulComponent> components = datasourceTypeMenuPopup.getChildNodes();
// remove exist import and plugins
for (int i = 0; i < components.size(); i++) {
XulComponent component = components.get(i);
if (component.getId() == null) {
continue;
}
if (component.getId().startsWith("import") || component.getId().startsWith("plugin")) {
// remove import and plugins items
datasourceTypeMenuPopup.removeComponent(component);
}
}
// find separator
components = datasourceTypeMenuPopup.getChildNodes();
int beforePlugins = 0;
XulComponent beforePluginsMenuItem = null;
for (int i = 0; i < components.size(); i++) {
XulComponent component = components.get(i);
if ("beforePlugins".equals(component.getId())) {
beforePlugins = i;
beforePluginsMenuItem = component;
}
}
List<IDatasourceInfo> datasourceInfoList = datasourceAdminDialogModel.getDatasourcesList();
// Add "Import..." items first
for (String datasourceType : datasourceTypes) {
IUIDatasourceAdminService datasourceAdminService = manager.getService(datasourceType);
if (datasourceAdminService instanceof DSWUIDatasourceService) {
// Data Source Wizard
continue;
}
if (datasourceAdminService instanceof JdbcDatasourceService) {
// JDBC
continue;
}
if (// Analysis - import
!(datasourceAdminService instanceof MondrianUIDatasourceService) && !(datasourceAdminService instanceof MetadataUIDatasourceService)) {
// Metadata - import
continue;
}
if (!datasourceAdminService.isCreatable()) {
continue;
}
XulMenuitem menuItem;
try {
String displayName = DatasourceInfo.getDisplayType(datasourceType, messageBundle);
String label = messageBundle.getString(IMPORT_MSG_ID, displayName);
menuItem = (XulMenuitem) document.createElement("menuitem");
menuItem.setLabel(label);
menuItem.setCommand(getName() + ".launchNewUI(\"" + datasourceType + "\")");
menuItem.setId("import" + datasourceType);
datasourceTypeMenuPopup.addChildAt(menuItem, beforePlugins++);
} catch (XulException e) {
throw new RuntimeException(e);
}
}
// Add plugin items
boolean hasPlugins = false;
beforePlugins++;
for (String datasourceType : datasourceTypes) {
IUIDatasourceAdminService datasourceAdminService = manager.getService(datasourceType);
if (datasourceAdminService instanceof DSWUIDatasourceService) {
// Data Source Wizard
continue;
}
if (datasourceAdminService instanceof JdbcDatasourceService) {
// JDBC
continue;
}
if (datasourceAdminService instanceof MondrianUIDatasourceService) {
// Analysis - import
continue;
} else if (datasourceAdminService instanceof MetadataUIDatasourceService) {
// Metadata - import
continue;
}
if (!datasourceAdminService.isCreatable()) {
continue;
}
hasPlugins = true;
XulMenuitem menuItem;
try {
String displayName = DatasourceInfo.getDisplayType(datasourceType, messageBundle);
String label = messageBundle.getString(PLUGIN_MSG_ID, displayName);
menuItem = (XulMenuitem) document.createElement("menuitem");
menuItem.setLabel(label);
menuItem.setCommand(getName() + ".launchNewUI(\"" + datasourceType + "\")");
menuItem.setId("plugin" + datasourceType);
datasourceTypeMenuPopup.addChildAt(menuItem, beforePlugins++);
} catch (XulException e) {
throw new RuntimeException(e);
}
}
beforePluginsMenuItem.setVisible(hasPlugins);
datasourceAdminDialogModel.setDatasourceTypeList(datasourceTypes);
}
use of org.pentaho.platform.dataaccess.datasource.IDatasourceInfo in project data-access by pentaho.
the class DatasourceAdminDialogController method edit.
@Bindable
public void edit() {
IDatasourceInfo dsInfo = datasourceAdminDialogModel.getSelectedDatasource();
if (dsInfo == null) {
showErrorDialog("datasourceAdminErrorDialog.SELECT_DATASOURCE", "datasourceAdminErrorDialog.SELECT_DATASOURCE_EDIT");
return;
}
String type = dsInfo.getType();
final String dsId = dsInfo.getId();
if (DSWUIDatasourceService.TYPE.equals(type)) {
dswService.getLogicalModels(dsId, new XulServiceCallback<List<LogicalModelSummary>>() {
@Override
public void success(List<LogicalModelSummary> retVal) {
for (LogicalModelSummary logicalModelSummary : retVal) {
if (!dsId.equals(logicalModelSummary.getDomainId())) {
continue;
}
entryPoint.showWizardEdit(logicalModelSummary.getDomainId(), logicalModelSummary.getModelId(), false, new DialogListener<Domain>() {
@Override
public void onDialogAccept(Domain returnValue) {
// TODO Auto-generated method stub
}
@Override
public void onDialogCancel() {
// TODO Auto-generated method stub
}
@Override
public void onDialogReady() {
// TODO Auto-generated method stub
}
@Override
public void onDialogError(String errorMessage) {
// TODO Auto-generated method stub
}
});
}
}
@Override
public void error(String message, Throwable error) {
// TODO Auto-generated method stub
}
});
} else if (JdbcDatasourceService.TYPE.equals(type)) {
entryPoint.showEditDatabaseDialog(adminDatasourceListener, dsId);
} else if (MondrianUIDatasourceService.TYPE.equals(type)) {
IDatasourceInfo datasourceInfo = datasourceAdminDialogModel.getSelectedDatasource();
entryPoint.showEditAnalysisDialog(adminDatasourceListener, datasourceInfo);
} else if (MetadataUIDatasourceService.TYPE.equals(type)) {
showErrorDialog("datasourceAdminErrorDialog.CANNOT_EDIT_HEADER", "datasourceAdminErrorDialog.CANNOT_EDIT_TEXT");
return;
}
}
use of org.pentaho.platform.dataaccess.datasource.IDatasourceInfo in project data-access by pentaho.
the class DatasourceAdminDialogController method remove.
@Bindable
public void remove() {
IDatasourceInfo dsInfo = datasourceAdminDialogModel.getSelectedDatasource();
if (dsInfo == null) {
showErrorDialog("datasourceAdminErrorDialog.SELECT_DATASOURCE", "datasourceAdminErrorDialog.SELECT_DATASOURCE_DELETE");
return;
}
if (messageBundle != null) {
XulLabel removeDatasourceConfirmationDialogLabel = (XulLabel) removeDatasourceConfirmationDialog.getElementById("removeDatasourceConfirmationDialogLabel");
removeDatasourceConfirmationDialogLabel.setValue(messageBundle.getString(REMOVE_DS_MSG_ID, dsInfo.getName()));
}
removeDatasourceConfirmationDialog.show();
}
Aggregations