Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug/Cast QueryInterface to QueryDimInterface #646

Merged
merged 2 commits into from
Jul 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ public Iterable<SearchResult> call() throws Exception {
return queryEngine.query(query, parameters);
} catch (RuntimeException ex) {
logger.warn("Query plugin {} failed unexpectedly", querySource, ex);
return Collections.EMPTY_LIST;
return Collections.emptyList();
}

}
Expand All @@ -618,19 +618,30 @@ public Iterable<SearchResult> call() throws Exception {
private Task<Iterable<SearchResult>> getTaskForQueryDim(final String querySource, final String query,
final DimLevel level, final Object... parameters) {

final QueryInterface queryEngine = getQueryProviderByName(querySource, true);
final QueryDimInterface queryEngine;
QueryInterface tmpQueryDimInterface = getQueryProviderByName(querySource, true);
if (tmpQueryDimInterface instanceof QueryDimInterface) {
queryEngine = (QueryDimInterface) tmpQueryDimInterface;
} else {
logger.warn("Query plugin {} is not a DIM query provider", querySource);
queryEngine = null;
}

// returns a tasks that runs the query from the selected query engine
String uid = UUID.randomUUID().toString();
Task<Iterable<SearchResult>> queryTask = new Task<>(uid, querySource, new Callable<Iterable<SearchResult>>() {
@Override
public Iterable<SearchResult> call() throws Exception {
if (queryEngine == null || !(queryEngine instanceof QueryDimInterface))
public Iterable<SearchResult> call() {
if (queryEngine == null) {
logger.warn("Could not query provider {} as a DIM source", querySource);

return Collections.emptyList();
}
try {
return queryEngine.query(query, level, parameters);
} catch (RuntimeException ex) {
logger.warn("Query plugin {} failed unexpectedly", querySource, ex);
return Collections.EMPTY_LIST;
return Collections.emptyList();
}

}
Expand Down