Search in sources :

Example 1 with IDatasourceInfo

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;
}
Also used : IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) DatasourceInfo(org.pentaho.platform.dataaccess.datasource.DatasourceInfo) NodeList(com.google.gwt.xml.client.NodeList) Element(com.google.gwt.xml.client.Element) ArrayList(java.util.ArrayList) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)

Example 2 with IDatasourceInfo

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);
}
Also used : IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 3 with IDatasourceInfo

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);
}
Also used : JdbcDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.JdbcDatasourceService) GwtDatasourceEditorEntryPoint(org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceEditorEntryPoint) IUIDatasourceAdminService(org.pentaho.platform.dataaccess.datasource.ui.service.IUIDatasourceAdminService) XulException(org.pentaho.ui.xul.XulException) MondrianUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.MondrianUIDatasourceService) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) XulComponent(org.pentaho.ui.xul.XulComponent) DSWUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.DSWUIDatasourceService) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) MetadataUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.MetadataUIDatasourceService)

Example 4 with IDatasourceInfo

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;
    }
}
Also used : LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) List(java.util.List) Domain(org.pentaho.metadata.model.Domain) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 5 with IDatasourceInfo

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();
}
Also used : XulLabel(org.pentaho.ui.xul.components.XulLabel) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Aggregations

IDatasourceInfo (org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)10 ArrayList (java.util.ArrayList)5 Bindable (org.pentaho.ui.xul.stereotype.Bindable)5 List (java.util.List)3 DatasourceInfo (org.pentaho.platform.dataaccess.datasource.DatasourceInfo)3 RequestException (com.google.gwt.http.client.RequestException)2 LogicalModelSummary (org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary)2 XulException (org.pentaho.ui.xul.XulException)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 Request (com.google.gwt.http.client.Request)1 RequestBuilder (com.google.gwt.http.client.RequestBuilder)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 Response (com.google.gwt.http.client.Response)1 Element (com.google.gwt.xml.client.Element)1 NodeList (com.google.gwt.xml.client.NodeList)1 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)1 Domain (org.pentaho.metadata.model.Domain)1 DSWUIDatasourceService (org.pentaho.platform.dataaccess.datasource.ui.service.DSWUIDatasourceService)1 IUIDatasourceAdminService (org.pentaho.platform.dataaccess.datasource.ui.service.IUIDatasourceAdminService)1 JdbcDatasourceService (org.pentaho.platform.dataaccess.datasource.ui.service.JdbcDatasourceService)1