@POST
  @Path("view")
  public Response view(Request request) {

    final Map<String, Object> data = request.getData();
    final String name = (String) data.get("name");
    final String type = (String) data.get("type");

    return view(request.getModel(), name, type);
  }
 @POST
 @Path("view/save")
 public Response save(Request request) {
   final Map<String, Object> data = request.getData();
   final ObjectMapper om = Beans.get(ObjectMapper.class);
   try {
     final String type = (String) data.get("type");
     final String json = om.writeValueAsString(data);
     AbstractView view = null;
     switch (type) {
       case "dashboard":
         view = om.readValue(json, Dashboard.class);
         break;
     }
     if (view != null) {
       return service.saveView(view, AuthUtils.getUser());
     }
   } catch (Exception e) {
   }
   return null;
 }
 @POST
 @Path("view/fields")
 public Response viewFields(Request request) {
   final Response response = new Response();
   response.setData(findFields(request.getModel(), request.getFields()));
   return response;
 }
  @GET
  @Path("chart/{name}")
  public Response chart(@PathParam("name") String name) {
    final MultivaluedMap<String, String> params = getUriInfo().getQueryParameters(true);
    final Map<String, Object> context = Maps.newHashMap();
    final Request request = new Request();

    for (String key : params.keySet()) {
      List<String> values = params.get(key);
      if (values.size() == 1) {
        context.put(key, values.get(0));
      } else {
        context.put(key, values);
      }
    }
    request.setData(context);

    return service.getChart(name, request);
  }