@Override public void run() { PartialList<Map<String, Serializable>> workflows = session.queryProjection(WORKFLOWS_QUERY, limit, 0); numberOfCleanedUpWorkflows = workflows.size(); for (Map<String, Serializable> workflow : workflows) { String routeDocId = workflow.get(ECM_UUID).toString(); final String associatedTaskQuery = String.format(TASKS_QUERY, routeDocId); session.queryProjection(associatedTaskQuery, 0, 0) .stream() .map(task -> new IdRef(task.get(ECM_UUID).toString())) .forEach(session::removeDocument); session.removeDocument(new IdRef(routeDocId)); } }
protected void writeRepliesSummary(CoreSession session, Comment entity, JsonGenerator jg) throws IOException { PartialList<Comment> comments = commentManager.getComments(session, entity.getId(), 1L, 0L, false); jg.writeNumberField(COMMENT_NUMBER_OF_REPLIES, comments.totalSize()); if (comments.size() > 0) { jg.writeStringField(COMMENT_LAST_REPLY_DATE, comments.get(0).getCreationDate().toString()); } } }
protected boolean hasContent(DocumentModel document, String query) throws IOException { try (SessionWrapper wrapper = ctx.getSession(document)) { // Limit result set to 1 as we just want to know if there's at least one child return wrapper.getSession() .queryProjection(String.format(query, NXQL.escapeString(document.getId())), 1, 0) .size() > 0; } }
DocumentModelListImpl dms = new DocumentModelListImpl(pl.size()); dms.setTotalSize(pl.totalSize()); for (Document doc : pl) {