@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;
 }
  @GET
  @Path("view")
  public Response view(
      @QueryParam("model") String model,
      @QueryParam("name") String name,
      @QueryParam("type") String type) {

    final Response response = service.findView(model, name, type);
    final AbstractView view = (AbstractView) response.getData();

    final Map<String, Object> data = Maps.newHashMap();
    data.put("view", view);

    if (view instanceof Search && ((Search) view).getSearchForm() != null) {
      String searchForm = ((Search) view).getSearchForm();
      Response searchResponse = service.findView(null, searchForm, "form");
      data.put("searchForm", searchResponse.getData());
    }

    if (view instanceof AbstractView) {
      data.putAll(findFields(model, findNames((AbstractView) view)));
    }

    response.setData(data);
    response.setStatus(Response.STATUS_SUCCESS);

    return response;
  }
 @GET
 @Path("views/{model}")
 public Response views(@PathParam("model") String model) {
   final MultivaluedMap<String, String> params = getUriInfo().getQueryParameters(true);
   final Map<String, String> views = Maps.newHashMap();
   for (String mode : params.keySet()) {
     views.put(mode, params.getFirst(mode));
   }
   return service.findViews(findClass(model), views);
 }
  @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);
  }
 @POST
 @Path("custom/{name}")
 public Response dataset(@PathParam("name") String name, Request request) {
   return service.getDataSet(name, request);
 }
 @POST
 @Path("chart/{name}")
 public Response chart(@PathParam("name") String name, Request request) {
   return service.getChart(name, request);
 }