Search in sources :

Example 6 with ResponseBuilder

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

the class ImpactAnalysisJavaFileTest method getQueries.

protected Set<NamedQuery> getQueries() {
    return new HashSet<NamedQuery>() {

        {
            add(new FindResourceReferencesQuery() {

                @Override
                public ResponseBuilder getResponseBuilder() {
                    return new DefaultResponseBuilder(ioService());
                }
            });
            add(new FindAllChangeImpactQuery() {

                @Override
                public ResponseBuilder getResponseBuilder() {
                    return new DefaultResponseBuilder(ioService());
                }
            });
        }
    };
}
Also used : FindAllChangeImpactQuery(org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindAllChangeImpactQuery) DefaultResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.DefaultResponseBuilder) ResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.ResponseBuilder) DefaultResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.DefaultResponseBuilder) FindResourceReferencesQuery(org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindResourceReferencesQuery) HashSet(java.util.HashSet)

Example 7 with ResponseBuilder

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

the class RefactoringQueryServiceImpl method query.

@Override
public PageResponse<RefactoringPageRow> query(final RefactoringPageRequest request) {
    PortablePreconditions.checkNotNull("request", request);
    final String queryName = PortablePreconditions.checkNotNull("queryName", request.getQueryName());
    final NamedQuery namedQuery = namedQueries.findNamedQuery(queryName);
    // Validate provided terms against those required for the named query
    namedQuery.validateTerms(request.getQueryTerms());
    final Query query = namedQuery.toQuery(request.getQueryTerms());
    final Sort sort = namedQuery.getSortOrder();
    final int pageSize = request.getPageSize();
    final int startIndex = request.getStartRowIndex();
    List<KObject> kObjects = search(query, sort, () -> (startIndex), // start index of docs to get
    (numHits) -> (numHits - startIndex > pageSize ? pageSize : numHits - startIndex), request.distinctResults());
    if (!kObjects.isEmpty()) {
        final ResponseBuilder responseBuilder = namedQuery.getResponseBuilder();
        return responseBuilder.buildResponse(pageSize, startIndex, new ArrayList<>(kObjects));
    } else {
        return emptyResponse;
    }
}
Also used : KObject(org.uberfire.ext.metadata.model.KObject) Query(org.apache.lucene.search.Query) FindAllChangeImpactQuery(org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindAllChangeImpactQuery) Sort(org.apache.lucene.search.Sort) ResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.ResponseBuilder)

Example 8 with ResponseBuilder

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

the class PackageDescrIndexVisitorIndexingTest method getQueries.

protected Set<NamedQuery> getQueries() {
    return new HashSet<NamedQuery>() {

        {
            add(new FindResourceReferencesQuery() {

                @Override
                public ResponseBuilder getResponseBuilder() {
                    return new DefaultResponseBuilder(ioService());
                }
            });
            add(new FindAllChangeImpactQuery() {

                @Override
                public ResponseBuilder getResponseBuilder() {
                    return new DefaultResponseBuilder(ioService());
                }
            });
        }
    };
}
Also used : FindAllChangeImpactQuery(org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindAllChangeImpactQuery) DefaultResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.DefaultResponseBuilder) ResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.ResponseBuilder) DefaultResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.DefaultResponseBuilder) FindResourceReferencesQuery(org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindResourceReferencesQuery) HashSet(java.util.HashSet)

Aggregations

ResponseBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.response.ResponseBuilder)8 FindAllChangeImpactQuery (org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindAllChangeImpactQuery)8 HashSet (java.util.HashSet)6 DefaultResponseBuilder (org.kie.workbench.common.services.refactoring.backend.server.query.response.DefaultResponseBuilder)6 FindResourceReferencesQuery (org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindResourceReferencesQuery)3 Query (org.apache.lucene.search.Query)2 Sort (org.apache.lucene.search.Sort)2 FindResourcesQuery (org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindResourcesQuery)2 KObject (org.uberfire.ext.metadata.model.KObject)2 FindFormDefinitionIdsQuery (org.kie.workbench.common.forms.editor.backend.indexing.query.FindFormDefinitionIdsQuery)1 FindResourcePartReferencesQuery (org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindResourcePartReferencesQuery)1 FindBpmnProcessIdsQuery (org.kie.workbench.common.stunner.bpmn.backend.query.FindBpmnProcessIdsQuery)1