Package org.saiku.olap.dto.resultset

Examples of org.saiku.olap.dto.resultset.CellDataSet


      @PathParam("queryname") String queryName,
      @PathParam("format") String format,
      @FormParam("svg") @DefaultValue("") String svg) {

    try {
      CellDataSet cs = thinQueryService.getFormattedResult(queryName, format);
      QueryResult qr = RestUtil.convert(cs);
      PdfReport pdf = new PdfReport();
      byte[] doc = pdf.pdf(qr, svg);
      return Response.ok(doc).type("application/pdf").header(
          "content-disposition",
View Full Code Here


      @QueryParam("css") @DefaultValue("false") Boolean css,
      @QueryParam("tableonly") @DefaultValue("false") Boolean tableonly,
      @QueryParam("wrapcontent") @DefaultValue("true") Boolean wrapcontent) {

    try {
      CellDataSet cs = null;
      if (StringUtils.isNotBlank(format)) {
        cs = thinQueryService.execute(tq, format);
      } else {
        cs = thinQueryService.execute(tq);
      }
View Full Code Here

  }

  public static byte[] exportExcel(CellSet cellSet,
                                   @NotNull ICellSetFormatter formatter,
                                   List<ThinHierarchy> filters) {
    CellDataSet table = OlapResultSetUtil.cellSet2Matrix(cellSet, formatter);
    ExcelBuilderOptions exb = new ExcelBuilderOptions();
    exb.repeatValues = formatter instanceof FlattenedCellSetFormatter;
    return getExcel(table, filters, exb);
  }
View Full Code Here

  }

  @NotNull
  public static byte[] exportCsv(CellSet cellSet, String delimiter, String enclosing,
                                 @NotNull ICellSetFormatter formatter) {
    CellDataSet table = OlapResultSetUtil.cellSet2Matrix(cellSet, formatter);
    return getCsv(table, delimiter, enclosing);
  }
View Full Code Here

      if (query.getScenario() != null) {
        LOG.info("Query (" + queryName + ") removing scenario:" + query.getScenario().getId());
        con.setScenario(null);
      }

      CellDataSet result = OlapResultSetUtil.cellSet2Matrix(cellSet, formatter);
      Long format = new Date().getTime();

      result.setRuntime(new Double(format - start).intValue());
      getIQuery(queryName).storeCellset(cellSet);
      getIQuery(queryName).storeFormatter(formatter);
      // we could do a check if query.getTotalFunctions() actually includes a total function and if not
      // dont execute the following
      if (QueryType.QM.equals(query.getType()) && formatter instanceof FlattenedCellSetFormatter) {
        QueryDimension queryDimension = query.getDimension("Measures");
        Measure[] selectedMeasures = new Measure[queryDimension.getInclusions().size()];
        for (int i = 0; i < selectedMeasures.length; i++) {
          selectedMeasures[i] = (Measure) queryDimension.getInclusions().get(i).getRootElement();
        }
        result.setSelectedMeasures(selectedMeasures);

        int rowsIndex = 0;
        if (!cellSet.getAxes().get(0).getAxisOrdinal().equals(Axis.ROWS)) {
          rowsIndex = rowsIndex + 1 & 1;
        }
        // TODO - refactor this using axis ordinals etc.
        //@formatter:off
        final AxisInfo[] axisInfos = new AxisInfo[] { new AxisInfo(cellSet.getAxes().get(rowsIndex)),
          new AxisInfo(cellSet.getAxes().get(rowsIndex + 1 & 1)) };
        //@formatter:on
        List<TotalNode>[][] totals = new List[2][];
        TotalsListsBuilder builder = null;
        for (int index = 0; index < 2; index++) {
          final int second = index + 1 & 1;
          TotalAggregator[] aggregators = new TotalAggregator[axisInfos[second].maxDepth + 1];
          for (int i = 1; i < aggregators.length - 1; i++) {
            String totalFunctionName = query.getTotalFunction(axisInfos[second].uniqueLevelNames.get(i - 1));
            aggregators[i] = TotalAggregator.newInstanceByFunctionName(totalFunctionName);
          }
          String totalFunctionName = query.getTotalFunction(axisInfos[second].axis.getAxisOrdinal().name());
          aggregators[0] =
              totalFunctionName != null ? TotalAggregator.newInstanceByFunctionName(totalFunctionName) : null;
          builder = new TotalsListsBuilder(selectedMeasures, aggregators, cellSet, axisInfos[index], axisInfos[second]);
          totals[index] = builder.buildTotalsLists();
        }
        result.setLeftOffset(axisInfos[0].maxDepth);
        result.setRowTotalsLists(totals[1]);
        result.setColTotalsLists(totals[0]);
      }
      Long totals = new Date().getTime();
      LOG.info(runId + "\tSize: " + result.getWidth() + "/" + result.getHeight() + "\tExecute:\t" + (exec - start)
               + "ms\tFormat:\t" + (format - exec) + "ms\tTotals:\t" + (totals - format) + "ms\t Total: " + (totals
                                                                                                             - start)
               + "ms");

      return result;
View Full Code Here

      CellSet cs = query.getCellset();
      if (cs == null) {
        throw new SaikuServiceException("Cannot get filter of result if last cellset is null");
      }

      CellDataSet result = OlapResultSetUtil.cellSet2Matrix(cs, query.getFormatter());

      List<SimpleCubeElement> members = new ArrayList<SimpleCubeElement>();
      Set<MetadataElement> mset = new HashSet<MetadataElement>();

      Cube cube = query.getCube();
      Hierarchy h = cube.getHierarchies().get(hierarchyName);
      if (h == null) {
        throw new Exception("Cannot find hierarchy in cube " + cube.getName() + " with name " + hierarchyName);
      }
      Dimension d = h.getDimension();
      Level l = h.getLevels().get(levelName);
      if (l == null) {
        throw new Exception("Cannot find level in hierarchy " + h.getName() + " with name " + levelName);
      }
      SimpleCubeElement hierarchy = new SimpleCubeElement(h.getName(), h.getUniqueName(), h.getCaption());
      SimpleCubeElement dimension = new SimpleCubeElement(d.getName(), d.getUniqueName(), d.getCaption());

      Long start = new Date().getTime();

      // try headers first
      AbstractBaseCell[][] headers = result.getCellSetHeaders();
      if (headers != null && headers.length > 0 && headers[0].length > 0) {
        for (AbstractBaseCell[] header : headers) {
          for (int k = 0; k < headers[0].length; k++) {
            if (header[k] == null) {
              continue;
            }
            MemberCell mc = (MemberCell) header[k];
            if (mc.getUniqueName() != null) {
              if (mc.getHierarchy().equals(hierarchy.getUniqueName()) && mc.getLevel().equals(l.getUniqueName())) {
                String mu = mc.getUniqueName();
                List<IdentifierSegment> memberList = IdentifierNode.parseIdentifier(mu).getSegmentList();
                Member m = cube.lookupMember(memberList);
                mset.add(m);
              }
            }
          }
        }
      }
      Long header = new Date().getTime();

      if (mset.size() == 0) {
        // try body next
        AbstractBaseCell[][] body = result.getCellSetBody();
        if (body != null && body.length > 0 && body[0].length > 0) {
          for (AbstractBaseCell[] aBody : body) {
            for (int k = 0; k < body[0].length; k++) {
              if (aBody[k] == null) {
                continue;
View Full Code Here

      @PathParam("format") String format,
      @FormParam("svg") @DefaultValue("") String svg) {

    try {
      PdfReport pdf = new PdfReport();
      CellDataSet cs = null;
      if (StringUtils.isNotBlank(format)) {
        cs = olapQueryService.execute(queryName, format);
      } else {
        cs = olapQueryService.execute(queryName);
      }
View Full Code Here

    if (LOG.isDebugEnabled()) {
      LOG.debug("TRACK\t" + "\t/query/" + queryName + "/result\tGET");
    }
    try {

      CellDataSet cs = olapQueryService.execute(queryName);
      return RestUtil.convert(cs, limit);
    } catch (Exception e) {
      LOG.error("Cannot execute query (" + queryName + ")", e);
      String error = ExceptionUtils.getRootCauseMessage(e);
      return new QueryResult(error);
View Full Code Here

        QueryResult rsc = RestUtil.convert(rs);
        Long runtime = (new Date()).getTime() - start;
        rsc.setRuntime(runtime.intValue());
        return rsc;
      }
      CellDataSet cs = olapQueryService.executeMdx(queryName, mdx, icf);
      return RestUtil.convert(cs, limit);
    } catch (Exception e) {
      LOG.error("Cannot execute query (" + queryName + ") using mdx:\n" + mdx, e);
      String error = ExceptionUtils.getRootCauseMessage(e);
      return new QueryResult(error);
View Full Code Here

      @QueryParam("limit") @DefaultValue("0") int limit) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("TRACK\t" + "\t/query/" + queryName + "/result" + formatter + "\tGET");
    }
    try {
      CellDataSet cs = olapQueryService.execute(queryName, formatter);
      return RestUtil.convert(cs, limit);
    } catch (Exception e) {
      LOG.error("Cannot execute query (" + queryName + ")", e);
      String error = ExceptionUtils.getRootCauseMessage(e);
      return new QueryResult(error);
View Full Code Here

TOP

Related Classes of org.saiku.olap.dto.resultset.CellDataSet

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.