Pregunta

Estoy planeando un poco de una aplicación que utiliza el motor OLAP Mondrian con OLAP4J y debe presentar/mostrar datos al usuario. Entiendo todas las cosas de back-end, pero no estoy seguro de cómo debo mostrar los datos en la capa de vista.

Por ejemplo, OLAP4J tiene un formato que imprime la selección muy bien en la consola.

¿Cómo se muestran los datos que obtengo de OLAP4J en la capa View? Acabo de pasar por la API OLAP4J, y no parece haber nada para obtener el resultado en un formulario que de alguna manera se puede procesar y mostrar de alguna manera. ¿Es este proceso parte de la solución de Pentaho? ¿Entonces que de lo contrario no es fácil presentar datos solo del motor OLAP Mondrian y OLAP4J?

EDITAR: Estoy acostumbrado a obtener tradicionalmente algunos datos de una base de datos en mi DTO y mostrarlos en la capa de vista. Pero, ¿cómo creo DTO para un conjunto de resultados tan complicado?

¿Fue útil?

Solución

Puede crear su propia capa de vista, es un poco complicado.

Estatemia.ExCuteOlapQuery () devuelve un Conjunto de células, tendrás que trabajar con eso. También lee el especificaciones, es una buena fuente de información.

Aquí hay un ejemplo, que crea List<List<MyCell>> (No es la mejor representación, pero es fácil desenredar cómo funciona). Esto crea una tabla similar a http://www.olap4j.org/api/index.html?org/olap4j/position.html (sin las etiquetas de "género" y "producto").

private final static int COLUMNS = 0; //see Cellset javadoc
private final static int ROWS= 1; //see Cellset javadoc
/**
* Outer list: rows, inner list: elements in a row
*/
private List<List<MyCell>> getListFromCellSet(CellSet cellSet) {
    List<List<MyCell>> toReturn= new ArrayList<List<MyCell>>();
    //Column header
    //See http://www.olap4j.org/api/index.html?org/olap4j/Position.html on how Position works, it helps a lot
    //Every position will be a column in the header
    for (Position pos : cellSet.getAxes().get(COLUMNS).getPositions()) {
        for (int i = 0; i < pos.getMembers().size(); i++) {
            if (toReturn.size() <= i) {
                toReturn.add(i, new ArrayList<MyCell>());
            }
            Member m = pos.getMembers().get(i);
            MyCell myCell = new MyCell(m); //use m.getCaption() for display
            toReturn.get(i).add(myCell );
        }
    }
    //Put empty elements to the beginning of the list, so there will be place for the rows header
    if (cellSet.getAxes().get(ROWS).getPositions().size() > 0) {
        for (int count=0; count < cellSet.getAxes().get(1).getPositions().get(0).getMembers().size(); count++) {
            for (int i = 0; i < toReturn.size(); i++) {
                toReturn.get(i).add(0, new MyCell());
            }
        }
    }
    //Content + row header
    for(int i = 0; i < cellSet.getAxes().get(ROWS).getPositionCount(); i++) {
        List<MyCell> row = new ArrayList<MyCell>();
        //Header
        for (org.olap4j.metadata.Member m : cellSet.getAxes().get(ROWS).getPositions().get(i).getMembers()) {
            row.add(new MyCell(m));
        }
        //Content
        for (int j = 0; j < cellSet.getAxes().get(COLUMNS).getPositionCount(); j++) {
            ArrayList<Integer> list = new ArrayList<Integer>();
            list.add(j); //coordinte
            list.add(i); //coordinte
            row.add(new MyCell(cellSet.getCell(list))); //use cell.getFormattedValue() for display
        }
        toReturn.add(row);
    }
    return toReturn;
}

Crea la clase MyCell con estos constructores:

public class MyCell {   
    ...
    public MyCell(){...}
    public MyCell(Member m){...}
    public MyCell(Cell c){...}  
}

No olvide mostrar los filtros, use CellSet.GetFilTeraxis () para eso.

También puedes verificar el Rectangular Forma en SourceForge, pero es un poco más largo.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top