<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/models/product_sales_cube.rb</filename>
    </added>
    <added>
      <filename>app/views/demo/date_dimension.rhtml</filename>
    </added>
    <added>
      <filename>app/views/demo/example2.rhtml</filename>
    </added>
    <added>
      <filename>app/views/demo/example3.rhtml</filename>
    </added>
    <added>
      <filename>app/views/demo/example4.rhtml</filename>
    </added>
    <added>
      <filename>db/setup/product.rb</filename>
    </added>
    <added>
      <filename>test/unit/product_sales_cube_test.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -3,11 +3,62 @@ class DemoController &lt; ApplicationController
   def index
     render :action =&gt; &quot;demo/index&quot;, :layout =&gt; &quot;application&quot;
   end
+  
   def example1
     
   end
+  def example2
+
+  end
+  def example3
+
+  end
+  def example4
+    # TODO: this is ugly as sin right now. I need to clean it up and put it into a helper
+    
+    @pivots = []
+    index = 0
+    ProductSalesCube.dimensions.each do |dim|
+      dim_class = ActiveWarehouse::Dimension.class_for_name(dim)
+      dim_class.hierarchies.each do |hierarchy|
+        @pivots &lt;&lt; {:dimension =&gt; dim, :hierarchy =&gt; hierarchy, :name =&gt; &quot;#{dim}/#{hierarchy}&quot;, :index =&gt; index}
+        index += 1
+      end
+    end
+    
+    @col_dimension = params[:cd] || :date
+    @col_hierarchy = params[:ch] || :cy
+    if params[:col_pivot]
+      col_pivot = @pivots[params[:col_pivot].to_i]
+      @col_dimension = col_pivot[:dimension]
+      @col_hierarchy = col_pivot[:hierarchy]
+    end
+    
+    @row_dimension = params[:rd] || :product
+    @row_hierarchy = params[:rh] || :product
+    if params[:row_pivot]
+      row_pivot = @pivots[params[:row_pivot].to_i]
+      @row_dimension = row_pivot[:dimension]
+      @row_hierarchy = row_pivot[:hierarchy]
+    end
+    
+    puts &quot;@col_dimension=#{@col_dimension}&quot;
+    puts &quot;@col_hierarchy=#{@col_hierarchy}&quot;
+    puts &quot;@row_dimension=#{@row_dimension}&quot;
+    puts &quot;@row_hierarchy=#{@row_hierarchy}&quot;
+    
+    params[:cd] = @col_dimension = @col_dimension.to_sym
+    params[:ch] = @col_hierarchy = @col_hierarchy.to_sym
+    params[:rd] = @row_dimension = @row_dimension.to_sym
+    params[:rh] = @row_hierarchy = @row_hierarchy.to_sym
+    
+  end
+  
   def fact_list
     @facts = PosRetailSalesTransactionFact.find(
       :all, :include =&gt; [:date, :store])
   end
+  def date_dimension
+    @dimension_pages, @dimension_records = paginate(:date_dimension, :per_page =&gt; 30)
+  end
 end</diff>
      <filename>app/controllers/demo_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,10 @@
 class PosRetailSalesTransactionFact &lt; ActiveWarehouse::Fact
-  define_aggregate :sales_quantity, :type =&gt; :sum
-  define_aggregate :sales_dollar_amount, :type =&gt; :sum
+  aggregate :sales_quantity#, :type =&gt; :sum
+  aggregate :sales_dollar_amount#, :type =&gt; :sum
+  aggregate :gross_profit_dollar_amount#, :type =&gt; :sum
+  
+  calculated_field (:gross_margin) { |agg_rec| agg_rec.gross_profit_dollar_amount / agg_rec.sales_dollar_amount}
+  
   belongs_to :date, :foreign_key =&gt; 'date_id', :class_name =&gt; 'DateDimension'
   belongs_to :store, :foreign_key =&gt; 'store_id', :class_name =&gt; 'StoreDimension'
 end
\ No newline at end of file</diff>
      <filename>app/models/pos_retail_sales_transaction_fact.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,3 @@
 class ProductDimension &lt; ActiveWarehouse::Dimension
-  
+  define_hierarchy :product, [:department_description, :category_description, :brand_description]
 end
\ No newline at end of file</diff>
      <filename>app/models/product_dimension.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,14 +7,35 @@
   &lt;h1&gt;ActiveWarehouse Demo&lt;/h1&gt;
 
   &lt;p&gt;This is a simple demo to show how ActiveWarehouse works.&lt;/p&gt;
+  
   &lt;ol&gt;
     &lt;li&gt;
-      &lt;h2&gt;Example 1&lt;/h2&gt;
-      &lt;%= image_tag 'example1-erd.png', :alt =&gt; 'Example 1 ERD Diagram' %&gt;
-      &lt;p&gt;&lt;%= link_to 'Example #1', :action =&gt; 'example1' %&gt;&lt;/p&gt;
+      &lt;h2&gt;&lt;%= link_to 'Example #1', :action =&gt; 'example1' %&gt;&lt;/h2&gt;
+      &lt;p&gt;Canned report pivoting on Store dimension on the Region hierarchy and Date Dimension on the Calendar Year hierarchy.&lt;/p&gt;
+    &lt;/li&gt;
+    &lt;li&gt;
+      &lt;h2&gt;&lt;%= link_to 'Example #2', :action =&gt; 'example2' %&gt;&lt;/h2&gt;
+      &lt;p&gt;Canned report pivoting on Store dimension on the Location hierarchy and Date dimension on the Fiscal Year hierarchy.&lt;/p&gt;
+    &lt;/li&gt;
+    &lt;li&gt;
+      &lt;h2&gt;&lt;%= link_to 'Example #3', :action =&gt; 'example3' %&gt;&lt;/h2&gt;
+      &lt;p&gt;Canned report pivoting on Production dimension and Date dimension on the Calendar Year hierarchy.&lt;/p&gt;
+    &lt;/li&gt;
+    &lt;li&gt;
+      &lt;h2&gt;&lt;%= link_to 'Example #4', :action =&gt; 'example4' %&gt;&lt;/h2&gt;
+      &lt;p&gt;Dynamic pivot report.&lt;/p&gt;
     &lt;/li&gt;
     &lt;li&gt;
       &lt;h2&gt;Fact List&lt;/h2&gt;
       &lt;p&gt;&lt;%= link_to 'Fact List', :action =&gt; 'fact_list' %&gt;&lt;/p&gt;
+    &lt;/li&gt;
+    &lt;li&gt;
+      &lt;h2&gt;Date Dimension&lt;/h2&gt;
+      &lt;p&gt;&lt;%= link_to 'Date Dimension', :action =&gt; 'date_dimension' %&gt;&lt;/p&gt;
+    &lt;/li&gt;
   &lt;/ol&gt;
+  
+  &lt;p&gt;ERD Diagram:&lt;/p&gt;
+  &lt;%= image_tag 'example1-erd.png', :alt =&gt; 'Example 1 ERD Diagram' %&gt;
+  
 &lt;/div&gt;
\ No newline at end of file</diff>
      <filename>app/views/demo/index.rhtml</filename>
    </modified>
    <modified>
      <diff>@@ -19,3 +19,6 @@ config.action_view.debug_rjs                         = true
 
 # Don't care if the mailer can't send
 config.action_mailer.raise_delivery_errors = false
+
+#require 'ruby-debug'
+#Debugger.start
\ No newline at end of file</diff>
      <filename>config/environments/development.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,5 +2,6 @@ namespace :warehouse do
   desc &quot;Rebuild the warehouse&quot; # TODO: extract into a generic rake task for AW plugin
   task :rebuild =&gt; :environment do
     RegionalSalesCube.rebuild(:force =&gt; true)
+    ProductSalesCube.rebuild(:force =&gt; true)
   end
 end
\ No newline at end of file</diff>
      <filename>lib/tasks/warehouse.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c57ca3c40cdf9323bd78a63e0002c112b01bcb70</id>
    </parent>
  </parents>
  <author>
    <name>aeden</name>
    <email>aeden@78b0de1e-7a20-0410-a083-82450d3afd0a</email>
  </author>
  <url>http://github.com/bcotton/activewarehouse-demo/commit/56c16705d25955a9a2f8295256a92eec237b8c8e</url>
  <id>56c16705d25955a9a2f8295256a92eec237b8c8e</id>
  <committed-date>2006-11-13T12:55:11-08:00</committed-date>
  <authored-date>2006-11-13T12:55:11-08:00</authored-date>
  <message>Added more examples

git-svn-id: svn://rubyforge.org/var/svn/activewarehouse/demo/trunk@66 78b0de1e-7a20-0410-a083-82450d3afd0a</message>
  <tree>9d618b34f21cf22545490d96333b6566eac67092</tree>
  <committer>
    <name>aeden</name>
    <email>aeden@78b0de1e-7a20-0410-a083-82450d3afd0a</email>
  </committer>
</commit>
