private GroupResult doQuery(final Date start, final Date end) { if (logger.isTraceEnabled()) { logger.trace("Doing query..."); } final NodeQuery and = and(); final NodeQuery query; if (start == null) { query = and != null ? and : NodeQueries.matchAll(); } else { final NodeQuery range = NodeQueries.range(Schema.DATE, start, end, true, true); query = and != null ? NodeQueries.all(range, and) : range; } if (logger.isTraceEnabled()) { logger.trace("Query ", query.toString()); } final List<String> fields = fields(); if (logger.isTraceEnabled()) { logger.trace("Fields ", fields.toString()); } final GroupResult result = this.contentRepository.getRepository().groupBy(query, null, fields); if (logger.isTraceEnabled() && result != null) { logger.trace("Recover {} results", result.getTotalHits()); } return result; }
@Transactional(rollbackFor = Throwable.class) /** Return repository summary */ public NodeRepositoryDTO getSummary(String repositoryId) throws PMSException { if (logger.isTraceEnabled()) { logger.trace("Getting summary for repository service with id {}", repositoryId); } final NodeRepositoryDTO dto = new NodeRepositoryDTO(); final NodeRepository repository = getExternalService(repositoryId); final GroupResult result = repository.groupBy(NodeQueries.matchAll(), null, Lists.newArrayList(Schema.TYPE)); final Group root = result.getGroup(); final ContentTypesObject types = loadContentTypes(); dto.setNodeCount(result.getTotalHits()); final List<ContentTypeCountDTO> contentTypes = Lists.newArrayListWithCapacity(root.getGroupNames().size()); for (String name : root.getGroupNames()) { final Group g = root.getGroup(name); final ContentTypeCountDTO count = new ContentTypeCountDTO(); count.setContentType(getContentType(types, name)); count.setCount(g.getHits()); contentTypes.add(count); } dto.setContentTypes(contentTypes); return dto; }
public void edit() { try { final NodeQuery q; final String contentType = config.contentType(); final NodeQuery qct = contentType == null ? null : NodeQueries.term(Schema.TYPE, contentType); final String id = config.contentId(); final NodeQuery qid = id == null ? null : NodeQueries.term(Schema.ID, id); if (qid != null && qct != null) { q = NodeQueries.bool().must(qct).must(qid); } else if (qid != null) { q = qid; } else if (qct != null) { q = qct; } else { q = NodeQueries.matchAll(); } final Item<Node> item = repository.getFirst(q, null, null, false, null); node = item != null ? item.getItem() : null; } catch (Exception e) { exception = e; } } }
final NodeRepository repository = getExternalService(repositoryId); final NodeQuery query = (filter == null || (filter.getQuery() == null && filter.getContentTypeId() == null)) ? NodeQueries .matchAll() : filteredQuery(filter); final Page<Node> nodes = repository.getPage(query, null, null, false, 0, 100, null);