예제 #1
0
  // при параметре nID_Subject != null
  private SubjectContact syncMail(String sMail, Long nID_Subject) {

    Subject subject = subjectDao.getSubject(nID_Subject);
    SubjectHuman subjectHuman = null;
    try {
      subjectHuman = subjectHumanDao.findByExpected("oSubject", subject);
    } catch (Exception e) {
      LOG.error(e.getMessage(), e);
    }

    List<SubjectContact> subjectContacts = subjectContactDao.findContacts(subject);

    SubjectContact res = null;

    for (SubjectContact subjectContact : subjectContacts) {
      SubjectContactType sct = subjectContact.getSubjectContactType();
      if (sct.getsName_EN().equals("Email")) {
        if (subjectContact.getsValue().equals(sMail)) {
          res = subjectContact;
          res.setSubject(subject);
          res.setsDate();
          subjectContactDao.saveOrUpdate(res);
          break;
        }
      }
    }

    if (res == null) {
      res = new SubjectContact();
      SubjectContactType subjectContactType = subjectContactTypeDao.getEmailType();
      res.setSubject(subject);
      res.setSubjectContactType(subjectContactType);
      res.setsValue(sMail);
      res.setsDate();
      subjectContactDao.saveOrUpdate(res);
      if (subjectHuman != null) {
        subjectHuman.setDefaultEmail(res);
        // subjectHuman.setSubjectHumanIdType(SubjectHumanIdType.Email);
        subjectHumanDao.saveOrUpdateHuman(subjectHuman);
      }
    }

    return res;
  }
예제 #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;
  }