ExportContext with consolidated elements

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • ExportContext with consolidated elements

      Hello everybody,

      I've got a problem getting my cell data out of a cube while using consolidated elements. To give an example what I mean I'll show you a part of my data structure.

      My Regions Dimension looks like this:

      Source Code

      1. ID | name | level
      2. 0 | Germany | 0
      3. 1 | France | 0
      4. 3 | Europe | 1

      So Europe is a consolidated Element with Germany and France as children. When I set an area to my ExportContext with Element Id 0 or 1 or both of them I got the data I want.

      Is there a possibility to set the area with Element ID 3 (Europe) and get the data for all children as a result?
      Or do I have to implement my own method to get all children from Europe and add them to the area?

    • RE: ExportContext with consolidated elements

      Hi Thomas,

      I think Russ is right.
      You have to specify the elements you want to export.
      Maybe an example will make this more clear:

      Source Code

      1. Database demo = conn.getDatabaseByName("Demo");
      2. Cube sales = demo.getCubeByName("Sales");
      3. Dimension[] salesDimension = sales.getDimensions();
      4. Element[][] area = new Element[salesDimension.length][];
      5. int index = 0;
      6. for(Dimension dim : salesDimension) {
      7. if(dim.getName().equals("Regions")) {
      8. Element europe = regions.getElementByName("Europe");
      9. Element germany = regions.getElementByName("Germany");
      10. Element france = regions.getElementByName("France");
      11. area[index++] = new Element[] {europe, germany, france};
      12. } else
      13. area[index++] = dim.getRootElements();
      14. }
      15. ExportContext ec = sales.getExportContext(area);
      16. ec.setBaseCellsOnly(false);
      17. while(ec.getProgress() < 1.0) {
      18. dump(sales.getDataExport(ec));
      19. }
      Display All

      This snippet will export 6 cells from the standard Sales demo cube.
      To include the children of Europe you have to explicitly set the "base cells only" flag to false via ExportContext#setBaseCellsOnly(false).


      The post was edited 2 times, last by arnd ().

    • RE: ExportContext with consolidated elements

      Originally posted by swissruss
      you'll have to loop over the consolidations

      Originally posted by arnd
      To include the children of Europe you have to explicitly set the "base cells only" flag to false via ExportContext#setBaseCellsOnly(false).

      Thanks Russ and arnd, that definitely helps :)
      Now I know that I have to implement the loop for myself.
      My DataExport is now doing what I expect it to do.

      A last questions regarding to your code russ,
      what is "while(ec.getProgress() < 1.0)" doing? Do I have to do the loop if my amount of result cells is bigger that the block size?
      Can i use it to get a rough percentage of data that has already been exported or is it 0 until all data has been exported?

    • Hi Thomas,

      I'm afraid I can't claim credit for the code, which arnd posted ;o)
      However, from the Javadoc for ExportContext:

      Source Code

      1. getProgress
      2. double getProgress()Returns the current progress of the data export as a double value, with range between 0.0 to 1.0
      3. Returns:
      4. a double which represents current export progress.

      Think that's fairly clear!