Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions lib/mondrian_rest/api_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ class PropertyError < StandardError
end

module APIHelpers
@@olap = nil
@@olap = nil # env['mondrian-olap.conn']
@@mdx_parser = nil

def olap
if @@olap.nil?
@@olap = Mondrian::OLAP::Connection.new(env['mondrian-olap.params'])
@@olap.connect
raise 'Please create mondrian connection and .connect in config.ru'
end
@@olap
end
Expand All @@ -19,22 +18,21 @@ def olap
# Returns an instance of org.olap4j.mdx.parser.MdxParser
def mdx_parser
if @@mdx_parser.nil?
@@mdx_parser = olap.raw_connection.getParserFactory
.createMdxParser(olap.raw_connection)
raise 'Please create mondrian mdx parser'
end
@@mdx_parser
end

def olap_flush
if olap.connected?
olap.flush_schema_cache
olap.close
if @@olap.connected?
@@olap.flush_schema_cache
@@olap.close
end
olap.connect
@@olap.connect
end

def get_cube_or_404(name)
cube = olap.cube(name)
cube = @@olap.cube(name)
error!('Not found', 404) if cube.nil?
cube
end
Expand Down