Search in sources :

Example 1 with LibraryValueFileNameIndexTerm

use of org.kie.workbench.common.services.refactoring.backend.server.query.standard.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(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 LibraryValueRepositoryRootIndexTerm(getRepositoryRootPath(), TermSearchType.NORMAL));
                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) LibraryValueRepositoryRootIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm) LibraryValueFileNameIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileNameIndexTerm) PageResponse(org.uberfire.paging.PageResponse) 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.services.refactoring.backend.server.query.standard.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 LibraryValueRepositoryRootIndexTerm(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) LibraryValueRepositoryRootIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm) LibraryValueFileNameIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileNameIndexTerm) LibraryValueFileExtensionIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileExtensionIndexTerm) HashSet(java.util.HashSet)

Aggregations

HashSet (java.util.HashSet)2 LibraryValueFileNameIndexTerm (org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileNameIndexTerm)2 LibraryValueRepositoryRootIndexTerm (org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm)2 Test (org.junit.Test)1 LibraryValueFileExtensionIndexTerm (org.kie.workbench.common.services.refactoring.backend.server.query.standard.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