Example #1
0
  public SubjectMessage createSubjectMessage(
      String sHead,
      String sBody,
      Long nID_subject,
      String sMail,
      String sContacts,
      String sData,
      Long nID_subjectMessageType) {
    SubjectContact subjectContact = null;
    Subject subject = new Subject();

    if (sMail != null && !sMail.isEmpty()) {
      if (nID_subject != null) subjectContact = syncMail(sMail, nID_subject);
      if (nID_subject == null) subjectContact = syncMail(sMail, subject);
    }

    SubjectMessage message = new SubjectMessage();
    message.setHead(sHead);
    message.setBody(sBody == null ? "" : sBody);
    message.setId_subject(
        (nID_subject == null) ? ((subject.getId() == null) ? 0 : subject.getId()) : nID_subject);
    message.setoMail((subjectContact == null) ? null : subjectContact);
    // message.setMail((sMail == null) ? "" : sMail);
    message.setContacts((sContacts == null) ? "" : sContacts);
    message.setData((sData == null) ? "" : sData);
    message.setDate(new DateTime());
    if (nID_subjectMessageType != null) {
      SubjectMessageType subjectMessageType =
          subjectMessageTypeDao.findByIdExpected(nID_subjectMessageType);
      message.setSubjectMessageType(subjectMessageType);
    }
    return message;
  }
Example #2
0
  // при параметре nID_Subject == null
  private SubjectContact syncMail(String sMail, Subject oSubject) {
    SubjectContact res = null;
    SubjectHuman oSubjectHuman = subjectHumanDao.getSubjectHuman(SubjectHumanIdType.Email, sMail);

    Subject subject = (oSubjectHuman != null) ? oSubjectHuman.getoSubject() : null;
    if (subject != null) {
      oSubject.setId(subject.getId());
      oSubject.setsID(subject.getsID());
      oSubject.setsLabel(subject.getsLabel());
      oSubject.setsLabelShort(subject.getsLabelShort());

      res = subjectContactDao.findByExpected("sValue", sMail);
      if (res != null) {
        res.setSubject(subject);
        res.setsDate();

        subjectContactDao.saveOrUpdate(res);
      }
    }

    return res;
  }