Module: Mondrian::REST::APIHelpers
- Defined in:
- lib/mondrian_rest/api_helpers.rb
Constant Summary collapse
- @@olap =
nil- @@mdx_parser =
nil
Instance Method Summary collapse
- #get_cube_or_404(name) ⇒ Object
- #mdx(query) ⇒ Object
-
#mdx_parser ⇒ Object
Returns an instance of org.olap4j.mdx.parser.MdxParser.
- #olap ⇒ Object
- #olap_flush ⇒ Object
Instance Method Details
#get_cube_or_404(name) ⇒ Object
33 34 35 36 37 |
# File 'lib/mondrian_rest/api_helpers.rb', line 33 def get_cube_or_404(name) cube = olap.cube(name) error!('Not found', 404) if cube.nil? cube end |
#mdx(query) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/mondrian_rest/api_helpers.rb', line 39 def mdx(query) logger.info("Executing MDX query #{query}") begin result = olap.execute query return result rescue Mondrian::OLAP::Error => st error!({error: st.backtrace}, 400) end end |
#mdx_parser ⇒ Object
Returns an instance of org.olap4j.mdx.parser.MdxParser
17 18 19 20 21 22 23 |
# File 'lib/mondrian_rest/api_helpers.rb', line 17 def mdx_parser if @@mdx_parser.nil? @@mdx_parser = olap.raw_connection.getParserFactory .createMdxParser(olap.raw_connection) end @@mdx_parser end |
#olap ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/mondrian_rest/api_helpers.rb', line 7 def olap if @@olap.nil? @@olap = Mondrian::OLAP::Connection.new(env['mondrian-olap.params']) @@olap.connect end @@olap end |
#olap_flush ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/mondrian_rest/api_helpers.rb', line 25 def olap_flush if olap.connected? olap.flush_schema_cache olap.close end olap.connect end |