Search in sources :

Example 21 with ValueIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm in project kie-wb-common by kiegroup.

the class SearchEmptyQueryBuilder method addRuleNameWildCardTerm.

public SearchEmptyQueryBuilder addRuleNameWildCardTerm() {
    ValueIndexTerm valTerm = new ValueResourceIndexTerm("*", ResourceType.RULE, TermSearchType.WILDCARD);
    queryBuilder.add(new WildcardQuery(new Term(valTerm.getTerm(), valTerm.getValue())), MUST);
    return this;
}
Also used : ValueResourceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm) WildcardQuery(org.apache.lucene.search.WildcardQuery) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) ValueResourceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm) Term(org.apache.lucene.index.Term) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)

Example 22 with ValueIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm in project kie-wb-common by kiegroup.

the class FindResourcePartsQueryInvalidIndexTermsTest method testFindResourcePartsQueryInvalidIndexTerms.

@Test
public void testFindResourcePartsQueryInvalidIndexTerms() throws IOException, InterruptedException {
    {
        final RefactoringPageRequest request = new RefactoringPageRequest("FindResourcePartsQuery", new HashSet<ValueIndexTerm>(), 0, -1);
        try {
            service.query(request);
            fail();
        } catch (IllegalArgumentException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), e.getMessage().startsWith("Expected '" + ValuePartIndexTerm.class.getSimpleName() + "' term was not found"));
        // and Swallow. Expected
        }
    }
    ValueIndexTerm ruleRefTerm = new ValueReferenceIndexTerm("myRule", ResourceType.RULE);
    {
        final RefactoringPageRequest request = new RefactoringPageRequest("FindResourcePartsQuery", new HashSet<ValueIndexTerm>() {

            {
                add(ruleRefTerm);
            }
        }, 0, -1);
        try {
            service.query(request);
            fail();
        } catch (IllegalArgumentException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), e.getMessage().startsWith("Index term '" + ruleRefTerm.getTerm() + "' can not be used with"));
        // and Swallow. Expected
        }
    }
    {
        final RefactoringPageRequest request = new RefactoringPageRequest("FindResourcePartsQuery", new HashSet<ValueIndexTerm>() {

            {
                add(new ValueReferenceIndexTerm("org.kie.workbench.common.services.refactoring.backend.server.drl.classes.Applicant", ResourceType.JAVA));
                add(ruleRefTerm);
            }
        }, 0, -1);
        try {
            service.query(request);
            fail();
        } catch (IllegalArgumentException e) {
            assertTrue("Unexpected exception: " + e.getMessage(), e.getMessage().contains(" can not be used with the " + FindResourcePartsQuery.NAME));
        // and Swallow. Expected
        }
    }
}
Also used : RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) ValueReferenceIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueReferenceIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) HashSet(java.util.HashSet) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Example 23 with ValueIndexTerm

use of org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm in project drools-wb by kiegroup.

the class IndexDecisionTableXLSAttributeNameAndValueTest method testIndexDecisionTableXLSAttributeNameAndValue.

@Test
public void testIndexDecisionTableXLSAttributeNameAndValue() throws IOException, InterruptedException {
    // Add test files
    final Path path1 = loadXLSFile(basePath, "dtable1.xls");
    final Path path2 = loadXLSFile(basePath, "dtable2.xls");
    // wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
    Thread.sleep(5000);
    List<String> index = Arrays.asList(KObjectUtil.toKCluster(basePath.getFileSystem()).getClusterId());
    // This simply checks whether there is a Rule Attribute "ruleflow-group" with a Rule Attribute Value "myRuleflowGroup"
    {
        final BooleanQuery.Builder query = new BooleanQuery.Builder();
        ValueIndexTerm valTerm = new ValueSharedPartIndexTerm("myruleflowgroup", PartType.RULEFLOW_GROUP);
        query.add(new TermQuery(new Term(valTerm.getTerm(), valTerm.getValue())), BooleanClause.Occur.MUST);
        searchFor(index, query.build(), 1, path1);
    }
}
Also used : Path(org.uberfire.java.nio.file.Path) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) BooleanQuery(org.apache.lucene.search.BooleanQuery) TermQuery(org.apache.lucene.search.TermQuery) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) Term(org.apache.lucene.index.Term) ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) Test(org.junit.Test) BaseIndexingTest(org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)

Aggregations

ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)23 HashSet (java.util.HashSet)13 Test (org.junit.Test)12 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)10 RefactoringPageRequest (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest)8 RefactoringPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)8 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)7 Path (org.uberfire.java.nio.file.Path)6 ArrayList (java.util.ArrayList)5 LibraryValueModuleRootPathIndexTerm (org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm)5 ValueSharedPartIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm)5 PageResponse (org.uberfire.paging.PageResponse)5 Map (java.util.Map)4 Term (org.apache.lucene.index.Term)4 List (java.util.List)3 Set (java.util.Set)3 BooleanQuery (org.apache.lucene.search.BooleanQuery)3 Query (org.apache.lucene.search.Query)3 TermQuery (org.apache.lucene.search.TermQuery)3 Path (org.uberfire.backend.vfs.Path)3