mysticfall / pivot4j

Pivot4J provides a common API for OLAP servers which can be used to build an analytical service frontend with pivot style GUI.
Other
128 stars 101 forks source link

Headers rendered incorrectly with showParentMembers and parent-child hierachy #186

Closed d-amelin closed 9 years ago

d-amelin commented 9 years ago

Steps to reproduce

  1. display result of query: "select [Measures].[SomeMeasure] on columns, [ParentChildHierachy] on rows from [SomeCube]" Where ParentChildHierachy is parent-child hierarchy. For example: [HR].[Employees] from mondrian example schema "foodmart".
  2. enable showParentMembers mode. (Click toolbar button "Show Parent")
  3. expand at least two branches of ParentChildHierachy. (Click on some members to expand it)

Expected behavior: expanded headers rendered correctly Actual behavior: expanded headers rendered incorrectly: Some of header`s cells placed in "measures" column because wrong colspan. see screenshot for example: headers-rendered-incorrectly

The reason is comparison of levels at org.pivot4j.ui.table.TableHeaderNode:573 if (OlapUtils.equals(member.getLevel(),level))

In parent-child and ragged hierarchies level can contains members with different depth. For example: member [DirectoryHierachy].[DirectoryLevel].[ParentDirectory] has children [DirectoryHierachy].[DirectoryLevel].[SubDirectory1] and [DirectoryHierachy].[DirectoryLevel].[SubDirectory2]. All these members has same level. While calculating SubDirectory1 span, we should look for SubDirectory2, not for ParentDirectory. Because ParentDirectory will be different pivot header column (or row) when showParentsMembers == true. So, it is preferabble to compare member.getDepth instead of member.getLevel.

See pull request