use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDef in project kie-wb-common by kiegroup.
the class DataSourceDefDeployerImpl method deployDef.
@Override
protected void deployDef(DataSourceDefInfo defInfo) {
try {
logger.debug("Deploying data source def: " + defInfo);
String source = ioService.readAllString(Paths.convert(defInfo.getPath()));
DataSourceDef dataSourceDef = DataSourceDefSerializer.deserialize(source);
runtimeManager.deployDataSource(dataSourceDef, DeploymentOptions.createOrResync());
defRegistry.setEntry(defInfo.getPath(), dataSourceDef);
logger.debug("Data source was successfully deployed");
} catch (Exception e) {
logger.error("Data source deployment failed, defInfo: " + defInfo, e);
}
}
use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDef 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.DataSourceDef in project kie-wb-common by kiegroup.
the class AbstractDefChangeHandlerTest method setup.
@Before
public void setup() {
setupChangeHandler();
when(serviceHelper.getDefRegistry()).thenReturn(defRegistry);
when(moduleService.resolveModule(path)).thenReturn(module);
when(sessionInfo.getId()).thenReturn(SESSION_ID);
when(sessionInfo.getIdentity()).thenReturn(identity);
when(identity.getIdentifier()).thenReturn(IDENTIFIER);
dataSourceDef = new DataSourceDef();
dataSourceDef.setUuid("uuid");
dataSourceDef.setName("dataSourceName");
dataSourceDef.setConnectionURL("connectionURL");
dataSourceDef.setUser("user");
dataSourceDef.setPassword("password");
driverDef = new DriverDef();
driverDef.setUuid("uuid");
driverDef.setName("driverName");
driverDef.setDriverClass(TestDriver.class.getName());
driverDef.setGroupId("groupId");
driverDef.setArtifactId("artifactId");
driverDef.setVersion("version");
when(registeredDataSourceDef.getUuid()).thenReturn("registeredDataSourceUuid");
when(registeredDataSourceDeploymentInfo.getUuid()).thenReturn("registeredDataSourceUuid");
when(originalDataSourceDef.getUuid()).thenReturn("originalDataSourceUuid");
when(originalDatasourceDeploymentInfo.getUuid()).thenReturn("originalDataSourceUuid");
when(registeredDriverDef.getUuid()).thenReturn("registeredDriverDefUuid");
when(registeredDriverDeploymentInfo.getUuid()).thenReturn("registeredDriverDefUuid");
when(originalDriverDef.getUuid()).thenReturn("originalDriverDefUuid");
when(originalDriverDeploymentInfo.getUuid()).thenReturn("originalDriverDefUuid");
}
use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDef in project kie-wb-common by kiegroup.
the class AbstractDefChangeHandlerTest method verifyUnDeployed.
/**
* Verifies that the given definition has been un-deployed.
*/
protected void verifyUnDeployed(Def def) throws Exception {
// the definition should have been un-deployed.
if (def instanceof DataSourceDef) {
DataSourceDeploymentInfo deploymentInfo = runtimeManager.getDataSourceDeploymentInfo(def.getUuid());
// is deployed by construction
assertNotNull(deploymentInfo);
verify(runtimeManager, times(1)).unDeployDataSource(deploymentInfo, UnDeploymentOptions.forcedUnDeployment());
} else {
DriverDeploymentInfo deploymentInfo = runtimeManager.getDriverDeploymentInfo(def.getUuid());
// is deployed by construction
assertNotNull(deploymentInfo);
verify(runtimeManager, times(1)).unDeployDriver(deploymentInfo, UnDeploymentOptions.forcedUnDeployment());
}
}
Aggregations