Search in sources :

Example 1 with LibraryValueFileNameIndexTerm

use of org.kie.workbench.common.screens.library.api.index.LibraryValueFileNameIndexTerm in project kie-wb-common by kiegroup.

the class FindAllLibraryAssetsQueryTest method filterFilesFromModule.

@Test
public void filterFilesFromModule() throws IOException, InterruptedException {
    // Add test files
    addTestFile(TEST_MODULE_ROOT, "rule1.rule");
    addTestFile(TEST_MODULE_ROOT, "rule2.rule");
    addTestFile(SOME_OTHER_MODULE_ROOT, "rule3.rule");
    addTestFile(TEST_MODULE_ROOT, "functions.functions");
    // wait for events to be consumed from jgit -> (notify changes -> watcher -> index) -> lucene index
    Thread.sleep(5000);
    {
        final RefactoringPageRequest request = new RefactoringPageRequest(FindAllLibraryAssetsQuery.NAME, new HashSet<ValueIndexTerm>() {

            {
                add(new LibraryValueModuleRootPathIndexTerm(TEST_MODULE_ROOT, TermSearchType.WILDCARD));
                add(new LibraryValueFileNameIndexTerm("*rule*", TermSearchType.WILDCARD));
            }
        }, 0, 10);
        try {
            final PageResponse<RefactoringPageRow> response = service.query(request);
            assertNotNull(response);
            for (RefactoringPageRow refactoringPageRow : response.getPageRowList()) {
                System.out.println(refactoringPageRow.getValue());
            }
            assertEquals(2, response.getPageRowList().size());
        } catch (IllegalArgumentException e) {
            fail("Exception thrown: " + e.getMessage());
        }
    }
}
Also used : RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) LibraryValueFileNameIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueFileNameIndexTerm) PageResponse(org.uberfire.paging.PageResponse) LibraryValueModuleRootPathIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with LibraryValueFileNameIndexTerm

use of org.kie.workbench.common.screens.library.api.index.LibraryValueFileNameIndexTerm in project kie-wb-common by kiegroup.

the class LibraryServiceImpl method buildProjectAssetsQuery.

private HashSet<ValueIndexTerm> buildProjectAssetsQuery(ProjectAssetsQuery query) {
    final HashSet<ValueIndexTerm> queryTerms = new HashSet<>();
    queryTerms.add(new LibraryValueModuleRootPathIndexTerm(query.getProject().getRootPath().toURI()));
    if (query.hasFilter()) {
        queryTerms.add(new LibraryValueFileNameIndexTerm("*" + query.getFilter() + "*", ValueIndexTerm.TermSearchType.WILDCARD));
    }
    if (query.hasExtension()) {
        queryTerms.add(new LibraryValueFileExtensionIndexTerm(query.getExtensions()));
    }
    return queryTerms;
}
Also used : ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) LibraryValueFileNameIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueFileNameIndexTerm) LibraryValueFileExtensionIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueFileExtensionIndexTerm) LibraryValueModuleRootPathIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 LibraryValueFileNameIndexTerm (org.kie.workbench.common.screens.library.api.index.LibraryValueFileNameIndexTerm)2 LibraryValueModuleRootPathIndexTerm (org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm)2 Test (org.junit.Test)1 LibraryValueFileExtensionIndexTerm (org.kie.workbench.common.screens.library.api.index.LibraryValueFileExtensionIndexTerm)1 ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)1 RefactoringPageRequest (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest)1 RefactoringPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)1 PageResponse (org.uberfire.paging.PageResponse)1