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 pattern(Long patternId) {

    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);

    TripPattern pattern = TripPattern.findById(patternId);

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

    renderJSON(gson.toJson(pattern));
  }