Search in sources :

Example 6 with LibraryValueRepositoryRootIndexTerm

use of org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm 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 LibraryValueRepositoryRootIndexTerm(getRepositoryRootPath(), TermSearchType.NORMAL));
        }
    }, 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("Observed: " + resultSet, 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) LibraryValueRepositoryRootIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) Test(org.junit.Test)

Example 7 with LibraryValueRepositoryRootIndexTerm

use of org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm 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)

Example 8 with LibraryValueRepositoryRootIndexTerm

use of org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm in project kie-wb-common by kiegroup.

the class FileLoader method loadPaths.

public List<Path> loadPaths(final Path path, final String suffix) {
    PortablePreconditions.checkNotNull("path", path);
    PortablePreconditions.checkNotNull("suffix", suffix);
    org.uberfire.java.nio.file.Path nioPath = Paths.convert(path);
    // Check Path exists
    final List<Path> items = new ArrayList<>();
    if (!Files.exists(nioPath)) {
        return items;
    }
    // Ensure Path represents a Folder
    if (!Files.isDirectory(nioPath)) {
        nioPath = nioPath.getParent();
    }
    final Set<ValueIndexTerm> queryTerms = new HashSet<>();
    final ArrayList<String> extensions = new ArrayList<>();
    extensions.add(suffix);
    queryTerms.add(new LibraryValueRepositoryRootIndexTerm(Paths.convert(nioPath).toURI(), ValueIndexTerm.TermSearchType.NORMAL));
    queryTerms.add(new LibraryValueFileExtensionIndexTerm(extensions));
    final List<RefactoringPageRow> rows = refactoringQueryService.query(FindAllLibraryAssetsQuery.NAME, queryTerms);
    for (RefactoringPageRow row : rows) {
        items.add((Path) row.getValue());
    }
    return items;
}
Also used : Path(org.uberfire.backend.vfs.Path) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) LibraryValueRepositoryRootIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm) ArrayList(java.util.ArrayList) LibraryValueFileExtensionIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileExtensionIndexTerm) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) HashSet(java.util.HashSet)

Aggregations

LibraryValueRepositoryRootIndexTerm (org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm)8 ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)6 HashSet (java.util.HashSet)5 RefactoringPageRequest (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest)5 RefactoringPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)5 Test (org.junit.Test)4 Path (org.uberfire.backend.vfs.Path)3 TreeSet (java.util.TreeSet)2 LibraryValueFileExtensionIndexTerm (org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileExtensionIndexTerm)2 LibraryValueFileNameIndexTerm (org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileNameIndexTerm)2 PageResponse (org.uberfire.paging.PageResponse)2 ArrayList (java.util.ArrayList)1