use of org.kie.workbench.common.screens.datasource.management.service.DefExplorerQueryResult in project kie-wb-common by kiegroup.
the class DefExplorerQueryServiceImpl method resolveQuery.
private DefExplorerQueryResult resolveQuery(final DefExplorerQuery query) {
final DefExplorerQueryResult result = new DefExplorerQueryResult();
// load the organizational units.
final Collection<OrganizationalUnit> organizationalUnits = resolveOrganizationalUnits();
// piggyback the organizational units.
result.getOrganizationalUnits().addAll(organizationalUnits);
if (query.getOrganizationalUnit() == null || !containsOU(organizationalUnits, query.getOrganizationalUnit())) {
// if no OU was set for filtering or the selected OU has been removed or has changed in backend.
return result;
}
// set the repositories for current OU.
final Map<String, Repository> repositories = resolveRepositories(query.getOrganizationalUnit());
// piggyback the repositories.
result.getRepositories().addAll(repositories.values());
if (query.getRepository() == null || !repositories.containsKey(query.getRepository().getAlias())) {
// changed in backend.
return result;
}
// load the modules for current OU/Repository and the selected branch.
final Map<String, Module> modules = resolveModules(repositories, query.getBranchName());
result.getModules().addAll(modules.values());
if (query.getModule() == null || !modules.containsKey(query.getModule().getModuleName())) {
// changed in backend.
return result;
}
// get the data sources and drivers for the selected module.
result.setDataSourceDefs(queryService.findModuleDataSources(query.getModule()));
result.setDriverDefs(queryService.findModuleDrivers(query.getModule()));
return result;
}
use of org.kie.workbench.common.screens.datasource.management.service.DefExplorerQueryResult in project kie-wb-common by kiegroup.
the class ExplorerBaseTest method setup.
protected void setup() {
queryServiceCaller = new CallerMock<>(queryService);
result = new DefExplorerQueryResult();
}
use of org.kie.workbench.common.screens.datasource.management.service.DefExplorerQueryResult in project kie-wb-common by kiegroup.
the class DefExplorerQueryServiceImpl method executeQuery.
public DefExplorerQueryResult executeQuery(final DefExplorerQuery query) {
checkNotNull("query", query);
if (query.isGlobalQuery()) {
DefExplorerQueryResult result = new DefExplorerQueryResult();
result.setDataSourceDefs(queryService.findGlobalDataSources(true));
result.setDriverDefs(queryService.findGlobalDrivers());
return result;
} else {
return resolveQuery(query);
}
}
use of org.kie.workbench.common.screens.datasource.management.service.DefExplorerQueryResult in project kie-wb-common by kiegroup.
the class DefExplorerQueryServiceTest method testQueryForOrganizationalUnitRepository.
/**
* Tests a query for a given Organizational Unit and a given repository. In this case the list of available
* authorized modules for the given repository should be returned.
*/
@Test
public void testQueryForOrganizationalUnitRepository() {
DefExplorerQuery query = new DefExplorerQuery();
query.setOrganizationalUnit(o3);
query.setRepository(repo_o3_3);
query.setBranchName("master");
DefExplorerQueryResult result = explorerQueryService.executeQuery(query);
verifyResultForQueryForOrganizationalUnitRepository(result);
}
use of org.kie.workbench.common.screens.datasource.management.service.DefExplorerQueryResult in project kie-wb-common by kiegroup.
the class DefExplorerQueryServiceTest method testQueryForOrganizationalUnit.
/**
* Tests a query for a given Organizational Unit as the only parameter. In this case the query should return the
* list of available authorized repositories for the selected OU.
*/
@Test
public void testQueryForOrganizationalUnit() {
DefExplorerQuery query = new DefExplorerQuery();
query.setOrganizationalUnit(o2);
DefExplorerQueryResult result = explorerQueryService.executeQuery(query);
// o1 should not be included in the result since it's not authorized.
assertFalse(result.getOrganizationalUnits().contains(o1));
// o2 must be included in the result.
assertTrue(result.getOrganizationalUnits().contains(o2));
// o3 is still included in the result since organizational units are piggybacked to let the UI be refreshed
assertTrue(result.getOrganizationalUnits().contains(o3));
// authorized repositories for organizational unit o2 must be in the result.
assertTrue(result.getRepositories().contains(repo_o2_1));
assertTrue(result.getRepositories().contains(repo_o2_2));
assertEquals(2, result.getRepositories().size());
}
Aggregations