@Override public List<DocumentModel> getWorkflowInputDocuments(CoreSession session, Task task) throws DocumentRouteException { DocumentRoutingService routing = Framework.getService(DocumentRoutingService.class); return routing.getWorkflowInputDocuments(session, task); }
@OperationMethod public DocumentModel run(DocumentModel taskDoc) { Task task = taskDoc.getAdapter(Task.class); if (task == null) { throw new NuxeoException("Input document is not a Task"); } List<DocumentModel> docs = routing.getWorkflowInputDocuments(session, task); if (docs.size() == 0) { throw new NuxeoException("Can not fetch the input documents in the related workflow instance"); } if (docs.size() > 1) { log.warn("Using as mapping source only the first document in the input documents in the workflow"); } mappingService.mapProperties(session, docs.get(0), taskDoc, mappingName); return taskDoc; } }