Class: PbBaseController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- PbBaseController
show all
- Includes:
- Marshaller, PbHelper
- Defined in:
- lib/controllers/pbbase_controller.rb
Instance Method Summary
collapse
Methods included from PbHelper
#addProduct, #addProductEntity, #cloneProduct, #copyDirectoryWithoutHiddenRecursively, #deleteProduct, #deleteProductEntity, #findAndReplaceInFile, #getBrands, #getCardinalities, #getDefaultSelections, #getEntityDetails, #getLanguages, #getLibraryEntities, #getProductEntities, #getProducts, #getPropertyHash, #loadLibraryEntity, #product?, #saveEntityDetails, #updateDictionary, #updateEntityCardinality, #walkLibraryEntity
Instance Method Details
#dictionary_update ⇒ Object
107
108
109
110
111
112
113
114
115
116
|
# File 'lib/controllers/pbbase_controller.rb', line 107
def dictionary_update
lang = session[:lang]
id = params['id']
value = params['value']
if ((lang != nil) && (id != nil)) then
updateDictionary(lang, id, value)
end
render(:text => value)
end
|
#entity_add ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
|
# File 'lib/controllers/pbbase_controller.rb', line 65
def entity_add
name = params['name']
if (params['type'] == 'coverage') then
type = :coverage
else
type = :entity
end
unless (name == nil) then
addProductEntity(session[:selected_product], type, name)
end
render(:text => :OK)
end
|
#entity_delete ⇒ Object
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/controllers/pbbase_controller.rb', line 87
def entity_delete
name = params['name']
unless (name == nil) then
deleteProductEntity(session[:selected_product], name)
if (session[:selected_product_item] == name) then
session[:selected_product_item] = nil
end
end
render(:text => :OK)
end
|
#entity_save ⇒ Object
98
99
100
101
102
103
104
105
|
# File 'lib/controllers/pbbase_controller.rb', line 98
def entity_save
entities = params['entities']
unless (entities == nil) then
selected = entities.split(' ');
saveEntityDetails(session[:selected_product], session[:selected_product_item], selected.sort)
end
render(:text => :OK)
end
|
#product_add ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/controllers/pbbase_controller.rb', line 30
def product_add
name = params['name']
unless (name == nil) then
name.strip!()
name.capitalize!()
addProduct(name)
session[:selected_product] = name
session[:selected_product_item] = nil
end
redirect_to(:action => 'products')
end
|
#product_clone ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/controllers/pbbase_controller.rb', line 42
def product_clone
existingName = session[:selected_product]
clonedName = params['clonedName']
unless ((existingName == nil) || (clonedName == nil) || (clonedName.empty?())) then
clonedName.strip!()
clonedName = Inflector.camelize(clonedName)
cloneProduct(existingName, clonedName)
session[:selected_product] = clonedName
session[:selected_product_item] = nil
end
redirect_to(:action => 'products')
end
|
#product_delete ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'lib/controllers/pbbase_controller.rb', line 55
def product_delete
name = session[:selected_product]
unless (name == nil) then
deleteProduct(name)
session[:selected_product] = nil
session[:selected_product_item] = nil
end
redirect_to(:action => 'products')
end
|
#products ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/controllers/pbbase_controller.rb', line 12
def products
product = params['product']
if (product != nil) then
if (!product?(product)) then
session[:selected_product] = nil
session[:selected_product_item] = nil
else
session[:selected_product] = product
session[:selected_product_item] = nil
end
end
entity = params['entity']
if (entity != nil) then
session[:selected_product_item] = entity
end
render(:template => "pb/products", :layout => 'products')
end
|
#test_drive ⇒ Object
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
|
# File 'lib/controllers/pbbase_controller.rb', line 118
def test_drive
lang = params['lang']
brand = params['brand']
product = params['product']
port = '9000'
edit = 'true'
environment = 'development'
logDir = 'log'
pidFile = File.join(logDir, 'testdrive.pid')
logFile = File.join(logDir, 'testdrive.log')
if (File.exist?(logFile)) then
FileUtils.rm(logFile)
end
startCmd = "source ~/.bash_profile;mongrel_rails start --daemonize --port #{port} --environment #{environment} --log #{logFile} --pid #{pidFile}"
stopCmd = "mongrel_rails stop --pid #{pidFile}"
restartCmd = "mongrel_rails restart --pid #{pidFile}"
if (File.exist?(pidFile)) then
cmd = restartCmd
else
cmd = startCmd
end
system(cmd)
sleep(1)
puts "Executed Mongrel command [#{cmd}] see log file [#{logFile}] for further details\n"
url = "http://127.0.0.1:#{port}/iab/QNBRiskDataCollect?brand=#{brand}&product=#{product}&lang=#{lang}&edit=#{edit}"
puts "Returned URL for test drive [#{url}]"
render(:text => url)
end
|
#update_cardinality ⇒ Object
78
79
80
81
82
83
84
85
|
# File 'lib/controllers/pbbase_controller.rb', line 78
def update_cardinality
entity = params['entity']
cardinality = params['cardinality']
unless ((entity == nil) || (cardinality == nil)) then
updateEntityCardinality(session[:selected_product], entity, cardinality)
end
render(:text => :OK)
end
|
#update_mandatory ⇒ Object
151
152
153
154
|
# File 'lib/controllers/pbbase_controller.rb', line 151
def update_mandatory
puts 'PLEASE WRITE ME'
render(:text => :OK)
end
|