public static void list(String unitId) {

    Http.Header hd = new Http.Header();

    hd.name = "Access-Control-Allow-Origin";
    hd.values = new ArrayList<String>();
    hd.values.add("*");

    Http.Response.current().headers.put("Access-Control-Allow-Origin", hd);

    if (unitId == null) badRequest();

    Phone p = Phone.find("unitId = ?", unitId).first();

    if (p == null) badRequest();

    List<TripPattern> patterns = TripPattern.find("route.phone = ?", p).fetch();

    Gson gson =
        new GsonBuilder()
            .registerTypeAdapter(TripPattern.class, new TripPatternSerializer())
            .serializeSpecialFloatingPointValues()
            .serializeNulls()
            .create();

    renderJSON(gson.toJson(patterns));
  }
  public static void view(String unitId) {

    if (unitId == null) index(true);

    Phone p = Phone.find("unitId = ?", unitId).first();

    if (p == null) index(true);

    List<TripPattern> patterns = TripPattern.find("route.phone = ?", p).fetch();

    render(p, patterns);
  }
  public static void export(String unitId) throws InterruptedException {

    Phone p = Phone.find("unitId = ?", unitId).first();

    List<TripPattern> tripPatterns = TripPattern.find("route.phone = ?", p).fetch();

    ArrayList<Long> patternIds = new ArrayList<Long>();

    for (TripPattern pattern : tripPatterns) {
      patternIds.add(pattern.id);
    }

    ProcessGisExport gisExport = new ProcessGisExport(patternIds, unitId.toString());
    gisExport.doJob();
    ok();
  }