private ItemData getItemData(QueryServiceHelperBean helperBean) {
   ItemData id =
       itemDataDao.findByEventCrfItemName(
           helperBean.getContainer().getEventCrf().getEventCrfId(),
           helperBean.getParentElementName(),
           helperBean.getItemOrdinal());
   return id;
 }
 private ItemData createBlankItemData(QueryServiceHelperBean helperBean) {
   Item item =
       itemDao.findByNameCrfId(
           helperBean.getParentElementName(),
           helperBean.getContainer().getCrfVersion().getCrf().getCrfId());
   ItemData itemData = new ItemData();
   itemData.setItem(item);
   itemData.setEventCrf(helperBean.getContainer().getEventCrf());
   itemData.setValue("");
   itemData.setDateCreated(new Date());
   itemData.setStatus(Status.AVAILABLE);
   // TODO this value should change once you have an ordinal attribute specified in the query
   itemData.setOrdinal(helperBean.getItemOrdinal());
   itemData.setUserAccount(helperBean.getUserAccount());
   itemData.setDeleted(false);
   itemDataDao.saveOrUpdate(itemData);
   return itemData;
 }
  private void prepareEmail(QueryServiceHelperBean helperBean) throws Exception {
    StringBuffer message = new StringBuffer();

    message.append(
        MessageFormat.format(
            respage.getString("mailDNHeader"),
            helperBean.getUserAccount().getFirstName(),
            helperBean.getUserAccount().getLastName()));
    message.append(
        "<A HREF='"
            + SQLInitServlet.getField("sysURL.base")
            + "ViewNotes?module=submit&listNotes_f_discrepancyNoteBean.user="******"&listNotes_f_entityName="
            + helperBean.getParentElementName()
            + "'>"
            + SQLInitServlet.getField("sysURL.base")
            + "</A><BR/>");
    message.append(respage.getString("you_received_this_from"));
    message.append(respage.getString("email_body_separator"));
    message.append(respage.getString("disc_note_info"));
    message.append(respage.getString("email_body_separator"));
    message.append(
        MessageFormat.format(
            respage.getString("mailDNParameters1"),
            helperBean.getDn().getDescription(),
            helperBean.getDn().getDetailedNotes(),
            helperBean.getUserAccount().getUserName()));
    message.append(respage.getString("email_body_separator"));
    message.append(respage.getString("entity_information"));
    message.append(respage.getString("email_body_separator"));
    message.append(
        MessageFormat.format(
            respage.getString("mailDNParameters2"),
            helperBean.getDn().getStudy().getName(),
            helperBean.getDn().getDescription()));

    if (!("studySub".equalsIgnoreCase(helperBean.getDn().getEntityType())
        || "subject".equalsIgnoreCase(helperBean.getDn().getEntityType()))) {
      message.append(
          MessageFormat.format(
              respage.getString("mailDNParameters3"),
              helperBean.getContainer().getStudyEvent().getStudyEventDefinition().getName()));
      if (!"studyEvent".equalsIgnoreCase(helperBean.getDn().getEntityType())) {
        message.append(
            MessageFormat.format(
                respage.getString("mailDNParameters4"),
                helperBean.getContainer().getCrfVersion().getCrf().getName()));
        if (!"eventCrf".equalsIgnoreCase(helperBean.getDn().getEntityType())) {
          message.append(
              MessageFormat.format(
                  respage.getString("mailDNParameters6"), helperBean.getParentElementName()));
        }
      }
    }

    message.append(respage.getString("email_body_separator"));
    message.append(
        MessageFormat.format(
            respage.getString("mailDNThanks"), helperBean.getDn().getStudy().getName()));
    message.append(respage.getString("email_body_separator"));
    message.append(respage.getString("disclaimer"));
    message.append(respage.getString("email_body_separator"));
    message.append(respage.getString("email_footer"));
    String subject =
        MessageFormat.format(
            respage.getString("mailDNSubject"),
            helperBean.getDn().getStudy().getName(),
            helperBean.getParentElementName());

    String emailBodyString = message.toString();
    try {
      sendEmail(helperBean.getUserAccount().getEmail().trim(), subject, emailBodyString, true);
    } catch (Exception e) {
      logger.error(e.getMessage());
      throw e;
    }
  }
 public String getQueryAttribute(QueryServiceHelperBean helperBean, Node itemNode) {
   helperBean.setItemNode(itemNode);
   helperBean.setParentElementName(QueryService.super.getQueryAttribute(helperBean, itemNode));
   return helperBean.getParentElementName();
 }