Package mondrian.olap

Examples of mondrian.olap.Connection


   *
   */
  private void fill(String connProps, String fileName) throws JRException
  {
    long start = System.currentTimeMillis();
    Connection conn = null;
    try
    {
      conn = getConnection(connProps);
      if (conn != null)
      {
        Map parameters = new HashMap();
        parameters.put(JRMondrianQueryExecuterFactory.PARAMETER_MONDRIAN_CONNECTION, conn);
       
        JasperFillManager.fillReportToFile(fileName, parameters);
        System.err.println("Report : " + fileName + ". Filling time : " + (System.currentTimeMillis() - start));
      }
    }
    catch (FileNotFoundException e)
    {
      throw new JRException(e);
    }
    catch (IOException e)
    {
      throw new JRException(e);
    }
    finally
    {
      if (conn != null)
      {
        conn.close();
      }
    }
  }
View Full Code Here


  {
    if (propertiesFileName == null) {
      throw new RuntimeException("connection properties file not set");
    }
    ConnectionData data = getConnectionData(propertiesFileName);
    Connection connection = null;
    if (data.isEnabled())
    {
      connection =
        DriverManager.getConnection(
          "Provider=mondrian;" +
View Full Code Here

  public void clearCache(final DataRow parameters,
                         final boolean onlyCurrentSchema) throws ReportDataFactoryException
  {
    try
    {
      final Connection connection =
          mondrianConnectionProvider.createConnection(computeProperties(parameters), dataSourceProvider.getDataSource());
      try
      {
        final CacheControl cacheControl = connection.getCacheControl(null);
        if (onlyCurrentSchema)
        {
          cacheControl.flushSchema(connection.getSchema());
        }
        else
        {
          cacheControl.flushSchemaCache();
        }
      }
      finally
      {
        connection.close();
      }
    }
    catch (SQLException e)
    {
      logger.error(e);
View Full Code Here

        }

        // Choose the appropriate scrollability. If we need to start from an
        // offset row, it is useful that the cursor is scrollable, but not
        // essential.
        final Connection connection = result.getQuery().getConnection();
        int resultSetType = ResultSet.TYPE_SCROLL_INSENSITIVE;
        int resultSetConcurrency = ResultSet.CONCUR_READ_ONLY;
        final Schema schema = connection.getSchema();
        Dialect dialect = ((RolapSchema) schema).getDialect();
        if (!dialect.supportsResultSetConcurrency(
            resultSetType, resultSetConcurrency)
            || firstRowOrdinal <= 1)
        {
            // downgrade to non-scroll cursor, since we can
            // fake absolute() via forward fetch
            resultSetType = ResultSet.TYPE_FORWARD_ONLY;
        }
        return
            RolapUtil.executeQuery(
                connection.getDataSource(),
                sql,
                maxRowCount,
                firstRowOrdinal,
                "RolapCell.drillThrough",
                "Error in drill through",
View Full Code Here

        DataSourcesConfig.DataSource ds = getDataSource(request);
        DataSourcesConfig.Catalog dsCatalog = getCatalog(request, ds, true);
        String roleName = request.getRoleName();
        Role role = request.getRole();

        final Connection connection = getConnection(dsCatalog, role, roleName);

        final String statement = request.getStatement();
        final QueryPart parseTree = connection.parseStatement(statement);
        final DrillThrough drillThrough = (DrillThrough) parseTree;
        final Query query = drillThrough.getQuery();
        query.setResultStyle(ResultStyle.LIST);
        final Result result = connection.execute(query);
        // cell [0, 0] in a 2-dimensional query, [0, 0, 0] in 3 dimensions, etc.
        final int[] coords = new int[result.getAxes().length];
        Cell dtCell = result.getCell(coords);

        if (!dtCell.canDrillThrough()) {
View Full Code Here

            DataSourcesConfig.DataSource ds = getDataSource(request);
            DataSourcesConfig.Catalog dsCatalog = getCatalog(request, ds, true);
            String roleName = request.getRoleName();
            Role role = request.getRole();

            final Connection connection =
                getConnection(dsCatalog, role, roleName);

            final Query query;
            try {
                query = connection.parseQuery(statement);
                query.setResultStyle(ResultStyle.LIST);
            } catch (XmlaException ex) {
                throw ex;
            } catch (Exception ex) {
                throw new XmlaException(
                    CLIENT_FAULT_FC,
                    HSB_PARSE_QUERY_CODE,
                    HSB_PARSE_QUERY_FAULT_FS,
                    ex);
            }
            final Result result;
            try {
                result = connection.execute(query);
            } catch (XmlaException ex) {
                throw ex;
            } catch (Exception ex) {
                throw new XmlaException(
                    SERVER_FAULT_FC,
View Full Code Here

    MDXConnection mdxConnection =
      (MDXConnection) PentahoConnectionFactory.getConnection( IPentahoConnection.MDX_DATASOURCE, properties, session,
        null );
    // mdxConnection.setProperties( properties );
    Connection connection = mdxConnection.getConnection();
    if ( connection == null ) {
      Logger
        .error(
          "MondrianModelComponent", Messages.getInstance()
          .getErrorString( "MondrianModel.ERROR_0001_INVALID_CONNECTION",
View Full Code Here

                new MondrianException(
                    "No such catalog: " + catalogName )
            );
          }

          Connection con =
              DriverManager.getConnection(
                  mc.getDataSourceInfo() + ";Catalog=" + mc.getDefinition(),
                  makeCatalogLocator( servletConfig ) );

          try {
            final MondrianServer server = MondrianServer.forConnection( con );

            FileRepository fr =
                new FileRepository(
                    makeContentFinder( makeDataSourcesUrl( servletConfig ) ),
                    makeCatalogLocator( servletConfig ) );

            return fr.getConnection(
                server, databaseName, catalogName, roleName, props );
          } finally {
            con.close();
          }
        }
      }
    };
  }
View Full Code Here

    // stores current analysis information on session
    session.setAttribute("analysisBean", analysis);
   
    // retrieves Mondrian connection
    ScriptableMondrianDrillThrough smdt = (ScriptableMondrianDrillThrough) olapModel.getExtension("drillThrough");
    Connection mondrianConnection = smdt.getConnection();
    // retrieves CacheControl object
    CacheControl cacheControl = mondrianConnection.getCacheControl(null);
    // retrieves the MDX query
    MdxQuery mdxQuery = (MdxQuery) olapModel.getExtension("mdxQuery");
    Query mondrianQuery = mondrianConnection.parseQuery(mdxQuery.getMdxQuery());
    // finds the cube in the MDX query
      Cube cube = mondrianQuery.getCube();
      // flush cache on all measures for that cube
      CacheControl.CellRegion measuresRegion = cacheControl.createMeasuresRegion(cube);
      cacheControl.flush(measuresRegion);
View Full Code Here

    if(dimensionRules.isEmpty()) {
      return;
    }
   
    ScriptableMondrianDrillThrough smdt = (ScriptableMondrianDrillThrough) olapModel.getExtension("drillThrough");
    Connection monConnection = smdt.getConnection();
    // get the connection role, cube and schema reader
    RoleImpl connRole = (RoleImpl) monConnection.getRole();
    //connRole.makeMutableClone();
      logger.debug("DataSecurityManager::setMondrianRole:connection role retrived: " + connRole);
      Query monQuery = monConnection.parseQuery(query);
      Cube cube = monQuery.getCube();
      logger.debug("DataSecurityManager::setMondrianRole: cube retrived: " + cube);
      SchemaReader schemaReader = cube.getSchemaReader(null);
      logger.debug("DataSecurityManager::setMondrianRole: schema reader retrived: " + schemaReader);
   
     
      // FOR EACH DIMENSION NAME SET THE RIGHT GRANT TO THE DIMENSION OR HIERARCHY
      logger.debug("DataSecurityManager::setMondrianRole: start setting grant for each dimension or hierachy");
      Iterator iterDimRules = dimensionRules.iterator();
      while(iterDimRules.hasNext()){
        DimensionRulesBean drb = (DimensionRulesBean)iterDimRules.next();
        String dimName = drb.getName();
        String dimAccess = drb.getAccess();
        String bottomLevel = drb.getBottomLevel();
        String topLevel = drb.getTopLevel();
        String rollupPolicy = drb.getRollupPolicy();
        logger.debug("DataSecurityManager::setMondrianRole: processing dimension named: " + dimName);
        //List dimMembs = drb.getMembers();
        logger.debug("DataSecurityManager::setMondrianRole: try to search the dimension into the cube");
      Dimension[] dimensions = cube.getDimensions();
       for (int i = 0; i < dimensions.length; i++) {
            Dimension dim = dimensions[i];
            String cubeDimKey = dim.getName();
            if(cubeDimKey.equalsIgnoreCase(dimName)) {
              logger.debug("DataSecurityManager::setMondrianRole: dimension found into the cube");
             mondrian.olap.Hierarchy[] hierarchies = dim.getHierarchies();
             if(hierarchies == null || hierarchies.length == 0) {
               if(dimAccess.equalsIgnoreCase("none")) {
                 connRole.grant(dim, Access.NONE);
                 logger.debug("DataSecurityManager::setMondrianRole: setted access.none to the dimension")
               } else {
                 connRole.grant(dim, Access.ALL);
                 logger.debug("DataSecurityManager::setMondrianRole: setted access.all to the dimension");
               }
               break;
             } else {
                for (int j = 0; j < hierarchies.length; j++) {
                  mondrian.olap.Hierarchy aHierarchy =  hierarchies[j];
                  if (aHierarchy.getName().equalsIgnoreCase(dimName)) {
                    Level[] levels = aHierarchy.getLevels();
                    Level topLev = null;
                    Level bottomLev = null;
                    for(int k=0; k<levels.length; k++) {
                      Level level = levels[k];
                      if(level.getUniqueName().equals(topLevel)) {
                        topLev = level;
                      }
                      if(level.getUniqueName().equals(bottomLevel)) {
                        bottomLev = level;
                      }
                    }
                    Role.RollupPolicy rp = null;
                    if (rollupPolicy == null) {
                      rp = Role.RollupPolicy.FULL;
                    } else {
                      try {
                        rp = Role.RollupPolicy.valueOf(rollupPolicy);
                      } catch (Exception e) {
                        logger.error("Error evaluating rollup policy: " + rollupPolicy, e);
                        logger.warn("Using default policy Role.RollupPolicy.FULL");
                        rp = Role.RollupPolicy.FULL;
                      }
                    }
                    logger.debug("DataSecurityManager::setMondrianRole: hierarchy found into the cube");
                    connRole.grant(aHierarchy, Access.CUSTOM, topLev, bottomLev, rp);
                    logger.debug("DataSecurityManager::setMondrianRole: setted access.custom to the hierarchy");
                   }
                }
             }
           }
        }
         logger.debug("DataSecurityManager::setMondrianRole: end search dimension into the cube");
      }
      logger.debug("DataSecurityManager::setMondrianRole: end setting grant for each dimension or hierachy");
     
     
      // FOR EACH MEMBER SET THE GRANT
      logger.debug("DataSecurityManager::setMondrianRole: start setting grant for members of dimensions");
      iterDimRules = dimensionRules.iterator();
      while(iterDimRules.hasNext()){
        DimensionRulesBean drb = (DimensionRulesBean)iterDimRules.next();
        String dimName = drb.getName();
        logger.debug("DataSecurityManager::setMondrianRole: processing dimension named: " + dimName);
        List dimMembs = drb.getMembers();
        logger.debug("DataSecurityManager::setMondrianRole: start processing dimension named: " + dimName);
        Iterator iterDimMembs = dimMembs.iterator();
          while(iterDimMembs.hasNext()) {
            MemberRulesBean mrb = (MemberRulesBean)iterDimMembs.next();
            String dimMemb = mrb.getName();
            String membAccess = mrb.getAccess();
            logger.debug("DataSecurityManager::setMondrianRole: processing member : " + dimMemb);
            List<Id.Segment> membParts = Util.parseIdentifier(dimMemb);
            mondrian.olap.Member member = schemaReader.getMemberByUniqueName(membParts,true);
            logger.debug("DataSecurityManager::setMondrianRole: mondrian member object retrived: " + member);
            if(membAccess.equalsIgnoreCase("none")) {
              connRole.grant(member, Access.NONE)
            logger.debug("DataSecurityManager::setMondrianRole: setted access.none to the member");   
          } else {
            connRole.grant(member, Access.ALL)
            logger.debug("DataSecurityManager::setMondrianRole: setted access.all to the member")
          }
          }
      }
      logger.debug("DataSecurityManager::setMondrianRole: end setting grant for members of dimensions");
         
     
      // SET THE ROLE INTO CONNECTION
      //connRole.makeImmutable();
      monConnection.setRole(connRole);
      logger.debug("DataSecurityManager::setMondrianRole: setted role with grants into connection");
      logger.debug("DataSecurityManager::setMondrianRole: end setting data access");
    
     
     
View Full Code Here

TOP

Related Classes of mondrian.olap.Connection

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.