Package mondrian.olap

Examples of mondrian.olap.Query


      if (log.isDebugEnabled())
      {
        log.debug("MDX query: " + queryStr);
      }
     
      Query query = connection.parseQuery(queryStr);
      result = connection.execute(query);
     
      dataSource = new JRMondrianDataSource(dataset, result);
    }
View Full Code Here


  {
    this.result = result;

    JRMondrianFactory factory = new JRMondrianFactory();

    Query query = result.getQuery();
    Axis[] resultAxes = result.getAxes();
    axes = new JRMondrianAxis[resultAxes.length];
    for (int i = 0; i < resultAxes.length; i++)
    {
      AxisOrdinal ordinal = AxisOrdinal.StandardAxisOrdinal.forLogicalOrdinal(i);
      axes[i] = new JRMondrianAxis(resultAxes[i], query.getMdxHierarchiesOnAxis(ordinal), factory);
    }
  }
View Full Code Here

      }

      final MDXCompiler compiler = new MDXCompiler(parameters, locale);
      final String mdxQuery = compiler.translateAndLookup(rawMdxQuery, parameters);
      // Alternatively, JNDI is possible. Maybe even more ..
      final Query query = connection.parseQuery(mdxQuery);
      if (queryTimeoutValue > 0)
      {
        query.setQueryTimeoutMillis(queryTimeoutValue * 1000);
      }

      final Parameter[] parameterDefs = query.getParameters();
      for (int i = 0; i < parameterDefs.length; i++)
      {
        final Parameter def = parameterDefs[i];
        Object parameterValue = parameters.get(def.getName());
        final Object processedParamValue;
        final Type parameterType = def.getType();

        // Mondrian doesn't handle null MemberType/SetType parameters well (http://jira.pentaho.com/browse/MONDRIAN-745)
        // If parameterValue is null, give it the default value
        try
        {
          if (parameterValue == null && (parameterType instanceof MemberType || parameterType instanceof SetType))
          {
            parameterValue = def.getDefaultExp().toString();
          }
        }
        catch (Exception e)
        {
          // Ignore - this is a safety procedure anyway
        }

        if (parameterValue != null)
        {

          if (parameterType instanceof StringType)
          {
            if (!(parameterValue instanceof String))
            {
              throw new ReportDataFactoryException(parameterValue + " is incorrect for type " + parameterType);
            }
            processedParamValue = parameterValue;
          }
          else if (parameterType instanceof NumericType)
          {
            if (!(parameterValue instanceof Number))
            {
              throw new ReportDataFactoryException(parameterValue + " is incorrect for type " + parameterType);
            }
            processedParamValue = parameterValue;
          }
          else if (parameterType instanceof MemberType)
          {
            final MemberType memberType = (MemberType) parameterType;
            final Hierarchy hierarchy = memberType.getHierarchy();
            if (parameterValue instanceof String)
            {
              final Member member = findMember(query, hierarchy, query.getCube(), String.valueOf(parameterValue));
              if (member != null)
              {
                processedParamValue = new MemberExpr(member);
              }
              else
              {
                processedParamValue = null;
              }
            }
            else
            {
              if (!(parameterValue instanceof OlapElement))
              {
                throw new ReportDataFactoryException(parameterValue + " is incorrect for type " + parameterType);
              }
              else
              {
                processedParamValue = parameterValue;
              }
            }
          }
          else if (parameterType instanceof SetType)
          {
            final SetType setType = (SetType) parameterType;
            final Hierarchy hierarchy = setType.getHierarchy();
            if (parameterValue instanceof String)
            {
              final String rawString = (String) parameterValue;
              final String[] memberStr = rawString.replaceFirst("^ *\\{", "").replaceFirst("} *$", "").split(",");
              final List<Member> list = new ArrayList<Member>(memberStr.length);

              for (int j = 0; j < memberStr.length; j++)
              {
                final String str = memberStr[j];
                final Member member = findMember(query, hierarchy, query.getCube(), String.valueOf(str));
                if (member != null)
                {
                  list.add(member);
                }
              }
View Full Code Here

    catch (Exception e)
    {
      // It is non fatal if that fails. Invalid input has this effect.
    }

    final Query memberQuery = connection.parseQuery("SELECT " + hierarchy.getQualifiedName() // NON-NLS
        + ".AllMembers ON 0, {} ON 1 FROM " + cube.getQualifiedName()); // NON-NLS
    final Result result = connection.execute(memberQuery);
    try
    {
      final List<Position> positionList = result.getAxes()[0].getPositions();
View Full Code Here

                                final String parameter,
                                final boolean searchForNames)
  {
    Member memberById = null;
    Member memberByUniqueId = null;
    final Query queryDirect = connection.parseQuery("SELECT STRTOMEMBER(" + quote(parameter) + ") ON 0, {} ON 1 FROM " // NON-NLS
        + cube.getQualifiedName());
    final Result resultDirect = connection.execute(queryDirect);
    try
    {
      final List<Position> positionList = resultDirect.getAxes()[0].getPositions();
View Full Code Here

      final MDXCompiler compiler = new MDXCompiler(parameters, locale);
      final String mdxQuery = compiler.translateAndLookup(rawMdxQuery, parameters);
      parameter.addAll(compiler.getCollectedParameter());
      // Alternatively, JNDI is possible. Maybe even more ..
      final Query query = connection.parseQuery(mdxQuery);
      final Parameter[] queryParameters = query.getParameters();
      for (int i = 0; i < queryParameters.length; i++)
      {
        final Parameter queryParameter = queryParameters[i];
        parameter.add(queryParameter.getName());
      }
View Full Code Here

      }

      final MDXCompiler compiler = new MDXCompiler(parameters, getLocale());
      final String mdxQuery = compiler.translateAndLookup(rawMdxQuery, parameters);
      // Alternatively, JNDI is possible. Maybe even more ..
      final Query query = connection.parseQuery(mdxQuery);
      final Statement statement = query.getStatement();
      final int queryTimeoutValue = calculateQueryTimeOut(parameters);
      if (queryTimeoutValue > 0)
      {
        statement.setQueryTimeoutMillis(queryTimeoutValue * 1000);
      }
View Full Code Here

    catch (Exception e)
    {
      // It is non fatal if that fails. Invalid input has this effect.
    }

    final Query memberQuery = connection.parseQuery("SELECT " + hierarchy.getQualifiedName() // NON-NLS
        + ".AllMembers ON 0, {} ON 1 FROM " + cube.getQualifiedName()); // NON-NLS
    final Result result = connection.execute(memberQuery);
    try
    {
      final List<Position> positionList = result.getAxes()[0].getPositions();
View Full Code Here

                                final String parameter,
                                final boolean searchForNames)
  {
    Member memberById = null;
    Member memberByUniqueId = null;
    final Query queryDirect = connection.parseQuery("SELECT STRTOMEMBER(" + quote(parameter) + ") ON 0, {} ON 1 FROM " // NON-NLS
        + cube.getQualifiedName());
    final Result resultDirect = connection.execute(queryDirect);
    try
    {
      final List<Position> positionList = resultDirect.getAxes()[0].getPositions();
View Full Code Here

      final MDXCompiler compiler = new MDXCompiler(parameters, getLocale());
      final String computedQuery = computedQuery(queryName, parameters);
      final String mdxQuery = compiler.translateAndLookup(computedQuery, parameters);
      parameter.addAll(compiler.getCollectedParameter());
      // Alternatively, JNDI is possible. Maybe even more ..
      final Query query = connection.parseQuery(mdxQuery);
      final Parameter[] queryParameters = query.getParameters();
      for (int i = 0; i < queryParameters.length; i++)
      {
        final Parameter queryParameter = queryParameters[i];
        parameter.add(queryParameter.getName());
      }
View Full Code Here

TOP

Related Classes of mondrian.olap.Query

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.