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);
}
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);
}
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);
}
}
}
Aggregations