Search in sources :

Example 1 with MondrianUIDatasourceService

use of org.pentaho.platform.dataaccess.datasource.ui.service.MondrianUIDatasourceService 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);
}
Also used : GwtModelerServiceImpl(org.pentaho.agilebi.modeler.services.impl.GwtModelerServiceImpl) RequestBuilder(com.google.gwt.http.client.RequestBuilder) JdbcDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.JdbcDatasourceService) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException) UIDatasourceServiceManager(org.pentaho.platform.dataaccess.datasource.ui.service.UIDatasourceServiceManager) XulServiceCallback(org.pentaho.ui.xul.XulServiceCallback) Response(com.google.gwt.http.client.Response) IDatabaseType(org.pentaho.database.model.IDatabaseType) DatasourceServiceManagerGwtImpl(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.DatasourceServiceManagerGwtImpl) RequestCallback(com.google.gwt.http.client.RequestCallback) DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) MondrianUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.MondrianUIDatasourceService) List(java.util.List) DSWDatasourceServiceGwtImpl(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.DSWDatasourceServiceGwtImpl) DSWUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.DSWUIDatasourceService) MetadataUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.MetadataUIDatasourceService) BogoPojo(org.pentaho.agilebi.modeler.gwt.BogoPojo)

Example 2 with MondrianUIDatasourceService

use of org.pentaho.platform.dataaccess.datasource.ui.service.MondrianUIDatasourceService 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)

Aggregations

DSWUIDatasourceService (org.pentaho.platform.dataaccess.datasource.ui.service.DSWUIDatasourceService)2 JdbcDatasourceService (org.pentaho.platform.dataaccess.datasource.ui.service.JdbcDatasourceService)2 MetadataUIDatasourceService (org.pentaho.platform.dataaccess.datasource.ui.service.MetadataUIDatasourceService)2 MondrianUIDatasourceService (org.pentaho.platform.dataaccess.datasource.ui.service.MondrianUIDatasourceService)2 Request (com.google.gwt.http.client.Request)1 RequestBuilder (com.google.gwt.http.client.RequestBuilder)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 RequestException (com.google.gwt.http.client.RequestException)1 Response (com.google.gwt.http.client.Response)1 List (java.util.List)1 BogoPojo (org.pentaho.agilebi.modeler.gwt.BogoPojo)1 GwtModelerServiceImpl (org.pentaho.agilebi.modeler.services.impl.GwtModelerServiceImpl)1 IDatabaseType (org.pentaho.database.model.IDatabaseType)1 DatabaseTypeHelper (org.pentaho.database.util.DatabaseTypeHelper)1 IDatasourceInfo (org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)1 IUIDatasourceAdminService (org.pentaho.platform.dataaccess.datasource.ui.service.IUIDatasourceAdminService)1 UIDatasourceServiceManager (org.pentaho.platform.dataaccess.datasource.ui.service.UIDatasourceServiceManager)1 GwtDatasourceEditorEntryPoint (org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceEditorEntryPoint)1 DSWDatasourceServiceGwtImpl (org.pentaho.platform.dataaccess.datasource.wizard.service.impl.DSWDatasourceServiceGwtImpl)1 DatasourceServiceManagerGwtImpl (org.pentaho.platform.dataaccess.datasource.wizard.service.impl.DatasourceServiceManagerGwtImpl)1