Package com.google.visualization.datasource

Examples of com.google.visualization.datasource.DataSourceRequest


        new ColumnDescription(MOONS_COLUMN, ValueType.NUMBER, "Number of Moons")
  };

  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    DataSourceRequest dsRequest = null;

    try {
      // Extract the request parameters.
      dsRequest = new DataSourceRequest(req);

      // NOTE: If you want to work in restricted mode, which means that only
      // requests from the same domain can access the data source, you should
      // uncomment the following call.
      //
      // DataSourceHelper.verifyAccessApproved(dsRequest);

      // Split the query.
      QueryPair query = DataSourceHelper.splitQuery(dsRequest.getQuery(), Capabilities.SELECT);

      // Generate the data table.
      DataTable data = generateMyDataTable(query.getDataSourceQuery(), req);

      // Apply the completion query to the data table.
      DataTable newData = DataSourceHelper.applyQuery(query.getCompletionQuery(), data,
          dsRequest.getUserLocale());

      DataSourceHelper.setServletResponse(newData, dsRequest, resp);
    } catch (RuntimeException rte) {
      log.error("A runtime exception has occured", rte);
      ResponseStatus status = new ResponseStatus(StatusType.ERROR, ReasonType.INTERNAL_ERROR,
View Full Code Here


 
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
      throws IOException {
    DataTable data = generateMyDataTable();
    DataSourceRequest dsRequest = null;

    try {
      // Extract the datasource request parameters.
      dsRequest = new DataSourceRequest(req);

      // NOTE: If you want to work in restricted mode, which means that only
      // requests from the same domain can access the data source, uncomment the following call.
      //
      // DataSourceHelper.verifyAccessApproved(dsRequest);

      // Apply the query to the data table.
      DataTable newData = DataSourceHelper.applyQuery(dsRequest.getQuery(), data,
          dsRequest.getUserLocale());

      // Set the response.
      DataSourceHelper.setServletResponse(newData, dsRequest, resp);
    } catch (RuntimeException rte) {
      log.error("A runtime exception has occured", rte);
View Full Code Here

        mockHttpServletResponse.setHeader(eq(csvheaderName), eq(csvheaderValue));
        expectLastCall();

        replay(mockHttpServletResponse);
        CsvRenderer r = new CsvRenderer();
        r.setHeaders(new DataSourceRequest(parameters), mockHttpServletResponse);
        verify(mockHttpServletResponse);
    }
View Full Code Here

    }

    public void testEmptyDataTableToCsv() throws DataSourceException {
        DataTable dataTable = new DataTable();
        CsvRenderer r = new CsvRenderer();
        DataSourceRequest request = new DataSourceRequest();
        assertEquals("", r.render(request, dataTable));
        assertEquals("", r.render(request, dataTable));
    }
View Full Code Here

        rows.add(row);

        testData.addRows(rows);

        CsvRenderer r = new CsvRenderer();
        DataSourceRequest request = new DataSourceRequest();
        assertEquals(
                "\"col0\",\"col1\",\"col2\"\n" +
                        "\"aaa\",222,false\n" +
                        "\"\",null,true\n" +
                        "\"bb@@b\",333,true\n" +
View Full Code Here

        testData.addRows(rows);

        testData.getRow(0).getCell(0).setCustomProperty("a", "b");

        CsvRenderer r = new CsvRenderer();
        DataSourceRequest request = new DataSourceRequest();
        assertEquals(
                "\"col0\",\"col1\"\n\"aaa\",2a2b2\n\"\",null\n",
                r.render(request, testData).toString());
        assertEquals(
                "\"col0\",\"col1\"\n\"aaa\",2a2b2\n\"\",null\n",
View Full Code Here

    public void testRenderError() throws DataSourceException {
        ResponseStatus responseStatus = new ResponseStatus(
                StatusType.ERROR, ReasonType.INVALID_REQUEST, "but why? why?");
        CsvRenderer r = new CsvRenderer();
        DataSourceRequest request = new DataSourceRequest();
        assertEquals(
                "\"Error: Invalid request. but why? why?\"",
                r.error(request, responseStatus));

        responseStatus = new ResponseStatus(
View Full Code Here

        String expected = "\"col0\",\"col1\",\"col2\",\"col3\",\"col4\",\"col5\"\n";
        expected += "\"aaa\",222,true,2009-02-01,2009-02-01 12:14:01,12:14:01\n";
        expected += "\"a,aa\",\"2,22\",\"true,\",2009-02-01,\"2009-02-01 12,14,01\",12:14:01\n";
        CsvRenderer r = new CsvRenderer();
        DataSourceRequest request = new DataSourceRequest();
        assertEquals(expected, r.render(request, testData));
    }
View Full Code Here

        mockHttpServletResponse.setContentType(eq(jsonContentType));
        expectLastCall();

        replay(mockHttpServletResponse);
        JsonRenderer r = new JsonRenderer();
        r.setHeaders(new DataSourceRequest(), mockHttpServletResponse);
        verify(mockHttpServletResponse);
    }
View Full Code Here

        testData.addRows(rows);
        testData.addWarning(new Warning(ReasonType.DATA_TRUNCATED, "Sorry, data truncated"));
        testData.addWarning(new Warning(ReasonType.NOT_SUPPORTED, "foobar"));

        JsonRenderer r = new JsonRenderer();
        DataSourceRequest request = new DataSourceRequest(new DataSourceParameters("reqId:7"));
        assertEquals(
                "{\"version\":\"0.6\","
                        + "\"reqId\":\"7\",\"status\":\"warning\","
                        + "\"warnings\":[{\"reason\":\"data_truncated\",\"message\":"
                        + "\"Retrieved data was truncated\",\"detailed_message\":"
View Full Code Here

TOP

Related Classes of com.google.visualization.datasource.DataSourceRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.