Package org.saiku.olap.query2

Examples of org.saiku.olap.query2.Parameter


      }
      ObjectMapper mapper = new ObjectMapper();
      Map<String, List<String>> levels = mapper.readValue(returns, TypeFactory
          .mapType(Map.class, TypeFactory.fromClass(String.class),
              TypeFactory.collectionType(ArrayList.class, String.class)));
      ThinQuery q = thinQueryService.drillacross(queryName, cellPosition, levels);
      return q;

    } catch (Exception e) {
      LOG.error("Cannot execute query (" + queryName + ")", e);
      String error = ExceptionUtils.getRootCauseMessage(e);
View Full Code Here


      String queryName = UUID.randomUUID().toString();
      //fileContent = ServletUtil.replaceParameters(servletRequest, fileContent);
//queryResource.createQuery(queryName,  null,  null, null, fileContent, queryName, null);
//queryResource.execute(queryName, formatter, 0);
      Map<String, String> parameters = ServletUtil.getParameters(servletRequest);
      ThinQuery tq = query2Resource.createQuery(queryName, fileContent, null, null);
      if (parameters != null) {
        tq.getParameters().putAll(parameters);
      }
      query2Resource.execute(tq);
      return query2Resource.getQueryExcelExport(queryName, formatter);
    } catch (Exception e) {
      LOG.error("Error exporting XLS for file: " + file, e);
View Full Code Here

      //fileContent = ServletUtil.replaceParameters(servletRequest, fileContent);
      String queryName = UUID.randomUUID().toString();
//query2Resource.createQuery(null,  null,  null, null, fileContent, queryName, null);
//query2Resource.execute(queryName,formatter, 0);
      Map<String, String> parameters = ServletUtil.getParameters(servletRequest);
      ThinQuery tq = query2Resource.createQuery(queryName, fileContent, null, null);
      if (parameters != null) {
        tq.getParameters().putAll(parameters);
      }
      query2Resource.execute(tq);
      return query2Resource.getQueryCsvExport(queryName);
    } catch (Exception e) {
      LOG.error("Error exporting CSV for file: " + file, e);
View Full Code Here

      fileContent = ServletUtil.replaceParameters(servletRequest, fileContent);
      String queryName = UUID.randomUUID().toString();
//query2Resource.createQuery(null,  null,  null, null, fileContent, queryName, null);
//QueryResult qr = query2Resource.execute(queryName, formatter, 0);
      Map<String, String> parameters = ServletUtil.getParameters(servletRequest);
      ThinQuery tq = query2Resource.createQuery(queryName, fileContent, null, null);
      if (parameters != null) {
        tq.getParameters().putAll(parameters);
      }
      QueryResult qr = query2Resource.execute(tq);
      return Response.ok().entity(qr).build();
    } catch (Exception e) {
      LOG.error("Error exporting JSON for file: " + file, e);
View Full Code Here

  @Deprecated
  public ThinQuery createEmpty(String name, SaikuCube cube) {
    try {
      Cube cub = olapDiscoverService.getNativeCube(cube);
      Query query = new Query(name, cub);
      ThinQuery tq = Thin.convert(query, cube);
      return tq;

    } catch (Exception e) {
      LOG.error("Cannot create new query for cube :" + cube, e);
    }
View Full Code Here

  }

  @NotNull
  public CellDataSet getFormattedResult(String query, @NotNull String format) throws Exception {
    QueryContext qc = getContext(query);
    ThinQuery tq = qc.getOlapQuery();
    CellSet cs = qc.getOlapResult();
    String formatterName = StringUtils.isBlank(format) ? "" : format.toLowerCase();
    ICellSetFormatter cf = cff.forName(formatterName);
    CellDataSet result = OlapResultSetUtil.cellSet2Matrix(cs, cf);

    if (ThinQuery.Type.QUERYMODEL.equals(tq.getType()) && cf instanceof FlattenedCellSetFormatter && tq
        .hasAggregators()) {
      calculateTotals(tq, result, cs, cf);
    }
    return result;
  }
View Full Code Here

  @NotNull
  public ThinQuery updateQuery(@NotNull ThinQuery old) throws Exception {
    if (ThinQuery.Type.QUERYMODEL.equals(old.getType())) {
      Cube cub = olapDiscoverService.getNativeCube(old.getCube());
      Query q = Fat.convert(old, cub);
      ThinQuery tqAfter = Thin.convert(q, old.getCube());
      old.setQueryModel(tqAfter.getQueryModel());
      old.setMdx(tqAfter.getMdx());
    }
    if (context.containsKey(old.getName())) {
      QueryContext qc = context.get(old.getName());
      qc.store(ObjectKey.QUERY, old);
    }
View Full Code Here

  }

  byte[] getExport(String queryName, @NotNull String type, ICellSetFormatter formatter) {
    if (StringUtils.isNotBlank(type) && context.containsKey(queryName)) {
      CellSet rs = context.get(queryName).getOlapResult();
      ThinQuery tq = context.get(queryName).getOlapQuery();
      List<ThinHierarchy> filterHierarchies = null;
      if (ThinQuery.Type.QUERYMODEL.equals(tq.getType())) {
        filterHierarchies = tq.getQueryModel().getAxes().get(AxisLocation.FILTER).getHierarchies();
      }
      if (type.toLowerCase().equals("xls")) {
        return ExcelExporter.exportExcel(rs, formatter, filterHierarchies);
      }
      if (type.toLowerCase().equals("csv")) {
View Full Code Here

  public ResultSet drillthrough(String queryName, int maxrows, String returns) {
    OlapStatement stmt = null;
    try {

      ThinQuery query = context.get(queryName).getOlapQuery();
      final OlapConnection con = olapDiscoverService.getNativeConnection(query.getCube().getConnection());
      stmt = con.createStatement();
      String mdx = query.getMdx();
      if (maxrows > 0) {
        mdx = "DRILLTHROUGH MAXROWS " + maxrows + " " + mdx;
      } else {
        mdx = "DRILLTHROUGH " + mdx;
      }
View Full Code Here

  public ResultSet drillthrough(String queryName, @NotNull List<Integer> cellPosition, Integer maxrows,
                                String returns) {
    OlapStatement stmt = null;
    try {
      QueryContext queryContext = context.get(queryName);
      ThinQuery query = queryContext.getOlapQuery();
      CellSet cs = queryContext.getOlapResult();
      SaikuCube cube = query.getCube();
      final OlapConnection con = olapDiscoverService.getNativeConnection(cube.getConnection());
      stmt = con.createStatement();

      SelectNode sn = new DefaultMdxParserImpl().parseSelect(query.getMdx());
      String select = null;
      StringBuilder buf = new StringBuilder();
      if (sn.getWithList() != null && sn.getWithList().size() > 0) {
        buf.append("WITH \n");
        StringWriter sw = new StringWriter();
View Full Code Here

TOP

Related Classes of org.saiku.olap.query2.Parameter

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.