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());
}
}
}
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;
}
Aggregations