Example #1
0
  /**
   * Loads up all candidate users for getting a retention email, does various bits of pruning and
   * sends emails to a random subset of qualifying users.
   */
  public void sendRetentionEmails() {
    log.info("Starting retention mailing");
    long now = System.currentTimeMillis();

    // find everyone who is lapsed, shuffled
    List<Integer> lapsedIds = findRetentionCandidates(new Date(now - LAPSED_CUTOFF));
    log.info("Found lapsed members", "size", lapsedIds.size());

    // load the filler, data from this is included in all mailings
    NewStuff filler = loadFiller();

    // do the sending and record results
    int totalSent = 0;
    Date secondEmailCutoff = new Date(now - SECOND_EMAIL_CUTOFF);
    CountHashMap<Status> stats = new CountHashMap<Status>();
    for (Integer memberId : lapsedIds) {
      Status result = sendRetentionEmail(memberId, secondEmailCutoff, filler);
      if (DeploymentConfig.devDeployment) {
        log.info("Retention email result (not sent)", "member", memberId, "result", result);
      }
      stats.incrementCount(result, 1);
      if (result.success && ++totalSent >= SEND_LIMIT) {
        break;
      }
    }

    // log results, we could use keys here but seeing e.g. OTHER = 0 might be comforting
    List<Object> statLog = Lists.newArrayList();
    for (Status r : Status.values()) {
      statLog.add(r);
      statLog.add(stats.getCount(r));
    }
    log.info("Finished retention mailing", statLog.toArray(new Object[statLog.size()]));
  }
Example #2
0
 public static Status fromValue(String v) {
   for (Status c : Status.values()) {
     if (c.value.equals(v)) {
       return c;
     }
   }
   throw new IllegalArgumentException(v.toString());
 }
Example #3
0
 public static String getEnumCode(String label) {
   for (Status c : Status.values()) {
     if (c.label.equals(label)) {
       return c.code;
     }
   }
   return null;
 }
Example #4
0
 public static Status getById(int id) {
   for (Status l : Status.values()) {
     if (l.getId() == id) {
       return l;
     }
   }
   return null;
 }
Example #5
0
File: Header.java Project: dbs/xoai
 public static Status fromRepresentation(String representation) {
   for (Status status : Status.values()) {
     if (status.representation.equals(representation)) {
       return status;
     }
   }
   throw new IllegalArgumentException(representation);
 }
Example #6
0
 public static String getEnumLabel(String code) {
   for (Status c : Status.values()) {
     if (c.code.equals(code)) {
       return c.label;
     }
   }
   return null;
 }
Example #7
0
 public static Status parse(int id) {
   Status status = null;
   for (Status item : Status.values()) {
     if (item.getId() == id) {
       status = item;
       break;
     }
   }
   return status;
 }
Example #8
0
 public static Status parse(String val) {
   Status status = null;
   for (Status item : Status.values()) {
     if (item.getValue() == val) {
       status = item;
       break;
     }
   }
   return status;
 }
Example #9
0
 protected BaseToonInfo(Parcel in) {
   this.id = in.readString();
   this.title = in.readString();
   this.image = in.readString();
   this.updateDate = in.readString();
   this.rate = in.readString();
   this.adult = in.readByte() != 0;
   this.loginNeed = in.readByte() != 0;
   int tmpStatus = in.readInt();
   this.status = tmpStatus == -1 ? null : Status.values()[tmpStatus];
 }
      public static Status getEnum(String stringValue) {
        if (null == stringValue) {
          return null;
        }

        for (Status status : Status.values()) {
          if (status.getStringValue().equals(stringValue)) {
            return status;
          }
        }
        return null;
      }
Example #11
0
  /**
   * Checks to see whether the provided status is one of the defined valid status(es).
   *
   * @param statusStr - Status String
   * @return true, if the provided status is valid. otherwise false.
   */
  private boolean isValidStatus(String statusStr) {
    boolean valid = false;
    Status[] validStatus = Status.values();

    for (Status status : validStatus) {
      if (status.name().toUpperCase().equals(statusStr.toUpperCase())) {
        valid = true;
        break;
      }
    }
    return valid;
  }
Example #12
0
  /**
   * Use this in place of valueOf.
   *
   * @param value real value
   * @return Status corresponding to the value
   */
  public static Status fromValue(String value) {
    if (value == null || "".equals(value)) {
      throw new IllegalArgumentException("Value cannot be null or empty!");
    }

    for (Status enumEntry : Status.values()) {
      if (enumEntry.toString().equals(value)) {
        return enumEntry;
      }
    }

    throw new IllegalArgumentException("Cannot create enum from " + value + " value!");
  }
 public Status getStatus() {
   int value = Integer.parseInt(input.substring("N02ANP".length()), 16);
   for (Status status : Status.values()) {
     if (status.value == value) return status;
   }
   Log.w(
       TAG,
       "UNKNOWN status assumed. Actual Monica status value not recognized: "
           + value
           + " input:"
           + input);
   return Status.UNKNOWN;
 }
Example #14
0
 public static Status get(Integer code) {
   for (Status status : Status.values()) {
     if (status.getCode().equals(code)) return status;
   }
   return null;
 }
Example #15
0
 public Status getStatus() {
   return Status.values()[getStatusNumber()];
 }
 public Status getStatus() {
   return Status.values()[status];
 }
Example #17
0
 static {
   // set up the static lookup table for result codes
   for (Status result : Status.values()) {
     _lookup.put(result.value, result);
   }
 }