@POST @Path("tasks") @Produces(MediaType.APPLICATION_JSON) public BaseDTO tasks(@HeaderParam("sessionId") String sessionId) throws Exception { logger.info("start"); PimDevice pimDevice = pimDeviceManager.findUniqueBy("sessionId", sessionId); if (pimDevice == null) { BaseDTO result = new BaseDTO(); result.setCode(401); result.setMessage("auth fail"); return result; } String userId = pimDevice.getUserId(); String tenantId = "1"; Page page = humanTaskConnector.findPersonalTasks(userId, tenantId, 1, 10); List<HumanTaskDTO> humanTaskDtos = (List<HumanTaskDTO>) page.getResult(); List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); for (HumanTaskDTO humanTaskDto : humanTaskDtos) { Map<String, Object> map = new HashMap<String, Object>(); map.put("id", humanTaskDto.getId()); map.put("name", humanTaskDto.getName()); map.put("presentationSubject", humanTaskDto.getPresentationSubject()); map.put("createTime", dateFormat.format(humanTaskDto.getCreateTime())); map.put("assignee", humanTaskDto.getAssignee()); map.put("assigneeDisplayName", userConnector.findById(userId).getDisplayName()); list.add(map); } String json = jsonMapper.toJson(list); BaseDTO result = new BaseDTO(); result.setCode(200); result.setData(json); logger.info("end"); return result; }
public String getJsonData() throws Exception { Map<String, Object> map = new HashMap<String, Object>(); for (Map.Entry<String, XformField> entry : fieldMap.entrySet()) { XformField xformField = entry.getValue(); if (xformField.getName() == null) { continue; } if ("fileupload".equals(xformField.getType())) { if (xformField.getValue() == null) { continue; } Map<String, Object> data = new HashMap<String, Object>(); data.put("key", xformField.getValue()); data.put("label", xformField.getLabel()); map.put(xformField.getName(), data); } else { map.put(xformField.getName(), xformField.getValue()); } } return jsonMapper.toJson(map); }