use of org.kie.workbench.common.services.refactoring.backend.server.query.builder.SearchEmptyQueryBuilder in project kie-wb-common by kiegroup.
the class FindRulesByModuleQuery method toQuery.
@Override
public Query toQuery(final Set<ValueIndexTerm> terms) {
checkNotNullAndNotEmpty(terms);
ValuePackageNameIndexTerm packageTerm = null;
ValueModuleRootPathIndexTerm projectTerm = null;
ValueResourceIndexTerm ruleTerm = null;
for (ValueIndexTerm term : terms) {
if (term instanceof ValuePackageNameIndexTerm) {
packageTerm = (ValuePackageNameIndexTerm) term;
} else if (term instanceof ValueModuleRootPathIndexTerm) {
projectTerm = (ValueModuleRootPathIndexTerm) term;
} else if (term instanceof ValueResourceIndexTerm) {
ruleTerm = (ValueResourceIndexTerm) term;
}
}
SearchEmptyQueryBuilder queryBuilder = new SearchEmptyQueryBuilder().addTerm(packageTerm).addTerm(projectTerm);
if (ruleTerm != null) {
queryBuilder.addTerm(ruleTerm);
} else {
queryBuilder.addRuleNameWildCardTerm();
}
return queryBuilder.build();
}
Aggregations