Search in sources :

Example 31 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow 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 32 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class RefactoringQueryServiceImpl method queryToList.

@Override
public List<RefactoringPageRow> queryToList(final QueryOperationRequest queryOpRequest) {
    final RefactoringPageRequest request = convertToRefactoringPageRequest(queryOpRequest);
    final List<RefactoringPageRow> response = query(request.getQueryName(), request.getQueryTerms());
    return response;
}
Also used : RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)

Example 33 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class RefactoringQueryServiceImpl method queryToPageResponse.

/* (non-Javadoc)
     * @see org.kie.workbench.common.services.refactoring.service.RefactoringQueryService#queryToPageResponse(org.kie.workbench.common.services.refactoring.service.impact.QueryOperationRequest)
     */
@Override
public PageResponse<RefactoringPageRow> queryToPageResponse(QueryOperationRequest queryOpRequest) {
    final RefactoringPageRequest request = convertToRefactoringPageRequest(queryOpRequest);
    final PageResponse<RefactoringPageRow> response = query(request);
    return response;
}
Also used : RefactoringPageRequest(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)

Example 34 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class PackageServiceLoaderImpl method find.

public Set<String> find(final Path path) {
    final Set<String> result = new HashSet<>();
    try {
        final WorkspaceProject workspaceProject = projectService.resolveProject(path);
        final List<RefactoringPageRow> rows = refactoringQueryService.query(FindPackageNamesQuery.NAME, getValueIndexTerms(workspaceProject));
        for (RefactoringPageRow row : rows) {
            result.add(row.getValue().toString());
        }
    } catch (Exception e) {
        return result;
    }
    return result;
}
Also used : WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) HashSet(java.util.HashSet)

Example 35 with RefactoringPageRow

use of org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow in project kie-wb-common by kiegroup.

the class ScoreCardServiceLoaderImpl method find.

public Set<String> find(final Path path, final String packageName) {
    final Set<String> result = new HashSet<>();
    try {
        final WorkspaceProject workspaceProject = projectService.resolveProject(path);
        final List<RefactoringPageRow> rows = refactoringQueryService.query(FindScorecardNamesQuery.NAME, new HashSet<ValueIndexTerm>() {

            {
                add(new ValueSharedPartIndexTerm("*", PartType.SCORECARD_MODEL_NAME, ValueIndexTerm.TermSearchType.WILDCARD));
                add(new ValueModuleRootPathIndexTerm(workspaceProject.getMainModule().getRootPath().toURI()));
                add(new ValuePackageNameIndexTerm(packageName));
            }
        });
        for (RefactoringPageRow row : rows) {
            result.add(row.getValue().toString());
        }
    } finally {
        return result;
    }
}
Also used : ValueSharedPartIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueSharedPartIndexTerm) ValueIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm) WorkspaceProject(org.guvnor.common.services.project.model.WorkspaceProject) ValueModuleRootPathIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueModuleRootPathIndexTerm) ValuePackageNameIndexTerm(org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValuePackageNameIndexTerm) RefactoringPageRow(org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow) HashSet(java.util.HashSet)

Aggregations

RefactoringPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRow)40 Test (org.junit.Test)20 ArrayList (java.util.ArrayList)19 Path (org.uberfire.backend.vfs.Path)16 HashSet (java.util.HashSet)13 RefactoringPageRequest (org.kie.workbench.common.services.refactoring.model.query.RefactoringPageRequest)12 ValueIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueIndexTerm)11 PageResponse (org.uberfire.paging.PageResponse)10 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)8 Path (org.uberfire.java.nio.file.Path)7 Map (java.util.Map)6 LibraryValueRepositoryRootIndexTerm (org.kie.workbench.common.services.refactoring.backend.server.query.standard.LibraryValueRepositoryRootIndexTerm)6 ValueResourceIndexTerm (org.kie.workbench.common.services.refactoring.model.index.terms.valueterms.ValueResourceIndexTerm)5 Set (java.util.Set)4 Branch (org.guvnor.structure.repositories.Branch)4 ProjectAssetsQuery (org.kie.workbench.common.screens.library.api.ProjectAssetsQuery)4 BaseIndexingTest (org.kie.workbench.common.services.refactoring.backend.server.BaseIndexingTest)4 RefactoringMapPageRow (org.kie.workbench.common.services.refactoring.model.query.RefactoringMapPageRow)4 KObject (org.uberfire.ext.metadata.model.KObject)4 List (java.util.List)3