Search in sources :

Example 16 with DataSourceDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo in project kie-wb-common by kiegroup.

the class DataManagementServiceImpl method getDisplayerSettings.

@Override
public DisplayerSettings getDisplayerSettings(String dataSourceUuid, String schema, String table) {
    checkNotNull("dataSourceUuid", dataSourceUuid);
    checkNotNull("table", table);
    try {
        DataSourceDeploymentInfo deploymentInfo = dataSourceRuntimeManager.getDataSourceDeploymentInfo(dataSourceUuid);
        DataSetDef dataSetDef = DataSetDefBuilder.newBuilder().dataSetUuid(buildDataSetUuid(dataSourceUuid, schema, table)).dataSetName(buildDataSetName(schema, table)).dataSourceUuid(deploymentInfo.getUuid()).schema(schema).table(buildDataSetTableName(dataSourceUuid, table)).isPublic(false).build();
        dataSetDefRegistry.registerDataSetDef(dataSetDef);
        DataSetLookup lookup = new DataSetLookup();
        lookup.setDataSetUUID(dataSetDef.getUUID());
        DataSet dataSet = dataSetManager.lookupDataSet(lookup);
        TableDisplayerSettingsBuilder settingsBuilder = DisplayerSettingsFactory.newTableSettings().dataset(dataSetDef.getUUID()).title(table).titleVisible(true).tablePageSize(20).tableOrderEnabled(true);
        List<DataColumn> columns = dataSet.getColumns();
        for (DataColumn column : columns) {
            settingsBuilder.column(column.getId());
        }
        int tableWith = columns.size() * COLUMN_WIDTH;
        settingsBuilder.tableWidth(tableWith);
        settingsBuilder.renderer(DefaultRenderer.UUID);
        return settingsBuilder.buildSettings();
    } catch (Exception e) {
        throw new GenericPortableException(e.getMessage());
    }
}
Also used : DataSetDef(org.dashbuilder.dataset.def.DataSetDef) DataSet(org.dashbuilder.dataset.DataSet) DataColumn(org.dashbuilder.dataset.DataColumn) GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException) TableDisplayerSettingsBuilder(org.dashbuilder.displayer.TableDisplayerSettingsBuilder) DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo) DataSetLookup(org.dashbuilder.dataset.DataSetLookup) GenericPortableException(org.guvnor.common.services.shared.exceptions.GenericPortableException)

Example 17 with DataSourceDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo in project kie-wb-common by kiegroup.

the class DataSourceDefQueryServiceImpl method createDataSourceDefInfo.

private DataSourceDefInfo createDataSourceDefInfo(final org.uberfire.java.nio.file.Path path) {
    String content = ioService.readAllString(path);
    DataSourceDef dataSourceDef = DataSourceDefSerializer.deserialize(content);
    DataSourceDeploymentInfo deploymentInfo = null;
    try {
        deploymentInfo = runtimeManager.getDataSourceDeploymentInfo(dataSourceDef.getUuid());
    } catch (Exception e) {
        logger.warn("It was not possible to read deployment info when building DataSourceDefInfo for data source: " + dataSourceDef.getUuid(), e);
    }
    return new DataSourceDefInfo(dataSourceDef.getUuid(), dataSourceDef.getName(), Paths.convert(path), deploymentInfo);
}
Also used : DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef) DataSourceDefInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo) DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)

Example 18 with DataSourceDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo in project kie-wb-common by kiegroup.

the class DataSourceProviderBaseTest method testDeployDataSourceWithMissingDriver.

/**
 * Tests a data source deployment attempt in the case when the required driver is not deployed.
 */
@Test
public void testDeployDataSourceWithMissingDriver() throws Exception {
    // an exception should have been thrown.
    expectedException.expectMessage("Required driver: " + dataSourceDef.getDriverUuid() + " is not deployed");
    dataSourceProvider.deploy(dataSourceDef);
    DataSourceDeploymentInfo deploymentInfo = dataSourceProvider.getDeploymentInfo(dataSourceDef.getUuid());
    assertNull(deploymentInfo);
}
Also used : DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo) Test(org.junit.Test)

Example 19 with DataSourceDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo in project kie-wb-common by kiegroup.

the class DataSourceProviderBaseTest method testDeployDataSource.

/**
 * Tests the successful deployment of a data source.
 */
@Test
public void testDeployDataSource() throws Exception {
    setupDrivers();
    // deploy the data source
    deployDataSource(dataSourceDef);
    DataSourceDeploymentInfo deploymentInfo = dataSourceProvider.getDeploymentInfo(dataSourceDef.getUuid());
    // the data source should have been properly deployed.
    assertNotNull(deploymentInfo);
}
Also used : DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo) Test(org.junit.Test)

Example 20 with DataSourceDeploymentInfo

use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo in project kie-wb-common by kiegroup.

the class DataSourceRuntimeManagerTest method testUnDeployDataSource.

/**
 * Tests the un-deployment of a data source.
 */
@Test
public void testUnDeployDataSource() {
    try {
        // emulates that the required driver is properly deployed.
        when(driverProvider.getDeploymentInfo(dataSourceDef.getDriverUuid())).thenReturn(driverDeploymentInfo);
        // simulate we have an already deployed data source
        deployDataSource(dataSourceDef);
        DataSourceDeploymentInfo deploymentInfo = runtimeManager.getDataSourceDeploymentInfo(dataSourceDef.getUuid());
        assertNotNull(deploymentInfo);
        runtimeManager.unDeployDataSource(deploymentInfo, UnDeploymentOptions.forcedUnDeployment());
        when(dataSourceProvider.getDeploymentInfo(dataSourceDef.getUuid())).thenReturn(null);
        // the data source should have been un-deployed with the provider.
        verify(dataSourceProvider, times(1)).undeploy(dataSourceDeploymentInfo);
        deploymentInfo = runtimeManager.getDataSourceDeploymentInfo(dataSourceDef.getUuid());
        // no deployment info should exist
        assertNull(deploymentInfo);
    } catch (Exception e) {
        fail(e.getMessage());
    }
}
Also used : DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Aggregations

DataSourceDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)21 Test (org.junit.Test)7 DriverDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo)4 SQLException (java.sql.SQLException)3 DataSourceDef (org.kie.workbench.common.screens.datasource.management.model.DataSourceDef)3 Before (org.junit.Before)2 DataSource (org.kie.workbench.common.screens.datasource.management.backend.core.DataSource)2 WildflyDataSourceDef (org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef)2 DataSourceDefInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo)2 DriverDef (org.kie.workbench.common.screens.datasource.management.model.DriverDef)2 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Properties (java.util.Properties)1 ConnectionFactory (org.apache.commons.dbcp2.ConnectionFactory)1 PoolableConnection (org.apache.commons.dbcp2.PoolableConnection)1 PoolableConnectionFactory (org.apache.commons.dbcp2.PoolableConnectionFactory)1 PoolingDataSource (org.apache.commons.dbcp2.PoolingDataSource)1 GenericObjectPool (org.apache.commons.pool2.impl.GenericObjectPool)1 DataColumn (org.dashbuilder.dataset.DataColumn)1 DataSet (org.dashbuilder.dataset.DataSet)1