@Override public void process( QueryServiceHelperBean helperBean, SubmissionContainer container, Node itemNode, int itemOrdinal) throws Exception { helperBean.setContainer(container); helperBean.setItemOrdinal(itemOrdinal); helperBean.setItemNode(itemNode); helperBean.setItemData(getItemData(helperBean)); // helperBean.setResStatus(resolutionStatusDao.findByResolutionStatusId(1)); QueriesBean queries = null; try { ObjectMapper objectMapper = new ObjectMapper(); queries = objectMapper.readValue(itemNode.getTextContent(), QueriesBean.class); } catch (IOException e) { logger.error(e.getMessage()); throw e; } List<Integer> idList = new ArrayList(); List<QueryBean> qBeans = queries.getQueries(); QueryBean queryBean = null; DiscrepancyNote childDN = null; DiscrepancyNote parentDN = null; if (qBeans.size() == 1) { queryBean = qBeans.get(0); // this is the first entry , expected to build 2 records in DN table, one parent, the other // child parentDN = createQuery(helperBean, queryBean); parentDN = discrepancyNoteDao.saveOrUpdate(parentDN); childDN = createQuery(helperBean, queryBean); childDN.setParentDiscrepancyNote(parentDN); childDN = discrepancyNoteDao.saveOrUpdate(childDN); parentDN.setUserAccount(childDN.getUserAccount()); parentDN = discrepancyNoteDao.saveOrUpdate(parentDN); helperBean.setDn(parentDN); saveQueryItemDatamap(helperBean); } else if (qBeans.size() > 1) { for (QueryBean qBean : qBeans) { idList.add(Integer.valueOf(qBean.getId())); } Collections.reverse(idList); queryBean = qBeans.get(0); // Enketo passes JSON "id" attribute for unsubmitted queries only // if (StringUtils.isEmpty(queryBean.getId())){ childDN = createQuery(helperBean, queryBean); childDN.setParentDiscrepancyNote(findQueryParent(helperBean)); childDN = discrepancyNoteDao.saveOrUpdate(childDN); parentDN = findQueryParent(helperBean); parentDN.setUserAccount(childDN.getUserAccount()); parentDN = discrepancyNoteDao.saveOrUpdate(parentDN); } helperBean.setDn(childDN); saveQueryItemDatamap(helperBean); handleEmailNotification(helperBean, queryBean); }
public String getQueryAttribute(QueryServiceHelperBean helperBean, Node itemNode) { helperBean.setItemNode(itemNode); helperBean.setParentElementName(QueryService.super.getQueryAttribute(helperBean, itemNode)); return helperBean.getParentElementName(); }