gd_bam 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/bam +29 -9
- data/bin/bam.orig +375 -0
- data/lib/bam/version.rb +1 -1
- data/lib/base/project.rb +8 -7
- data/lib/base/tap.rb +4 -0
- data/lib/cloud_connect/dsl/es_helpers.rb +1 -1
- data/lib/cloud_connect/dsl/sf_helpers.rb +33 -2
- data/lib/commands/commands.rb +16 -8
- data/lib/commands/docs_commands.rb +1 -1
- data/lib/commands/gd_commands.rb +2 -2
- data/lib/commands/sf_commands.rb +1 -1
- data/lib/compiler/etl_visitor.rb +1 -1
- data/lib/generators/downloaders.rb +209 -0
- data/lib/generators/downloaders.rb.orig +663 -0
- data/lib/generators/etl.rb +5 -1
- data/lib/graphs/goodsales_v2/process_opportunity_line_item.grf +4 -2
- data/lib/graphs/goodsales_v2/process_velocity_duration.grf +1 -1
- metadata +4 -2
data/bin/bam
CHANGED
@@ -49,14 +49,14 @@ command :sf_jack_in do |c|
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
desc 'Jacks into project.'
|
53
|
-
# arg_name 'Describe arguments to new here'
|
54
|
-
command :project_jack_in do |c|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
52
|
+
# desc 'Jacks into project.'
|
53
|
+
# # arg_name 'Describe arguments to new here'
|
54
|
+
# command :project_jack_in do |c|
|
55
|
+
#
|
56
|
+
# c.action do |global_options,options,args|
|
57
|
+
# GoodData::Bam::Commands::project_jack_in(PARAMS)
|
58
|
+
# end
|
59
|
+
# end
|
60
60
|
|
61
61
|
|
62
62
|
desc 'Validatates connection to SalesForce.'
|
@@ -125,6 +125,26 @@ command :generate_downloaders do |c|
|
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
|
+
command :generate_history_downloaders do |c|
|
129
|
+
|
130
|
+
c.desc 's3 backup'
|
131
|
+
c.arg_name 'backup'
|
132
|
+
c.flag :backup
|
133
|
+
|
134
|
+
c.action do |global_options,options,args|
|
135
|
+
params = global_options[:user_params]
|
136
|
+
params = PARAMS.merge({
|
137
|
+
:project_name => "downloaders-#{PARAMS[:project_name]}",
|
138
|
+
:graph_repos => [
|
139
|
+
GoodData::Bam::Repository.create(:type => :file, :base => './local_graphs'),
|
140
|
+
GoodData::Bam::Repository.create(:type => :file, :base => GoodData::CloverGenerator::BAM_DEFINED_GRAPHS_ROOT)]
|
141
|
+
})
|
142
|
+
GoodData::Bam::Commands::generate_history_downloaders(".", params)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
|
128
148
|
desc 'Validates that the tap has the fields it is claimed it should have. This is supposed to make the mitigate errors during deploy.'
|
129
149
|
# arg_name 'Describe arguments to new here'
|
130
150
|
command :sf_taps_validate do |c|
|
@@ -269,7 +289,7 @@ command :model_sync do |c|
|
|
269
289
|
c.switch :dry
|
270
290
|
|
271
291
|
c.action do |global_options,options,args|
|
272
|
-
GoodData::Bam::Commands::model_sync(options)
|
292
|
+
GoodData::Bam::Commands::model_sync('.', options)
|
273
293
|
end
|
274
294
|
end
|
275
295
|
|
data/bin/bam.orig
ADDED
@@ -0,0 +1,375 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'gli'
|
3
|
+
require 'bam'
|
4
|
+
|
5
|
+
include GLI::App
|
6
|
+
|
7
|
+
program_desc 'Describe your application here'
|
8
|
+
|
9
|
+
version Bam::VERSION
|
10
|
+
|
11
|
+
# desc 'Describe some switch here'
|
12
|
+
# switch [:s,:switch]
|
13
|
+
#
|
14
|
+
desc 'Verbose'
|
15
|
+
default_value false
|
16
|
+
arg_name 'verbose'
|
17
|
+
switch [:v,:verbose]
|
18
|
+
|
19
|
+
desc 'Http logger'
|
20
|
+
default_value false
|
21
|
+
arg_name 'logger'
|
22
|
+
switch [:l,:logger]
|
23
|
+
|
24
|
+
desc 'Generates clover project based on information in current directory. The default ouptut is the directory ./clover-project'
|
25
|
+
# arg_name 'Describe arguments to new here'
|
26
|
+
command :generate do |c|
|
27
|
+
|
28
|
+
c.desc 'generate only specified flow'
|
29
|
+
c.arg_name 'only'
|
30
|
+
c.flag :only
|
31
|
+
|
32
|
+
c.action do |global_options,options,args|
|
33
|
+
params = PARAMS.merge(options).merge({
|
34
|
+
:project_name => "etl-#{PARAMS[:project_name]}",
|
35
|
+
:graph_repos => [
|
36
|
+
GoodData::Bam::Repository.create(:type => :file, :base => Pathname('./local_graphs').expand_path),
|
37
|
+
GoodData::Bam::Repository.create(:type => :file, :base => GoodData::CloverGenerator::BAM_DEFINED_GRAPHS_ROOT)
|
38
|
+
]})
|
39
|
+
GoodData::Bam::Commands::generate('.', params)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
desc 'Jacks into SF.'
|
44
|
+
# arg_name 'Describe arguments to new here'
|
45
|
+
command :sf_jack_in do |c|
|
46
|
+
|
47
|
+
c.action do |global_options,options,args|
|
48
|
+
GoodData::Bam::Commands::sf_jack_in(PARAMS)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# desc 'Jacks into project.'
|
53
|
+
# # arg_name 'Describe arguments to new here'
|
54
|
+
# command :project_jack_in do |c|
|
55
|
+
#
|
56
|
+
# c.action do |global_options,options,args|
|
57
|
+
# GoodData::Bam::Commands::project_jack_in(PARAMS)
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
|
61
|
+
|
62
|
+
desc 'Validatates connection to SalesForce.'
|
63
|
+
# arg_name 'Describe arguments to new here'
|
64
|
+
command :sf_validate_connection do |c|
|
65
|
+
|
66
|
+
c.action do |global_options,options,args|
|
67
|
+
GoodData::Bam::Commands::sf_validate_connection(PARAMS)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
desc 'Generate data validator.'
|
73
|
+
# arg_name 'Describe arguments to new here'
|
74
|
+
command :generate_validator do |c|
|
75
|
+
c.action do |global_options,options,args|
|
76
|
+
GoodData::Bam::Commands::generate_validators('.', PARAMS.merge(options).merge({
|
77
|
+
:project_name => "validator-#{PARAMS[:project_name]}",
|
78
|
+
:graph_repos => [
|
79
|
+
GoodData::Bam::Repository.create(:type => :file, :base => './local_graphs'),
|
80
|
+
GoodData::Bam::Repository.create(:type => :file, :base => GoodData::CloverGenerator::BAM_DEFINED_GRAPHS_ROOT)
|
81
|
+
]
|
82
|
+
}))
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
desc 'Run data validator.'
|
87
|
+
# arg_name 'Describe arguments to new here'
|
88
|
+
command :run_validator do |c|
|
89
|
+
|
90
|
+
c.desc 'Checker process ID'
|
91
|
+
c.arg_name 'process'
|
92
|
+
c.flag :process
|
93
|
+
|
94
|
+
c.action do |global_options,options,args|
|
95
|
+
process = options[:process]
|
96
|
+
files = args.map {|f| Pathname(f)}
|
97
|
+
files.each do |f|
|
98
|
+
fail "Provded file \"#{f}\" does not exist." unless File.exist?(f)
|
99
|
+
end
|
100
|
+
fail "You need to specify process" if process.blank?
|
101
|
+
|
102
|
+
GoodData::Bam::Commands::connect_to_gd()
|
103
|
+
GoodData::Bam::Commands::run_validator(process, files, PARAMS)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
desc 'Generates clover project for downloaders.'
|
109
|
+
# arg_name 'Describe arguments to new here'
|
110
|
+
command :generate_downloaders do |c|
|
111
|
+
|
112
|
+
c.desc 's3 backup'
|
113
|
+
c.arg_name 'backup'
|
114
|
+
c.flag :backup
|
115
|
+
|
116
|
+
c.action do |global_options,options,args|
|
117
|
+
params = global_options[:user_params]
|
118
|
+
params = PARAMS.merge({
|
119
|
+
:project_name => "downloaders-#{PARAMS[:project_name]}",
|
120
|
+
:graph_repos => [
|
121
|
+
GoodData::Bam::Repository.create(:type => :file, :base => './local_graphs'),
|
122
|
+
GoodData::Bam::Repository.create(:type => :file, :base => GoodData::CloverGenerator::BAM_DEFINED_GRAPHS_ROOT)]
|
123
|
+
})
|
124
|
+
GoodData::Bam::Commands::generate_downloaders(".", params)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
command :generate_history_downloaders do |c|
|
129
|
+
|
130
|
+
c.desc 's3 backup'
|
131
|
+
c.arg_name 'backup'
|
132
|
+
c.flag :backup
|
133
|
+
|
134
|
+
c.action do |global_options,options,args|
|
135
|
+
params = global_options[:user_params]
|
136
|
+
params = PARAMS.merge({
|
137
|
+
:project_name => "downloaders-#{PARAMS[:project_name]}",
|
138
|
+
:graph_repos => [
|
139
|
+
GoodData::Bam::Repository.create(:type => :file, :base => './local_graphs'),
|
140
|
+
GoodData::Bam::Repository.create(:type => :file, :base => GoodData::CloverGenerator::BAM_DEFINED_GRAPHS_ROOT)]
|
141
|
+
})
|
142
|
+
<<<<<<< HEAD
|
143
|
+
GoodData::Bam::Commands::generate_downloaders(".", params)
|
144
|
+
=======
|
145
|
+
GoodData::Bam::Commands::generate_history_downloaders(".", params)
|
146
|
+
>>>>>>> Added historical SF downloader
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
desc 'Validates that the tap has the fields it is claimed it should have. This is supposed to make the mitigate errors during deploy.'
|
153
|
+
# arg_name 'Describe arguments to new here'
|
154
|
+
command :sf_taps_validate do |c|
|
155
|
+
c.action do |global_options,options,args|
|
156
|
+
verbose = global_options[:v]
|
157
|
+
params = PARAMS.merge({
|
158
|
+
:graph_repos => [
|
159
|
+
GoodData::Bam::Repository.create(:type => :file, :base => './local_graphs'),
|
160
|
+
GoodData::Bam::Repository.create(:type => :file, :base => GoodData::CloverGenerator::BAM_DEFINED_GRAPHS_ROOT)]})
|
161
|
+
result = GoodData::Bam::Commands::validate_sf_taps(params)
|
162
|
+
|
163
|
+
error = false
|
164
|
+
result.each_pair do |obj, fields|
|
165
|
+
if fields.empty?
|
166
|
+
puts HighLine::color("GOOD", :green) + " #{obj}"
|
167
|
+
else
|
168
|
+
error = true
|
169
|
+
puts HighLine::color("BAD", :red) + " #{obj} [" + fields.join(', ') + "]"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
exit_now!("Errors found",exit_code=1) if error
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
desc "Prepares params.prm file for debugging that particular graph"
|
177
|
+
command :debug do |c|
|
178
|
+
c.action do |global_options,options,args|
|
179
|
+
fail "Arguments should be passed as \"project\" \"flow\" \"graph\"" if args.length < 3
|
180
|
+
GoodData::Bam::Commands::set_up_debug(args.first, args[1], args[2])
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
desc 'Validates that the tap has the fields it is claimed it should have. This is supposed to make the mitigate errors during deploy.'
|
185
|
+
# arg_name 'Describe arguments to new here'
|
186
|
+
command :docs do |c|
|
187
|
+
c.action do |global_options,options,args|
|
188
|
+
GoodData::Bam::Commands::generate_docs
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
desc 'Lists processes for the project.'
|
193
|
+
# arg_name 'Describe arguments to new here'
|
194
|
+
command :procs do |c|
|
195
|
+
|
196
|
+
c.desc 'procs for all projects'
|
197
|
+
c.arg_name 'all'
|
198
|
+
c.switch :all
|
199
|
+
|
200
|
+
c.action do |global_options,options,args|
|
201
|
+
out = GoodData::Bam::Commands::procs_list(options)
|
202
|
+
out.each do |proc|
|
203
|
+
puts proc.join(',')
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
208
|
+
|
209
|
+
desc 'Creates project'
|
210
|
+
command :project do |c|
|
211
|
+
|
212
|
+
c.desc 'blueprint name. Currently support goodsales'
|
213
|
+
c.arg_name 'blueprint'
|
214
|
+
c.flag :blueprint
|
215
|
+
|
216
|
+
c.desc 'token'
|
217
|
+
c.arg_name 'token'
|
218
|
+
c.flag :token
|
219
|
+
|
220
|
+
c.action do |global_options,options,args|
|
221
|
+
fail "You need to specify token to create a project" if options[:token].nil?
|
222
|
+
|
223
|
+
GoodData::Bam::Commands::connect_to_gd()
|
224
|
+
pid = case options[:blueprint]
|
225
|
+
when "goodsales"
|
226
|
+
"nt935rwzls50zfqwy6dh62tabu8h0ocy"
|
227
|
+
end
|
228
|
+
|
229
|
+
params = PARAMS.merge({:token => options[:token]})
|
230
|
+
|
231
|
+
new_project = if pid
|
232
|
+
GoodData::Bam::Commands.clone_project(pid, params)
|
233
|
+
else
|
234
|
+
GoodData::Bam::Commands.create_project(params)
|
235
|
+
end
|
236
|
+
|
237
|
+
puts "Your project pid is #{new_project}"
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
|
243
|
+
desc 'Generates structures'
|
244
|
+
arg_name 'what you want to generate project, tap, flow, sink'
|
245
|
+
command :scaffold do |c|
|
246
|
+
|
247
|
+
c.desc 'blueprint name. Currently support goodsales'
|
248
|
+
c.arg_name 'blueprint'
|
249
|
+
c.flag :blueprint
|
250
|
+
|
251
|
+
c.action do |global_options,options,args|
|
252
|
+
command = args.first
|
253
|
+
fail "You did not provide what I should scaffold. I can generate project, tap, flow, sink, graph_template nothing else" unless ["project", "tap", "flow", "sink", "graph_template"].include?(command)
|
254
|
+
case command
|
255
|
+
when "project"
|
256
|
+
directory = args[1]
|
257
|
+
fail "Directory has to be provided as an argument. See help" if directory.nil?
|
258
|
+
if options[:blueprint].nil?
|
259
|
+
GoodData::Bam::Commands::setup_bash_structure(directory)
|
260
|
+
else
|
261
|
+
case options[:blueprint]
|
262
|
+
when "goodsales"
|
263
|
+
system "git clone git://github.com/gooddata/goodsales_base.git #{directory}"
|
264
|
+
end
|
265
|
+
end
|
266
|
+
when "flow"
|
267
|
+
name = args[1]
|
268
|
+
fail "Name of the flow has to be provided as an argument. See help" if name.nil?
|
269
|
+
GoodData::Bam::Commands::setup_flow(name)
|
270
|
+
when "tap"
|
271
|
+
name = args[1]
|
272
|
+
fail "Name of the tap has to be provided as an argument. See help" if name.nil?
|
273
|
+
GoodData::Bam::Commands::setup_tap(name)
|
274
|
+
when "sink"
|
275
|
+
name = args[1]
|
276
|
+
fail "Name of the sink has to be provided as an argument. See help" if name.nil?
|
277
|
+
GoodData::Bam::Commands::setup_sink(name)
|
278
|
+
when "graph_template"
|
279
|
+
name = args[1]
|
280
|
+
target = args[2]
|
281
|
+
fail "Name of the template has to be provided as an argument. See help" if name.nil?
|
282
|
+
fail "Name of the target has to be provided as an argument. See help" if target.nil?
|
283
|
+
GoodData::Bam::Commands::generate_graph_template(name, target)
|
284
|
+
end
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
desc 'Runs the project on server'
|
289
|
+
command :model_sync do |c|
|
290
|
+
|
291
|
+
c.desc 'do not execute'
|
292
|
+
c.arg_name 'dry'
|
293
|
+
c.switch :dry
|
294
|
+
|
295
|
+
c.action do |global_options,options,args|
|
296
|
+
GoodData::Bam::Commands::model_sync('.', options)
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
|
301
|
+
desc 'Deploys the project on server and schedules it'
|
302
|
+
command :deploy do |c|
|
303
|
+
|
304
|
+
c.desc 'existing process id under which it is going to be redeployed'
|
305
|
+
c.arg_name 'process'
|
306
|
+
c.flag :process
|
307
|
+
|
308
|
+
c.desc 'name of the process'
|
309
|
+
c.arg_name 'name'
|
310
|
+
c.flag :name
|
311
|
+
|
312
|
+
c.action do |global_options,options,args|
|
313
|
+
dir = args.first
|
314
|
+
fail "You have to specify directory to deploy as an argument" if dir.nil?
|
315
|
+
fail "Specified directory does not exist" unless File.exist?(dir)
|
316
|
+
|
317
|
+
GoodData::Bam::Commands::connect_to_gd()
|
318
|
+
params = PARAMS.merge(global_options.merge(options))
|
319
|
+
response = GoodData::Bam::Commands::deploy(dir, params)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
desc 'Runs the project on server'
|
324
|
+
command :run do |c|
|
325
|
+
|
326
|
+
c.desc 'email to addresses when the run is finished'
|
327
|
+
c.arg_name 'email'
|
328
|
+
c.flag :email
|
329
|
+
|
330
|
+
c.action do |global_options,options,args|
|
331
|
+
|
332
|
+
dir = args.first
|
333
|
+
fail "You have to specify directory to deploy as an argument" if dir.nil?
|
334
|
+
fail "Specified directory does not exist" unless File.exist?(dir)
|
335
|
+
|
336
|
+
params = PARAMS.merge(global_options.merge(options))
|
337
|
+
GoodData::Bam::Commands::connect_to_gd()
|
338
|
+
GoodData::Bam::Commands::run(dir, params)
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
|
343
|
+
pre do |global_options,command,options,args|
|
344
|
+
|
345
|
+
logger = Logger.new(STDOUT) if global_options[:l]
|
346
|
+
GoodData.logger = logger
|
347
|
+
params = GoodData::Bam::Utils::get_user_params('.')
|
348
|
+
s3_backup = GoodData::Bam::Utils::should_backup_to_s3?(params)
|
349
|
+
PARAMS = params.merge({:s3_backup => s3_backup})
|
350
|
+
|
351
|
+
# Pre logic here
|
352
|
+
# Return true to proceed; false to abort and not call the
|
353
|
+
# chosen command
|
354
|
+
# Use skips_pre before a command to skip this block
|
355
|
+
# on that command only
|
356
|
+
|
357
|
+
true
|
358
|
+
end
|
359
|
+
|
360
|
+
post do |global_options,command,options,args|
|
361
|
+
# Post logic here
|
362
|
+
# Use skips_post before a command to skip this
|
363
|
+
# block on that command only
|
364
|
+
verbose = global_options[:v]
|
365
|
+
puts HighLine::color("DONE", :green) if verbose
|
366
|
+
end
|
367
|
+
|
368
|
+
on_error do |exception|
|
369
|
+
pp exception.backtrace
|
370
|
+
# Error logic here
|
371
|
+
# return false to skip default error handling
|
372
|
+
true
|
373
|
+
end
|
374
|
+
|
375
|
+
exit run(ARGV)
|
data/lib/bam/version.rb
CHANGED
data/lib/base/project.rb
CHANGED
@@ -42,7 +42,7 @@ module GoodData
|
|
42
42
|
found.first
|
43
43
|
end
|
44
44
|
|
45
|
-
def self.load_taps(project, path
|
45
|
+
def self.load_taps(project, path)
|
46
46
|
p = Pathname(path)
|
47
47
|
taps = Pathname.glob(p + "*.json").map do |p|
|
48
48
|
Tap.create(JSON.parse(File.read(p), :symbolize_names => true))
|
@@ -64,7 +64,7 @@ module GoodData
|
|
64
64
|
Project.create(project.merge({:graph_repos => repos}))
|
65
65
|
end
|
66
66
|
|
67
|
-
def self.load_sinks(project, path
|
67
|
+
def self.load_sinks(project, path)
|
68
68
|
p = Pathname(path)
|
69
69
|
sinks = Pathname.glob(p + "*.json").map do |p|
|
70
70
|
Sink.create(JSON.parse(File.read(p), :symbolize_names => true))
|
@@ -72,7 +72,7 @@ module GoodData
|
|
72
72
|
Project.create(project.merge({:sinks => sinks}))
|
73
73
|
end
|
74
74
|
|
75
|
-
def self.load_flows_definitions(project, path
|
75
|
+
def self.load_flows_definitions(project, path)
|
76
76
|
p = Pathname(path)
|
77
77
|
flows = Pathname.glob(p + "*.rb").map do |p|
|
78
78
|
GoodData::Bam::DSL.class_eval(File.read p).to_hash
|
@@ -80,13 +80,14 @@ module GoodData
|
|
80
80
|
Project.create(project.merge({:flows_definitions => flows}))
|
81
81
|
end
|
82
82
|
|
83
|
-
def self.build_project(options={})
|
83
|
+
def self.build_project(home='.', options={})
|
84
|
+
home = Pathname(home)
|
84
85
|
project = Project.create({})
|
85
86
|
paths = options[:graph_repos] || []
|
86
|
-
p = Project.load_taps(project)
|
87
|
-
p = Project.load_sinks(p)
|
87
|
+
p = Project.load_taps(project, home + 'taps')
|
88
|
+
p = Project.load_sinks(p, home + 'sinks')
|
88
89
|
p = Project.set_graph_repos(p, paths)
|
89
|
-
p = Project.load_flows_definitions(p)
|
90
|
+
p = Project.load_flows_definitions(p, home + "flows")
|
90
91
|
p = Compiler.compile_dsl(p)
|
91
92
|
end
|
92
93
|
|
data/lib/base/tap.rb
CHANGED
@@ -2,8 +2,20 @@ module GoodData
|
|
2
2
|
module CloudConnect
|
3
3
|
module Helpers
|
4
4
|
|
5
|
-
def self.
|
6
|
-
|
5
|
+
def self.objects_for_history(client, tap)
|
6
|
+
sf_module = tap[:object]
|
7
|
+
modules = client.modules.map {|o| o[:name]}
|
8
|
+
modules.find_all {|m| ["#{sf_module}History", "#{sf_module}FieldHistory"].include?(m) }
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.generate_select(tap, options={})
|
12
|
+
field = options[:only]
|
13
|
+
fields = if field.nil?
|
14
|
+
tap[:fields]
|
15
|
+
else
|
16
|
+
tap[:fields].find_all {|f| f[:name] == field}
|
17
|
+
end
|
18
|
+
fields = fields.map do |f|
|
7
19
|
f.has_key?(:multi_currency) ? "convertCurrency(#{f[:name]})" : f[:name]
|
8
20
|
end
|
9
21
|
condition = tap[:condition].nil?() ? "" : "WHERE #{tap[:condition]}"
|
@@ -20,6 +32,25 @@ module GoodData
|
|
20
32
|
generate_select(tap)
|
21
33
|
end
|
22
34
|
|
35
|
+
def self.generate_history_query(client, field, sf_object, for_sf_object)
|
36
|
+
fields = client.fields(sf_object)
|
37
|
+
generic_field_history = ["NewValue", "OldValue", "ParentId"].all? {|f| fields.include?(f)}
|
38
|
+
specific_field_history = ["NewValue", "OldValue", "#{for_sf_object}Id"].all? {|f| fields.include?(f)}
|
39
|
+
specific_history = ["SystemModstamp", "#{for_sf_object}Id"].all? {|f| fields.include?(f)}
|
40
|
+
|
41
|
+
|
42
|
+
if generic_field_history
|
43
|
+
"SELECT NewValue, CreatedDate, ParentId FROM #{sf_object} WHERE Field = '#{field}'"
|
44
|
+
elsif specific_field_history
|
45
|
+
"SELECT NewValue, CreatedDate, ParentId FROM #{sf_object} WHERE Field = '#{field}'"
|
46
|
+
elsif specific_history
|
47
|
+
return nil unless fields.include?(field)
|
48
|
+
"SELECT #{field}, SystemModstamp, #{for_sf_object}Id FROM #{sf_object}"
|
49
|
+
else
|
50
|
+
fail "Unrecognized fields configuration for historization in SF."
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
23
54
|
def self.sf_connection(builder, data)
|
24
55
|
builder.Connection({
|
25
56
|
:clientId => "${SFDC_CLIENT_ID}",
|
data/lib/commands/commands.rb
CHANGED
@@ -13,16 +13,16 @@ module GoodData
|
|
13
13
|
render_template(template_name, PARAMS, :to_file => USER_DEFINED_GRAPHS_ROOT + target)
|
14
14
|
end
|
15
15
|
|
16
|
-
def self.project_jack_in(params)
|
17
|
-
|
18
|
-
end
|
16
|
+
# def self.project_jack_in(params)
|
17
|
+
# project = GoodData::Bam::Project.build_project
|
18
|
+
# end
|
19
19
|
|
20
20
|
def self.generate_validators(home, params)
|
21
21
|
home = Pathname(home)
|
22
22
|
clobber_contract_project(home, params)
|
23
23
|
setup_contract_project(home, params)
|
24
24
|
|
25
|
-
project = GoodData::Bam::Project.build_project(params)
|
25
|
+
project = GoodData::Bam::Project.build_project(home, params)
|
26
26
|
file_taps = Taps.get_file(project[:taps])
|
27
27
|
file_taps = file_taps.find_all {|t| t[:validation_source]}
|
28
28
|
file_taps.each do |t|
|
@@ -90,16 +90,24 @@ module GoodData
|
|
90
90
|
def self.generate_downloaders(home, params)
|
91
91
|
home = Pathname(home)
|
92
92
|
clobber_downloaders_project(home)
|
93
|
-
project = GoodData::Bam::Project.build_project(params)
|
93
|
+
project = GoodData::Bam::Project.build_project(home, params)
|
94
94
|
setup_downloaders_project(home, params)
|
95
95
|
GoodData::Bam::Generators::Downloaders.generate_downloaders(home + DOWNLOADERS_HOME + "graphs", project, params)
|
96
96
|
end
|
97
97
|
|
98
|
+
def self.generate_history_downloaders(home, params)
|
99
|
+
home = Pathname(home)
|
100
|
+
clobber_downloaders_project(home)
|
101
|
+
project = GoodData::Bam::Project.build_project(params)
|
102
|
+
setup_downloaders_project(home, params)
|
103
|
+
GoodData::Bam::Generators::Downloaders.generate_history_downloaders(home + DOWNLOADERS_HOME + "graphs", project, params)
|
104
|
+
end
|
105
|
+
|
98
106
|
def self.generate(home, params)
|
99
107
|
# fail "The flow you specified was not found" if flows.empty? && !only_flow.nil?
|
100
|
-
|
101
|
-
|
102
|
-
GoodData::Bam::Generators::Etl.generate(
|
108
|
+
clobber_etl_project(home)
|
109
|
+
setup_etl_project(home, params)
|
110
|
+
GoodData::Bam::Generators::Etl.generate(home, params)
|
103
111
|
end
|
104
112
|
|
105
113
|
end
|
data/lib/commands/gd_commands.rb
CHANGED
@@ -18,9 +18,9 @@ module GoodData
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.model_sync(options)
|
21
|
+
def self.model_sync(path, options)
|
22
22
|
dry_run = options[:dry]
|
23
|
-
project = build_project
|
23
|
+
project = build_project(path, options)
|
24
24
|
datasets = project.sinks
|
25
25
|
model_update_dir = Pathname('model_update')
|
26
26
|
cl_home = ENV['CL_HOME'] || PARAMS['CL_HOME'] || fail("Home of cl tool cannot be found. Either set up CL_HOME in your env with 'export CL_HOME=path/to/cl or set it up in your params.json. Point to the directory of CL not to the bin dir.'")
|
data/lib/commands/sf_commands.rb
CHANGED
@@ -3,7 +3,7 @@ module GoodData
|
|
3
3
|
module Commands
|
4
4
|
|
5
5
|
def self.validate_sf_taps(params)
|
6
|
-
project = GoodData::Bam::Project.build_project(params)
|
6
|
+
project = GoodData::Bam::Project.build_project(params[:home], params)
|
7
7
|
client = get_sf_client(params)
|
8
8
|
validate_sf_metadata(client, Taps.get_salesforce(project[:taps]))
|
9
9
|
end
|
data/lib/compiler/etl_visitor.rb
CHANGED
@@ -6,7 +6,7 @@ module GoodData
|
|
6
6
|
def visit(node, state)
|
7
7
|
case node[:type]
|
8
8
|
when :project
|
9
|
-
FileUtils::cd(GoodData::Bam::Commands::ETL_HOME) do
|
9
|
+
FileUtils::cd(Pathname(state[:home]) + GoodData::Bam::Commands::ETL_HOME) do
|
10
10
|
flows = if state[:only]
|
11
11
|
node[:flows].find_all {|f| f[:name] == state[:only]}
|
12
12
|
else
|