Ejemplo n.º 1
0
  /** Create a properly-configured grid with default settings, on first load. */
  public void loadTupleTableConfig(Database db, MolgenisRequest request, TupleTable tupleTable)
      throws TableException, IOException {
    tupleTable.setDb(db);
    final JQGridConfiguration config =
        new JQGridConfiguration(getId(), "Name", tupleTableBuilder.getUrl(), "test", tupleTable);

    final String jqJsonConfig = new Gson().toJson(config);
    request.getResponse().getOutputStream().println(jqJsonConfig);
  }
Ejemplo n.º 2
0
  /**
   * Render a particular subset of data from a {@link TupleTable} to a particular {@link Renderer}.
   *
   * @param request The request encoding the particulars of the rendering to be done.
   * @param postData The selected page (only relevant for {@link JQGridRenderer} rendering)
   * @param totalPages The total number of pages (only relevant for {@link JQGridRenderer}
   *     rendering)
   * @param tupleTable The table from which to render the data.
   */
  private void renderData(
      MolgenisRequest request, JQGridPostData postData, int totalPages, final TupleTable tupleTable)
      throws TableException {
    tupleTable.setDb(request.getDatabase());

    String strViewType = request.getString("viewType");
    if (StringUtils.isEmpty(strViewType)) {
      strViewType = "JQ_GRID";
    }

    try {
      final ViewFactory viewFactory = new ViewFactoryImpl();
      final Renderers.Renderer view = viewFactory.createView(strViewType);
      view.export(request, request.getString("caption"), tupleTable, totalPages, postData.page);
    } catch (final Exception e) {
      throw new TableException(e);
    }
  }