gd_bam 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
data/bin/bam CHANGED
@@ -191,6 +191,11 @@ command :debug do |c|
191
191
  flows = project[:flows].find_all do |flow|
192
192
  GoodData::Bam::Flow.find_graphs(flow).map {|s| GoodData::Bam::Step.get_graph_path(s).basename}.any? {|name| name == debug_path}
193
193
  end
194
+
195
+ if flows.empty?
196
+ fail "Graph \"#{debug_path}\" is not used in any flow."
197
+ end
198
+
194
199
  index = if flows.count > 1
195
200
  m = HighLine::Menu.new
196
201
  m.choose do |menu|
@@ -248,8 +253,9 @@ command :project do |c|
248
253
 
249
254
  c.action do |global_options,options,args|
250
255
  fail "You need to specify token to create a project" if options[:token].nil?
251
-
256
+ binding.pry
252
257
  GoodData::Bam::Commands::connect_to_gd()
258
+ binding.pry
253
259
  pid = case options[:blueprint]
254
260
  when "goodsales"
255
261
  "nt935rwzls50zfqwy6dh62tabu8h0ocy"
data/lib/bam/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bam
2
- VERSION = '0.1.19'
2
+ VERSION = '0.1.20'
3
3
  end
data/lib/base/sink.rb CHANGED
@@ -17,6 +17,10 @@ module GoodData
17
17
  !find_field(sink, name).nil?
18
18
  end
19
19
 
20
+ def self.get_date_fields(sink)
21
+ sink[:fields].find_all {|f| f[:type] == "date"}
22
+ end
23
+
20
24
  def self.add_target_type(sink)
21
25
  target = sink[:target].to_s
22
26
  path = Pathname(target)
@@ -14,7 +14,11 @@ module GoodData
14
14
  u = sf_client.describe(sf_object)
15
15
  sf_fields = u[:describeSObjectResponse][:result][:fields].map {|field| field[:name]}
16
16
  fields_to_validate = tap[:fields].map {|field| field[:name]}
17
- memo[sf_object] = (fields_to_validate - sf_fields)
17
+ if memo.has_key?(sf_object)
18
+ memo[sf_object] = memo[sf_object].concat(fields_to_validate - sf_fields)
19
+ else
20
+ memo[sf_object] = (fields_to_validate - sf_fields)
21
+ end
18
22
  memo
19
23
  end
20
24
  end
@@ -109,11 +109,36 @@ module GoodData
109
109
  Helpers::csv_metadata(builder, state[:metadata][input_name])
110
110
  end
111
111
  end
112
+
112
113
  builder.Phase(:number => 0) do
113
114
  gd_dataset = sink[:gd_name] || sink[:id]
114
115
  to_svinstvo = GoodData::CloverGenerator::build_gd_dataset_loader_json(sink)
115
116
  Core::build_node2(builder, Nodes.reader2({:name => "CSV Loader", :id => "loader", :fileURL => "${PROJECT}/data/#{input_name}.csv"}))
116
- Core::build_node2(builder, Nodes.edge2({:toNode => "gd_load:0", :fromNode => "loader:0", :metadata => "load_metadata"}))
117
+ Core::build_node2(builder, Nodes.edge2({:toNode => "gd_load:0", :fromNode => "reformat:0", :metadata => "load_metadata"}))
118
+
119
+ transform = <<HEREDOC
120
+ function string gd_date_compliance(string a_date) {
121
+ if (a_date != null && a_date != "" && left(a_date, 4) < "1950") {
122
+ return '1950-01-01';
123
+ }
124
+ if (a_date != null && a_date != "" && left(a_date, 4) > "2049") {
125
+ return '2049-01-01';
126
+ }
127
+ return a_date;
128
+ }
129
+
130
+ function integer transform() {
131
+ $out.0.* = $in.0.*;
132
+ #{Sink.get_date_fields(sink).map do |f|
133
+ "$out.0.#{f[:meta]} = gd_date_compliance($in.0.#{f[:meta]});"
134
+ end.join("\n")}
135
+
136
+ return ALL;
137
+ }
138
+ HEREDOC
139
+
140
+ Core::build_node2(builder, Nodes.reformat2({:name => "Reformat", :id => "reformat", :transformation => transform}))
141
+ Core::build_node2(builder, Nodes.edge2({:toNode => "reformat:0", :fromNode => "loader:0", :metadata => "load_metadata"}))
117
142
  Core::build_node2(builder, Nodes.gd_loader2({:name => "GD Loader", :id => "gd_load", :dataset => "dataset.#{gd_dataset}", :datasetFieldMappings => to_svinstvo.to_json}))
118
143
  end
119
144
  end
@@ -345,39 +345,39 @@ module GoodData
345
345
 
346
346
 
347
347
 
348
- def self.create_es_uploading_graph(file, options={})
349
- metadata = options[:metadata]
350
- dataset_infos = [options[:datasets]]
351
- input_file = options[:input_file]
352
-
353
- File.open(file, "w") do |file|
354
- builder = Builder::XmlMarkup.new(:target=>file, :indent=>2)
355
- builder.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
356
- builder.Graph({
357
- :name => "Goodsales Downloader"
358
- }) do
359
- builder.Global do
360
- property_file(builder, {:id => "workspace_params", :fileURL => "workspace.prm"})
361
- dataset_infos.each do |dataset_info|
362
- dataset = dataset_info[:id]
363
- builder.Metadata({:id => "#{dataset}_load"}) do |builder|
364
- csv_metadata(builder, metadata)
365
- end
366
- end
367
- end
368
- builder.Phase(:number => 0) do
369
- dataset_infos.each do |dataset_info|
370
- dataset = dataset_info[:id]
371
- gd_dataset = dataset_info[:gd_name] || dataset_info[:id]
372
- to_svinstvo = build_gd_dataset_loader_json(dataset_info)
373
- build_node2(builder, GoodData::CloverGenerator::Nodes.reader2({:name => "#{dataset} CSV Loader", :id => "#{dataset}_loader", :fileURL => "${PROJECT}/data/#{dataset}.csv"}))
374
- build_node2(builder, GoodData::CloverGenerator::Nodes.edge2({:toNode => "#{dataset}_load:0", :fromNode => "#{dataset}_loader:0", :metadata => "#{dataset}_load", :id => get_id()}))
375
- build_node2(builder, GoodData::CloverGenerator::Nodes.gd_loader2({:name => "#{dataset} Loader", :id => "#{dataset}_load", :dataset => "dataset.#{gd_dataset}", :datasetFieldMappings => to_svinstvo.to_json}))
376
- end
377
- end
378
- end
379
- end
380
- end
348
+ # def self.create_es_uploading_graph(file, options={})
349
+ # metadata = options[:metadata]
350
+ # dataset_infos = [options[:datasets]]
351
+ # input_file = options[:input_file]
352
+ #
353
+ # File.open(file, "w") do |file|
354
+ # builder = Builder::XmlMarkup.new(:target=>file, :indent=>2)
355
+ # builder.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8"
356
+ # builder.Graph({
357
+ # :name => "GoodData Uploader"
358
+ # }) do
359
+ # builder.Global do
360
+ # property_file(builder, {:id => "workspace_params", :fileURL => "workspace.prm"})
361
+ # dataset_infos.each do |dataset_info|
362
+ # dataset = dataset_info[:id]
363
+ # builder.Metadata({:id => "#{dataset}_load"}) do |builder|
364
+ # csv_metadata(builder, metadata)
365
+ # end
366
+ # end
367
+ # end
368
+ # builder.Phase(:number => 0) do
369
+ # dataset_infos.each do |dataset_info|
370
+ # dataset = dataset_info[:id]
371
+ # gd_dataset = dataset_info[:gd_name] || dataset_info[:id]
372
+ # to_svinstvo = build_gd_dataset_loader_json(dataset_info)
373
+ # build_node2(builder, GoodData::CloverGenerator::Nodes.reader2({:name => "#{dataset} CSV Loader", :id => "#{dataset}_loader", :fileURL => "${PROJECT}/data/#{dataset}.csv"}))
374
+ # build_node2(builder, GoodData::CloverGenerator::Nodes.edge2({:toNode => "#{dataset}_load:0", :fromNode => "#{dataset}_loader:0", :metadata => "#{dataset}_load", :id => get_id()}))
375
+ # build_node2(builder, GoodData::CloverGenerator::Nodes.gd_loader2({:name => "#{dataset} Loader", :id => "#{dataset}_load", :dataset => "dataset.#{gd_dataset}", :datasetFieldMappings => to_svinstvo.to_json}))
376
+ # end
377
+ # end
378
+ # end
379
+ # end
380
+ # end
381
381
 
382
382
  def self.create_metadata(mod)
383
383
  module_name = mod.object
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gd_bam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.20
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-01 00:00:00.000000000 Z
12
+ date: 2013-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake