Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

Commit

Permalink
move dimension_hierarchy to cube class from pipelined rolap aggregate.
Browse files Browse the repository at this point in the history
  • Loading branch information
kookster committed Nov 29, 2011
1 parent c60eac9 commit 0b4a8ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
19 changes: 7 additions & 12 deletions lib/active_warehouse/aggregate/pipelined_rolap_aggregate.rb
Expand Up @@ -42,7 +42,7 @@ def query(*args)

column_dimension_name = options[:column_dimension_name] || options[:column]
column_dimension = fact_class.dimension_class(column_dimension_name)
column_hierarchy = dimension_hierarchy(column_dimension_name)
column_hierarchy = cube_class.dimension_hierarchy(column_dimension_name)

if cstage.to_s == 'all'
current_column_name = "#{column_dimension_name}_all"
Expand All @@ -54,7 +54,7 @@ def query(*args)

row_dimension_name = options[:row_dimension_name] || options[:row]
row_dimension = fact_class.dimension_class(row_dimension_name)
row_hierarchy = dimension_hierarchy(row_dimension_name)
row_hierarchy = cube_class.dimension_hierarchy(row_dimension_name)

if rstage.to_s == 'all'
current_row_name = "#{row_dimension_name}_all"
Expand Down Expand Up @@ -89,7 +89,7 @@ def query(*args)
dimension_name, column = key.split('.')

dim_class = fact_class.dimension_class(dimension_name.to_sym)
dim_hierarchy = dimension_hierarchy(dimension_name.to_sym)
dim_hierarchy = cube_class.dimension_hierarchy(dimension_name.to_sym)
dim_level = dim_hierarchy.index(column.to_sym)
name = "#{dimension_name}_#{column}"

Expand All @@ -100,6 +100,8 @@ def query(*args)
where_clause << "(#{name} >= #{sanitize(value.begin)}) AND (#{name} <= #{sanitize(value.end)})"
elsif value == :not_null
where_clause << "#{name} IS NOT NULL"
elsif value == :not_blank
where_clause << "#{name} IS NOT NULL AND #{name} != ''"
elsif (value.nil? || value == :null)
where_clause << "#{name} IS NULL"
else
Expand Down Expand Up @@ -539,7 +541,7 @@ def aggregate_dimension_fields
dimension_class = fact_class.dimension_class(dimension_name)
dim_cols[dimension_class] = []

dimension_hierarchy(dimension_name).each do |level|
cube_class.dimension_hierarchy(dimension_name).each do |level|
# puts "level.to_s = #{level.to_s}"
column = dimension_class.columns_hash[level.to_s]
dim_cols[dimension_class] << Field.new( dimension_class,
Expand All @@ -555,14 +557,7 @@ def aggregate_dimension_fields
end
dim_cols
end

def dimension_hierarchy(dimension_name)
hierarchy_name = cube_class.dimensions_hierarchies[dimension_name]
dimension_class = fact_class.dimension_class(dimension_name)
levels = hierarchy_name ? dimension_class.hierarchy_levels[hierarchy_name] || [hierarchy_name] : ['id']
levels.uniq
end


end

end
Expand Down
7 changes: 7 additions & 0 deletions lib/active_warehouse/cube.rb
Expand Up @@ -79,6 +79,13 @@ def dimensions_hierarchies
@dimensions_hierarchies
end

def dimension_hierarchy(dimension_name)
hierarchy_name = dimensions_hierarchies[dimension_name]
dimension_class = fact_class.dimension_class(dimension_name)
levels = hierarchy_name ? dimension_class.hierarchy_levels[hierarchy_name] || [hierarchy_name] : ['id']
levels.uniq
end

# returns true if this cube pivots on a hierarchical dimension.
def pivot_on_hierarchical_dimension?
dimension_classes.each do |dimension|
Expand Down

0 comments on commit 0b4a8ef

Please sign in to comment.