private void doOperatorTask() throws ClassNotFoundException, IOException { BlockingTaskSummaryResponseHandler handler = new BlockingTaskSummaryResponseHandler(); client.getTasksAssignedAsPotentialOwner("operator", "en-UK", handler); List<TaskSummary> sums = handler.getResults(); assertNotNull(sums); assertEquals(1, sums.size()); BlockingTaskOperationResponseHandler startTaskOperationHandler = new BlockingTaskOperationResponseHandler(); client.start(sums.get(0).getId(), "operator", startTaskOperationHandler); BlockingGetTaskResponseHandler getTaskHandler = new BlockingGetTaskResponseHandler(); client.getTask(sums.get(0).getId(), getTaskHandler); Task operatorTask = getTaskHandler.getTask(); BlockingGetContentResponseHandler getContentHandler = new BlockingGetContentResponseHandler(); client.getContent(operatorTask.getTaskData().getDocumentContentId(), getContentHandler); Content content = getContentHandler.getContent(); assertNotNull(content); ByteArrayInputStream bais = new ByteArrayInputStream(content.getContent()); ObjectInputStream ois = new ObjectInputStream(bais); Map<String, Object> deserializedContent = (Map<String, Object>) ois.readObject(); Call restoredCall = (Call) deserializedContent.get("call"); persistenceService.storeCall(restoredCall); Emergency emergency = new Emergency(); emergency.setCall(restoredCall); emergency.setLocation(new Location(1, 2)); emergency.setType(Emergency.EmergencyType.HEART_ATTACK); emergency.setNroOfPeople(1); persistenceService.storeEmergency(emergency); trackingService.attachEmergency(restoredCall.getId(), emergency.getId()); Map<String, Object> info = new HashMap<String, Object>(); info.put("emergency", emergency); ContentData result = new ContentData(); result.setAccessType(AccessType.Inline); result.setType("java.util.Map"); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(bos); out.writeObject(info); out.close(); result.setContent(bos.toByteArray()); BlockingTaskOperationResponseHandler completeTaskOperationHandler = new BlockingTaskOperationResponseHandler(); client.complete(sums.get(0).getId(), "operator", result, completeTaskOperationHandler); }
protected Map<String, Object> generateOutputForForm(String form, Map<String, String> data) { // TODO for now, only for phone call form Map<String, Object> info = new HashMap<String, Object>(); Emergency emergency = new Emergency(); Location location = new Location(); location.setLocationX(Integer.parseInt(data.get("Location X"))); location.setLocationY(Integer.parseInt(data.get("Location Y"))); emergency.setLocation(location); emergency.setNroOfPeople(Integer.valueOf(Integer.parseInt(data.get("Number Of People")))); emergency.setType(data.get("Emergency Type")); emergency.setCall(callsById.get(Integer.parseInt(data.get("callId")))); info.put("emergency", emergency); if (data.get("Number Of People").equals("1")) { Patient patient = new Patient(); patient.setAge(Integer.valueOf(data.get("Age"))); patient.setGender(data.get("Gender")); info.put("patient", patient); } return info; }