mondrian-olap 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Changelog.md +20 -0
- data/Gemfile +4 -3
- data/LICENSE.txt +1 -1
- data/README.rdoc +1 -1
- data/RUNNING_TESTS.rdoc +9 -3
- data/VERSION +1 -1
- data/lib/mondrian/jars/mondrian.jar +0 -0
- data/lib/mondrian/jars/olap4j.jar +0 -0
- data/lib/mondrian/olap/connection.rb +21 -2
- data/lib/mondrian/olap/cube.rb +20 -5
- data/lib/mondrian/olap/query.rb +18 -0
- data/lib/mondrian/olap/schema.rb +69 -3
- data/lib/mondrian/olap/schema_element.rb +12 -0
- data/mondrian-olap.gemspec +17 -14
- data/spec/cube_spec.rb +20 -0
- data/spec/query_spec.rb +29 -0
- data/spec/rake_tasks.rb +2 -2
- data/spec/schema_definition_spec.rb +255 -0
- data/spec/spec_helper.rb +50 -22
- metadata +23 -14
data/Changelog.md
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
### 0.3.0 / 2011-11-12
|
2
|
+
|
3
|
+
* New features
|
4
|
+
* upgraded to Mondrian 3.3.0 version (latest shapshot with additional bug fixes)
|
5
|
+
as well as corresponding olap4j 1.0.0 version
|
6
|
+
* support for SQL Server (jTDS and Microsoft drivers)
|
7
|
+
* aggregates definition in schema
|
8
|
+
* possibility to include XML fragments in schema
|
9
|
+
(e.g. to paste XML for aggregates that is generated by Mondrian aggregation designer)
|
10
|
+
* define level properties in schema
|
11
|
+
* `sql` element for `table` element in schema
|
12
|
+
(to define custom WHERE conditions for dimensions or fact table)
|
13
|
+
* `view` element in schema
|
14
|
+
(to define custom SQL SELECT statements instead of existing table)
|
15
|
+
* `measure_expression` element in schema
|
16
|
+
(to define custom SQL expression for measure instead of fact column)
|
17
|
+
* allow crossjoin of where conditions as well as where with several same dimension members
|
18
|
+
* Improvements
|
19
|
+
* use latest Nokogiri 1.5.0 version
|
20
|
+
|
1
21
|
### 0.2.0 / 2011-07-01
|
2
22
|
|
3
23
|
* New features
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
gem 'nokogiri', '~> 1.5.0
|
3
|
+
gem 'nokogiri', '~> 1.5.0'
|
4
4
|
|
5
5
|
group :development do
|
6
6
|
gem 'jruby-openssl'
|
@@ -11,7 +11,8 @@ group :development do
|
|
11
11
|
gem 'jdbc-mysql'
|
12
12
|
gem 'jdbc-postgres'
|
13
13
|
gem 'jdbc-luciddb'
|
14
|
-
gem '
|
15
|
-
gem 'activerecord
|
14
|
+
gem 'jdbc-jtds'
|
15
|
+
gem 'activerecord', '= 3.0.10'
|
16
|
+
gem 'activerecord-jdbc-adapter', '= 1.1.1'
|
16
17
|
gem 'activerecord-oracle_enhanced-adapter', :require => false
|
17
18
|
end
|
data/LICENSE.txt
CHANGED
data/README.rdoc
CHANGED
@@ -195,7 +195,7 @@ See more examples of dimension and member queries in spec/cube_spec.rb.
|
|
195
195
|
|
196
196
|
mondrian-olap gem is compatible with JRuby versions 1.5 and 1.6 (have not been tested with earlier versions). mondrian-olap works only with JRuby and not with other Ruby implementations as it includes Mondrian OLAP Java libraries.
|
197
197
|
|
198
|
-
mondrian-olap currently supports MySQL, PostgreSQL, Oracle and
|
198
|
+
mondrian-olap currently supports MySQL, PostgreSQL, Oracle, LucidDB and SQL Server databases. When using MySQL, PostgreSQL or LucidDB databases then install jdbc-mysql, jdbc-postgres or jdbc-luciddb gem and require "jdbc/mysql", "jdbc/postgres" or "jdbc/luciddb" to load the corresponding JDBC database driver. When using Oracle then include Oracle JDBC driver (ojdbc6.jar for Java 6) in CLASSPATH or copy to JRUBY_HOME/lib or require it in application manually. When using SQL Server you can choose between the jTDS or Microsoft JDBC drivers. If you use jTDS require "jdbc/jtds". If you use the Microsoft JDBC driver include sqljdbc.jar or sqljdbc4.jar in CLASSPATH or copy to JRUBY_HOME/lib or require it in application manually.
|
199
199
|
|
200
200
|
== INSTALL
|
201
201
|
|
data/RUNNING_TESTS.rdoc
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
== Creating test database
|
2
2
|
|
3
|
-
By default unit tests use MySQL database but PostgreSQL and
|
3
|
+
By default unit tests use MySQL database but PostgreSQL, Oracle and SQL Server databases are supported as well. Set MONDRIAN_DRIVER environment variable to "mysql" (default), "postgresql", "oracle", "luciddb", "mssql" (jTDS) or "sqlserver" (Microsoft JDBC) to specify database driver that should be used.
|
4
4
|
|
5
|
-
If using MySQL or
|
5
|
+
If using MySQL, PostgreSQL or SQL Server database then create database user mondrian_test with password mondrian_test, create database mondrian_test and grant full access to this database for mondrian_test user. By default it is assumed that database is located on localhost (can be overridden with DATABASE_HOST environment variable).
|
6
6
|
|
7
7
|
If using Oracle database then create database user mondrian_test with password mondrian_test. By default it is assumed that database orcl is located on localhost (can be overridden with DATABASE_NAME and DATABASE_HOST environment variables).
|
8
8
|
|
@@ -20,11 +20,13 @@ Create tables with test data using
|
|
20
20
|
|
21
21
|
rake db:create_data
|
22
22
|
|
23
|
-
or specify which database driver to use
|
23
|
+
or specify which database driver to use
|
24
24
|
|
25
25
|
rake db:create_data MONDRIAN_DRIVER=mysql
|
26
26
|
rake db:create_data MONDRIAN_DRIVER=postgresql
|
27
27
|
rake db:create_data MONDRIAN_DRIVER=oracle
|
28
|
+
rake db:create_data MONDRIAN_DRIVER=mssql
|
29
|
+
rake db:create_data MONDRIAN_DRIVER=sqlserver
|
28
30
|
|
29
31
|
In case of LucidDB data are not generated and inserted directly into database but are imported from MySQL mondrian_test database (because inserting individual records into LucidDB is very inefficient). Therefore at first generate test data with mysql (using default database settings) and then run data creation task for LucidDB.
|
30
32
|
|
@@ -43,6 +45,8 @@ or specify which database driver to use
|
|
43
45
|
rake spec MONDRIAN_DRIVER=postgresql
|
44
46
|
rake spec MONDRIAN_DRIVER=oracle
|
45
47
|
rake spec MONDRIAN_DRIVER=luciddb
|
48
|
+
rake spec MONDRIAN_DRIVER=mssql
|
49
|
+
rake spec MONDRIAN_DRIVER=sqlserver
|
46
50
|
|
47
51
|
or also alternatively with
|
48
52
|
|
@@ -50,6 +54,8 @@ or also alternatively with
|
|
50
54
|
rake spec:postgresql
|
51
55
|
rake spec:oracle
|
52
56
|
rake spec:luciddb
|
57
|
+
rake spec:mssql
|
58
|
+
rake spec:sqlserver
|
53
59
|
|
54
60
|
You can also run all tests on all databases with
|
55
61
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
Binary file
|
Binary file
|
@@ -7,7 +7,7 @@ module Mondrian
|
|
7
7
|
connection
|
8
8
|
end
|
9
9
|
|
10
|
-
attr_reader :raw_connection, :
|
10
|
+
attr_reader :raw_connection, :raw_catalog, :raw_schema
|
11
11
|
|
12
12
|
def initialize(params={})
|
13
13
|
@params = params
|
@@ -41,7 +41,9 @@ module Mondrian
|
|
41
41
|
end
|
42
42
|
|
43
43
|
@raw_connection = @raw_jdbc_connection.unwrap(Java::OrgOlap4j::OlapConnection.java_class)
|
44
|
-
@
|
44
|
+
@raw_catalog = @raw_connection.getOlapCatalog
|
45
|
+
# currently it is assumed that there is just one schema per connection catalog
|
46
|
+
@raw_schema = @raw_catalog.getSchemas.first
|
45
47
|
@connected = true
|
46
48
|
true
|
47
49
|
end
|
@@ -109,6 +111,19 @@ module Mondrian
|
|
109
111
|
uri = "jdbc:luciddb:http://#{@params[:host]}#{@params[:port] && ":#{@params[:port]}"}"
|
110
112
|
uri << ";schema=#{@params[:database_schema]}" if @params[:database_schema]
|
111
113
|
uri
|
114
|
+
when 'mssql'
|
115
|
+
uri = "jdbc:jtds:sqlserver://#{@params[:host]}#{@params[:port] && ":#{@params[:port]}"}/#{@params[:database]}"
|
116
|
+
uri << ";instance=#{@params[:instance]}" if @params[:instance]
|
117
|
+
uri << ";domain=#{@params[:domain]}" if @params[:domain]
|
118
|
+
uri << ";appname=#{@params[:appname]}" if @params[:appname]
|
119
|
+
uri
|
120
|
+
when 'sqlserver'
|
121
|
+
uri = "jdbc:sqlserver://#{@params[:host]}#{@params[:port] && ":#{@params[:port]}"}"
|
122
|
+
uri << ";databaseName=#{@params[:database]}" if @params[:database]
|
123
|
+
uri << ";integratedSecurity=#{@params[:integrated_security]}" if @params[:integrated_security]
|
124
|
+
uri << ";applicationName=#{@params[:application_name]}" if @params[:application_name]
|
125
|
+
uri << ";instanceName=#{@params[:instance_name]}" if @params[:instance_name]
|
126
|
+
uri
|
112
127
|
else
|
113
128
|
raise ArgumentError, 'unknown JDBC driver'
|
114
129
|
end
|
@@ -124,6 +139,10 @@ module Mondrian
|
|
124
139
|
'oracle.jdbc.OracleDriver'
|
125
140
|
when 'luciddb'
|
126
141
|
'org.luciddb.jdbc.LucidDbClientDriver'
|
142
|
+
when 'mssql'
|
143
|
+
'net.sourceforge.jtds.jdbc.Driver'
|
144
|
+
when 'sqlserver'
|
145
|
+
'com.microsoft.sqlserver.jdbc.SQLServerDriver'
|
127
146
|
else
|
128
147
|
raise ArgumentError, 'unknown JDBC driver'
|
129
148
|
end
|
data/lib/mondrian/olap/cube.rb
CHANGED
@@ -33,14 +33,14 @@ module Mondrian
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def member(full_name)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
member_by_segments(*segment_names)
|
36
|
+
segment_list = Java::OrgOlap4jMdx::IdentifierNode.parseIdentifier(full_name).getSegmentList
|
37
|
+
raw_member = @raw_cube.lookupMember(segment_list)
|
38
|
+
raw_member && Member.new(raw_member)
|
40
39
|
end
|
41
40
|
|
42
41
|
def member_by_segments(*segment_names)
|
43
|
-
|
42
|
+
segment_list = Java::OrgOlap4jMdx::IdentifierNode.ofNames(*segment_names).getSegmentList
|
43
|
+
raw_member = @raw_cube.lookupMember(segment_list)
|
44
44
|
raw_member && Member.new(raw_member)
|
45
45
|
end
|
46
46
|
end
|
@@ -197,6 +197,10 @@ module Mondrian
|
|
197
197
|
@raw_member.isCalculated
|
198
198
|
end
|
199
199
|
|
200
|
+
def all_member?
|
201
|
+
@raw_member.isAll
|
202
|
+
end
|
203
|
+
|
200
204
|
def drillable?
|
201
205
|
return false if calculated?
|
202
206
|
# @raw_member.getChildMemberCount > 0
|
@@ -210,6 +214,17 @@ module Mondrian
|
|
210
214
|
@raw_member.getDepth
|
211
215
|
end
|
212
216
|
|
217
|
+
def dimension_type
|
218
|
+
case @raw_member.getDimension.getDimensionType
|
219
|
+
when Java::OrgOlap4jMetadata::Dimension::Type::TIME
|
220
|
+
:time
|
221
|
+
when Java::OrgOlap4jMetadata::Dimension::Type::MEASURE
|
222
|
+
:measures
|
223
|
+
else
|
224
|
+
:standard
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
213
228
|
def children
|
214
229
|
@raw_member.getChildMembers.map{|m| Member.new(m)}
|
215
230
|
end
|
data/lib/mondrian/olap/query.rb
CHANGED
@@ -139,6 +139,7 @@ module Mondrian
|
|
139
139
|
if members.empty?
|
140
140
|
@where
|
141
141
|
else
|
142
|
+
@current_set = @where
|
142
143
|
if members.length == 1 && members[0].is_a?(Array)
|
143
144
|
@where.concat(members[0])
|
144
145
|
else
|
@@ -289,6 +290,17 @@ module Mondrian
|
|
289
290
|
end
|
290
291
|
|
291
292
|
def where_to_mdx
|
293
|
+
# generate set MDX expression
|
294
|
+
if @where[0].is_a?(Symbol) ||
|
295
|
+
@where.length > 1 && @where.map{|full_name| extract_dimension_name(full_name)}.uniq.length == 1
|
296
|
+
members_to_mdx(@where)
|
297
|
+
# generate tupple MDX expression
|
298
|
+
else
|
299
|
+
where_to_mdx_tupple
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
def where_to_mdx_tupple
|
292
304
|
mdx = '('
|
293
305
|
mdx << @where.map do |condition|
|
294
306
|
condition
|
@@ -308,6 +320,12 @@ module Mondrian
|
|
308
320
|
"#{value}"
|
309
321
|
end
|
310
322
|
end
|
323
|
+
|
324
|
+
def extract_dimension_name(full_name)
|
325
|
+
if full_name =~ /\A\[([^\]]+)\]/
|
326
|
+
$1
|
327
|
+
end
|
328
|
+
end
|
311
329
|
end
|
312
330
|
end
|
313
331
|
end
|
data/lib/mondrian/olap/schema.rb
CHANGED
@@ -55,7 +55,7 @@ module Mondrian
|
|
55
55
|
:cache,
|
56
56
|
# Whether element is enabled - if true, then the Cube is realized otherwise it is ignored.
|
57
57
|
:enabled
|
58
|
-
elements :table, :dimension, :measure, :calculated_member
|
58
|
+
elements :table, :view, :dimension, :measure, :calculated_member
|
59
59
|
end
|
60
60
|
|
61
61
|
class Table < SchemaElement
|
@@ -65,6 +65,13 @@ module Mondrian
|
|
65
65
|
# (You can use the same table in different hierarchies, but it must have different aliases.)
|
66
66
|
:alias
|
67
67
|
data_dictionary_names :name, :schema, :alias # values in XML will be uppercased when using Oracle driver
|
68
|
+
elements :agg_exclude, :agg_name, :agg_pattern, :sql
|
69
|
+
end
|
70
|
+
|
71
|
+
class View < SchemaElement
|
72
|
+
attributes :alias
|
73
|
+
# Defines a "table" using SQL query which can have different variants for different underlying databases
|
74
|
+
elements :sql
|
68
75
|
end
|
69
76
|
|
70
77
|
class Dimension < SchemaElement
|
@@ -101,7 +108,7 @@ module Mondrian
|
|
101
108
|
# that all members have entirely unique rows, allowing SQL GROUP BY clauses to be completely eliminated from the query.
|
102
109
|
:unique_key_level_name
|
103
110
|
data_dictionary_names :primary_key, :primary_key_table # values in XML will be uppercased when using Oracle driver
|
104
|
-
elements :table, :join, :level
|
111
|
+
elements :table, :join, :property, :level
|
105
112
|
end
|
106
113
|
|
107
114
|
class Join < SchemaElement
|
@@ -156,7 +163,7 @@ module Mondrian
|
|
156
163
|
# Default value: 'Never'
|
157
164
|
:hide_member_if
|
158
165
|
data_dictionary_names :table, :column, :name_column, :ordinal_column, :parent_column # values in XML will be uppercased when using Oracle driver
|
159
|
-
elements :key_expression, :name_expression, :ordinal_expression
|
166
|
+
elements :key_expression, :name_expression, :ordinal_expression, :property
|
160
167
|
end
|
161
168
|
|
162
169
|
class KeyExpression < SchemaElement
|
@@ -179,6 +186,18 @@ module Mondrian
|
|
179
186
|
content :text
|
180
187
|
end
|
181
188
|
|
189
|
+
class Property < SchemaElement
|
190
|
+
attributes :name, :description,
|
191
|
+
:column,
|
192
|
+
# Data type of this property: String, Numeric, Integer, Boolean, Date, Time or Timestamp.
|
193
|
+
:type,
|
194
|
+
# Should be set to true if the value of the property is functionally dependent on the level value.
|
195
|
+
# This permits the associated property column to be omitted from the GROUP BY clause
|
196
|
+
# (if the database permits columns in the SELECT that are not in the GROUP BY).
|
197
|
+
# This can be a significant performance enhancement on some databases, such as MySQL.
|
198
|
+
:depends_on_level_value
|
199
|
+
end
|
200
|
+
|
182
201
|
class Measure < SchemaElement
|
183
202
|
attributes :name, :description,
|
184
203
|
# Column which is source of this measure's values.
|
@@ -192,6 +211,11 @@ module Mondrian
|
|
192
211
|
# Format string with which to format cells of this measure. For more details, see the mondrian.util.Format class.
|
193
212
|
:format_string
|
194
213
|
data_dictionary_names :column # values in XML will be uppercased when using Oracle driver
|
214
|
+
elements :measure_expression
|
215
|
+
end
|
216
|
+
|
217
|
+
class MeasureExpression < SchemaElement
|
218
|
+
elements :sql
|
195
219
|
end
|
196
220
|
|
197
221
|
class CalculatedMember < SchemaElement
|
@@ -216,6 +240,48 @@ module Mondrian
|
|
216
240
|
:value
|
217
241
|
end
|
218
242
|
|
243
|
+
class AggName < SchemaElement
|
244
|
+
attributes :name
|
245
|
+
data_dictionary_names :name
|
246
|
+
elements :agg_fact_count, :agg_measure, :agg_level, :agg_foreign_key
|
247
|
+
end
|
248
|
+
|
249
|
+
class AggFactCount < SchemaElement
|
250
|
+
attributes :column
|
251
|
+
data_dictionary_names :column
|
252
|
+
end
|
253
|
+
|
254
|
+
class AggMeasure < SchemaElement
|
255
|
+
attributes :name, :column
|
256
|
+
data_dictionary_names :column
|
257
|
+
end
|
258
|
+
|
259
|
+
class AggLevel < SchemaElement
|
260
|
+
attributes :name, :column
|
261
|
+
data_dictionary_names :column
|
262
|
+
end
|
263
|
+
|
264
|
+
class AggForeignKey < SchemaElement
|
265
|
+
attributes :fact_column, :agg_column
|
266
|
+
data_dictionary_names :fact_column, :agg_column
|
267
|
+
end
|
268
|
+
|
269
|
+
class AggIgnoreColumn < SchemaElement
|
270
|
+
attributes :column
|
271
|
+
data_dictionary_names :column
|
272
|
+
end
|
273
|
+
|
274
|
+
class AggPattern < SchemaElement
|
275
|
+
attributes :pattern
|
276
|
+
data_dictionary_names :pattern
|
277
|
+
elements :agg_fact_count, :agg_measure, :agg_level, :agg_foreign_key, :agg_exclude
|
278
|
+
end
|
279
|
+
|
280
|
+
class AggExclude < SchemaElement
|
281
|
+
attributes :name, :pattern, :ignorecase
|
282
|
+
data_dictionary_names :name, :pattern
|
283
|
+
end
|
284
|
+
|
219
285
|
end
|
220
286
|
end
|
221
287
|
end
|
@@ -21,6 +21,7 @@ module Mondrian
|
|
21
21
|
self.class.elements.each do |element|
|
22
22
|
instance_variable_set("@#{pluralize(element)}", [])
|
23
23
|
end
|
24
|
+
@xml_fragments = []
|
24
25
|
instance_eval &block if block
|
25
26
|
end
|
26
27
|
|
@@ -67,6 +68,14 @@ module Mondrian
|
|
67
68
|
@content = type
|
68
69
|
end
|
69
70
|
|
71
|
+
attr_reader :xml_fragments
|
72
|
+
def xml(string)
|
73
|
+
string = string.strip
|
74
|
+
fragment = Nokogiri::XML::DocumentFragment.parse(string)
|
75
|
+
raise ArgumentError, "Invalid XML fragment:\n#{string}" if fragment.children.empty?
|
76
|
+
@xml_fragments << string
|
77
|
+
end
|
78
|
+
|
70
79
|
def to_xml(options={})
|
71
80
|
options[:upcase_data_dictionary] = @upcase_data_dictionary unless @upcase_data_dictionary.nil?
|
72
81
|
Nokogiri::XML::Builder.new do |xml|
|
@@ -84,6 +93,9 @@ module Mondrian
|
|
84
93
|
self.class.elements.each do |element|
|
85
94
|
instance_variable_get("@#{pluralize(element)}").each {|item| item.add_to_xml(xml, options)}
|
86
95
|
end
|
96
|
+
@xml_fragments.each do |xml_fragment|
|
97
|
+
xml.send(:insert, Nokogiri::XML::DocumentFragment.parse(xml_fragment))
|
98
|
+
end
|
87
99
|
end
|
88
100
|
end
|
89
101
|
end
|
data/mondrian-olap.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{mondrian-olap}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{2011-
|
11
|
+
s.authors = [%q{Raimonds Simanovskis}]
|
12
|
+
s.date = %q{2011-11-12}
|
13
13
|
s.description = %q{JRuby gem for performing multidimensional queries of relational database data using Mondrian OLAP Java library
|
14
14
|
}
|
15
15
|
s.email = %q{raimonds.simanovskis@gmail.com}
|
@@ -62,8 +62,8 @@ Gem::Specification.new do |s|
|
|
62
62
|
"spec/support/matchers/be_like.rb"
|
63
63
|
]
|
64
64
|
s.homepage = %q{http://github.com/rsim/mondrian-olap}
|
65
|
-
s.require_paths = [
|
66
|
-
s.rubygems_version = %q{1.
|
65
|
+
s.require_paths = [%q{lib}]
|
66
|
+
s.rubygems_version = %q{1.8.9}
|
67
67
|
s.summary = %q{JRuby API for Mondrian OLAP Java library}
|
68
68
|
s.test_files = [
|
69
69
|
"spec/connection_spec.rb",
|
@@ -79,7 +79,7 @@ Gem::Specification.new do |s|
|
|
79
79
|
s.specification_version = 3
|
80
80
|
|
81
81
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
82
|
-
s.add_runtime_dependency(%q<nokogiri>, ["~> 1.5.0
|
82
|
+
s.add_runtime_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
83
83
|
s.add_development_dependency(%q<jruby-openssl>, [">= 0"])
|
84
84
|
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
85
85
|
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
@@ -88,11 +88,12 @@ Gem::Specification.new do |s|
|
|
88
88
|
s.add_development_dependency(%q<jdbc-mysql>, [">= 0"])
|
89
89
|
s.add_development_dependency(%q<jdbc-postgres>, [">= 0"])
|
90
90
|
s.add_development_dependency(%q<jdbc-luciddb>, [">= 0"])
|
91
|
-
s.add_development_dependency(%q<
|
92
|
-
s.add_development_dependency(%q<activerecord
|
91
|
+
s.add_development_dependency(%q<jdbc-jtds>, [">= 0"])
|
92
|
+
s.add_development_dependency(%q<activerecord>, ["= 3.0.10"])
|
93
|
+
s.add_development_dependency(%q<activerecord-jdbc-adapter>, ["= 1.1.1"])
|
93
94
|
s.add_development_dependency(%q<activerecord-oracle_enhanced-adapter>, [">= 0"])
|
94
95
|
else
|
95
|
-
s.add_dependency(%q<nokogiri>, ["~> 1.5.0
|
96
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
96
97
|
s.add_dependency(%q<jruby-openssl>, [">= 0"])
|
97
98
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
98
99
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
@@ -101,12 +102,13 @@ Gem::Specification.new do |s|
|
|
101
102
|
s.add_dependency(%q<jdbc-mysql>, [">= 0"])
|
102
103
|
s.add_dependency(%q<jdbc-postgres>, [">= 0"])
|
103
104
|
s.add_dependency(%q<jdbc-luciddb>, [">= 0"])
|
104
|
-
s.add_dependency(%q<
|
105
|
-
s.add_dependency(%q<activerecord
|
105
|
+
s.add_dependency(%q<jdbc-jtds>, [">= 0"])
|
106
|
+
s.add_dependency(%q<activerecord>, ["= 3.0.10"])
|
107
|
+
s.add_dependency(%q<activerecord-jdbc-adapter>, ["= 1.1.1"])
|
106
108
|
s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, [">= 0"])
|
107
109
|
end
|
108
110
|
else
|
109
|
-
s.add_dependency(%q<nokogiri>, ["~> 1.5.0
|
111
|
+
s.add_dependency(%q<nokogiri>, ["~> 1.5.0"])
|
110
112
|
s.add_dependency(%q<jruby-openssl>, [">= 0"])
|
111
113
|
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
112
114
|
s.add_dependency(%q<rdoc>, [">= 0"])
|
@@ -115,8 +117,9 @@ Gem::Specification.new do |s|
|
|
115
117
|
s.add_dependency(%q<jdbc-mysql>, [">= 0"])
|
116
118
|
s.add_dependency(%q<jdbc-postgres>, [">= 0"])
|
117
119
|
s.add_dependency(%q<jdbc-luciddb>, [">= 0"])
|
118
|
-
s.add_dependency(%q<
|
119
|
-
s.add_dependency(%q<activerecord
|
120
|
+
s.add_dependency(%q<jdbc-jtds>, [">= 0"])
|
121
|
+
s.add_dependency(%q<activerecord>, ["= 3.0.10"])
|
122
|
+
s.add_dependency(%q<activerecord-jdbc-adapter>, ["= 1.1.1"])
|
120
123
|
s.add_dependency(%q<activerecord-oracle_enhanced-adapter>, [">= 0"])
|
121
124
|
end
|
122
125
|
end
|
data/spec/cube_spec.rb
CHANGED
@@ -254,6 +254,26 @@ describe "Cube" do
|
|
254
254
|
@cube.member('[Customers].[USA]').should_not be_calculated
|
255
255
|
end
|
256
256
|
|
257
|
+
it "should be all member when member is all member" do
|
258
|
+
@cube.member('[Customers].[All Customers]').should be_all_member
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should not be all member when member is not all member" do
|
262
|
+
@cube.member('[Customers].[USA]').should_not be_all_member
|
263
|
+
end
|
264
|
+
|
265
|
+
it "should get dimension type of standard dimension member" do
|
266
|
+
@cube.member('[Customers].[USA]').dimension_type.should == :standard
|
267
|
+
end
|
268
|
+
|
269
|
+
it "should get dimension type of measure" do
|
270
|
+
@cube.member('[Measures].[Unit Sales]').dimension_type.should == :measures
|
271
|
+
end
|
272
|
+
|
273
|
+
it "should get dimension type of time dimension member" do
|
274
|
+
@cube.member('[Time].[2011]').dimension_type.should == :time
|
275
|
+
end
|
276
|
+
|
257
277
|
end
|
258
278
|
|
259
279
|
end
|
data/spec/query_spec.rb
CHANGED
@@ -278,6 +278,11 @@ describe "Query" do
|
|
278
278
|
@query.where('[Time].[2010].[Q1]').where('[Customers].[USA].[CA]')
|
279
279
|
@query.where.should == ['[Time].[2010].[Q1]', '[Customers].[USA].[CA]']
|
280
280
|
end
|
281
|
+
|
282
|
+
it "should do crossjoin of where conditions" do
|
283
|
+
@query.where('[Customers].[USA]').crossjoin('[Time].[2011].[Q1]', '[Time].[2011].[Q2]')
|
284
|
+
@query.where.should == [:crossjoin, ['[Customers].[USA]'], ['[Time].[2011].[Q1]', '[Time].[2011].[Q2]']]
|
285
|
+
end
|
281
286
|
end
|
282
287
|
|
283
288
|
describe "with member" do
|
@@ -375,6 +380,30 @@ describe "Query" do
|
|
375
380
|
SQL
|
376
381
|
end
|
377
382
|
|
383
|
+
it "should return query with where with several same dimension members" do
|
384
|
+
@query.columns('[Measures].[Unit Sales]', '[Measures].[Store Sales]').
|
385
|
+
rows('[Product].children').
|
386
|
+
where('[Customers].[Canada]', '[Customers].[USA]').
|
387
|
+
to_mdx.should be_like <<-SQL
|
388
|
+
SELECT {[Measures].[Unit Sales], [Measures].[Store Sales]} ON COLUMNS,
|
389
|
+
[Product].children ON ROWS
|
390
|
+
FROM [Sales]
|
391
|
+
WHERE {[Customers].[Canada], [Customers].[USA]}
|
392
|
+
SQL
|
393
|
+
end
|
394
|
+
|
395
|
+
it "should return query with where with crossjoin" do
|
396
|
+
@query.columns('[Measures].[Unit Sales]', '[Measures].[Store Sales]').
|
397
|
+
rows('[Product].children').
|
398
|
+
where('[Customers].[USA]').crossjoin('[Time].[2011].[Q1]', '[Time].[2011].[Q2]').
|
399
|
+
to_mdx.should be_like <<-SQL
|
400
|
+
SELECT {[Measures].[Unit Sales], [Measures].[Store Sales]} ON COLUMNS,
|
401
|
+
[Product].children ON ROWS
|
402
|
+
FROM [Sales]
|
403
|
+
WHERE CROSSJOIN([Customers].[USA], {[Time].[2011].[Q1], [Time].[2011].[Q2]})
|
404
|
+
SQL
|
405
|
+
end
|
406
|
+
|
378
407
|
it "should return query with order by one measure" do
|
379
408
|
@query.columns('[Measures].[Unit Sales]', '[Measures].[Store Sales]').
|
380
409
|
rows('[Product].children').order('[Measures].[Unit Sales]', :bdesc).
|
data/spec/rake_tasks.rb
CHANGED
@@ -242,7 +242,7 @@ namespace :db do
|
|
242
242
|
end
|
243
243
|
|
244
244
|
namespace :spec do
|
245
|
-
%w(mysql postgresql oracle luciddb).each do |driver|
|
245
|
+
%w(mysql postgresql oracle luciddb mssql sqlserver).each do |driver|
|
246
246
|
desc "Run specs with #{driver} driver"
|
247
247
|
task driver do
|
248
248
|
ENV['MONDRIAN_DRIVER'] = driver
|
@@ -253,7 +253,7 @@ namespace :spec do
|
|
253
253
|
|
254
254
|
desc "Run specs with all database drivers"
|
255
255
|
task :all do
|
256
|
-
%w(mysql postgresql oracle luciddb).each do |driver|
|
256
|
+
%w(mysql postgresql oracle luciddb mssql sqlserver).each do |driver|
|
257
257
|
Rake::Task["spec:#{driver}"].invoke
|
258
258
|
end
|
259
259
|
end
|
@@ -134,6 +134,48 @@ describe "Schema definition" do
|
|
134
134
|
XML
|
135
135
|
end
|
136
136
|
end
|
137
|
+
|
138
|
+
it "should render table with where condition" do
|
139
|
+
@schema.define do
|
140
|
+
cube 'Sales' do
|
141
|
+
table 'sales_fact', :alias => 'sales' do
|
142
|
+
sql 'customer_id IS NOT NULL'
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
@schema.to_xml.should be_like <<-XML
|
147
|
+
<?xml version="1.0"?>
|
148
|
+
<Schema name="default">
|
149
|
+
<Cube name="Sales">
|
150
|
+
<Table alias="sales" name="sales_fact">
|
151
|
+
<SQL>customer_id IS NOT NULL</SQL>
|
152
|
+
</Table>
|
153
|
+
</Cube>
|
154
|
+
</Schema>
|
155
|
+
XML
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
describe "View" do
|
160
|
+
it "should render to XML" do
|
161
|
+
@schema.define do
|
162
|
+
cube 'Sales' do
|
163
|
+
view :alias => 'sales' do
|
164
|
+
sql 'select * from sales_fact'
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
@schema.to_xml.should be_like <<-XML
|
169
|
+
<?xml version="1.0"?>
|
170
|
+
<Schema name="default">
|
171
|
+
<Cube name="Sales">
|
172
|
+
<View alias="sales">
|
173
|
+
<SQL>select * from sales_fact</SQL>
|
174
|
+
</View>
|
175
|
+
</Cube>
|
176
|
+
</Schema>
|
177
|
+
XML
|
178
|
+
end
|
137
179
|
end
|
138
180
|
|
139
181
|
describe "Dimension" do
|
@@ -314,6 +356,30 @@ describe "Schema definition" do
|
|
314
356
|
</Schema>
|
315
357
|
XML
|
316
358
|
end
|
359
|
+
|
360
|
+
it "should render with measure expression" do
|
361
|
+
@schema.define do
|
362
|
+
cube 'Sales' do
|
363
|
+
measure 'Double Unit Sales', :aggregator => 'sum' do
|
364
|
+
measure_expression do
|
365
|
+
sql 'unit_sales * 2'
|
366
|
+
end
|
367
|
+
end
|
368
|
+
end
|
369
|
+
end
|
370
|
+
@schema.to_xml.should be_like <<-XML
|
371
|
+
<?xml version="1.0"?>
|
372
|
+
<Schema name="default">
|
373
|
+
<Cube name="Sales">
|
374
|
+
<Measure aggregator="sum" name="Double Unit Sales">
|
375
|
+
<MeasureExpression>
|
376
|
+
<SQL>unit_sales * 2</SQL>
|
377
|
+
</MeasureExpression>
|
378
|
+
</Measure>
|
379
|
+
</Cube>
|
380
|
+
</Schema>
|
381
|
+
XML
|
382
|
+
end
|
317
383
|
end
|
318
384
|
|
319
385
|
describe "Calculated Member" do
|
@@ -339,6 +405,195 @@ describe "Schema definition" do
|
|
339
405
|
XML
|
340
406
|
end
|
341
407
|
end
|
408
|
+
|
409
|
+
describe "Aggregates" do
|
410
|
+
it "should render named aggregate to XML" do
|
411
|
+
@schema.define do
|
412
|
+
cube 'Sales' do
|
413
|
+
table 'sales_fact_1997' do
|
414
|
+
agg_name 'agg_c_special_sales_fact_1997' do
|
415
|
+
agg_fact_count :column => 'fact_count'
|
416
|
+
agg_measure '[Measures].[Store Cost]', :column => 'store_cost_sum'
|
417
|
+
agg_measure '[Measures].[Store Sales]', :column => 'store_sales_sum'
|
418
|
+
agg_level '[Product].[Product Family]', :column => 'product_family'
|
419
|
+
agg_level '[Time].[Quarter]', :column => 'time_quarter'
|
420
|
+
agg_level '[Time].[Year]', :column => 'time_year'
|
421
|
+
agg_level '[Time].[Quarter]', :column => 'time_quarter'
|
422
|
+
agg_level '[Time].[Month]', :column => 'time_month'
|
423
|
+
end
|
424
|
+
end
|
425
|
+
end
|
426
|
+
end
|
427
|
+
@schema.to_xml.should be_like <<-XML
|
428
|
+
<?xml version="1.0"?>
|
429
|
+
<Schema name="default">
|
430
|
+
<Cube name="Sales">
|
431
|
+
<Table name="sales_fact_1997">
|
432
|
+
<AggName name="agg_c_special_sales_fact_1997">
|
433
|
+
<AggFactCount column="fact_count"/>
|
434
|
+
<AggMeasure column="store_cost_sum" name="[Measures].[Store Cost]"/>
|
435
|
+
<AggMeasure column="store_sales_sum" name="[Measures].[Store Sales]"/>
|
436
|
+
<AggLevel column="product_family" name="[Product].[Product Family]"/>
|
437
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
438
|
+
<AggLevel column="time_year" name="[Time].[Year]"/>
|
439
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
440
|
+
<AggLevel column="time_month" name="[Time].[Month]"/>
|
441
|
+
</AggName>
|
442
|
+
</Table>
|
443
|
+
</Cube>
|
444
|
+
</Schema>
|
445
|
+
XML
|
446
|
+
end
|
447
|
+
|
448
|
+
it "should render aggregate pattern to XML" do
|
449
|
+
@schema.define do
|
450
|
+
cube 'Sales' do
|
451
|
+
table 'sales_fact_1997' do
|
452
|
+
agg_pattern :pattern => 'agg_.*_sales_fact_1997' do
|
453
|
+
agg_fact_count :column => 'fact_count'
|
454
|
+
agg_measure '[Measures].[Store Cost]', :column => 'store_cost_sum'
|
455
|
+
agg_measure '[Measures].[Store Sales]', :column => 'store_sales_sum'
|
456
|
+
agg_level '[Product].[Product Family]', :column => 'product_family'
|
457
|
+
agg_level '[Time].[Quarter]', :column => 'time_quarter'
|
458
|
+
agg_level '[Time].[Year]', :column => 'time_year'
|
459
|
+
agg_level '[Time].[Quarter]', :column => 'time_quarter'
|
460
|
+
agg_level '[Time].[Month]', :column => 'time_month'
|
461
|
+
agg_exclude 'agg_c_14_sales_fact_1997'
|
462
|
+
agg_exclude 'agg_lc_100_sales_fact_1997'
|
463
|
+
end
|
464
|
+
end
|
465
|
+
end
|
466
|
+
end
|
467
|
+
@schema.to_xml.should be_like <<-XML
|
468
|
+
<?xml version="1.0"?>
|
469
|
+
<Schema name="default">
|
470
|
+
<Cube name="Sales">
|
471
|
+
<Table name="sales_fact_1997">
|
472
|
+
<AggPattern pattern="agg_.*_sales_fact_1997">
|
473
|
+
<AggFactCount column="fact_count"/>
|
474
|
+
<AggMeasure column="store_cost_sum" name="[Measures].[Store Cost]"/>
|
475
|
+
<AggMeasure column="store_sales_sum" name="[Measures].[Store Sales]"/>
|
476
|
+
<AggLevel column="product_family" name="[Product].[Product Family]"/>
|
477
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
478
|
+
<AggLevel column="time_year" name="[Time].[Year]"/>
|
479
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
480
|
+
<AggLevel column="time_month" name="[Time].[Month]"/>
|
481
|
+
<AggExclude name="agg_c_14_sales_fact_1997"/>
|
482
|
+
<AggExclude name="agg_lc_100_sales_fact_1997"/>
|
483
|
+
</AggPattern>
|
484
|
+
</Table>
|
485
|
+
</Cube>
|
486
|
+
</Schema>
|
487
|
+
XML
|
488
|
+
end
|
489
|
+
|
490
|
+
it "should render embedded aggregate XML defintion to XML" do
|
491
|
+
@schema.define do
|
492
|
+
cube 'Sales' do
|
493
|
+
table 'sales_fact_1997' do
|
494
|
+
xml <<-XML
|
495
|
+
<AggName name="agg_c_special_sales_fact_1997">
|
496
|
+
<AggFactCount column="fact_count"/>
|
497
|
+
<AggMeasure column="store_cost_sum" name="[Measures].[Store Cost]"/>
|
498
|
+
<AggMeasure column="store_sales_sum" name="[Measures].[Store Sales]"/>
|
499
|
+
<AggLevel column="product_family" name="[Product].[Product Family]"/>
|
500
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
501
|
+
<AggLevel column="time_year" name="[Time].[Year]"/>
|
502
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
503
|
+
<AggLevel column="time_month" name="[Time].[Month]"/>
|
504
|
+
</AggName>
|
505
|
+
<AggPattern pattern="agg_.*_sales_fact_1997">
|
506
|
+
<AggFactCount column="fact_count"/>
|
507
|
+
<AggMeasure column="store_cost_sum" name="[Measures].[Store Cost]"/>
|
508
|
+
<AggMeasure column="store_sales_sum" name="[Measures].[Store Sales]"/>
|
509
|
+
<AggLevel column="product_family" name="[Product].[Product Family]"/>
|
510
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
511
|
+
<AggLevel column="time_year" name="[Time].[Year]"/>
|
512
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
513
|
+
<AggLevel column="time_month" name="[Time].[Month]"/>
|
514
|
+
<AggExclude name="agg_c_14_sales_fact_1997"/>
|
515
|
+
<AggExclude name="agg_lc_100_sales_fact_1997"/>
|
516
|
+
</AggPattern>
|
517
|
+
XML
|
518
|
+
end
|
519
|
+
end
|
520
|
+
end
|
521
|
+
@schema.to_xml.should be_like <<-XML
|
522
|
+
<?xml version="1.0"?>
|
523
|
+
<Schema name="default">
|
524
|
+
<Cube name="Sales">
|
525
|
+
<Table name="sales_fact_1997">
|
526
|
+
<AggName name="agg_c_special_sales_fact_1997">
|
527
|
+
<AggFactCount column="fact_count"/>
|
528
|
+
<AggMeasure column="store_cost_sum" name="[Measures].[Store Cost]"/>
|
529
|
+
<AggMeasure column="store_sales_sum" name="[Measures].[Store Sales]"/>
|
530
|
+
<AggLevel column="product_family" name="[Product].[Product Family]"/>
|
531
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
532
|
+
<AggLevel column="time_year" name="[Time].[Year]"/>
|
533
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
534
|
+
<AggLevel column="time_month" name="[Time].[Month]"/>
|
535
|
+
</AggName>
|
536
|
+
<AggPattern pattern="agg_.*_sales_fact_1997">
|
537
|
+
<AggFactCount column="fact_count"/>
|
538
|
+
<AggMeasure column="store_cost_sum" name="[Measures].[Store Cost]"/>
|
539
|
+
<AggMeasure column="store_sales_sum" name="[Measures].[Store Sales]"/>
|
540
|
+
<AggLevel column="product_family" name="[Product].[Product Family]"/>
|
541
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
542
|
+
<AggLevel column="time_year" name="[Time].[Year]"/>
|
543
|
+
<AggLevel column="time_quarter" name="[Time].[Quarter]"/>
|
544
|
+
<AggLevel column="time_month" name="[Time].[Month]"/>
|
545
|
+
<AggExclude name="agg_c_14_sales_fact_1997"/>
|
546
|
+
<AggExclude name="agg_lc_100_sales_fact_1997"/>
|
547
|
+
</AggPattern>
|
548
|
+
</Table>
|
549
|
+
</Cube>
|
550
|
+
</Schema>
|
551
|
+
XML
|
552
|
+
end
|
553
|
+
|
554
|
+
end
|
555
|
+
|
556
|
+
describe "Member properties" do
|
557
|
+
it "should render XML" do
|
558
|
+
@schema.define do
|
559
|
+
cube 'Sales' do
|
560
|
+
dimension 'Employees', :foreign_key => 'employee_id' do
|
561
|
+
hierarchy :has_all => true, :all_member_name => 'All Employees', :primary_key => 'employee_id' do
|
562
|
+
table 'employee'
|
563
|
+
level 'Employee Id', :unique_members => true, :type => 'Numeric', :column => 'employee_id', :name_column => 'full_name',
|
564
|
+
:parent_column => 'supervisor_id', :null_parent_value => 0 do
|
565
|
+
property 'Marital Status', :column => 'marital_status'
|
566
|
+
property 'Position Title', :column => 'position_title'
|
567
|
+
property 'Gender', :column => 'gender'
|
568
|
+
property 'Salary', :column => 'salary'
|
569
|
+
property 'Education Level', :column => 'education_level'
|
570
|
+
end
|
571
|
+
end
|
572
|
+
end
|
573
|
+
end
|
574
|
+
end
|
575
|
+
@schema.to_xml.should be_like <<-XML
|
576
|
+
<?xml version="1.0"?>
|
577
|
+
<Schema name="default">
|
578
|
+
<Cube name="Sales">
|
579
|
+
<Dimension foreignKey="employee_id" name="Employees">
|
580
|
+
<Hierarchy allMemberName="All Employees" hasAll="true" primaryKey="employee_id">
|
581
|
+
<Table name="employee"/>
|
582
|
+
<Level column="employee_id" name="Employee Id" nameColumn="full_name" nullParentValue="0" parentColumn="supervisor_id" type="Numeric" uniqueMembers="true">
|
583
|
+
<Property column="marital_status" name="Marital Status"/>
|
584
|
+
<Property column="position_title" name="Position Title"/>
|
585
|
+
<Property column="gender" name="Gender"/>
|
586
|
+
<Property column="salary" name="Salary"/>
|
587
|
+
<Property column="education_level" name="Education Level"/>
|
588
|
+
</Level>
|
589
|
+
</Hierarchy>
|
590
|
+
</Dimension>
|
591
|
+
</Cube>
|
592
|
+
</Schema>
|
593
|
+
XML
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
342
597
|
end
|
343
598
|
|
344
599
|
describe "connection with schema" do
|
data/spec/spec_helper.rb
CHANGED
@@ -7,25 +7,33 @@ $:.unshift(File.dirname(__FILE__) + '/../lib')
|
|
7
7
|
require 'rspec'
|
8
8
|
require 'active_record'
|
9
9
|
|
10
|
-
DATABASE_HOST
|
11
|
-
DATABASE_USER
|
10
|
+
DATABASE_HOST = ENV['DATABASE_HOST'] || 'localhost'
|
11
|
+
DATABASE_USER = ENV['DATABASE_USER'] || 'mondrian_test'
|
12
12
|
DATABASE_PASSWORD = ENV['DATABASE_PASSWORD'] || 'mondrian_test'
|
13
|
+
DATABASE_NAME = ENV['DATABASE_NAME'] || 'mondrian_test'
|
14
|
+
DATABASE_INSTANCE = ENV['DATABASE_INSTANCE']
|
15
|
+
MONDRIAN_DRIVER = ENV['MONDRIAN_DRIVER'] || 'mysql'
|
13
16
|
|
14
|
-
case MONDRIAN_DRIVER
|
17
|
+
case MONDRIAN_DRIVER
|
15
18
|
when 'mysql'
|
16
19
|
require 'jdbc/mysql'
|
17
20
|
JDBC_DRIVER = 'com.mysql.jdbc.Driver'
|
18
|
-
DATABASE_NAME = ENV['DATABASE_NAME'] || 'mondrian_test'
|
19
21
|
when 'postgresql'
|
20
22
|
require 'jdbc/postgres'
|
21
23
|
JDBC_DRIVER = 'org.postgresql.Driver'
|
22
|
-
DATABASE_NAME = ENV['DATABASE_NAME'] || 'mondrian_test'
|
23
24
|
when 'oracle'
|
24
25
|
require 'active_record/connection_adapters/oracle_enhanced_adapter'
|
25
26
|
DATABASE_NAME = ENV['DATABASE_NAME'] || 'orcl'
|
27
|
+
CATALOG_FILE = File.expand_path('../fixtures/MondrianTestOracle.xml', __FILE__)
|
28
|
+
when 'mssql'
|
29
|
+
require 'jdbc/jtds'
|
30
|
+
JDBC_DRIVER = 'net.sourceforge.jtds.jdbc.Driver'
|
31
|
+
when 'sqlserver'
|
32
|
+
JDBC_DRIVER = 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
|
26
33
|
when 'luciddb'
|
27
34
|
require 'jdbc/luciddb'
|
28
|
-
|
35
|
+
CATALOG_FILE = File.expand_path('../fixtures/MondrianTestOracle.xml', __FILE__)
|
36
|
+
|
29
37
|
# Hack to disable :text type for LucidDB
|
30
38
|
require 'arjdbc/jdbc/type_converter'
|
31
39
|
ActiveRecord::ConnectionAdapters::JdbcTypeConverter::AR_TO_JDBC_TYPES.delete(:text)
|
@@ -56,51 +64,71 @@ end
|
|
56
64
|
puts "==> Using #{MONDRIAN_DRIVER} driver"
|
57
65
|
|
58
66
|
require 'mondrian/olap'
|
59
|
-
|
60
67
|
require 'support/matchers/be_like'
|
61
68
|
|
62
69
|
RSpec.configure do |config|
|
63
70
|
config.include Matchers
|
64
71
|
end
|
65
72
|
|
73
|
+
CATALOG_FILE = File.expand_path('../fixtures/MondrianTest.xml', __FILE__) unless defined?(CATALOG_FILE)
|
74
|
+
|
66
75
|
CONNECTION_PARAMS = {
|
67
|
-
:driver
|
68
|
-
:host
|
76
|
+
:driver => MONDRIAN_DRIVER,
|
77
|
+
:host => DATABASE_HOST,
|
69
78
|
:database => DATABASE_NAME,
|
70
79
|
:username => DATABASE_USER,
|
71
80
|
:password => DATABASE_PASSWORD
|
72
81
|
}
|
73
82
|
|
74
|
-
|
75
|
-
|
83
|
+
case MONDRIAN_DRIVER
|
84
|
+
when 'oracle'
|
76
85
|
AR_CONNECTION_PARAMS = {
|
77
|
-
:adapter
|
78
|
-
:host
|
86
|
+
:adapter => 'oracle_enhanced',
|
87
|
+
:host => CONNECTION_PARAMS[:host],
|
79
88
|
:database => CONNECTION_PARAMS[:database],
|
80
89
|
:username => CONNECTION_PARAMS[:username],
|
81
90
|
:password => CONNECTION_PARAMS[:password]
|
82
91
|
}
|
83
|
-
|
84
|
-
CATALOG_FILE = File.expand_path('../fixtures/MondrianTestOracle.xml', __FILE__)
|
92
|
+
when 'luciddb'
|
85
93
|
CONNECTION_PARAMS[:database] = nil
|
86
94
|
CONNECTION_PARAMS[:database_schema] = DATABASE_SCHEMA
|
87
95
|
AR_CONNECTION_PARAMS = {
|
88
|
-
:adapter
|
89
|
-
:driver
|
90
|
-
:url
|
96
|
+
:adapter => 'jdbc',
|
97
|
+
:driver => JDBC_DRIVER,
|
98
|
+
:url => "jdbc:#{MONDRIAN_DRIVER}:http://#{CONNECTION_PARAMS[:host]};schema=#{CONNECTION_PARAMS[:database_schema]}",
|
99
|
+
:username => CONNECTION_PARAMS[:username],
|
100
|
+
:password => CONNECTION_PARAMS[:password]
|
101
|
+
}
|
102
|
+
when 'mssql'
|
103
|
+
url = "jdbc:jtds:sqlserver://#{CONNECTION_PARAMS[:host]}/#{CONNECTION_PARAMS[:database]}"
|
104
|
+
url << ";instance=#{DATABASE_INSTANCE}" if DATABASE_INSTANCE
|
105
|
+
AR_CONNECTION_PARAMS = {
|
106
|
+
:adapter => 'jdbc',
|
107
|
+
:driver => JDBC_DRIVER,
|
108
|
+
:url => url,
|
109
|
+
:username => CONNECTION_PARAMS[:username],
|
110
|
+
:password => CONNECTION_PARAMS[:password]
|
111
|
+
}
|
112
|
+
when 'sqlserver'
|
113
|
+
url = "jdbc:sqlserver://#{CONNECTION_PARAMS[:host]};databaseName=#{CONNECTION_PARAMS[:database]};"
|
114
|
+
url << ";instanceName=#{DATABASE_INSTANCE}" if DATABASE_INSTANCE
|
115
|
+
AR_CONNECTION_PARAMS = {
|
116
|
+
:adapter => 'jdbc',
|
117
|
+
:driver => JDBC_DRIVER,
|
118
|
+
:url => url,
|
91
119
|
:username => CONNECTION_PARAMS[:username],
|
92
120
|
:password => CONNECTION_PARAMS[:password]
|
93
121
|
}
|
94
122
|
else
|
95
|
-
CATALOG_FILE = File.expand_path('../fixtures/MondrianTest.xml', __FILE__)
|
96
123
|
AR_CONNECTION_PARAMS = {
|
97
|
-
:adapter
|
98
|
-
:driver
|
99
|
-
:url
|
124
|
+
:adapter => 'jdbc',
|
125
|
+
:driver => JDBC_DRIVER,
|
126
|
+
:url => "jdbc:#{MONDRIAN_DRIVER}://#{CONNECTION_PARAMS[:host]}/#{CONNECTION_PARAMS[:database]}",
|
100
127
|
:username => CONNECTION_PARAMS[:username],
|
101
128
|
:password => CONNECTION_PARAMS[:password]
|
102
129
|
}
|
103
130
|
end
|
131
|
+
|
104
132
|
CONNECTION_PARAMS_WITH_CATALOG = CONNECTION_PARAMS.merge(:catalog => CATALOG_FILE)
|
105
133
|
|
106
134
|
ActiveRecord::Base.establish_connection(AR_CONNECTION_PARAMS)
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: mondrian-olap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 0.3.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Raimonds Simanovskis
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-11-12 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: nokogiri
|
@@ -20,7 +19,7 @@ dependencies:
|
|
20
19
|
requirements:
|
21
20
|
- - ~>
|
22
21
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.5.0
|
22
|
+
version: 1.5.0
|
24
23
|
requirement: *id001
|
25
24
|
prerelease: false
|
26
25
|
type: :runtime
|
@@ -113,36 +112,47 @@ dependencies:
|
|
113
112
|
prerelease: false
|
114
113
|
type: :development
|
115
114
|
- !ruby/object:Gem::Dependency
|
116
|
-
name:
|
115
|
+
name: jdbc-jtds
|
117
116
|
version_requirements: &id010 !ruby/object:Gem::Requirement
|
118
117
|
none: false
|
119
118
|
requirements:
|
120
|
-
- -
|
119
|
+
- - ">="
|
121
120
|
- !ruby/object:Gem::Version
|
122
|
-
version:
|
121
|
+
version: "0"
|
123
122
|
requirement: *id010
|
124
123
|
prerelease: false
|
125
124
|
type: :development
|
126
125
|
- !ruby/object:Gem::Dependency
|
127
|
-
name: activerecord
|
126
|
+
name: activerecord
|
128
127
|
version_requirements: &id011 !ruby/object:Gem::Requirement
|
129
128
|
none: false
|
130
129
|
requirements:
|
131
|
-
- - "
|
130
|
+
- - "="
|
132
131
|
- !ruby/object:Gem::Version
|
133
|
-
version:
|
132
|
+
version: 3.0.10
|
134
133
|
requirement: *id011
|
135
134
|
prerelease: false
|
136
135
|
type: :development
|
137
136
|
- !ruby/object:Gem::Dependency
|
138
|
-
name: activerecord-
|
137
|
+
name: activerecord-jdbc-adapter
|
139
138
|
version_requirements: &id012 !ruby/object:Gem::Requirement
|
139
|
+
none: false
|
140
|
+
requirements:
|
141
|
+
- - "="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 1.1.1
|
144
|
+
requirement: *id012
|
145
|
+
prerelease: false
|
146
|
+
type: :development
|
147
|
+
- !ruby/object:Gem::Dependency
|
148
|
+
name: activerecord-oracle_enhanced-adapter
|
149
|
+
version_requirements: &id013 !ruby/object:Gem::Requirement
|
140
150
|
none: false
|
141
151
|
requirements:
|
142
152
|
- - ">="
|
143
153
|
- !ruby/object:Gem::Version
|
144
154
|
version: "0"
|
145
|
-
requirement: *
|
155
|
+
requirement: *id013
|
146
156
|
prerelease: false
|
147
157
|
type: :development
|
148
158
|
description: |
|
@@ -199,7 +209,6 @@ files:
|
|
199
209
|
- spec/schema_definition_spec.rb
|
200
210
|
- spec/spec_helper.rb
|
201
211
|
- spec/support/matchers/be_like.rb
|
202
|
-
has_rdoc: true
|
203
212
|
homepage: http://github.com/rsim/mondrian-olap
|
204
213
|
licenses: []
|
205
214
|
|
@@ -226,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
235
|
requirements: []
|
227
236
|
|
228
237
|
rubyforge_project:
|
229
|
-
rubygems_version: 1.
|
238
|
+
rubygems_version: 1.8.9
|
230
239
|
signing_key:
|
231
240
|
specification_version: 3
|
232
241
|
summary: JRuby API for Mondrian OLAP Java library
|