Search in sources :

Example 6 with DatabaseTypeHelper

use of org.pentaho.database.util.DatabaseTypeHelper in project data-access by pentaho.

the class WizardConnectionController method init.

@Bindable
public void init() {
    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);
        }
    };
    dialectService.getDatabaseTypes(callback);
    saveConnectionConfirmationDialog = // $NON-NLS-1$
    (XulDialog) document.getElementById("saveConnectionConfirmationDialog");
    overwriteConnectionConfirmationDialog = (XulDialog) document.getElementById("overwriteConnectionConfirmationDialog");
    renameConnectionConfirmationDialog = (XulDialog) document.getElementById("renameConnectionConfirmationDialog");
    // $NON-NLS-1$
    errorDialog = (XulDialog) document.getElementById("errorDialog");
    // $NON-NLS-1$
    errorDetailsDialog = (XulDialog) document.getElementById("errorDetailsDialog");
    // $NON-NLS-1$
    errorLabel = (XulLabel) document.getElementById("errorLabel");
    // $NON-NLS-1$
    successDialog = (XulDialog) document.getElementById("successDialog");
    // $NON-NLS-1$
    successDetailsDialog = (XulDialog) document.getElementById("successDetailsDialog");
    // $NON-NLS-1$
    successLabel = (XulLabel) document.getElementById("successLabel");
    // $NON-NLS-1$
    removeConfirmationDialog = (XulDialog) document.getElementById("removeConfirmationDialog");
}
Also used : XulServiceCallback(org.pentaho.ui.xul.XulServiceCallback) IDatabaseType(org.pentaho.database.model.IDatabaseType) DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) ArrayList(java.util.ArrayList) List(java.util.List) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 7 with DatabaseTypeHelper

use of org.pentaho.database.util.DatabaseTypeHelper in project pentaho-platform by pentaho.

the class DatabaseConnectionAdapter method unmarshal.

@Override
public DatabaseConnection unmarshal(DatabaseConnectionDto dbConnDto) throws Exception {
    if (dbConnDto != null) {
        IDatabaseDialectService databaseDialectService = new DatabaseDialectService();
        DatabaseTypeHelper databaseTypeHelper = new DatabaseTypeHelper(databaseDialectService.getDatabaseTypes());
        DatabaseConnection dbConn = new DatabaseConnection();
        dbConn.setId(dbConnDto.getId());
        dbConn.setAccessType(dbConnDto.getAccessType());
        dbConn.setAccessTypeValue(dbConnDto.getAccessTypeValue());
        dbConn.setChanged(dbConnDto.getChanged());
        dbConn.setConnectionPoolingProperties(dbConnDto.getConnectionPoolingProperties());
        dbConn.setConnectSql(dbConnDto.getConnectSql());
        dbConn.setDatabaseName(dbConnDto.getDatabaseName());
        dbConn.setDatabasePort(dbConnDto.getDatabasePort());
        if (dbConnDto.getDatabaseType() != null) {
            dbConn.setDatabaseType(databaseTypeHelper.getDatabaseTypeByShortName(dbConnDto.getDatabaseType()));
        }
        dbConn.setDataTablespace(dbConnDto.getDataTablespace());
        dbConn.setForcingIdentifiersToLowerCase(dbConnDto.isForcingIdentifiersToLowerCase());
        dbConn.setForcingIdentifiersToUpperCase(dbConnDto.isForcingIdentifiersToUpperCase());
        dbConn.setHostname(dbConnDto.getHostname());
        dbConn.setIndexTablespace(dbConnDto.getIndexTablespace());
        dbConn.setInformixServername(dbConnDto.getInformixServername());
        dbConn.setInitialPoolSize(dbConnDto.getInitialPoolSize());
        dbConn.setMaximumPoolSize(dbConnDto.getMaximumPoolSize());
        dbConn.setName(dbConnDto.getName());
        dbConn.setPartitioned(dbConnDto.isPartitioned());
        dbConn.setPartitioningInformation(dbConnDto.getPartitioningInformation());
        dbConn.setPassword(dbConnDto.getPassword());
        dbConn.setQuoteAllFields(dbConnDto.isQuoteAllFields());
        dbConn.setSQLServerInstance(dbConnDto.getSQLServerInstance());
        dbConn.setStreamingResults(dbConnDto.isStreamingResults());
        dbConn.setUsername(dbConnDto.getUsername());
        dbConn.setUsingConnectionPool(dbConnDto.isUsingConnectionPool());
        dbConn.setUsingDoubleDecimalAsSchemaTableSeparator(dbConnDto.isUsingDoubleDecimalAsSchemaTableSeparator());
        return dbConn;
    } else {
        return null;
    }
}
Also used : DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) DatabaseDialectService(org.pentaho.database.service.DatabaseDialectService) IDatabaseDialectService(org.pentaho.database.service.IDatabaseDialectService) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseDialectService(org.pentaho.database.service.IDatabaseDialectService)

Example 8 with DatabaseTypeHelper

use of org.pentaho.database.util.DatabaseTypeHelper in project pentaho-platform by pentaho.

the class PooledDatasourceHelperTest method testCreatePoolNoDialectService.

@Test
public void testCreatePoolNoDialectService() throws Exception {
    DatabaseDialectService dialectService = new DatabaseDialectService(false);
    final DatabaseTypeHelper databaseTypeHelper = new DatabaseTypeHelper(dialectService.getDatabaseTypes());
    final DatabaseConnection con = new DatabaseConnection();
    con.setId("Postgres");
    con.setName("Postgres");
    con.setAccessType(DatabaseAccessType.NATIVE);
    con.setDatabaseType(databaseTypeHelper.getDatabaseTypeByShortName("GENERIC"));
    con.setUsername("pentaho_user");
    con.setPassword("password");
    final HashMap<String, String> attrs = new HashMap<>();
    attrs.put(DatabaseConnection.ATTRIBUTE_CUSTOM_DRIVER_CLASS, "org.postgresql.Driver");
    attrs.put(DatabaseConnection.ATTRIBUTE_CUSTOM_URL, "jdbc:postgresql://localhost:5432/hibernate");
    con.setAttributes(attrs);
    try {
        PooledDatasourceHelper.setupPooledDataSource(con);
        fail("Expecting the exception to be thrown");
    } catch (DBDatasourceServiceException ex) {
        assertNotNull(ex);
    }
}
Also used : DBDatasourceServiceException(org.pentaho.platform.api.data.DBDatasourceServiceException) DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) HashMap(java.util.HashMap) DatabaseDialectService(org.pentaho.database.service.DatabaseDialectService) IDatabaseDialectService(org.pentaho.database.service.IDatabaseDialectService) DatabaseConnection(org.pentaho.database.model.DatabaseConnection) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 9 with DatabaseTypeHelper

use of org.pentaho.database.util.DatabaseTypeHelper 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 10 with DatabaseTypeHelper

use of org.pentaho.database.util.DatabaseTypeHelper in project data-access by pentaho.

the class ConnectionController method createNewDatabaseDialog.

private void createNewDatabaseDialog() {
    if (databaseTypeHelper == null) {
        XulServiceCallback<List<IDatabaseType>> callback = new XulServiceCallback<List<IDatabaseType>>() {

            public void error(String message, Throwable error) {
                Window.alert(message + ":  " + error.getLocalizedMessage());
            // error.printStackTrace();
            }

            public void success(List<IDatabaseType> retVal) {
                databaseTypeHelper = new DatabaseTypeHelper(retVal);
                databaseDialog = new GwtDatabaseDialog(databaseTypeHelper, GWT.getModuleBaseURL() + "dataaccess-databasedialog.xul", // $NON-NLS-1$
                connectionSetter);
            }
        };
        dialectService.getDatabaseTypes(callback);
    } else {
        databaseDialog = new GwtDatabaseDialog(databaseTypeHelper, GWT.getModuleBaseURL() + "dataaccess-databasedialog.xul", // $NON-NLS-1$
        connectionSetter);
    }
}
Also used : XulServiceCallback(org.pentaho.ui.xul.XulServiceCallback) IDatabaseType(org.pentaho.database.model.IDatabaseType) DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) GwtDatabaseDialog(org.pentaho.ui.database.gwt.GwtDatabaseDialog) ArrayList(java.util.ArrayList) IDatabaseConnectionList(org.pentaho.ui.database.event.IDatabaseConnectionList) List(java.util.List)

Aggregations

DatabaseTypeHelper (org.pentaho.database.util.DatabaseTypeHelper)10 DatabaseConnection (org.pentaho.database.model.DatabaseConnection)6 HashMap (java.util.HashMap)5 IDatabaseType (org.pentaho.database.model.IDatabaseType)5 IDatabaseDialectService (org.pentaho.database.service.IDatabaseDialectService)5 List (java.util.List)4 Test (org.junit.Test)4 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)4 DatabaseDialectService (org.pentaho.database.service.DatabaseDialectService)4 XulServiceCallback (org.pentaho.ui.xul.XulServiceCallback)4 ArrayList (java.util.ArrayList)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 DBDatasourceServiceException (org.pentaho.platform.api.data.DBDatasourceServiceException)3 IDatabaseConnectionList (org.pentaho.ui.database.event.IDatabaseConnectionList)2 Bindable (org.pentaho.ui.xul.stereotype.Bindable)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