Home | History | Annotate | Download | only in afe
      1 package autotest.afe;
      2 
      3 import autotest.common.table.DynamicTable;
      4 import autotest.common.table.RpcDataSource;
      5 import autotest.common.table.DataSource.SortDirection;
      6 
      7 import com.google.gwt.json.client.JSONObject;
      8 import com.google.gwt.json.client.JSONString;
      9 
     10 /**
     11  * A table to display scheduled runs.
     12  */
     13 public class RecurringTable extends DynamicTable {
     14     public static final String START_DATE_TEXT = "start_date";
     15 
     16     private static final String[][] RECURRING_COLUMNS = {
     17                             {CLICKABLE_WIDGET_COLUMN, "Select"},
     18                             { "job_id", "Job ID" },
     19                             { "owner", "Owner" },
     20                             { START_DATE_TEXT, "Recurring start" },
     21                             { "loop_period", "Loop period" },
     22                             { "loop_count", "Loop count" }};
     23 
     24     public RecurringTable() {
     25         super(RECURRING_COLUMNS, new RpcDataSource("get_recurring",
     26                                                    "get_num_recurring"));
     27         sortOnColumn("id", SortDirection.DESCENDING);
     28     }
     29 
     30     @Override
     31     protected void preprocessRow(JSONObject row) {
     32         JSONObject job = row.get("job").isObject();
     33         int jobId = (int) job.get("id").isNumber().doubleValue();
     34         JSONObject owner = row.get("owner").isObject();
     35         row.put("job_id", new JSONString(Integer.toString(jobId)));
     36         row.put("owner", owner.get("login"));
     37         // remove seconds from start_date
     38         AfeUtils.removeSecondsFromDateField(row, "start_date", START_DATE_TEXT);
     39 
     40     }
     41 }
     42