mondrian.olap.Result Java Examples
The following examples show how to use
mondrian.olap.Result.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CubeService.java From youkefu with Apache License 2.0 | 6 votes |
/** * * @param axes * @param axis * @param pos * @param result * @param dataList * @param rowno */ private void getRowData(Axis[] axes, int axis, int[] pos, Result result, List<List<ValueData>> dataList, int rowno , Position position , CubeReportData cubeData , List<ColumnProperties> cols) { if (axis < 0) { if (dataList.size() <= rowno || dataList.get(rowno) == null) { dataList.add(new ArrayList<ValueData>()); } Cell cell = result.getCell(pos) ; ValueData valueData = new ValueData(cell.getValue(), cell.getFormattedValue(), null , cell.canDrillThrough(), cell.getDrillThroughSQL(true) , position!=null && position.size()>0 ? position.get(position.size()-1).getName():"" , cell.getCachedFormatString() , cols) ; int rows = 0 ; valueData.setRow(getParentLevel(cubeData.getRow() , rowno, rows)) ; dataList.get(rowno).add(valueData); } else { Axis _axis = axes[axis]; List<Position> positions = _axis.getPositions(); for (int i = 0; i < positions.size(); i++) { Position posit = positions.get(i) ; pos[axis] = i; if (axis == 0) { int row = axis + 1 < pos.length ? pos[axis + 1] : 0; rowno = row; } getRowData(axes, axis - 1, pos, result, dataList, rowno , posit , cubeData , cols); } } }
Example #2
Source File: DenormalizedMDXTableModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
private Member computeMeasureName( final Result resultSet ) { final List<Position> positionList = resultSet.getSlicerAxis().getPositions(); for ( int i = 0; i < positionList.size(); i++ ) { final Position position = positionList.get( i ); for ( int positionIndex = 0; positionIndex < position.size(); positionIndex++ ) { Member m = position.get( positionIndex ); while ( m != null ) { if ( m.isMeasure() ) { return m; } m = m.getParentMember(); } } } return null; }
Example #3
Source File: DenormalizedMDXTableModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public DenormalizedMDXTableModel( final Result resultSet, final int rowLimit, final boolean membersOnAxisSorted ) { ArgumentNullException.validate( "resultSet", resultSet ); this.resultSet = resultSet; final Axis[] axes = this.resultSet.getAxes(); this.axesSize = ResultSetProcessingLib.computeItemsPerAxis( axes ); this.rowCount = computeRowCount( axesSize ); final int[] axesMembers = ResultSetProcessingLib.computeTotalColumnsPerAxis( axes, 0, membersOnAxisSorted ); this.columnCount = computeColumnCount( axesMembers ); this.columnToAxisPosition = ResultSetProcessingLib.computeColumnToAxisMapping( axes, axesMembers, columnCount, 0 ); this.columnToMemberMapping = Collections.unmodifiableList ( ResultSetProcessingLib.computeColumnToMemberMapping( axes, axesMembers, 0, membersOnAxisSorted ) ); this.columnNames = computeColumnNames( columnToMemberMapping ); if ( rowLimit > 0 ) { rowCount = Math.min( rowLimit, rowCount ); } }
Example #4
Source File: MondrianHelper.java From pentaho-kettle with Apache License 2.0 | 5 votes |
private static void outputFlattenedRecurse( Result result, List<List<Object>> rows, List<Object> rowValues, int[] coords, int axisOrdinal ) { final Axis[] axes = result.getAxes(); if ( axisOrdinal == axes.length ) { final Cell cell = result.getCell( coords ); // Output the raw (unformatted) value of the cell. // NOTE: We could output other properties of the cell here, such as its // formatted value, too. rowValues.add( cell.getValue() ); // Add a copy of the completed row to the list of rows. rows.add( new ArrayList<>( rowValues ) ); } else { final Axis axis = axes[axisOrdinal]; int k = -1; int saveLength = rowValues.size(); for ( Position position : axis.getPositions() ) { coords[axisOrdinal] = ++k; for ( Member member : position ) { rowValues.add( member.getUniqueName() ); } outputFlattenedRecurse( result, rows, rowValues, coords, axisOrdinal + 1 ); while ( rowValues.size() > saveLength ) { rowValues.remove( rowValues.size() - 1 ); } } } }
Example #5
Source File: JRMondrianResult.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
public JRMondrianResult(Result result) { 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); } }
Example #6
Source File: BandedMDXTableModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public BandedMDXTableModel( final Result resultSet, final int rowLimit, final boolean membersOnAxisSorted ) { ArgumentNullException.validate( "resultSet", resultSet ); this.resultSet = resultSet; // rowcount is the product of all axis-sizes. If an axis contains more than one member, then // Mondrian already performs the crossjoin for us. // column count is the sum of the maximum of all hierachy levels of all axis. final Axis[] axes = this.resultSet.getAxes(); this.axesSize = ResultSetProcessingLib.computeItemsPerAxis( axes ); this.rowCount = computeRowCount( axesSize ); final int[] axesMembers = ResultSetProcessingLib.computeTotalColumnsPerAxis( axes, 1, membersOnAxisSorted ); this.columnCount = computeColumnCount( axesMembers, this.axesSize ); this.columnToAxisPosition = ResultSetProcessingLib.computeColumnToAxisMapping( axes, axesMembers, columnCount, 1 ); this.columnToMemberMapping = Collections.unmodifiableList ( ResultSetProcessingLib.computeColumnToMemberMapping( axes, axesMembers, 1, membersOnAxisSorted ) ); this.columnNames = computeColumnNames( axes, columnToMemberMapping ); if ( rowLimit > 0 ) { rowCount = Math.min( rowLimit, rowCount ); } }
Example #7
Source File: LegacyBandedMDXTableModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public LegacyBandedMDXTableModel( final Result resultSet, final int queryLimitValue ) throws ReportDataFactoryException { this.resultSet = resultSet; final Axis[] axes = resultSet.getAxes(); final int axisCount = axes.length; if ( axisCount > 2 ) { throw new ReportDataFactoryException( "Cannot handle results with more than two axes." ); } this.rowHeaders = createRowHeaders(); this.columnHeaders = createColumnHeaders(); if ( rowHeaders.getRowCount() > 0 ) { columnCount = rowHeaders.getColumnCount() + columnHeaders.getColumnCount(); } else { columnCount = columnHeaders.getColumnCount(); } if ( columnCount == 0 ) { columnCount = 1; emptyAxisCase = true; columnNames = new String[] { "Measure" }; rowCount = 1; } else { columnNames = new String[ columnCount ]; for ( int i = 0; i < columnNames.length; i++ ) { columnNames[ i ] = calcColumnName( i ); } if ( axisCount == 2 ) { rowCount = rowHeaders.getRowCount(); } else { rowCount = Math.max( 1, rowHeaders.getRowCount() ); } } if ( queryLimitValue > 0 ) { rowCount = Math.min( queryLimitValue, rowCount ); } }
Example #8
Source File: MondrianHelper.java From pentaho-kettle with Apache License 2.0 | 4 votes |
/** * @return the result */ public Result getResult() { return result; }
Example #9
Source File: CubeService.java From youkefu with Apache License 2.0 | 4 votes |
@SuppressWarnings("deprecation") public CubeReportData execute(String mdx,List<ColumnProperties> cols) throws Exception{ Connection connection = null ; CubeReportData cubeReportData = new CubeReportData(); try{ connection = dataSource.service(schemaFile.getAbsolutePath()) ; Query query = connection.parseQuery(mdx); Result result = connection.execute(query) ; Axis[] axises = result.getAxes(); cubeReportData.setData(new ArrayList<List<ValueData>>()); for (int i = 0; i < axises.length; i++) { if (i == 0) { cubeReportData.setCol(createTitle(axises[i], i , cols)); } else { cubeReportData.setRow(createTitle(axises[i], i , cols)); // cubeReportData.setTotal(axises[i].getDataSize()); } } if(cubeReportData.getRow()==null){ cubeReportData.setRow(new Level("root","row", null , 0)) ; cubeReportData.getRow().setTitle(new ArrayList<List<Level>>()); if(cubeReportData.getRow().getTitle().size()==0){ List<Level> rowList = new ArrayList<Level>() ; rowList.add(new Level("合计","row", null , 0)) ; cubeReportData.getRow().getTitle().add(rowList) ; } } getRowData(result.getAxes(), result.getAxes().length - 1, new int[result.getAxes().length], result, cubeReportData.getData(), 0 , null , cubeReportData , cols); processSum(cubeReportData.getRow(), cubeReportData.getData() , cubeReportData.getRow()) ; processSum(cubeReportData.getCol(), cubeReportData.getData() , cubeReportData.getCol()) ; cubeReportData.getRow().setTitle(new ArrayList<List<Level>>()) ; processTitle(cubeReportData.getRow() , cubeReportData.getRow()); }catch(Exception ex){ ex.printStackTrace(); throw ex; }finally{ if(connection!=null){ connection.close(); } if(schemaFile.exists()){ schemaFile.delete(); } } return cubeReportData ; }
Example #10
Source File: DenormalizedMDXTableModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
@Deprecated public DenormalizedMDXTableModel( final Result resultSet ) { this( resultSet, 0, false ); }
Example #11
Source File: BandedMDXTableModel.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 4 votes |
@Deprecated public BandedMDXTableModel( final Result resultSet, final int rowLimit ) { this( resultSet, rowLimit, false ); }
Example #12
Source File: JRMondrianDataSource.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
public JRMondrianDataSource(JRDataset dataset, Result result) { super(dataset, new JRMondrianResult(result)); this.result = result; }
Example #13
Source File: JRMondrianQueryExecuter.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
public Result getResult() { return result; }
Example #14
Source File: AbstractNamedMDXDataFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 3 votes |
/** * Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain * more data than actually needed for the query. * <p/> * The parameter-dataset may change between two calls, do not assume anything, and do not hold references to the * parameter-dataset or the position of the columns in the dataset. * * @param queryName the query name * @param parameters the parameters for the query * @return the result of the query as table model. * @throws org.pentaho.reporting.engine.classic.core.ReportDataFactoryException if an error occured while performing * the query. */ public Result performQuery( final String queryName, final DataRow parameters ) throws ReportDataFactoryException { final String query = scriptingSupport.computeQuery( queryName, parameters ); if ( query == null ) { throw new ReportDataFactoryException( "No such query: " + queryName ); } return super.performQuery( query, parameters ); }
Example #15
Source File: SimpleLegacyBandedMDXDataFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 2 votes |
/** * Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain * more data than actually needed for the query. * <p/> * The parameter-dataset may change between two calls, do not assume anything, and do not hold references to the * parameter-dataset or the position of the columns in the dataset. * * @param queryName the query name * @param parameters the parameters for the query * @return the result of the query as table model. * @throws org.pentaho.reporting.engine.classic.core.ReportDataFactoryException if an error occured while performing * the query. */ public TableModel queryData( final String queryName, final DataRow parameters ) throws ReportDataFactoryException { final Result cellSet = performQuery( queryName, parameters ); return new LegacyBandedMDXTableModel( cellSet, extractQueryLimit( parameters ) ); }
Example #16
Source File: DenormalizedMDXDataFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 2 votes |
/** * Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain * more data than actually needed for the query. * <p/> * The parameter-dataset may change between two calls, do not assume anything, and do not hold references to the * parameter-dataset or the position of the columns in the dataset. * * @param queryName the query name * @param parameters the parameters for the query * @return the result of the query as table model. * @throws ReportDataFactoryException if an error occured while performing the query. */ public TableModel queryData( final String queryName, final DataRow parameters ) throws ReportDataFactoryException { final Result cellSet = performQuery( queryName, parameters ); return postProcess( queryName, parameters, new DenormalizedMDXTableModel ( cellSet, extractQueryLimit( parameters ), isMembersOnAxisSorted() ) ); }
Example #17
Source File: BandedMDXDataFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 2 votes |
/** * Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain * more data than actually needed for the query. * <p/> * The parameter-dataset may change between two calls, do not assume anything, and do not hold references to the * parameter-dataset or the position of the columns in the dataset. * * @param queryName the query name * @param parameters the parameters for the query * @return the result of the query as table model. * @throws ReportDataFactoryException if an error occured while performing the query. */ public TableModel queryData( final String queryName, final DataRow parameters ) throws ReportDataFactoryException { final Result cellSet = performQuery( queryName, parameters ); return postProcess( queryName, parameters, new BandedMDXTableModel( cellSet, extractQueryLimit( parameters ), isMembersOnAxisSorted() ) ); }
Example #18
Source File: SimpleBandedMDXDataFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 2 votes |
/** * Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain * more data than actually needed for the query. * <p/> * The parameter-dataset may change between two calls, do not assume anything, and do not hold references to the * parameter-dataset or the position of the columns in the dataset. * * @param queryName the query name * @param parameters the parameters for the query * @return the result of the query as table model. * @throws org.pentaho.reporting.engine.classic.core.ReportDataFactoryException if an error occured while performing * the query. */ public TableModel queryData( final String queryName, final DataRow parameters ) throws ReportDataFactoryException { final Result cellSet = performQuery( queryName, parameters ); return new BandedMDXTableModel( cellSet, extractQueryLimit( parameters ), isMembersOnAxisSorted() ); }
Example #19
Source File: LegacyBandedMDXDataFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 2 votes |
/** * Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain * more data than actually needed for the query. * <p/> * The parameter-dataset may change between two calls, do not assume anything, and do not hold references to the * parameter-dataset or the position of the columns in the dataset. * * @param queryName the query name * @param parameters the parameters for the query * @return the result of the query as table model. * @throws ReportDataFactoryException if an error occured while performing the query. */ public TableModel queryData( final String queryName, final DataRow parameters ) throws ReportDataFactoryException { final Result cellSet = performQuery( queryName, parameters ); return postProcess( queryName, parameters, new LegacyBandedMDXTableModel( cellSet, extractQueryLimit( parameters ) ) ); }
Example #20
Source File: SimpleDenormalizedMDXDataFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 2 votes |
/** * Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain * more data than actually needed for the query. * <p/> * The parameter-dataset may change between two calls, do not assume anything, and do not hold references to the * parameter-dataset or the position of the columns in the dataset. * * @param queryName the query name * @param parameters the parameters for the query * @return the result of the query as table model. * @throws org.pentaho.reporting.engine.classic.core.ReportDataFactoryException if an error occured while performing * the query. */ public TableModel queryData( final String queryName, final DataRow parameters ) throws ReportDataFactoryException { final Result cellSet = performQuery( queryName, parameters ); return new DenormalizedMDXTableModel( cellSet, extractQueryLimit( parameters ), isMembersOnAxisSorted() ); }