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());
}
}
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);
}
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);
}
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);
}
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());
}
}
Aggregations