use of com.enonic.xp.schema.content.ContentTypeNames in project xp by enonic.
the class ContentQueryNodeQueryTranslator method processContentTypesNames.
private static void processContentTypesNames(final ContentQuery contentQuery, final NodeQuery.Builder builder) {
final ContentTypeNames contentTypeNames = contentQuery.getContentTypes();
if (contentTypeNames != null && contentTypeNames.isNotEmpty()) {
final ValueFilter.Builder contentTypeFilterBuilder = ValueFilter.create().fieldName(ContentPropertyNames.TYPE).setCache(true);
for (final ContentTypeName contentTypeName : contentTypeNames) {
contentTypeFilterBuilder.addValue(ValueFactory.newString(contentTypeName.toString()));
}
builder.addQueryFilter(contentTypeFilterBuilder.build());
}
}
use of com.enonic.xp.schema.content.ContentTypeNames 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);
}
Aggregations