Source:
<code>public List<Task> getCurrentPage() { Object[] parameters = getParameters(); if (parameters == null || parameters.length != 2) { throw new IllegalStateException("Invalid parameters: " + Arrays.toString(parameters)); } String actorId = (String) parameters[0]; String workflowInstanceId = (String) parameters[1]; CoreSession session = getCoreSession(); StringBuilder query = new StringBuilder( String.format("SELECT * FROM Document WHERE ecm:mixinType = '%s' AND ecm:currentLifeCycleState = '%s'", TaskConstants.TASK_FACET_NAME, TaskConstants.TASK_OPENED_LIFE_CYCLE_STATE)); if (StringUtils.isNotBlank(actorId)) { List<String> actors = new ArrayList<>(); UserManager userManager = Framework.getService(UserManager.class); NuxeoPrincipal principal = userManager.getPrincipal(actorId); if (principal != null) { for (String actor : TaskActorsHelper.getTaskActors(principal)) { actors.add(NXQL.escapeString(actor)); } } else { actors.add(NXQL.escapeString(actorId)); } String actorsParam = StringUtils.join(actors, ", "); query.append(String.format(" AND (nt:actors/* IN (%s) OR nt:delegatedActors/* IN (%s))", actorsParam, actorsParam)); } if (StringUtils.isNotBlank(workflowInstanceId)) { query.append(String.format(" AND nt:processId = %s", NXQL.escapeString(workflowInstanceId))); } query.append(String.format(" ORDER BY %s ASC", TaskConstants.TASK_DUE_DATE_PROPERTY_NAME)); PartialList<Map<String, Serializable>> results = session.queryProjection(query.toString(), getPageSize(), getCurrentPageOffset(), true); setResultsCount(results.totalSize()); <START> List<Task> tasks = results.stream() .map(map -> session.getDocument(new IdRef((String) map.get(ECM_UUID))) .getAdapter(Task.class)) .collect(toList()); return tasks; <END> }</code><technical_language>do returning tasks</technical_language>

Target:
public List<Task> getCurrentPage() { Object[] parameters = getParameters(); if (parameters == null || parameters.length != 2) { throw new IllegalStateException("Invalid parameters: " + Arrays.toString(parameters)); } String actorId = (String) parameters[0]; String workflowInstanceId = (String) parameters[1]; CoreSession session = getCoreSession(); StringBuilder query = new StringBuilder( String.format("SELECT * FROM Document WHERE ecm:mixinType = '%s' AND ecm:currentLifeCycleState = '%s'", TaskConstants.TASK_FACET_NAME, TaskConstants.TASK_OPENED_LIFE_CYCLE_STATE)); if (StringUtils.isNotBlank(actorId)) { List<String> actors = new ArrayList<>(); UserManager userManager = Framework.getService(UserManager.class); NuxeoPrincipal principal = userManager.getPrincipal(actorId); if (principal != null) { for (String actor : TaskActorsHelper.getTaskActors(principal)) { actors.add(NXQL.escapeString(actor)); } } else { actors.add(NXQL.escapeString(actorId)); } String actorsParam = String.join(", ", actors); query.append(String.format(" AND (nt:actors/* IN (%s) OR nt:delegatedActors/* IN (%s))", actorsParam, actorsParam)); } if (StringUtils.isNotBlank(workflowInstanceId)) { query.append(String.format(" AND nt:processId = %s", NXQL.escapeString(workflowInstanceId))); } query.append(String.format(" ORDER BY %s ASC", TaskConstants.TASK_DUE_DATE_PROPERTY_NAME)); PartialList<Map<String, Serializable>> results = session.queryProjection(query.toString(), getPageSize(), getCurrentPageOffset(), true); setResultsCount(results.totalSize()); return results.stream() .map(map -> session.getDocument(new IdRef((String) map.get(ECM_UUID)))) .map(doc -> doc.getAdapter(Task.class)) .collect(toList()); }