예제 #1
0
  /**
   * Renders the report for a given query to html
   *
   * @param sessionId
   * @param report
   * @param acceptedPage
   * @param template
   * @return
   * @throws Exception
   * @throws IOException
   * @throws ResourceException
   */
  public void renderReportHtml(
      String sessionId, String templateName, HtmlReport report, Integer acceptedPage)
      throws Exception {

    SaikuMasterModel model = sessionHolder.getModel(sessionId);

    if (model == null) {
      throw new SaikuAdhocException(
          Messages.getErrorString("ReportGeneratorService.ERROR_0001_MASTERMODEL_NOT_FOUND"));
    }

    sessionHolder.materializeModel(sessionId);
    String path = prptManager.getTemplatePath();
    String solution = prptManager.getSolution();

    if (templateName != null && !templateName.equals("default")) {
      ReportTemplate template = prptManager.getTemplate(path, solution, templateName);
      model.setReportTemplate(template);
    }

    MasterReport output = processReport(model);

    ByteArrayOutputStream stream = new ByteArrayOutputStream();

    generateHtmlReport(
        output, stream, ParamUtils.getReportParameters("", model), report, acceptedPage);

    String string = stream.toString();

    //		if(log.isDebugEnabled()){
    //			writeHtmlFile(string);
    //		}

    report.setData(string);
  }
예제 #2
0
  /**
   * Renders the report for a given query to pdf
   *
   * @param sessionId
   * @param report
   * @param acceptedPage
   * @param template
   * @return
   * @throws Exception
   * @throws IOException
   */
  public void renderReportPdf(String sessionId, OutputStream stream) throws Exception {

    // html
    SaikuMasterModel model = sessionHolder.getModel(sessionId);

    sessionHolder.materializeModel(sessionId);

    MasterReport output = processReport(model);

    generatePdfReport(output, stream, ParamUtils.getReportParameters("", model));
  }
예제 #3
0
  protected ReportParameterValues getReportParameterValues(SaikuMasterModel model) {

    ReportParameterValues vals = new ReportParameterValues();

    Map<String, Object> reportParameters = ParamUtils.getReportParameters("", model);

    if (null != model) {
      Collection<String> keyset = reportParameters.keySet();
      for (Iterator<String> iterator = keyset.iterator(); iterator.hasNext(); ) {
        String key = (String) iterator.next();
        vals.put(key, reportParameters.get(key));
      }
    }
    return vals;
  }
예제 #4
0
  public void saveCda(String sessionId, String path, String file)
      throws OperationNotSupportedException, IOException, TransformerFactoryConfigurationError,
          TransformerException {

    SaikuMasterModel model = sessionHolder.getModel(sessionId);

    if (!file.endsWith(".cda")) {
      file += ".cda";
    }

    String[] splits = ParamUtils.splitFirst(path.substring(1), "/");

    cdaManager.addDatasource(splits[0], splits[1], file, model.getCdaSettings().asXML());
    //		repository.writeFile(splits[0], splits[1], file, model.getCdaSettings().asXML());

  }
예제 #5
0
  public void savePrpt(String sessionId, String path, String file)
      throws ReportException, BundleWriterException, ContentIOException, IOException,
          ReportProcessingException, SaikuAdhocException, ResourceException {

    SaikuMasterModel model = sessionHolder.getModel(sessionId);

    if (!file.endsWith(".prpt")) {
      file += ".prpt";
    }

    String[] splits = ParamUtils.splitFirst(path.substring(1), "/");

    ByteArrayOutputStream prptContent = null;
    ;
    MasterReport output = processReport(model);
    prptContent = generatePrptOutput(model, output);

    String solPath = splits.length > 1 ? splits[1] : "";

    repository.writeFile(splits[0], solPath, file, prptContent);
  }