88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
# File 'lib/processengine/engine.rb', line 88
def push(session,process,params)
package = 'CommercialProperty'
case process
when "ProcessDefinition"
require 'RailsProcessInterpreter'
open("#{PRODUCT_ROOT.gsub(/%product/,session[:product])}/DSL/processes.oil") {|f| @contents = f.read }
dsl = @contents.to_s
action_methods = RailsProcessInterpreter.execute(dsl)
action_methods
when "GetNBQuote"
eval(deriveActiveRecordDefinitionOfProduct(session[:product]))
xml = createXMLMessage(session[:product],params,false) { |k,v| "<#{k}>#{v}</#{k}>" }
require 'models/persist'
persist = Persist.instance
key = persist.put("UUID",xml)
session[:policyKey] = key
if APP_CONFIG['use_rating_engine']
nvpxml = buildVPMSMessage(session[:product],package,session[:brand],params)
response = callVPMS(nvpxml)
parseVPMSresponse(response,session[:product])
xml = mergeIntoXMLDoc(xml,@premiums)
end
prepareModels(session[:product],xml)
when "GetBrokerQuotes"
eval(deriveActiveRecordDefinitionOfProduct(session[:product]))
dataTweak = Hash.new
drill(params,dataTweak)
result = Kerrylondon.makeQuote("Tony Lorriman","liability1","CSP",false,Kerrylondon.keyfacts(dataTweak))
premiums = "<ContractorPlant><Quotes>#{result}#{result}</Quotes></ContractorPlant>"
prepareModels(session[:product],premiums)
when "RefineNBQuote"
eval(deriveActiveRecordDefinitionOfProduct(session[:product]))
require 'models/persist'
persist = Persist.instance
origxml = persist.get(session[:policyKey])
h = prepareModels(session[:product],origxml)
params = h.deep_merge(params)
combinedxml = createXMLMessage(session[:product],params,false) { |k,v| "<#{k}>#{v}</#{k}>" }
key = persist.put(session[:policyKey],combinedxml)
if APP_CONFIG['use_rating_engine']
nvpxml = buildVPMSMessage(session[:product],package,session[:brand],params)
response = callVPMS(nvpxml)
parseVPMSresponse(response,session[:product])
combinedxml = mergeIntoXMLDoc(combinedxml,@premiums)
end
prepareModels(session[:product],combinedxml)
when "Search"
executeSearch(session[:product],params)
when "FindPolicyOrQuote"
require 'models/persist'
persist = Persist.instance
xml = persist.get(params[:choosen][:one])
prepareModels(session[:product],xml)
when "Authenticate"
begin
if params[:User] and params[:User][:User] and params[:User][:User].length > 0
session[:user_email] = params[:User][:User]
elsif params[:ProfilePersonalDetailsClientContact] and params[:ProfilePersonalDetailsClientContact][:Email]
session[:user_email] = params[:ProfilePersonalDetailsClientContact][:Email]
end
eval(deriveActiveRecordDefinitionOfProduct(session[:product]))
open("#{File.dirname(__FILE__)}/../bizLogic/xquery2") {|f| @query = f.read }
require 'models/persist'
persist = Persist.instance
results = persist.find(@query.gsub('EMAIL',session[:user_email]))
key = results[0]
xml = persist.get(key)
doc = Document.new(xml)
node = doc.elements['Telenexus/Profile/PersonalDetails/Client']
node.parent.delete(node) if node and session[:user_email].index("telenexus.com")
prepareModels(session[:product],doc.to_s)
rescue
if !session[:user_email]
raise "Credentials missing - you have not logged in"
end
raise "An error occurred during the authentication process"
end
when "SaveProfile"
begin
session[:user_email] = params[:ProfilePersonalDetailsClientContact][:Email]
eval(deriveActiveRecordDefinitionOfProduct(session[:product]))
xml = createXMLMessage(session[:product],params,false) { |k,v| "<#{k}>#{v}</#{k}>" }
open("#{File.dirname(__FILE__)}/../bizLogic/xquery2") {|f| @query = f.read }
require 'models/persist'
persist = Persist.instance
results = persist.find(@query.gsub('EMAIL',session[:user_email]))
key = nil
if !results
key = persist.create_key_and_doc(xml)
else
key = results[0]
persist.put(key,xml)
end
xml = persist.get(key)
prepareModels(session[:product],xml)
rescue
if !session[:user_email]
raise "Credentials missing for new customer"
end
raise "An error occurred whilst saving a new profile"
end
when "SectionRating"
"1553.25"
when "MTAReason"
require 'models/persist'
persist = Persist.instance
xml = persist.get(session[:policyKey])
prepareModels(session[:product],xml)
when "GetMTAQuote"
require 'models/persist'
persist = Persist.instance
origImage = persist.get(session[:policyKey])
xml = createXMLMessage(session[:product],params,false) { |k,v| "<#{k}>#{v}</#{k}>" }
applyMTA(session[:mtaStartDate],session[:mtaEndDate],session[:policyKey],origImage,xml)
prepareModels(session[:product],xml)
when "PolicyDocumentation"
require 'models/persist'
persist = Persist.instance
xml = persist.get(session[:policyKey])
cmd = SBroker.RequestRatingService("NB",session[:product],true,false,false)
quote = cmd.call(xml)
prepareModels(session[:product],xml)
when "Checkout"
next_url = setup_payment(params)
next_url
when "ConfirmPayment"
get_gateway_payment_details(params)
when "CompletedPayment"
complete_payment(params)
when "CaptureInputXML"
eval(deriveActiveRecordDefinitionOfProduct(session[:product]))
xml = createXMLMessage(session[:product],params,false) { |k,v| "<#{k}>#{v}</#{k}>" }
File.open("dump.xml", 'w') {|f| f.write(xml) }
else
puts "**********> #{process} logic performed once it has been written <**********"
end
end
|