private void updateParentQuery(QueryServiceHelperBean helperBean) {
    if (helperBean.getDn().getParentDiscrepancyNote() == null) return;

    DiscrepancyNote itemParentNote =
        discrepancyNoteDao.findByDiscrepancyNoteId(
            helperBean.getDn().getParentDiscrepancyNote().getDiscrepancyNoteId());
    itemParentNote.setResolutionStatus(helperBean.getResStatus());
    discrepancyNoteDao.saveOrUpdate(itemParentNote);
  }
  @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);
  }
 private DiscrepancyNote findQueryParent(QueryServiceHelperBean helperBean) {
   DiscrepancyNote parentDiscrepancyNote =
       discrepancyNoteDao.findParentQueryByItemData(helperBean.getItemData().getItemDataId());
   return parentDiscrepancyNote;
 }