Search in sources :

Example 1 with DataSourceDef

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

the class DataSourceDefEditorTest method createContent.

private DataSourceDefEditorContent createContent() {
    DataSourceDefEditorContent content = new DataSourceDefEditorContent();
    content.setDef(new DataSourceDef());
    content.getDef().setName(NAME);
    content.getDef().setDriverUuid(DRIVER_UUID);
    content.getDef().setConnectionURL(CONNECTION_URL);
    content.getDef().setUser(USER);
    content.getDef().setPassword(PASSWORD);
    return content;
}
Also used : DataSourceDefEditorContent(org.kie.workbench.common.screens.datasource.management.model.DataSourceDefEditorContent) DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef)

Example 2 with DataSourceDef

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

the class DataSourceWizardTestBase method setup.

/**
 * Initializes the services, the wizard pages, and drivers information.
 */
protected void setup() {
    // initialize the services
    editorServiceCaller = new CallerMock<>(editorService);
    queryServiceCaller = new CallerMock<>(queryService);
    // initialize the wizard page
    mainPanel = new DataSourceDefMainPanel(mainPanelView);
    dataSourceDef = new DataSourceDef();
    editorHelper = new DataSourceDefEditorHelper(translationService, editorServiceCaller, queryServiceCaller, new ClientValidationServiceMock(), popupsUtil);
    defPage = new DataSourceDefPage(view, mainPanel, editorHelper, statusChangeEvent);
    defPage.setDataSourceDef(dataSourceDef);
    // prepare the drivers info
    drivers = new ArrayList<>();
    drivers.add(driver1);
    drivers.add(driver2);
    options = new ArrayList<>();
    options.add(new Pair("Driver1.name", DRIVER_UUID));
    options.add(new Pair("Driver2.name", DRIVER_UUID_2));
    when(driver1.getName()).thenReturn("Driver1.name");
    when(driver1.getUuid()).thenReturn(DRIVER_UUID);
    when(driver2.getName()).thenReturn("Driver2.name");
    when(driver2.getUuid()).thenReturn(DRIVER_UUID_2);
    // emulates the service returning the requested drivers.
    when(queryService.findModuleDrivers(path)).thenReturn(drivers);
    when(queryService.findGlobalDrivers()).thenReturn(drivers);
}
Also used : DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef) DataSourceDefMainPanel(org.kie.workbench.common.screens.datasource.management.client.editor.datasource.DataSourceDefMainPanel) DataSourceDefEditorHelper(org.kie.workbench.common.screens.datasource.management.client.editor.datasource.DataSourceDefEditorHelper) ClientValidationServiceMock(org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock) Pair(org.uberfire.commons.data.Pair)

Example 3 with DataSourceDef

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

the class WildflyDataSourceProvider method getDeployments.

/**
 * Gets the list of data source definitions for the currently defined data sources in the Wildfly server.
 * @return list with the definitions for the defined data sources.
 * @throws Exception exceptions may be thrown if e.g. communication with the Wildfly server fails, etc.
 */
@Override
public List<DataSourceDef> getDeployments() throws Exception {
    List<WildflyDataSourceDef> dataSources;
    List<DataSourceDef> dataSourceDefs = new ArrayList<>();
    DataSourceDef dataSourceDef;
    String dataSourceUuid;
    String driverUuid;
    dataSources = dataSourceMgmtClient.getDataSources();
    for (WildflyDataSourceDef internalDef : dataSources) {
        dataSourceDef = new DataSourceDef();
        try {
            dataSourceUuid = DeploymentIdGenerator.extractUuid(internalDef.getName());
        } catch (Exception e) {
            dataSourceUuid = internalDef.getName();
        }
        try {
            driverUuid = DeploymentIdGenerator.extractUuid(internalDef.getDriverName());
        } catch (Exception e) {
            driverUuid = internalDef.getDriverName();
        }
        dataSourceDef.setUuid(dataSourceUuid);
        dataSourceDef.setName(internalDef.getName());
        dataSourceDef.setConnectionURL(internalDef.getConnectionURL());
        dataSourceDef.setDriverUuid(driverUuid);
        dataSourceDef.setUser(internalDef.getUser());
        dataSourceDef.setPassword(internalDef.getPassword());
        dataSourceDefs.add(dataSourceDef);
    }
    return dataSourceDefs;
}
Also used : WildflyDataSourceDef(org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef) WildflyDataSourceDef(org.kie.workbench.common.screens.datasource.management.backend.integration.wildfly.WildflyDataSourceDef) DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef) ArrayList(java.util.ArrayList)

Example 4 with DataSourceDef

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

the class DataSourceDefQueryServiceImpl method findGlobalDataSources.

@Override
public Collection<DataSourceDefInfo> findGlobalDataSources(boolean includeUnManaged) {
    Collection<DataSourceDefInfo> result = resolveDataSources(serviceHelper.getGlobalDataSourcesContext());
    if (includeUnManaged) {
        Map<String, DataSourceDefInfo> managedDataSources = new HashMap<>();
        for (DataSourceDefInfo dataSourceDefInfo : result) {
            managedDataSources.put(dataSourceDefInfo.getUuid(), dataSourceDefInfo);
        }
        try {
            List<DataSourceDef> allDeployments = providerFactory.getDataSourceProvider().getDeployments();
            DeploymentInfo deploymentInfo;
            for (DataSourceDef dataSourceDef : allDeployments) {
                deploymentInfo = runtimeManager.getDataSourceDeploymentInfo(dataSourceDef.getUuid());
                if (!managedDataSources.containsKey(dataSourceDef.getUuid()) && (deploymentInfo != null && !deploymentInfo.isManaged())) {
                    result.add(new DataSourceDefInfo(dataSourceDef.getUuid(), dataSourceDef.getName(), runtimeManager.getDataSourceDeploymentInfo(dataSourceDef.getUuid())));
                }
            }
        } catch (Exception e) {
            logger.warn("It was not possible to read all deployed data sources. ", e);
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) 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) DeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DeploymentInfo) DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo)

Example 5 with DataSourceDef

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

the class DataSourceProviderBaseTest method setup.

protected void setup() throws Exception {
    dataSourceDef = new DataSourceDef();
    dataSourceDef.setUuid(DS1_UUID);
    dataSourceDef.setName(DS1_NAME);
    dataSourceDef.setDriverUuid(DRIVER1_UUID);
    dataSourceDef.setConnectionURL(DS1_CONNECTION_URL);
    dataSourceDef.setUser(DS1_USER);
    dataSourceDef.setPassword(DS1_PASSWORD);
}
Also used : DataSourceDef(org.kie.workbench.common.screens.datasource.management.model.DataSourceDef)

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