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