Example #1
0
  public void prepare() {
    int id = getSequence();
    ++id;
    ThreadResource tr = ThreadResource.getInstance();
    Random r = tr.getRandom();
    StringBuilder buffer = tr.getBuffer();
    fields[0] = RandomUtil.randomText(r, 15, 20); // title
    fields[1] = RandomUtil.randomText(r, 15, 50); // summary
    fields[2] = RandomUtil.randomText(r, 50, 495); // description
    fields[3] = UserName.getUserName(r.random(1, ScaleFactors.users)); // submitterUserName
    fields[4] = "e" + id + ".jpg"; // imageurl
    fields[5] = "e" + id + "t.jpg"; // imagethumburl
    fields[6] = "e" + id + "l.pdf"; // literatureurl
    fields[7] = RandomUtil.randomPhone(r, buffer); // phone
    DateFormat dateFormat = tr.getDateFormat(); // eventtimestamp
    String eventDate = dateFormat.format(r.makeDateInInterval(BASE_DATE, 0, 540));
    int eventHr = r.random(7, 21);
    String eventMin = EVT_MINUTES[r.random(0, 3)]; // eventtimestamp
    fields[8] = String.format("%s %02d:%s:00", eventDate, eventHr, eventMin);

    createdTimestamp =
        r.makeDateInInterval( // createdtimestamp
            BASE_DATE, -540, 0);
    ifields[0] = r.random(1, ScaleFactors.users); // addressId
    // The rest is initialized to 0 anyway, leave it that way.
  }
Example #2
0
 /**
  * The select method selects the operation to run next.
  *
  * @return The operation index selected to run next
  */
 public int select() {
   if (op == -1) { // first selection
     op = 0;
   } else { // Any subsequent selection
     double val = random.drandom(0, 1);
     int i;
     for (i = 0; i < selectMix.length; i++) {
       if (val <= selectMix[op][i]) {
         break;
       }
     }
     op = i;
   }
   return op;
 }