package com.google.sampling.experiential.server.stats.participation;

import org.joda.time.DateTime;


public class ResponseStat implements Comparable<ResponseStat> {
  
  public long experimentId;
  public String experimentGroupName;
  public String who;
  public int schedR;
  public int missedR;
  public int selfR;
  public DateTime date;
  
  
  public ResponseStat(long experimentId, String experimentGroupName, String who, int schedR, int missedR, int selfR) {
    super();
    this.experimentId = experimentId;
    this.experimentGroupName = experimentGroupName;
    this.who = who;
    this.schedR = schedR;
    this.missedR = missedR;
    this.selfR = selfR;
  }
  
  public ResponseStat(long experimentId, String experimentGroupName, String who, DateTime dateOfInterest, int schedR, int missedR, int selfR) {
    this(experimentId, experimentGroupName, who, schedR, missedR, selfR);
    this.date = dateOfInterest;  
  }

  /**
   * We want to order Response Stats by who and then by date, if those fields
   * are available. Otherwise we do not care.
   */
  @Override
  public int compareTo(ResponseStat o) {
    if (o == null) {
      return 1;
    } 
    if (who != null && o.who != null) {      
      int whoComparison = who.compareTo(o.who);
      if (whoComparison != 0) {
        return whoComparison;
      }
    }
    if (date != null && o.date != null) {
      return date.compareTo(o.date);
    }
    return 0;
  }
}

@@ -312,16 +312,115 @@
  selfR;%0A
+  %0A  // jackson 2 @JsonFormat(shape=JsonFormat.Shape.STRING, pattern=%22yyyy/MM/dd%22, timezone=%22UTC%22)%0A
   public
@@ -1530,11 +1530,127 @@
 n 0;%0A  %7D
+%0A%0A  public String getDate() %7B%0A    return date.toString(com.pacoapp.paco.shared.util.TimeUtil.dateFormatter);%0A  %7D%0A%0A  
 %0A%7D%0A

Add prettier date serialization