Search in sources :

Example 11 with QueryExpr

use of com.enonic.xp.query.expr.QueryExpr in project xp by enonic.

the class FindUsersHandler method execute.

public PrincipalsResultMapper execute() {
    final ConstraintExpr constraintExpr = QueryParser.parseCostraintExpression(this.query == null ? "" : this.query);
    final List<OrderExpr> orderExpressions = QueryParser.parseOrderExpressions(this.sort == null ? "" : this.sort);
    final QueryExpr queryExpr = QueryExpr.from(constraintExpr, orderExpressions);
    final UserQuery userQuery = UserQuery.create().from(this.start).size(this.count).queryExpr(queryExpr).build();
    final UserQueryResult result = this.securityService.get().query(userQuery);
    return new PrincipalsResultMapper(result.getUsers(), result.getTotalSize(), this.includeProfile);
}
Also used : ConstraintExpr(com.enonic.xp.query.expr.ConstraintExpr) QueryExpr(com.enonic.xp.query.expr.QueryExpr) OrderExpr(com.enonic.xp.query.expr.OrderExpr) UserQuery(com.enonic.xp.security.UserQuery) UserQueryResult(com.enonic.xp.security.UserQueryResult)

Example 12 with QueryExpr

use of com.enonic.xp.query.expr.QueryExpr in project xp by enonic.

the class QueryContentHandler method doExecute.

@Override
protected Object doExecute() {
    final int start = valueOrDefault(this.start, 0);
    final int count = valueOrDefault(this.count, GetChildContentHandler.DEFAULT_COUNT);
    final ContentTypeNames contentTypeNames = getContentTypeNames();
    final QueryExpr queryExpr = QueryExpr.from(buildConstraintExpr(), buildOrderExpr());
    final Filters filters = JsonToFilterMapper.create(this.filters);
    final Set<AggregationQuery> aggregations = new QueryAggregationParams().getAggregations(this.aggregations);
    final HighlightQuery highlight = new QueryHighlightParams().getHighlightQuery(this.highlight);
    final ContentQuery.Builder queryBuilder = ContentQuery.create().from(start).size(count).aggregationQueries(aggregations).highlight(highlight).addContentTypeNames(contentTypeNames).queryExpr(queryExpr);
    for (final Filter filter : filters) {
        queryBuilder.queryFilter(filter);
    }
    final FindContentIdsByQueryResult queryResult = contentService.find(queryBuilder.build());
    return convert(queryResult);
}
Also used : AggregationQuery(com.enonic.xp.query.aggregation.AggregationQuery) FindContentIdsByQueryResult(com.enonic.xp.content.FindContentIdsByQueryResult) QueryExpr(com.enonic.xp.query.expr.QueryExpr) Filters(com.enonic.xp.query.filter.Filters) ContentQuery(com.enonic.xp.content.ContentQuery) Filter(com.enonic.xp.query.filter.Filter) ContentTypeNames(com.enonic.xp.schema.content.ContentTypeNames) HighlightQuery(com.enonic.xp.query.highlight.HighlightQuery)

Example 13 with QueryExpr

use of com.enonic.xp.query.expr.QueryExpr in project xp by enonic.

the class AbstractFindNodesQueryHandler method createNodeQuery.

NodeQuery createNodeQuery() {
    final int start = valueOrDefault(this.start, 0);
    final int count = valueOrDefault(this.count, 10);
    final QueryExpr queryExpr = QueryExpr.from(buildConstraintExpr(), buildOrderExpr());
    final Filters filters = JsonToFilterMapper.create(this.filters);
    final AggregationQueries aggregations = new QueryAggregationParams().getAggregations(this.aggregations);
    final SuggestionQueries suggestions = new QuerySuggestionParams().getSuggestions(this.suggestions);
    final HighlightQuery highlight = new QueryHighlightParams().getHighlightQuery(this.highlight);
    return NodeQuery.create().from(start).size(count).addAggregationQueries(aggregations).addSuggestionQueries(suggestions).highlight(highlight).query(queryExpr).addQueryFilters(filters).explain(this.explain).build();
}
Also used : SuggestionQueries(com.enonic.xp.query.suggester.SuggestionQueries) Filters(com.enonic.xp.query.filter.Filters) QueryExpr(com.enonic.xp.query.expr.QueryExpr) AggregationQueries(com.enonic.xp.query.aggregation.AggregationQueries) HighlightQuery(com.enonic.xp.query.highlight.HighlightQuery)

Aggregations

QueryExpr (com.enonic.xp.query.expr.QueryExpr)13 FindNodesByQueryResult (com.enonic.xp.node.FindNodesByQueryResult)4 CompareExpr (com.enonic.xp.query.expr.CompareExpr)4 Nodes (com.enonic.xp.node.Nodes)3 ConstraintExpr (com.enonic.xp.query.expr.ConstraintExpr)3 Node (com.enonic.xp.node.Node)2 NodeQuery (com.enonic.xp.node.NodeQuery)2 OrderExpr (com.enonic.xp.query.expr.OrderExpr)2 Filters (com.enonic.xp.query.filter.Filters)2 HighlightQuery (com.enonic.xp.query.highlight.HighlightQuery)2 Test (org.junit.jupiter.api.Test)2 ContentQuery (com.enonic.xp.content.ContentQuery)1 FindContentIdsByQueryResult (com.enonic.xp.content.FindContentIdsByQueryResult)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 Value (com.enonic.xp.data.Value)1 NodeIds (com.enonic.xp.node.NodeIds)1 AggregationQueries (com.enonic.xp.query.aggregation.AggregationQueries)1 AggregationQuery (com.enonic.xp.query.aggregation.AggregationQuery)1 DynamicConstraintExpr (com.enonic.xp.query.expr.DynamicConstraintExpr)1 FunctionExpr (com.enonic.xp.query.expr.FunctionExpr)1