/** * Create task message. * * @param workerTask the worker task * @param taskId the task id * @return the task message * @throws CodecException the codec exception */ public TaskMessage create(final Object workerTask, TrackingInfo tracking, final String taskId) throws CodecException { Map<java.lang.String, byte[]> context = Collections.singletonMap(CONTEXT_KEY, CONTEXT_DATA); TaskMessage msg = new TaskMessage(taskId, workerName, apiVersion, codec.serialise(workerTask), TaskStatus.NEW_TASK, context, workerInputQueueName, tracking); return msg; } }
/** * Create a new task message to execute policies directly on a document, given a set of policy identifiers and collection sequence identifiers. * @param taskId * @param taskClassifier * @param documentToExecutePolicyOn * @param policyIDs * @param projectId * @param collectionSequenceIds * @param to * @param trackingInfo * @return * @throws CodecException */ public static TaskMessage getExecuteTaskMessage(String taskId, String taskClassifier, Document documentToExecutePolicyOn, Collection<Long> policyIDs, String projectId, List<String> collectionSequenceIds, final String to, final TrackingInfo trackingInfo) throws CodecException { TaskData taskData = TestTaskDataHelper.getExecuteTaskData(documentToExecutePolicyOn, policyIDs, projectId, collectionSequenceIds); return new TaskMessage(taskId, taskClassifier, TASK_API_VERSION, codec.serialise(taskData), TaskStatus.NEW_TASK, new HashMap<>(), to, trackingInfo); } }
/** * Create a new task message to classify a document, given a set of collectionSequences identifiers. * @param taskId * @param taskClassifier * @param document * @param collectionSequenceIds * @param executePolicy * @param projectId * @param datastoreRef * @param to * @param trackingInfo * @param taskStatus * @return * @throws CodecException */ public static TaskMessage getClassifyTaskMessage(final String taskId, final String taskClassifier, final Document document, final List<String> collectionSequenceIds, final Boolean executePolicy, final String projectId, final String datastoreRef, final String to, final TrackingInfo trackingInfo, final TaskStatus taskStatus) throws CodecException { TaskData taskData = TestTaskDataHelper.getClassifyTaskData(document, collectionSequenceIds, executePolicy, projectId, datastoreRef); return new TaskMessage(taskId, taskClassifier, TASK_API_VERSION, codec.serialise(taskData), taskStatus, new HashMap<>(), to, trackingInfo); }
/** * Create a new task message to classify a document, given a Workflow identifier. * @param taskId * @param taskClassifier * @param document * @param workflowId * @param executePolicy * @param projectId * @param datastoreRef * @param to * @param trackingInfo * @param taskStatus * @return * @throws CodecException */ public static TaskMessage getClassifyTaskMessage(final String taskId, final String taskClassifier, final Document document, final String workflowId, final Boolean executePolicy, final String projectId, final String datastoreRef, final String to, final TrackingInfo trackingInfo, final TaskStatus taskStatus ) throws CodecException { TaskData taskData = TestTaskDataHelper.getClassifyTaskData(document, workflowId, executePolicy, projectId,datastoreRef); return new TaskMessage(taskId, taskClassifier, TASK_API_VERSION, codec.serialise(taskData), taskStatus, new HashMap<>(), to, trackingInfo); }
final TaskMessage reportUpdateMessage = new TaskMessage( UUID.randomUUID().toString(), TrackingReportConstants.TRACKING_REPORT_TASK_NAME, TrackingReportConstants.TRACKING_REPORT_TASK_API_VER, reportUpdatesTaskData, TaskStatus.NEW_TASK,
private static TaskMessage buildTaskMessage(Document document, long workflowId, String projectId, String storageDirectory) throws CodecException { TaskData taskData = new TaskData(); taskData.setDocument(document); taskData.setOutputPartialReference(storageDirectory); taskData.setWorkflowId(String.valueOf(workflowId)); taskData.setExecutePolicyOnClassifiedDocuments(true); taskData.setProjectId(projectId); byte[] serializedTaskData = codec.serialise(taskData); TaskMessage taskMessage = new TaskMessage(); taskMessage.setTaskData(serializedTaskData); taskMessage.setContext(new HashMap<>()); taskMessage.setTaskId(String.valueOf(messageCount.addAndGet(1)) + "-" + document.getReference()); taskMessage.setTaskClassifier("PolicyWorker"); taskMessage.setTaskApiVersion(1); taskMessage.setTaskStatus(TaskStatus.NEW_TASK); taskMessage.setTo(destinationQueue); return taskMessage; } }
private TaskMessage createResponseMessage(final boolean includeTaskContext, final WorkerResponse response) { final Map<String, byte[]> responseContext = createFullResponseContext(includeTaskContext, response.getContext()); final String responseMessageType = response.getMessageType(); // Check if a tracking change is required. If empty string then no further changes required. final TrackingInfo trackingInfo; if ("".equals(response.getTrackTo())) { // No tracking changes required. trackingInfo = taskMessage.getTracking(); } else { // Set trackTo field to the specified value. trackingInfo = getTrackingInfoWithChanges(response.getTrackTo()); } final TaskMessage responseMessage = new TaskMessage( taskMessage.getTaskId(), responseMessageType, response.getApiVersion(), response.getData(), response.getTaskStatus(), responseContext, response.getQueueReference(), trackingInfo, new TaskSourceInfo(getWorkerName(responseMessageType), getWorkerVersion())); responseMessage.setPriority(priorityManager.getResponsePriority(taskMessage)); return responseMessage; }