@GET
  //	@Produces( "text/tab-separated-values" )
  @Path("{id}/export")
  public final Response export(
      @PathParam("id") long id,
      @Context HttpServletRequest httpRequest,
      @Context HttpServletResponse httpResponse) {
    try {
      final FormBean form = dbManager.selectFormBean(id);
      if (form == null) {
        return Response.status(Status.NOT_FOUND).build();
      }

      final List<CollectionBean> collections = dbManager.selectCollectionBeanList(id);
      if (collections.isEmpty()) {
        return Response.noContent().build();
      }

      form.setCollections(collections);
      final String date = String.format("%tF_%<tH-%<tM-%<tS", Calendar.getInstance().getTime());
      final String filename = String.format("collections_form%s_%s", id, date);
      final String contentDisposition = String.format("attachment; filename=\"%s.tsv\"", filename);
      httpResponse.addHeader("Content-Disposition", contentDisposition);
      httpResponse.addHeader("Cache-Control", "no-cache");

      final ServletOutputStream out = httpResponse.getOutputStream();
      final OutputStreamWriter writer = new OutputStreamWriter(out, Charset.forName("UTF-16LE"));
      Exporter.writeTsv(writer, form);
      return Response.ok().build();
    } catch (final Throwable e) {
      logger.error("Error exporting collections", e);
      return Response.serverError().build();
    }
  }
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  @Path("{id}/report")
  public final Response generateReport(
      @PathParam("id") long id, @Context HttpServletRequest httpRequest) {
    final FormBean form = dbManager.selectFormBean(id);
    if (form == null) {
      return Response.status(Status.NOT_FOUND).build();
    }

    final List<CollectionBean> collections = dbManager.selectCollectionBeanList(id);
    if (collections.isEmpty()) {
      return Response.noContent().build();
    }

    form.setCollections(collections);
    final Analyzer analyzer = new Analyzer(form);
    final Report report = analyzer.process();
    return Response.ok(report).build();
  }