Search in sources :

Example 1 with LibraryValueFileExtensionIndexTerm

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

the class FileLoaderTest method testLibraryValueFileExtensionIndexTerm.

private void testLibraryValueFileExtensionIndexTerm(final Set<ValueIndexTerm> terms) {
    for (final ValueIndexTerm term : terms) {
        if (term instanceof LibraryValueFileExtensionIndexTerm) {
            final LibraryValueFileExtensionIndexTerm libraryValueFileExtensionIndexTerm = (LibraryValueFileExtensionIndexTerm) term;
            assertEquals(".*(txt)", libraryValueFileExtensionIndexTerm.getValue());
            return;
        }
    }
    fail("LibraryValueFileExtensionIndexTerm was not found");
}
Also used : ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) LibraryValueFileExtensionIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileExtensionIndexTerm)

Example 2 with LibraryValueFileExtensionIndexTerm

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

the class LibraryValueFileExtensionIndexTermTest method testZeroExtension.

@Test(expected = IllegalArgumentException.class)
public void testZeroExtension() {
    List<String> extensions = Collections.emptyList();
    LibraryValueFileExtensionIndexTerm term = new LibraryValueFileExtensionIndexTerm(extensions);
}
Also used : LibraryValueFileExtensionIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileExtensionIndexTerm) Test(org.junit.Test)

Example 3 with LibraryValueFileExtensionIndexTerm

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

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

Example 5 with LibraryValueFileExtensionIndexTerm

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

the class LibraryValueFileExtensionIndexTermTest method testOneExtension.

@Test
public void testOneExtension() {
    List<String> extensions = Arrays.asList("xml");
    LibraryValueFileExtensionIndexTerm term = new LibraryValueFileExtensionIndexTerm(extensions);
    assertEquals(".*(xml)", term.getValue());
}
Also used : LibraryValueFileExtensionIndexTerm(org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueFileExtensionIndexTerm) Test(org.junit.Test)

Aggregations

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