Search in sources :

Example 1 with LibraryValueModuleRootPathIndexTerm

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

the class LibraryServiceImpl method getNumberOfAssets.

@Override
public int getNumberOfAssets(final WorkspaceProject module) {
    final HashSet<ValueIndexTerm> queryTerms = new HashSet<>();
    queryTerms.add(new LibraryValueModuleRootPathIndexTerm((module.getRootPath().toURI())));
    return refactoringQueryService.queryHitCount(new RefactoringPageRequest(FindAllLibraryAssetsQuery.NAME, queryTerms, 0, null, Boolean.TRUE));
}
Also used : RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) LibraryValueModuleRootPathIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm) HashSet(java.util.HashSet)

Example 2 with LibraryValueModuleRootPathIndexTerm

use of org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm 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 3 with LibraryValueModuleRootPathIndexTerm

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

the class FindAllLibraryAssetsQueryTest method listAllInModule.

@Test
public void listAllInModule() throws IOException, InterruptedException {
    // Add test files
    addTestFile(TEST_MODULE_ROOT, "drl1.drl");
    addTestFile(TEST_MODULE_ROOT, "drl2.ext2");
    addTestFile(SOME_OTHER_MODULE_ROOT, "drl3.ext3");
    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));
            }
        }, 0, 10);
        try {
            final PageResponse<RefactoringPageRow> response = service.query(request);
            assertNotNull(response);
            for (RefactoringPageRow refactoringPageRow : response.getPageRowList()) {
                System.out.println(refactoringPageRow.getValue());
            }
            assertEquals(3, response.getPageRowList().size());
        } catch (IllegalArgumentException e) {
            fail("Exception thrown: " + e.getMessage());
        }
    }
}
Also used : RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) 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 4 with LibraryValueModuleRootPathIndexTerm

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

the class FindAllLibraryAssetsSortedQueryTest method listAllInProjectSortedPaged.

@Test
public void listAllInProjectSortedPaged() throws IOException, InterruptedException {
    setUp(TEST_PROJECT_ROOT2);
    final RefactoringPageRequest request1 = new RefactoringPageRequest(FindAllLibraryAssetsQuery.NAME, new HashSet<ValueIndexTerm>() {

        {
            add(new LibraryValueModuleRootPathIndexTerm(TEST_PROJECT_ROOT2, TermSearchType.WILDCARD));
        }
    }, 0, 4);
    final PageResponse<RefactoringPageRow> response1 = service.query(request1);
    assertNotNull(response1);
    // Remove duplicates and sort file names alphabetically
    Set<String> resultSet1 = new TreeSet<>();
    for (RefactoringPageRow row : response1.getPageRowList()) {
        String fileName = ((Path) row.getValue()).getFileName();
        System.out.println(fileName);
        resultSet1.add(fileName);
    }
    String[] expectedResult1 = new String[] { "DRL4.drl", "drl1.drl", "drl2.ext2", "drl3.ext3" };
    assertArrayEquals(expectedResult1, resultSet1.toArray());
    final RefactoringPageRequest request2 = new RefactoringPageRequest(FindAllLibraryAssetsQuery.NAME, new HashSet<ValueIndexTerm>() {

        {
            add(new LibraryValueModuleRootPathIndexTerm(TEST_PROJECT_ROOT2, TermSearchType.WILDCARD));
        }
    }, 4, 4);
    final PageResponse<RefactoringPageRow> response2 = service.query(request2);
    assertNotNull(response2);
    // Remove duplicates and sort file names alphabetically
    Set<String> resultSet2 = new TreeSet<>();
    for (RefactoringPageRow row : response2.getPageRowList()) {
        String fileName = ((Path) row.getValue()).getFileName();
        System.out.println(fileName);
        resultSet2.add(fileName);
    }
    String[] expectedResult2 = new String[] { "RULE4.rule", "functions.functions", "rule3.rule" };
    assertArrayEquals(expectedResult2, resultSet2.toArray());
}
Also used : Path(org.uberfire.backend.vfs.Path) RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) TreeSet(java.util.TreeSet) LibraryValueModuleRootPathIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) Test(org.junit.Test)

Example 5 with LibraryValueModuleRootPathIndexTerm

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

the class FindAllLibraryAssetsSortedQueryTest method listAllInProjectSorted.

@Test
public void listAllInProjectSorted() throws IOException, InterruptedException {
    setUp(TEST_PROJECT_ROOT1);
    final RefactoringPageRequest request = new RefactoringPageRequest(FindAllLibraryAssetsQuery.NAME, new HashSet<ValueIndexTerm>() {

        {
            add(new LibraryValueModuleRootPathIndexTerm(TEST_PROJECT_ROOT1, TermSearchType.WILDCARD));
        }
    }, 0, 10);
    final PageResponse<RefactoringPageRow> response = service.query(request);
    assertNotNull(response);
    // Remove duplicates and sort file names alphabetically
    Set<String> resultSet = new TreeSet<>();
    for (RefactoringPageRow row : response.getPageRowList()) {
        String fileName = ((Path) row.getValue()).getFileName();
        System.out.println(fileName);
        resultSet.add(fileName);
    }
    assertArrayEquals(FILE_NAMES, resultSet.toArray());
}
Also used : Path(org.uberfire.backend.vfs.Path) RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) TreeSet(java.util.TreeSet) LibraryValueModuleRootPathIndexTerm(org.kie.workbench.common.screens.library.api.index.LibraryValueModuleRootPathIndexTerm) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) Test(org.junit.Test)

Aggregations

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