Search in sources :

Example 6 with DriverDefInfo

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

the class DataSourceDefQueryServiceImpl method findModuleDriver.

@Override
public DriverDefInfo findModuleDriver(final String uuid, final Path path) {
    checkNotNull("uuid", uuid);
    checkNotNull("path", path);
    for (DriverDefInfo driverDefInfo : findModuleDrivers(path)) {
        if (uuid.equals(driverDefInfo.getUuid())) {
            return driverDefInfo;
        }
    }
    return null;
}
Also used : DriverDefInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo)

Example 7 with DriverDefInfo

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

the class DataSourceDefQueryServiceImpl method createDriverInfo.

private DriverDefInfo createDriverInfo(final org.uberfire.java.nio.file.Path path) {
    String content = ioService.readAllString(path);
    DriverDef driverDef = DriverDefSerializer.deserialize(content);
    DriverDeploymentInfo deploymentInfo = null;
    try {
        deploymentInfo = runtimeManager.getDriverDeploymentInfo(driverDef.getUuid());
    } catch (Exception e) {
        logger.warn("It was not possible to read deployment info when building DriverDefInfo for driver: " + driverDef.getUuid(), e);
    }
    return new DriverDefInfo(driverDef.getUuid(), driverDef.getName(), Paths.convert(path), deploymentInfo);
}
Also used : DriverDefInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo) DriverDeploymentInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo) DriverDef(org.kie.workbench.common.screens.datasource.management.model.DriverDef)

Example 8 with DriverDefInfo

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

the class DefExplorerQueryServiceTest method setup.

@Before
public void setup() {
    createOrganizationalUnits();
    // setup current organizational units
    when(organizationalUnitService.getOrganizationalUnits()).thenReturn(organizationalUnits);
    when(organizationalUnitService.getOrganizationalUnit(o1.getName())).thenReturn(o1);
    when(organizationalUnitService.getOrganizationalUnit(o2.getName())).thenReturn(o2);
    when(organizationalUnitService.getOrganizationalUnit(o3.getName())).thenReturn(o3);
    // emulates the authorizations for current identity.
    // o1 is not authorized
    when(authorizationManager.authorize(o1, identity)).thenReturn(false);
    // o2 is authorized
    when(authorizationManager.authorize(o2, identity)).thenReturn(true);
    // repo_o2_1 is authorized
    when(authorizationManager.authorize(repo_o2_1, identity)).thenReturn(true);
    // repo_o2_2 is authorized
    when(authorizationManager.authorize(repo_o2_2, identity)).thenReturn(true);
    // o3 is authorized
    when(authorizationManager.authorize(o3, identity)).thenReturn(true);
    // repo_o3_1 is authorized
    when(authorizationManager.authorize(repo_o3_1, identity)).thenReturn(true);
    // repo_o3_2 is not authorized
    when(authorizationManager.authorize(repo_o3_2, identity)).thenReturn(false);
    // repo_o3_3 is authorized
    when(authorizationManager.authorize(repo_o3_3, identity)).thenReturn(true);
    // prepare the modules
    when(module1.getModuleName()).thenReturn("module1");
    when(module1.getRootPath()).thenReturn(rootPath1);
    when(module2.getModuleName()).thenReturn("module2");
    when(module2.getRootPath()).thenReturn(rootPath2);
    when(module3.getModuleName()).thenReturn("module3");
    when(module3.getRootPath()).thenReturn(rootPath3);
    doReturn(new WorkspaceProject(o3, repo_o3_1, new Branch("master", mock(Path.class)), module1)).when(projectService).resolveProject(repo_o3_1);
    doReturn(new WorkspaceProject(o3, repo_o3_2, new Branch("master", mock(Path.class)), module2)).when(projectService).resolveProject(repo_o3_2);
    doReturn(new WorkspaceProject(o3, repo_o3_3, new Branch("master", mock(Path.class)), module3)).when(projectService).resolveProject(repo_o3_3);
    // module1 has data sources ds1 and ds2, and drivers driver1, driver2 and driver3
    ArrayList<DataSourceDefInfo> module2DSs = new ArrayList<>();
    module2DSs.add(ds1);
    module2DSs.add(ds2);
    ArrayList<DriverDefInfo> module2Drivers = new ArrayList<>();
    module2Drivers.add(driver1);
    module2Drivers.add(driver2);
    module2Drivers.add(driver3);
    when(dataSourceDefQueryService.findModuleDataSources(module1)).thenReturn(module2DSs);
    when(dataSourceDefQueryService.findModuleDrivers(module1)).thenReturn(module2Drivers);
}
Also used : Path(org.uberfire.backend.vfs.Path) DriverDefInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) Branch(org.guvnor.structure.repositories.Branch) ArrayList(java.util.ArrayList) DataSourceDefInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo) Before(org.junit.Before)

Example 9 with DriverDefInfo

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

the class DataSourceDefEditorHelper method buildDriverOptions.

private List<Pair<String, String>> buildDriverOptions(final List<DriverDefInfo> driverDefs) {
    List<Pair<String, String>> options = new ArrayList<>();
    driverDefMap.clear();
    for (DriverDefInfo driverDef : driverDefs) {
        options.add(new Pair<>(driverDef.getName(), driverDef.getUuid()));
        driverDefMap.put(driverDef.getUuid(), driverDef);
    }
    return options;
}
Also used : DriverDefInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo) ArrayList(java.util.ArrayList) Pair(org.uberfire.commons.data.Pair)

Example 10 with DriverDefInfo

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

the class DefExplorerContent method loadDrivers.

public void loadDrivers(Collection<DriverDefInfo> driverDefInfos) {
    clearDrivers();
    if (driverDefInfos != null) {
        DefItem item;
        for (DriverDefInfo driverDefInfo : driverDefInfos) {
            item = createItem();
            item.setName(driverDefInfo.getName());
            item.addItemHandler(new DefItemView.ItemHandler() {

                @Override
                public void onClick(String itemId) {
                    onDriverItemClick(driverItemsMap.get(itemId));
                }
            });
            driverItemsMap.put(item.getId(), driverDefInfo);
            view.addDriverItem(item);
        }
    }
}
Also used : DriverDefInfo(org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo)

Aggregations

DriverDefInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo)10 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)2 DataSourceDefInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo)2 DriverDef (org.kie.workbench.common.screens.datasource.management.model.DriverDef)2 Path (org.uberfire.backend.vfs.Path)2 URI (java.net.URI)1 Connection (java.sql.Connection)1 Properties (java.util.Properties)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 Branch (org.guvnor.structure.repositories.Branch)1 Test (org.junit.Test)1 ClientValidationServiceMock (org.kie.workbench.common.screens.datasource.management.client.util.ClientValidationServiceMock)1 DataSourceDef (org.kie.workbench.common.screens.datasource.management.model.DataSourceDef)1 DriverDefEditorContent (org.kie.workbench.common.screens.datasource.management.model.DriverDefEditorContent)1 DriverDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo)1 TestResult (org.kie.workbench.common.screens.datasource.management.model.TestResult)1 URLConnectionFactory (org.kie.workbench.common.screens.datasource.management.util.URLConnectionFactory)1 Pair (org.uberfire.commons.data.Pair)1 Command (org.uberfire.mvp.Command)1