Search in sources :

Example 1 with SearchEmptyQueryBuilder

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();
}
Also used : ValueResourceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) SearchEmptyQueryBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.builder.SearchEmptyQueryBuilder) ValuePackageNameIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePackageNameIndexTerm) ValueModuleRootPathIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueModuleRootPathIndexTerm)

Aggregations

SearchEmptyQueryBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.builder.SearchEmptyQueryBuilder)1 ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)1 ValueModuleRootPathIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueModuleRootPathIndexTerm)1 ValuePackageNameIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePackageNameIndexTerm)1 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)1