endeca_on_demand 0.0.2 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +51 -17
- data/lib/endeca_on_demand.rb +155 -198
- data/lib/endeca_on_demand/crumb.rb +0 -2
- data/lib/endeca_on_demand/dimension.rb +2 -4
- data/lib/endeca_on_demand/dimension_value_id.rb +0 -2
- data/lib/endeca_on_demand/record.rb +0 -2
- data/lib/endeca_on_demand/rule.rb +3 -3
- data/lib/endeca_on_demand/{search_report.rb → search.rb} +2 -4
- data/lib/endeca_on_demand/version.rb +1 -1
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
-
|
1
|
+
== EndecaOnDemand
|
2
2
|
|
3
|
-
|
3
|
+
This Endeca On-Demand Web API gem will take a query-string and construct an XML query that it then sends to a hosted Endeca On-Demand Cluster. It will then parse the response and expose an API for using the response data.
|
4
4
|
|
5
|
-
|
5
|
+
NOTE: There are still some features that may not work completely, see the todo list below to see what I hope to get in as I continue to work on the gem. If there is anything missing let me know.
|
6
|
+
|
7
|
+
=== Features
|
6
8
|
|
7
9
|
* Provides an easy way for you to use the Thanx Media, Endeca On-Demand Web API
|
8
10
|
* Builds an XML query from a query-string, formatted for the Endeca On-Demand Service
|
9
11
|
* Handles the Endeca On-Demand response XML and exposes methods to use response data
|
10
12
|
|
11
|
-
|
13
|
+
=== Install
|
12
14
|
|
13
|
-
|
15
|
+
==== Rails
|
14
16
|
|
15
17
|
Add this line to your Gemfile:
|
16
18
|
|
@@ -22,11 +24,11 @@ Then bundle install:
|
|
22
24
|
|
23
25
|
---
|
24
26
|
|
25
|
-
|
27
|
+
==== Non Rails
|
26
28
|
|
27
29
|
gem install EndecaOnDemand
|
28
30
|
|
29
|
-
|
31
|
+
=== Usage
|
30
32
|
|
31
33
|
EndecaOnDemand constructs an XML query to send to a hosted Endeca On-Demand Cluster, via a query string:
|
32
34
|
NOTE: This is a complete example. Any unneeded option should not be included in the query-string
|
@@ -39,12 +41,12 @@ NOTE: The base options and current category are set manually and not via a query
|
|
39
41
|
options = {
|
40
42
|
'add_base' => {'RecordsSet' => true, 'Dimensions' => true, 'BusinessRulesResult' => true, 'AppliedFilters' => true},
|
41
43
|
'add_keyword_search' => {},
|
42
|
-
'add_dimension_value_id_navigation' =>
|
44
|
+
'add_dimension_value_id_navigation' => [],
|
43
45
|
'add_category_navigation_query' => "current_category_id",
|
44
46
|
'add_sorting' => {},
|
45
47
|
'add_paging' => {},
|
46
48
|
'add_advanced_parameters' => {},
|
47
|
-
'add_profiles' =>
|
49
|
+
'add_profiles' => [],
|
48
50
|
'add_filters' => {}
|
49
51
|
}
|
50
52
|
|
@@ -54,12 +56,12 @@ NOTE: This is a complete example. It is not necessary to include anything that y
|
|
54
56
|
options = {
|
55
57
|
'add_base' => {'RecordsSet' => true, 'Dimensions' => true, 'BusinessRulesResult' => true, 'AppliedFilters' => true},
|
56
58
|
'add_keyword_search' => {'searh-key => 'key', search-term => 'term'},
|
57
|
-
'add_dimension_value_id_navigation' =>
|
59
|
+
'add_dimension_value_id_navigation' => [1, 2, 3, 4],
|
58
60
|
'add_category_navigation_query' => 1,
|
59
61
|
'add_sorting' => {'sort-key' => 'key', 'sort-direction' => 'Descending'},
|
60
62
|
'add_paging' => {'RecordOffset' => 0, 'RecordsPerPage' => 9},
|
61
63
|
'add_advanced_parameters' => {'AggregationKey' => 'key'},
|
62
|
-
'add_profiles' =>
|
64
|
+
'add_profiles' => [1, 2, 3, 4],
|
63
65
|
'add_filters' => {}
|
64
66
|
}
|
65
67
|
|
@@ -70,6 +72,33 @@ Provide the location of your hosted Endeca On-Demand Cluster (this can be set as
|
|
70
72
|
Pass your 'host' and 'options' hash to new EndecaOnDemand
|
71
73
|
|
72
74
|
@endeca = EndecaOnDemand.new(host, options)
|
75
|
+
|
76
|
+
All of the following have been exposed as part of the API, most should be pretty self explanatory of what they return:
|
77
|
+
|
78
|
+
@endeca.records
|
79
|
+
@endeca.record_offset
|
80
|
+
@endeca.records_per_page
|
81
|
+
@endeca.total_record_count
|
82
|
+
@endeca.breadcrumbs
|
83
|
+
@endeca.filtercrumbs - Filtercrumbs are pretty much breadcrumbs that are tailored to be used as left nav filterables (per Thanx Medias recommendation)
|
84
|
+
@endeca.dimensions
|
85
|
+
@endeca.rules
|
86
|
+
@endeca.searchs
|
87
|
+
|
88
|
+
NOTE: The following are part of a search result so expect a change where they become part of a search results class rather than naked calls
|
89
|
+
@endeca.matchedrecordcount
|
90
|
+
@endeca.matchedmode
|
91
|
+
@endeca.applied_search_adjustments
|
92
|
+
@endeca.suggested_search_adjustments
|
93
|
+
@endeca.selected_dimension_value_ids
|
94
|
+
|
95
|
+
I also exposed some 'debug'-ish type options to the API so you can see a little of what your request/response looks like if your not getting back the results your expecting
|
96
|
+
|
97
|
+
@endeca.uri
|
98
|
+
@endeca.http
|
99
|
+
@endeca.base
|
100
|
+
@endeca.query
|
101
|
+
@endeca.response
|
73
102
|
|
74
103
|
Below are (ruby) examples of how you could access the response data:
|
75
104
|
|
@@ -125,20 +154,25 @@ Each object will have associated instance variables that will allow you directly
|
|
125
154
|
etc...
|
126
155
|
end
|
127
156
|
|
128
|
-
|
157
|
+
=== F.A.Q
|
129
158
|
|
130
159
|
* Q: I'm getting a response error saying something about multiple values for model Category
|
131
|
-
|
160
|
+
* A: You are most likely trying to pass a CategoryId (CID) with DimensionValueId(s) (DVID) that don't match. The DVIDs must belong to the category passed as the CID.
|
132
161
|
|
133
|
-
|
162
|
+
=== TODO
|
134
163
|
|
135
164
|
* More detail on breadcrumbs (and their suggested use as left nav filters)
|
136
165
|
* More on filters
|
166
|
+
* Build in support for filters
|
167
|
+
* Add tests
|
168
|
+
* I don't have all the possible advanced parameters, so for now it only handles the default 'AggregationKey'
|
169
|
+
* Search needs some more testing. Currently its only been setup with a basic search, so I'm not aware of what additional parameters might be coming in, and how I may need to handle them
|
170
|
+
* Review the classes and create any additional classes that might be useful where only an instance variable currently exists (i.e. search_reports or paging)
|
137
171
|
|
138
|
-
|
172
|
+
=== CONTACT
|
139
173
|
|
140
|
-
Please contact me with any question, bugs, suggestions,
|
174
|
+
Please contact me with any question, bugs, suggestions, etc.
|
141
175
|
|
142
|
-
|
176
|
+
=== Copyright
|
143
177
|
|
144
178
|
Copyright (c) 2011 Steve Domino. See LICENSE.txt for further details
|
data/lib/endeca_on_demand.rb
CHANGED
@@ -11,11 +11,9 @@ class EndecaOnDemand
|
|
11
11
|
@body = Builder::XmlMarkup.new(:indent => 2)
|
12
12
|
|
13
13
|
#
|
14
|
-
# puts "HOST: #{host}"
|
15
14
|
set_host(host)
|
16
15
|
|
17
16
|
#
|
18
|
-
# puts "OPTIONS: #{options}"
|
19
17
|
options.each do |key, value|
|
20
18
|
self.send(key.to_sym, value) unless value.empty?
|
21
19
|
end
|
@@ -26,33 +24,17 @@ class EndecaOnDemand
|
|
26
24
|
|
27
25
|
### API
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end
|
36
|
-
|
37
|
-
def filtercrumbs
|
38
|
-
@filtercrumbs
|
39
|
-
end
|
27
|
+
attr_reader :records, :record_offset, :records_per_page, :total_record_count
|
28
|
+
attr_reader :breadcrumbs, :filtercrumbs
|
29
|
+
attr_reader :dimensions
|
30
|
+
attr_reader :rules
|
31
|
+
attr_reader :searchs, :matchedrecordcount, :matchedmode, :applied_search_adjustments, :suggested_search_adjustments
|
32
|
+
attr_reader :selected_dimension_value_ids
|
40
33
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
def rules
|
46
|
-
@business_rules
|
47
|
-
end
|
48
|
-
|
49
|
-
def search_reports
|
50
|
-
@search_reports
|
51
|
-
end
|
52
|
-
|
53
|
-
def selected_dimension_value_ids
|
54
|
-
@selected_dimension_value_ids
|
55
|
-
end
|
34
|
+
## DEBUG
|
35
|
+
attr_reader :uri, :http
|
36
|
+
attr_reader :base, :query, :response
|
37
|
+
## /DEBUG
|
56
38
|
|
57
39
|
### /API
|
58
40
|
|
@@ -71,6 +53,8 @@ class EndecaOnDemand
|
|
71
53
|
options.each do |key, value|
|
72
54
|
@body.tag!(key, value)
|
73
55
|
end
|
56
|
+
|
57
|
+
@base = options
|
74
58
|
end
|
75
59
|
|
76
60
|
## BUILD REQUEST BODY
|
@@ -122,17 +106,15 @@ class EndecaOnDemand
|
|
122
106
|
end
|
123
107
|
end
|
124
108
|
|
125
|
-
#
|
109
|
+
# Adds advanced parameters to the request.
|
110
|
+
# NOTE: For this implementation I only had the default advanced parameter (AggregationKey) to test with. This has not been tested, and most likely will not work, with any other possible advanced parameters (if any)
|
126
111
|
def add_advanced_parameters(options)
|
127
|
-
# puts "PARAMETERS: #{options}"
|
128
112
|
options.each do |key, value|
|
129
113
|
@body.tag!(key, value)
|
130
114
|
end
|
131
|
-
# puts @body.target!
|
132
115
|
end
|
133
116
|
|
134
117
|
# Adds UserProfile(s) to the request.
|
135
|
-
#TODO: test and see what happens if profiles are passed and don't exist
|
136
118
|
def add_profiles(options)
|
137
119
|
@body.UserProfiles do
|
138
120
|
options.each do |profile|
|
@@ -161,16 +143,13 @@ class EndecaOnDemand
|
|
161
143
|
|
162
144
|
# Completes the endeca XML reqeust by inserting the XML body into the requred 'Query' tags, and sends the request to your hosted Endeca On-Demand Web API
|
163
145
|
def send_request
|
164
|
-
|
165
|
-
query
|
166
|
-
|
167
|
-
query << @body.target!
|
146
|
+
@query = Builder::XmlMarkup.new(:indent => 2)
|
147
|
+
@query.Query do
|
148
|
+
@query << @body.target!
|
168
149
|
end
|
169
|
-
|
170
|
-
# puts "QUERY: #{query.target!}"
|
171
|
-
|
150
|
+
|
172
151
|
begin
|
173
|
-
request, response = @http.post(@uri.path, query.target!, 'Content-type' => 'application/xml')
|
152
|
+
request, response = @http.post(@uri.path, @query.target!, 'Content-type' => 'application/xml')
|
174
153
|
handle_response(Crackoid::XML.parse(response))
|
175
154
|
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => error
|
176
155
|
puts "ERROR: #{error.message}"
|
@@ -179,112 +158,78 @@ class EndecaOnDemand
|
|
179
158
|
|
180
159
|
## HANDLE RESPONSE
|
181
160
|
|
182
|
-
# get the request response and parse it into an hash
|
183
161
|
def handle_response(response)
|
184
|
-
# puts "RESPONSE: #{response}"
|
185
162
|
@response = response['Final']
|
186
|
-
|
187
163
|
build_data
|
188
164
|
end
|
189
165
|
|
190
166
|
def build_data
|
191
167
|
build_records
|
192
168
|
build_breadcrumbs
|
169
|
+
build_filtercrumbs
|
193
170
|
build_dimensions
|
194
171
|
build_business_rules
|
195
|
-
|
196
|
-
build_selected_dimension_value_ids
|
172
|
+
build_applied_filters
|
197
173
|
end
|
198
174
|
|
199
|
-
#
|
175
|
+
# Builds an array of RECORDS
|
200
176
|
def build_records
|
201
|
-
puts "RECORDS SET: #{@response['RecordsSet']}"
|
202
|
-
|
203
|
-
# NOTE: this may need to be reworked a little. look in recordset for nodes that our outside of records...
|
204
177
|
@records = []
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
178
|
+
|
179
|
+
record_set = @response['RecordsSet']
|
180
|
+
|
181
|
+
@record_offset = record_set.fetch('offset')
|
182
|
+
@records_per_page = record_set.fetch('recordsperpage')
|
183
|
+
@total_record_count = record_set.fetch('totalrecordcount')
|
184
|
+
|
185
|
+
unless record_set.nil?
|
186
|
+
record = @response['RecordsSet']['Record']
|
187
|
+
if record.instance_of?(Hash)
|
188
|
+
@records.push(EndecaOnDemand::Record.new(record_set))
|
189
|
+
elsif record.instance_of?(Array)
|
190
|
+
record.each do |record|
|
191
|
+
@records.push(EndecaOnDemand::Record.new(record))
|
211
192
|
end
|
212
|
-
else
|
213
|
-
puts "This record is a(n): #{@response['RecordsSet'].class}"
|
214
193
|
end
|
215
194
|
else
|
216
195
|
puts 'There are no records with this response!'
|
217
196
|
end
|
218
197
|
end
|
219
198
|
|
220
|
-
#
|
221
|
-
# TODO: one final pass on this to make sure its awesome (do i need the has for each key/values?) readdress how the filtercrumbs are handles and see if it is the best way
|
199
|
+
# Builds an array of BREADCRUMBS
|
222
200
|
def build_breadcrumbs
|
223
201
|
@breadcrumbs = []
|
224
|
-
@filtercrumbs = []
|
225
202
|
|
226
|
-
# puts "BREADCRUMBS: #{@response['Breadcrumbs'}"
|
227
203
|
breadcrumbs = @response['Breadcrumbs']
|
228
204
|
unless breadcrumbs.nil?
|
229
|
-
|
230
|
-
# puts "BREADS: #{@response['Breadcrumbs']['Breads']}"
|
231
205
|
breads = @response['Breadcrumbs']['Breads']
|
232
|
-
|
233
|
-
breads.each do |bread|
|
234
|
-
bread.each do |key, value|
|
235
|
-
@filtercrumbs.push(value)
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
206
|
if breads.instance_of?(Hash)
|
240
|
-
|
241
|
-
if
|
242
|
-
|
243
|
-
|
244
|
-
# puts "HASH 2: #{breads['Bread']}"
|
245
|
-
breads['Bread'].each do |key, value|
|
246
|
-
# puts "#{key} :: #{value}"
|
247
|
-
@breadcrumbs.push(EndecaXml::Crumb.new(breads['Bread']))
|
248
|
-
end
|
249
|
-
elsif breads['Bread'].instance_of?(Array)
|
250
|
-
# puts "ARRAY 2: #{breads['Bread']}"
|
251
|
-
breads['Bread'].each do |crumb|
|
252
|
-
# puts "CRUMB 2: #{crumb}"
|
253
|
-
@breadcrumbs.push(EndecaXml::Crumb.new(crumb))
|
254
|
-
end
|
207
|
+
bread = breads['Bread']
|
208
|
+
if bread.instance_of?(Hash)
|
209
|
+
bread.each do |key, value|
|
210
|
+
@breadcrumbs.push(EndecaOnDemand::Crumb.new(bread))
|
255
211
|
end
|
256
|
-
@filtercrumbs.push(breads['Bread'])
|
257
212
|
elsif bread.instance_of?(Array)
|
258
|
-
|
259
|
-
|
260
|
-
# puts "CRUMB: #{crumb}"
|
261
|
-
@breadcrumbs.push(EndecaXml::Crumb.new(crumb))
|
213
|
+
bread.each do |crumb|
|
214
|
+
@breadcrumbs.push(EndecaOnDemand::Crumb.new(crumb))
|
262
215
|
end
|
263
216
|
end
|
264
217
|
elsif breads.instance_of?(Array)
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
# puts "HASH 2: #{bread}"
|
272
|
-
bread['Bread'].each do |key, value|
|
273
|
-
# puts "#{key} :: #{value}"
|
274
|
-
@breadcrumbs.push(EndecaXml::Crumb.new(bread['Bread']))
|
218
|
+
breads.each do |breadz|
|
219
|
+
bread = breadz['Bread']
|
220
|
+
if breadz.instance_of?(Hash)
|
221
|
+
if bread.instance_of?(Hash)
|
222
|
+
bread.each do |key, value|
|
223
|
+
@breadcrumbs.push(EndecaOnDemand::Crumb.new(bread))
|
275
224
|
end
|
276
|
-
elsif bread
|
277
|
-
|
278
|
-
|
279
|
-
# puts "CRUMB 2: #{crumb}"
|
280
|
-
@breadcrumbs.push(EndecaXml::Crumb.new(crumb))
|
225
|
+
elsif bread.instance_of?(Array)
|
226
|
+
bread.each do |crumb|
|
227
|
+
@breadcrumbs.push(EndecaOnDemand::Crumb.new(crumb))
|
281
228
|
end
|
282
229
|
end
|
283
|
-
elsif
|
284
|
-
|
285
|
-
|
286
|
-
# puts "CRUMB 3: #{crumb}"
|
287
|
-
@breadcrumbs.push(EndecaXml::Crumb.new(crumb))
|
230
|
+
elsif breadz.instance_of?(Array)
|
231
|
+
bread.each do |crumb|
|
232
|
+
@breadcrumbs.push(EndecaOnDemand::Crumb.new(crumb))
|
288
233
|
end
|
289
234
|
end
|
290
235
|
end
|
@@ -294,137 +239,149 @@ class EndecaOnDemand
|
|
294
239
|
end
|
295
240
|
end
|
296
241
|
|
297
|
-
#
|
298
|
-
|
242
|
+
# Builds an array of FILTERCRUMBS (BREADCRUMBS used as left nav filterables)
|
243
|
+
def build_filtercrumbs
|
244
|
+
@filtercrumbs = []
|
245
|
+
|
246
|
+
breads = @response['Breadcrumbs']['Breads']
|
247
|
+
if breads.instance_of?(Hash)
|
248
|
+
breads.each do |key, value|
|
249
|
+
@filtercrumbs.push(value)
|
250
|
+
end
|
251
|
+
elsif breads.instance_of?(Array)
|
252
|
+
breads.each do |bread|
|
253
|
+
if bread.instance_of?(Hash)
|
254
|
+
@filtercrumbs.push(bread['Bread'])
|
255
|
+
elsif bread.instance_of?(Array)
|
256
|
+
bread['Bread'].each do |crumb|
|
257
|
+
@filtercrumbs.push(crumb)
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# Builds an array of DIMENSIONS
|
299
265
|
def build_dimensions
|
300
266
|
@dimensions = []
|
301
267
|
|
302
|
-
puts "DIMENSIONS: #{@response['Dimensions']}"
|
303
268
|
dimensions = @response['Dimensions']
|
304
|
-
|
305
269
|
unless @response['Dimensions'].nil?
|
306
|
-
|
307
|
-
# puts "DIMENSION: #{@response['Dimensions']['Dimension']}"
|
308
270
|
dimension = @response['Dimensions']['Dimension']
|
309
|
-
|
310
271
|
if dimension.instance_of?(Hash)
|
311
|
-
@dimension =
|
312
|
-
|
313
|
-
if dimension['DimensionValues']['DimensionValue'].instance_of?(Hash)
|
314
|
-
@dimension.dimension_values.push(EndecaXml::Dimension.new(dimension['DimensionValues']))
|
315
|
-
elsif dimension['DimensionValues']['DimensionValue'].instance_of?(Array)
|
316
|
-
dimension['DimensionValues']['DimensionValue'].each do |dimension_value|
|
317
|
-
@dimension.dimension_values.push(EndecaXml::Dimension.new(dimension_value))
|
318
|
-
end
|
319
|
-
else
|
320
|
-
puts "This dimension value is a(n): #{dimension['DimensionValues']['DimensionValue'].class}"
|
321
|
-
end
|
322
|
-
@dimensions.push(@dimension)
|
323
|
-
else
|
324
|
-
puts "There are no dimension values on this dimension!"
|
325
|
-
end
|
272
|
+
@dimension = EndecaOnDemand::Dimension.new(dimensions)
|
273
|
+
add_dimension_values(dimension)
|
326
274
|
elsif dimension.instance_of?(Array)
|
327
275
|
dimension.each do |dimension|
|
328
|
-
@dimension =
|
329
|
-
|
330
|
-
if dimension['DimensionValues']['DimensionValue'].instance_of?(Hash)
|
331
|
-
@dimension.dimension_values.push(EndecaXml::Dimension.new(dimension['DimensionValues']))
|
332
|
-
elsif dimension['DimensionValues']['DimensionValue'].instance_of?(Array)
|
333
|
-
dimension['DimensionValues']['DimensionValue'].each do |dimension_value|
|
334
|
-
@dimension.dimension_values.push(EndecaXml::Dimension.new(dimension_value))
|
335
|
-
end
|
336
|
-
else
|
337
|
-
puts "This dimension value is a(n): #{dimension['DimensionValues']['DimensionValue'].class}"
|
338
|
-
end
|
339
|
-
@dimensions.push(@dimension)
|
340
|
-
else
|
341
|
-
puts 'There are no dimension values on this dimension!'
|
342
|
-
end
|
276
|
+
@dimension = EndecaOnDemand::Dimension.new(dimension)
|
277
|
+
add_dimension_values(dimension)
|
343
278
|
end
|
344
|
-
else
|
345
|
-
puts "This dimension is a(n): #{dimensions.class}"
|
346
279
|
end
|
347
280
|
else
|
348
281
|
puts 'There are no dimensions with this response!'
|
349
282
|
end
|
350
283
|
end
|
351
284
|
|
352
|
-
#
|
285
|
+
# Adds an array of DIMENSION VALUES to each DIMENSION
|
286
|
+
def add_dimension_values(dimension)
|
287
|
+
unless dimension['DimensionValues'].nil?
|
288
|
+
if dimension['DimensionValues']['DimensionValue'].instance_of?(Hash)
|
289
|
+
@dimension.dimension_values.push(EndecaOnDemand::Dimension.new(dimension['DimensionValues']))
|
290
|
+
elsif dimension['DimensionValues']['DimensionValue'].instance_of?(Array)
|
291
|
+
dimension['DimensionValues']['DimensionValue'].each do |dimension_value|
|
292
|
+
@dimension.dimension_values.push(EndecaOnDemand::Dimension.new(dimension_value))
|
293
|
+
end
|
294
|
+
end
|
295
|
+
@dimensions.push(@dimension)
|
296
|
+
else
|
297
|
+
puts "There are no dimension values on this dimension!"
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
# Builds an array of BUSINESS RULES
|
353
302
|
def build_business_rules
|
354
|
-
puts "BUSINESS RULES: #{@response['BusinessRulesResult']}"
|
355
|
-
|
356
|
-
# NOTE: needs to be looked at again. look at where the array is being pushed
|
357
303
|
@business_rules = []
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
304
|
+
|
305
|
+
business_rules_result = @response['BusinessRulesResult']
|
306
|
+
unless business_rules_result.nil?
|
307
|
+
business_rules = @response['BusinessRulesResult']['BusinessRules']
|
308
|
+
if business_rules.instance_of?(Hash)
|
309
|
+
business_rule = EndecaOnDemand::Rule.new(business_rules)
|
310
|
+
business_rules.each do |key, value|
|
311
|
+
add_business_rule_properties(value) if key == 'properties'
|
312
|
+
add_business_rule_records(value) if key == 'RecordSet'
|
366
313
|
end
|
367
|
-
elsif
|
314
|
+
elsif business_rules.instance_of?(Array)
|
368
315
|
@response['BusinessRulesResult']['BusinessRules']['BusinessRule'].each do |rule|
|
369
|
-
|
316
|
+
business_rule = EndecaOnDemand::Rule.new(rule)
|
370
317
|
rule.each do |key, value|
|
371
|
-
|
372
|
-
if key == 'RecordSet'
|
373
|
-
@business_rule.records.push(EndecaXml::Record.new(value['Record'])) unless value.nil?
|
374
|
-
end
|
318
|
+
add_business_rule_properties(key) if key == 'properties'
|
319
|
+
add_business_rule_records(key) if key == 'RecordSet'
|
375
320
|
end
|
376
321
|
end
|
377
|
-
else
|
378
|
-
puts "This busniess rule is a(n): #{@response['RecordsSet'].class}"
|
379
322
|
end
|
380
|
-
@business_rules.push(
|
323
|
+
@business_rules.push(business_rule)
|
381
324
|
else
|
382
325
|
puts 'There are no business rules with this response!'
|
383
326
|
end
|
384
327
|
end
|
385
328
|
|
386
|
-
#
|
387
|
-
def
|
388
|
-
@
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
329
|
+
# Adds an array of PROPERTIES to each BUSINESS RULE
|
330
|
+
def add_business_rule_properties(value)
|
331
|
+
@business_rule.properties_array.push(EndecaOnDemand::Rule.new(value)) unless value.nil?
|
332
|
+
end
|
333
|
+
|
334
|
+
# Adds an array of RECORDS to each BUSINESS RULE
|
335
|
+
def add_business_rule_records(value)
|
336
|
+
@business_rule.records.push(EndecaOnDemand::Record.new(value['Record'])) unless value.nil?
|
337
|
+
end
|
338
|
+
|
339
|
+
# Builds the SEARCH REPORTS and SELECTED DIMENSION VALUE IDS if included in response
|
340
|
+
def build_applied_filters
|
341
|
+
unless @response['AppliedFilters'].nil?
|
342
|
+
unless @response['AppliedFilters']['SearchReports'].nil?
|
343
|
+
build_search_reports
|
398
344
|
else
|
399
345
|
puts 'There are no search reports with this response!'
|
400
346
|
end
|
401
|
-
|
347
|
+
unless @response['AppliedFilters']['SelectedDimensionValueIds'].nil?
|
348
|
+
build_selected_dimension_value_ids
|
349
|
+
else
|
350
|
+
puts "There are no selected dimension value ids with this response!"
|
351
|
+
end
|
402
352
|
else
|
403
353
|
puts 'There were not applied filters with this response!'
|
404
354
|
end
|
405
355
|
end
|
406
356
|
|
407
|
-
#
|
357
|
+
# Builds an array of SEARCH REPORTS
|
358
|
+
def build_search_reports
|
359
|
+
@searchs = []
|
360
|
+
|
361
|
+
search_report = @response['AppliedFilters']['SearchReports']['SearchReport']
|
362
|
+
|
363
|
+
@matchedrecordcount = search_report.fetch('matchedrecordcount')
|
364
|
+
@matchedmode = search_report.fetch('matchmode')
|
365
|
+
@matchedtermscount = search_report.fetch('matchedtermscount')
|
366
|
+
@applied_search_adjustments = search_report.fetch('AppliedSearchAdjustments')
|
367
|
+
@suggested_search_adjustments = search_report.fetch('SuggestedSearchAdjustments')
|
368
|
+
|
369
|
+
@searchs.push(EndecaOnDemand::Search.new(search_report.fetch('Search')))
|
370
|
+
end
|
371
|
+
|
372
|
+
# Builds an array of SELECTED DIMENSION VALUE IDS
|
408
373
|
def build_selected_dimension_value_ids
|
409
374
|
@selected_dimension_value_ids = []
|
410
375
|
|
411
|
-
# puts "SELECTED DIMENSION VALUE IDS: #{@response['AppliedFilters']['SelectedDimensionValueIds']}"
|
412
376
|
selected_dimension_value_ids = @response['AppliedFilters']['SelectedDimensionValueIds']
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
selected_dimension_value_ids.each do |key, value|
|
419
|
-
selected_dimension_value_id = EndecaXml::DimensionValueId.new(value)
|
420
|
-
end
|
377
|
+
if selected_dimension_value_ids.instance_of?(Hash)
|
378
|
+
selected_dimension_value_id = EndecaOnDemand::DimensionValueId.new(selected_dimension_value_ids)
|
379
|
+
elsif selected_dimension_value_ids.instance_of?(Array)
|
380
|
+
selected_dimension_value_ids.each do |key, value|
|
381
|
+
selected_dimension_value_id = EndecaOnDemand::DimensionValueId.new(value)
|
421
382
|
end
|
422
|
-
|
423
|
-
@selected_dimension_value_ids.push(selected_dimension_value_id)
|
424
|
-
|
425
|
-
else
|
426
|
-
puts "There are no selected dimension value ids with this response!"
|
427
383
|
end
|
384
|
+
@selected_dimension_value_ids.push(selected_dimension_value_id)
|
428
385
|
end
|
429
386
|
|
430
387
|
end
|
@@ -2,13 +2,11 @@ class EndecaOnDemand
|
|
2
2
|
class Dimension
|
3
3
|
|
4
4
|
def initialize(dimension)
|
5
|
-
|
5
|
+
@dimension_values = []
|
6
|
+
|
6
7
|
dimension.each do |key, value|
|
7
|
-
# puts "#{key} | #{value}"
|
8
8
|
self.instance_variable_set(:"@#{key.downcase}", value)
|
9
9
|
end
|
10
|
-
|
11
|
-
@dimension_values = []
|
12
10
|
end
|
13
11
|
|
14
12
|
# is there anyway to do this dynamically?
|
@@ -2,12 +2,12 @@ class EndecaOnDemand
|
|
2
2
|
class Rule
|
3
3
|
|
4
4
|
def initialize(rule)
|
5
|
+
@properties_array = []
|
6
|
+
@records = []
|
7
|
+
|
5
8
|
rule.each do |key, value|
|
6
9
|
self.instance_variable_set(:"@#{key.downcase}", value)
|
7
10
|
end
|
8
|
-
|
9
|
-
@properties_array = []
|
10
|
-
@records = []
|
11
11
|
end
|
12
12
|
|
13
13
|
# is there anyway to do this dynamically?
|
@@ -1,16 +1,14 @@
|
|
1
1
|
class EndecaOnDemand
|
2
|
-
class
|
2
|
+
class Search
|
3
3
|
|
4
4
|
def initialize(report)
|
5
|
-
# puts "REPORT: #{report}"
|
6
5
|
report.each do |key, value|
|
7
|
-
# puts "#{key} | #{value}"
|
8
6
|
self.instance_variable_set(:"@#{key.downcase}", value)
|
9
7
|
end
|
10
8
|
end
|
11
9
|
|
12
10
|
# is there anyway to do this dynamically?
|
13
|
-
attr_reader :
|
11
|
+
attr_reader :key, :mode, :relevancerankingsstrategy, :terms
|
14
12
|
|
15
13
|
end
|
16
14
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: endeca_on_demand
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0
|
5
|
+
version: 0.9.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- sdomino
|
@@ -56,7 +56,7 @@ files:
|
|
56
56
|
- lib/endeca_on_demand/dimension_value_id.rb
|
57
57
|
- lib/endeca_on_demand/record.rb
|
58
58
|
- lib/endeca_on_demand/rule.rb
|
59
|
-
- lib/endeca_on_demand/
|
59
|
+
- lib/endeca_on_demand/search.rb
|
60
60
|
- lib/endeca_on_demand/version.rb
|
61
61
|
homepage: http://github.com/sdomino/endeca_on-demand
|
62
62
|
licenses: []
|