mondrian-rest 0.7.6-java → 0.7.7-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c13350ac3161dc2031518bc8a859f51d0bcff0165677b5a6c9017ab3a9d275c9
4
- data.tar.gz: e008ffd131647f8b9ae31573904d2dae12054cd7b329cfa56db03017da8c9736
3
+ metadata.gz: 24a3d3f8c5d0384eb3fdea6de63ddc4e14eec9ba9154792538271e278accb967
4
+ data.tar.gz: 4c022c15f4f841119e29729258600791fa6999e7134bf4488d97fbd146c2a66f
5
5
  SHA512:
6
- metadata.gz: 6ae80147fddcfdd6dc9df363708b913858c382e7efcf8f261e9671559625bd0d00200574a5dad0ed01d115935a9c6aa1977502cc6364a0e79173aaedea019b5f
7
- data.tar.gz: d58de20609080395e1a7773a0b203d78c5f1d77b6c4d073111a9c89cfa697ac9cc7f81263cbe1c558e711807cd1ac3bae0e32e76a17c45e1c6c7fc0c91efb32d
6
+ metadata.gz: 366ce7c3500be274b4348b200c84d9fa0c7461475bd5121f563b6875fc7641ae5f5765f6edfb7022067979d10f9d66e3333d0f428135a05591e1611f136431d9
7
+ data.tar.gz: 6e669fe42ef9e7e3bf44c0b5ae547e1d350ee3c5226dfb439eb833373cc171ed6372a0bd9731a6794b6492f6d14d2886d896ad3f4b4033901705fe3100e78693
@@ -1,3 +1,4 @@
1
+ require 'java'
1
2
  require 'uri'
2
3
 
3
4
  require_relative './api_helpers.rb'
@@ -139,6 +140,7 @@ module Mondrian::REST
139
140
  optional :cut, type: Array, desc: "Specification of slicer axis"
140
141
  optional :drilldown, type: Array, desc: "Dimension(s) to be drilled down"
141
142
  optional :nonempty, type: Boolean, desc: "Only return non empty cells"
143
+ optional :sparse, type: Boolean, desc: "Skip rows where all measures are null (only applies to CSV, XLS and JSONRECORDS)", default: !java.lang.System.getProperty('mondrian-rest.sparseDefault').nil?
142
144
  optional :distinct, type: Boolean, desc: "Apply DISTINCT() to every axis"
143
145
  optional :parents, type: Boolean, desc: "Include members' ancestors"
144
146
  optional :debug, type: Boolean, desc: "Include generated MDX", default: false
@@ -166,7 +168,7 @@ module Mondrian::REST
166
168
  get do
167
169
  cube = get_cube_or_404(params[:cube_name])
168
170
  dimension = cube.dimension(params[:dimension_name])
169
- dimension.to_h
171
+ dimension.to_h(get_members: true)
170
172
  end
171
173
 
172
174
  resource :levels do
@@ -16,6 +16,7 @@ module Mondrian::REST::Formatters
16
16
 
17
17
  add_parents = options[:add_parents]
18
18
  properties = options[:properties]
19
+ sparse = options[:sparse]
19
20
  rs = result.to_h(add_parents, options[:debug])
20
21
 
21
22
  if rs[:values].empty?
@@ -71,6 +72,8 @@ module Mondrian::REST::Formatters
71
72
  (cidxs + [mi]).reduce(values) { |_, idx| _[idx] }
72
73
  }
73
74
 
75
+ next if sparse && msrs.all?(&:nil?)
76
+
74
77
  if add_parents
75
78
  vdim = cm.each.with_index.reduce([]) { |cnames, (member, j)|
76
79
  member[:ancestors][0...slices[j] - (level_has_all[j] ? 1 : 0)].reverse.each { |ancestor|
@@ -1,8 +1,9 @@
1
1
  module Mondrian::REST::Formatters
2
2
  module AggregationJSON
3
3
  def self.call(result, env)
4
- add_parents = env['rack.request.query_hash']['parents'] == 'true'
5
- debug = env['rack.request.query_hash']['debug'] == 'true'
4
+ params = env['api.endpoint'].params
5
+ add_parents = params['parents']
6
+ debug = params['debug']
6
7
 
7
8
  result.to_h(add_parents, debug).to_json
8
9
  end
@@ -3,15 +3,17 @@ require 'csv'
3
3
  module Mondrian::REST::Formatters
4
4
  module CSV
5
5
  def self.call(result, env)
6
- qh = env['rack.request.query_hash']
7
- add_parents = qh['parents'] == 'true'
8
- debug = qh['debug'] == 'true'
9
- properties = qh['properties'] || []
6
+ params = env['api.endpoint'].params
7
+ add_parents = params['parents']
8
+ debug = params['debug']
9
+ sparse = params['sparse']
10
+ properties = params['properties'] || []
10
11
 
11
12
  rows = Mondrian::REST::Formatters.tidy(result,
12
13
  add_parents: add_parents,
13
14
  debug: debug,
14
- properties: properties)
15
+ properties: properties,
16
+ sparse: sparse)
15
17
 
16
18
  ::CSV.generate do |csv|
17
19
  rows.each { |row| csv << row }
@@ -3,10 +3,11 @@ require 'writeexcel'
3
3
  module Mondrian::REST::Formatters
4
4
  module XLS
5
5
  def self.call(result, env)
6
- qh = env['rack.request.query_hash']
7
- add_parents = qh['parents'] == 'true'
8
- debug = qh['debug'] == 'true'
9
- properties = qh['properties'] || []
6
+ params = env['api.endpoint'].params
7
+ add_parents = params['parents']
8
+ debug = params['debug']
9
+ sparse = params['sparse']
10
+ properties = params['properties'] || []
10
11
 
11
12
  out = StringIO.new
12
13
  book = WriteExcel.new(out)
@@ -16,6 +17,7 @@ module Mondrian::REST::Formatters
16
17
  .tidy(result,
17
18
  add_parents: add_parents,
18
19
  debug: debug,
20
+ sparse: sparse,
19
21
  properties: properties)
20
22
  .each_with_index do |row, i|
21
23
  row.each_with_index { |cell, j|
@@ -1,16 +1,20 @@
1
1
  module Mondrian::REST::Formatters
2
2
  module JSONRecords
3
3
  def self.call(result, env)
4
+ params = env['api.endpoint'].params
5
+ add_parents = params['parents']
6
+ debug = params['debug']
7
+ sparse = params['sparse']
8
+ properties = params['properties'] || []
9
+
4
10
  qh = env['rack.request.query_hash']
5
- add_parents = qh['parents'] == 'true'
6
- debug = qh['debug'] == 'true'
7
- properties = qh['properties'] || []
8
11
  format = qh['format'] == 'array' ? 'array' : 'object'
9
12
 
10
13
  rows = Mondrian::REST::Formatters.tidy(result,
11
14
  add_parents: add_parents,
12
15
  debug: debug,
13
- properties: properties).lazy
16
+ properties: properties,
17
+ sparse: sparse).lazy
14
18
  keys = rows.first
15
19
 
16
20
  if format == 'array'
@@ -10,28 +10,6 @@ module Mondrian
10
10
  end
11
11
 
12
12
  def to_h
13
- # gather dimensions
14
- dimensions = self.dimensions
15
- .find_all { |d| d.dimension_type != :measures }
16
- .map do |d|
17
- {
18
- :name => d.name,
19
- :caption => d.caption,
20
- :type => d.dimension_type,
21
- :annotations => d.annotations,
22
- :hierarchies => d.hierarchies.map { |h|
23
- {
24
- :name => h.name,
25
- :has_all => h.has_all?,
26
- :all_member_name => h.all_member_name,
27
- :levels => h.levels.map { |l|
28
- l.to_h(get_members: false)
29
- }
30
- }
31
- }
32
- }
33
- end
34
-
35
13
  # gather named sets
36
14
  named_sets = self.named_sets
37
15
  .map do |ns|
@@ -58,7 +36,9 @@ module Mondrian
58
36
  return {
59
37
  :name => self.name,
60
38
  :annotations => self.annotations,
61
- :dimensions => dimensions,
39
+ :dimensions => self.dimensions
40
+ .find_all { |d| d.dimension_type != :measures }
41
+ .map { |d| d.to_h(get_members: false) },
62
42
  :named_sets => named_sets,
63
43
  :measures => self.dimensions
64
44
  .find(&:measures?)
@@ -81,14 +61,20 @@ module Mondrian
81
61
  end
82
62
 
83
63
  class Dimension
84
- def to_h
64
+ def to_h(options={})
65
+ get_members = options[:get_members]
85
66
  {
67
+ name: self.name,
68
+ caption: self.caption,
69
+ type: self.dimension_type,
70
+ annotations: self.annotations,
86
71
  hierarchies: self.hierarchies.map { |h|
87
72
  {
88
73
  name: h.name,
89
74
  has_all: h.has_all?,
90
- levels: h.levels.map { |l|
91
- l.to_h(get_members: true)
75
+ all_member_name: h.all_member_name,
76
+ levels: h.levels.map { |l|
77
+ l.to_h(get_members: get_members)
92
78
  } #/levels
93
79
  } # /hierarchies
94
80
  } #/map
@@ -1,5 +1,5 @@
1
1
  module Mondrian
2
2
  module REST
3
- VERSION = "0.7.6"
3
+ VERSION = "0.7.7"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mondrian-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.6
4
+ version: 0.7.7
5
5
  platform: java
6
6
  authors:
7
7
  - Manuel Aristarán
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-19 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement