Search in sources :

Example 6 with DataSourceDefInfo

use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo 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 7 with DataSourceDefInfo

use of org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo 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 8 with DataSourceDefInfo

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

the class DefExplorerContent method loadDataSources.

public void loadDataSources(Collection<DataSourceDefInfo> dataSourceDefInfos) {
    clearDataSources();
    if (dataSourceDefInfos != null) {
        DefItem item;
        String itemName;
        for (DataSourceDefInfo dataSourceDefInfo : dataSourceDefInfos) {
            itemName = dataSourceDefInfo.getName() + (dataSourceDefInfo.isManaged() ? "" : " (external)");
            item = createItem();
            item.setName(itemName);
            item.addItemHandler(new DefItemView.ItemHandler() {

                @Override
                public void onClick(String itemId) {
                    onDataSourceItemClick(dataSourceItemsMap.get(itemId));
                }
            });
            dataSourceItemsMap.put(item.getId(), dataSourceDefInfo);
            view.addDataSourceItem(item);
        }
    }
}
Also used : DataSourceDefInfo(org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo)

Aggregations

DataSourceDefInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDefInfo)8 DataSourceDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DataSourceDeploymentInfo)3 ArrayList (java.util.ArrayList)2 Before (org.junit.Before)2 DataSourceDef (org.kie.workbench.common.screens.datasource.management.model.DataSourceDef)2 DriverDefInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDefInfo)2 HashMap (java.util.HashMap)1 SQLDataSourceDef (org.dashbuilder.dataset.def.SQLDataSourceDef)1 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)1 Branch (org.guvnor.structure.repositories.Branch)1 DeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DeploymentInfo)1 DriverDeploymentInfo (org.kie.workbench.common.screens.datasource.management.model.DriverDeploymentInfo)1 Path (org.uberfire.backend.vfs.Path)1