Search in sources :

Example 1 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 List<RefactoringPageRow> query(final String queryName, final Set<ValueIndexTerm> queryTerms) {
    PortablePreconditions.checkNotNull("queryName", queryName);
    PortablePreconditions.checkNotNull("queryTerms", queryTerms);
    final NamedQuery namedQuery = namedQueries.findNamedQuery(queryName);
    // Validate provided terms against those required for the named query
    namedQuery.validateTerms(queryTerms);
    final Query query = namedQuery.toQuery(queryTerms);
    final Sort sort = namedQuery.getSortOrder();
    final List<KObject> kObjects = search(query, sort, () -> (0), // start index of docs to get
    (numHits) -> (numHits), false);
    if (!kObjects.isEmpty()) {
        final ResponseBuilder responseBuilder = namedQuery.getResponseBuilder();
        return responseBuilder.buildResponse(kObjects);
    } else {
        return Collections.emptyList();
    }
}
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 2 with ResponseBuilder

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

the class AssetsUsageServiceImplTest method getQueries.

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

        {
            add(new FindResourcePartReferencesQuery() {

                @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) FindResourcePartReferencesQuery(org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindResourcePartReferencesQuery) ResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.ResponseBuilder) DefaultResponseBuilder(org.kie.workbench.common.services.refactoring.backend.server.query.response.DefaultResponseBuilder) HashSet(java.util.HashSet)

Example 3 with ResponseBuilder

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

the class FindResourceReferencesQueryValidIndexTermsTest 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 4 with ResponseBuilder

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

the class FormDefinitionIndexerTest method getQueries.

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

        {
            add(new FindResourcesQuery() {

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

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

                @Override
                public ResponseBuilder getResponseBuilder() {
                    return new FindFormDefinitionIdsQuery.FindFormDefinitionIdsResponseBuilder(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) FindResourcesQuery(org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindResourcesQuery) FindFormDefinitionIdsQuery(org.kie.workbench.common.forms.editor.backend.indexing.query.FindFormDefinitionIdsQuery) HashSet(java.util.HashSet)

Example 5 with ResponseBuilder

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

the class BpmnFileIndexerTest method getQueries.

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

        {
            add(new FindResourcesQuery() {

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

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

                @Override
                public ResponseBuilder getResponseBuilder() {
                    return new FindBpmnProcessIdsQuery.BpmnProcessIdsResponseBuilder(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) FindResourcesQuery(org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindResourcesQuery) HashSet(java.util.HashSet) FindBpmnProcessIdsQuery(org.kie.workbench.common.stunner.bpmn.backend.query.FindBpmnProcessIdsQuery)

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