Search in sources :

Example 11 with DataSourceDef

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);
    }
}
Also used : DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef)

Example 12 with DataSourceDef

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);
}
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 13 with DataSourceDef

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");
}
Also used : DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef) DriverDef(org.kie.workbench.common.screens.datasource.management.model.DriverDef) TestDriver(org.kie.workbench.common.screens.datasource.management.backend.service.TestDriver) Before(org.junit.Before)

Example 14 with DataSourceDef

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());
    }
}
Also used : DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo) DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef) DataSourceDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)

Aggregations

DataSourceDef (org.kie.workbench.common.screens.datasource.management.model.DataSourceDef)14 Before (org.junit.Before)4 DataSourceDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)4 DriverDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo)3 ArrayList (java.util.ArrayList)2 ClientValidationServiceMock (org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock)2 DataSourceDefEditorContent (org.kie.workbench.common.screens.datasource.management.model.DataSourceDefEditorContent)2 DataSourceDefInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo)2 DriverDef (org.kie.workbench.common.screens.datasource.management.model.DriverDef)2 HashMap (java.util.HashMap)1 WildflyDataSourceDef (org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef)1 TestDriver (org.kie.workbench.common.screens.datasource.management.backend.service.TestDriver)1 DataSourceDefEditorHelper (org.kie.workbench.common.screens.datasource.management.client.editor.datasource.DataSourceDefEditorHelper)1 DataSourceDefMainPanel (org.kie.workbench.common.screens.datasource.management.client.editor.datasource.DataSourceDefMainPanel)1 DeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DeploymentInfo)1 DriverDefInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo)1 Path (org.uberfire.backend.vfs.Path)1 Pair (org.uberfire.commons.data.Pair)1 Command (org.uberfire.mvp.Command)1 ParameterizedCommand (org.uberfire.mvp.ParameterizedCommand)1