示例#1
0
  // inform researchers that have logged an interest with the encounter or marked individual
  public static void informInterestedIndividualParties(
      HttpServletRequest request, String shark, String message, String context) {
    Shepherd myShepherd = new Shepherd(context);
    myShepherd.beginDBTransaction();

    if (myShepherd.isMarkedIndividual(shark)) {
      MarkedIndividual sharkie = myShepherd.getMarkedIndividual(shark);
      if (sharkie.getInterestedResearchers() != null) {
        Vector notifyMe = sharkie.getInterestedResearchers();
        int size = notifyMe.size();
        String[] interested = new String[size];
        for (int i = 0; i < size; i++) {
          interested[i] = (String) notifyMe.get(i);
        }
        myShepherd.rollbackDBTransaction();
        myShepherd.closeDBTransaction();
        if (size > 0) {

          ThreadPoolExecutor es = MailThreadExecutorService.getExecutorService();

          Vector e_images = new Vector();
          String mailMe = interested[0];
          String email =
              getText("dataUpdate.txt")
                  .replaceAll(
                      "INSERTTEXT",
                      ("Tag "
                          + shark
                          + ": "
                          + message
                          + "\n\nLink to individual: http://"
                          + CommonConfiguration.getURLLocation(request)
                          + "/individuals.jsp?number="
                          + shark));
          email +=
              ("\n\nWant to stop tracking this set of this individual's data? Use this link.\n\nhttp://"
                  + CommonConfiguration.getURLLocation(request)
                  + "/dontTrack?shark="
                  + shark
                  + "&email=");

          es.execute(
              new NotificationMailer(
                  CommonConfiguration.getMailHost(context),
                  CommonConfiguration.getAutoEmailAddress(context),
                  mailMe,
                  ("Marked individual data update: " + shark),
                  (email + mailMe),
                  e_images,
                  context));
          for (int j = 1; j < size; j++) {
            mailMe = interested[j];
            es.execute(
                new NotificationMailer(
                    CommonConfiguration.getMailHost(context),
                    CommonConfiguration.getAutoEmailAddress(context),
                    mailMe,
                    ("Individual data update: " + shark),
                    (email + mailMe),
                    e_images,
                    context));
          }
        }
      } else {
        myShepherd.rollbackDBTransaction();
        myShepherd.closeDBTransaction();
      }
    } else {
      myShepherd.rollbackDBTransaction();
      myShepherd.closeDBTransaction();
    }
  }