Module: GoodData::CloudConnect::Nodes

Defined in:
lib/cloud_connect/dsl/nodes.rb

Constant Summary collapse

SF_CONNECTION =
"SFDC"
EDGE =
"EDGE"
WRITER =
"DATA_WRITER"
DEDUP =
"DEDUP"
READER =
"DATA_READER"
SF_READER =
"SF_READER"
SF_DELETED_READER =
"SF_DELETED_READER"
REFORMAT =
"REFORMAT"
FILE_BACKUP =
"FILE_BACKUP"
PERSISTENT_LOOKUP =
"persistentLookup"
GD_LOOKUP =
"gdLookup"
GD_ESTORE_WRITER =
"GD_ESTORE_WRITER"
GD_FILE_BACKUP =
"FILE_BACKUP"
GD_FILE_COPY =
"FILE_COPY_MOVE"
FILE_DELETE =
"FILE_DELETE"
GD_ESTORE_READER =
"GD_ESTORE_READER"
ENABLED =
"ENABLED"
DEFAULT_HEIGHT =
"77"
DEFAULT_WIDTH =
"128"
GD_DATASET_WRITER =
"GD_DATASET_WRITER"
GD_ESTORE_TRUNCATE =
"GD_ESTORE_TRUNCATE"
DATA_GENERATOR =
"DATA_GENERATOR"
SIMPLE_GATHER =
"SIMPLE_GATHER"
SIMPLE_COPY =
"SIMPLE_COPY"
CHECK_FOREIGN_KEY =
"CHECK_FOREIGN_KEY"
RUN_GRAPH =
"RUN_GRAPH"
TRASH =
"TRASH"
LOOKUP_TABLE_READER_WRITER =
"LOOKUP_TABLE_READER_WRITER"
FILE_COPY_MOVE =
"FILE_COPY_MOVE"
FILE_LIST =
"FILE_LIST"
EXT_SORT =
"EXT_SORT"
EXT_HASH_JOIN =
"EXT_HASH_JOIN"
NORMALIZER =
"NORMALIZER"
MAP_ALL =
<<HEREDOC
function integer transform() {
    $out.0.* = $in.0.*;
    return ALL;
}
HEREDOC
DEFAULT_NODE_PARAMS =
{
  :enabled    => ENABLED,
  :guiHeight  => DEFAULT_HEIGHT,
  :guiWidth   => DEFAULT_WIDTH
}

Class Method Summary collapse

Class Method Details

.backup2(data, options = {}) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/cloud_connect/dsl/nodes.rb', line 149

def self.backup2(data, options={})
  local_defaults = {
    :type => GD_FILE_BACKUP,
    :mode => "ALL_TO_ONE",
    :appendTimestamp => true,
    :makeDirs => true
  }
  defaults = local_defaults.merge(options[:defaults] || {})

  base_node(defaults.merge(data), {
    :allowed => [:sourcePath, :makeDirs, :appendTimestamp, :mode, :baseURL],
    :defaults => defaults,
    :required => []
  })
end

.base_node(data, options = {}) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/cloud_connect/dsl/nodes.rb', line 70

def self.base_node(data, options={})
  defaults = DEFAULT_NODE_PARAMS.merge(options[:defaults] || {})
  required = (options[:required] || []).concat([:type, :id])
  allowed = options[:allowed] || []
  output_data = defaults.merge({
    :id => get_id()
  }).merge(data)

  node(output_data, {
    :allowed => [:enabled, :guiName, :id, :type, :guiHeight, :guiWidth, :name].concat(allowed),
    :required => required,
    :defaults => defaults
  })
end

.connection2(data, options = {}) ⇒ Object



463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
# File 'lib/cloud_connect/dsl/nodes.rb', line 463

def self.connection2(data, options={})
  local_defaults = {
    :type               => SF_CONNECTION,
    :passwordEncrypted  => "false",
    :loginHostname      => "login.salesforce.com",
    :clientId           => "gooddata/gooddata/",
    :name               => "Salesforce connection"
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  node(defaults.merge(data), {
    :allowed => [:type, :name, :clientId, :loginHostname, :name, :username, :password, :passwordEncrypted, :token, :id],
    :defaults => defaults,
    :required => [:password, :username, :token, :loginHostname, :id, :clientId, :name]
  })
end

.copy2(data, options = {}) ⇒ Object



451
452
453
454
455
456
457
458
459
460
461
# File 'lib/cloud_connect/dsl/nodes.rb', line 451

def self.copy2(data, options={})
  local_defaults = {
    :type           => SIMPLE_COPY,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.data_generator2(data, options = {}) ⇒ Object



337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/cloud_connect/dsl/nodes.rb', line 337

def self.data_generator2(data, options={})
  local_defaults = {
    :type           => DATA_GENERATOR,
    :recordsNumber  => 1
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.dedup2(data, options = {}) ⇒ Object



226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/cloud_connect/dsl/nodes.rb', line 226

def self.dedup2(data, options={})
  local_defaults = {
    :type => DEDUP,
  }
  defaults = local_defaults.merge(options[:defaults] || {})

  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => [:dedupKey]
  })

end

.edge2(data, options = {}) ⇒ Object



253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/cloud_connect/dsl/nodes.rb', line 253

def self.edge2(data, options={})
  local_defaults = {
    :type           => EDGE,
    :guiBendpoints  => "",
    :guiRouter      => "Manhattan",
    :inPort         => "Port 0 (in)",
    :outPort        => "Port 0 (output)"
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.es_reader2(data, options = {}) ⇒ Object



400
401
402
403
404
405
406
407
408
409
410
# File 'lib/cloud_connect/dsl/nodes.rb', line 400

def self.es_reader2(data, options={})
  local_defaults = {
    :type           => GD_ESTORE_READER,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.es_truncate2(data, options = {}) ⇒ Object



387
388
389
390
391
392
393
394
395
396
397
# File 'lib/cloud_connect/dsl/nodes.rb', line 387

def self.es_truncate2(data, options={})
  local_defaults = {
    :type           => GD_ESTORE_TRUNCATE,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.es_writer2(data, options = {}) ⇒ Object



412
413
414
415
416
417
418
419
420
421
422
# File 'lib/cloud_connect/dsl/nodes.rb', line 412

def self.es_writer2(data, options={})
  local_defaults = {
    :type           => GD_ESTORE_WRITER,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.file_backup2(data, options = {}) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
# File 'lib/cloud_connect/dsl/nodes.rb', line 165

def self.file_backup2(data, options={})
  local_defaults = {
    :type => FILE_BACKUP,
    :makeDirs => true
  }
  defaults = local_defaults.merge(options[:defaults] || {})

  base_node(defaults.merge(data), {
    :allowed => [:sourcePath, :baseURL, :mode, :makeDirs],
    :defaults => defaults,
    :required => []
  })
end

.file_copy2(data, options = {}) ⇒ Object



179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/cloud_connect/dsl/nodes.rb', line 179

def self.file_copy2(data, options={})
  local_defaults = {
    :type => GD_FILE_COPY,
    :operation => "COPY",
    :makeDirs => true
  }
  defaults = local_defaults.merge(options[:defaults] || {})

  base_node(defaults.merge(data), {
    :allowed => [:sourcePath, :targetPath, :makeDirs, :operation, :baseURL],
    :defaults => defaults,
    :required => []
  })
end

.file_delete2(data, options = {}) ⇒ Object



136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/cloud_connect/dsl/nodes.rb', line 136

def self.file_delete2(data, options={})
  local_defaults = {
    :type => FILE_DELETE
  }
  defaults = local_defaults.merge(options[:defaults] || {})

  base_node(defaults.merge(data), {
    :allowed => [:baseURL],
    :defaults => defaults,
    :required => [:baseURL]
  })
end

.file_list2(data, options = {}) ⇒ Object

<Node baseURL=“$DATA/1_in.csv” enabled=“enabled” guiHeight=“65” guiName=“File List” guiWidth=“128” guiX=“147” guiY=“213” id=“FILE_LIST0” outputMapping=“//#CTL2&#10;&#10;// Transforms input record into output record.&#10;function integer transform() = $in.0.fileName;&#10;&#10;&#9;return ALL;&#10;&#10;&#10;// Called during component initialization.&#10;// function boolean init() {}&#10;&#10;// Called during each graph run before the transform is executed. May be used to allocate and initialize resources&#10;// required by the transform. All resources allocated within this method should be released&#10;// by the postExecute() method.&#10;// function void preExecute() {}&#10;&#10;// Called only if transform() throws an exception.&#10;// function integer transformOnError(string errorMessage, string stackTrace) {}&#10;&#10;// Called during each graph run after the entire transform was executed. Should be used to free any resources&#10;// allocated within the preExecute() method.&#10;// function void postExecute() {}&#10;&#10;// Called to return a user-defined error message when an error occurs.&#10;// function string getMessage() {}&#10;” type=“FILE_LIST”/>



351
352
353
354
355
356
357
358
359
360
361
# File 'lib/cloud_connect/dsl/nodes.rb', line 351

def self.file_list2(data, options={})
  local_defaults = {
    :type           => FILE_LIST,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => [:output_mapping]
  })
end

.gather2(data, options = {}) ⇒ Object



438
439
440
441
442
443
444
445
446
447
448
# File 'lib/cloud_connect/dsl/nodes.rb', line 438

def self.gather2(data, options={})
  local_defaults = {
    :type           => SIMPLE_GATHER,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.gd_loader2(data, options = {}) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/cloud_connect/dsl/nodes.rb', line 85

def self.gd_loader2(data, options={})
  local_defaults = {
    :type => GD_DATASET_WRITER,
    :projectId => "${GDC_PROJECT_ID}",
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [:enabled, :guiName, :id, :type, :guiHeight, :guiWidth, :name, :projectId, :dataset, :datasetFieldMappings],
    :defaults => defaults,
    :required => []
  })
end

.get_idObject



53
54
55
# File 'lib/cloud_connect/dsl/nodes.rb', line 53

def self.get_id()
  $__cloud_connect_id += 1
end

.hash_join2(data, options = {}) ⇒ Object



363
364
365
366
367
368
369
370
371
372
373
# File 'lib/cloud_connect/dsl/nodes.rb', line 363

def self.hash_join2(data, options={})
  local_defaults = {
    :type           => EXT_HASH_JOIN,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.lookup2(data, options = {}) ⇒ Object



310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/cloud_connect/dsl/nodes.rb', line 310

def self.lookup2(data, options={})
  local_defaults = {
    :type           => PERSISTENT_LOOKUP,
    :cacheSize      => "1000",
    :commitInterval => "100",
    :pageSize       => "16"
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => [:metadata]
  })
end

.lookup_reader_writer2(data, options = {}) ⇒ Object



298
299
300
301
302
303
304
305
306
307
308
# File 'lib/cloud_connect/dsl/nodes.rb', line 298

def self.lookup_reader_writer2(data, options={})
  local_defaults = {
    :type           => LOOKUP_TABLE_READER_WRITER,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.metadata2(data) ⇒ Object



269
270
271
# File 'lib/cloud_connect/dsl/nodes.rb', line 269

def self.metadata2(data)
  data
end

.node(data, options = {}) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/cloud_connect/dsl/nodes.rb', line 57

def self.node(data, options={})
  defaults = options[:defaults] || {}
  required = options[:required] || []
  allowed = options[:allowed] || []
  output_data = defaults.merge(data)
  required.each do |key|
    unless output_data.has_key?(key)
      fail "#{key} is required but not provided. You defined \"#{data}\""
    end
  end
  output_data
end

.normalizer2(data, options = {}) ⇒ Object



285
286
287
288
289
290
291
292
293
294
295
# File 'lib/cloud_connect/dsl/nodes.rb', line 285

def self.normalizer2(data, options={})
  local_defaults = {
    :type           => NORMALIZER,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.reader2(data, options = {}) ⇒ Object



117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/cloud_connect/dsl/nodes.rb', line 117

def self.reader2(data, options={})
  local_defaults = {
    :type => READER,
    :quoteCharacter => "\"",
    :charset => "UTF-8",
    :quotedStrings => "true",
    :skipRows => 1
  }
  defaults = local_defaults.merge(options[:defaults] || {})

  base_node(defaults.merge(data), {
    :allowed => [:fileURL, :quotedStrings, :quoteCharacter, :charset, :skipRows],
    :defaults => defaults,
    :required => [:fileURL]
  })
end

.reformat2(data, options = {}) ⇒ Object



273
274
275
276
277
278
279
280
281
282
283
# File 'lib/cloud_connect/dsl/nodes.rb', line 273

def self.reformat2(data, options={})
  local_defaults = {
    :type           => REFORMAT,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.run_graph2(data, options = {}) ⇒ Object



240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/cloud_connect/dsl/nodes.rb', line 240

def self.run_graph2(data, options={})
  local_defaults = {
    :type => RUN_GRAPH,
    :paramsToPass => "GDC_WEBDAV_ROOT;GDC_PROJECT_ID;GDC_USERNAME;GDC_PASSWORD;GDC_SST"
  }
  defaults = local_defaults.merge(options[:defaults] || {})

  base_node(defaults.merge(data), {
    :allowed => [:paramsToPass, :type, :name, :clientId, :loginHostname, :name, :username, :password, :passwordEncrypted, :token, :id],
    :defaults => defaults
  })
end

.sfdc_deleted_records(data, options = {}) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
208
# File 'lib/cloud_connect/dsl/nodes.rb', line 195

def self.sfdc_deleted_records(data, options={})
  local_defaults = {
    :type => SF_DELETED_READER,
    :retryDelay => 100,
    :startDateTime => "`date2str(dateadd(today(), -20, day), \"yyyy-MM-dd'T'00:00:00.000'Z'\")`"
  }
  defaults = local_defaults.merge(options[:defaults] || {})

  base_node(defaults.merge(data), {
    :allowed => [:entity, :sfdcConnection],
    :defaults => defaults,
    :required => [:entity, :sfdcConnection, :startDateTime]
  })
end

.sfdc_reader2(data, options = {}) ⇒ Object



211
212
213
214
215
216
217
218
219
220
221
222
223
224
# File 'lib/cloud_connect/dsl/nodes.rb', line 211

def self.sfdc_reader2(data, options={})
  local_defaults = {
    :type => SF_READER,
    :retryDelay => 100
  }
  defaults = local_defaults.merge(options[:defaults] || {})

  base_node(defaults.merge(data), {
    :allowed => [:soql, :sfdcConnection, :mandatoryFields],
    :defaults => defaults,
    :required => [:soql, :sfdcConnection]
  })

end

.sort2(data, options = {}) ⇒ Object



375
376
377
378
379
380
381
382
383
384
385
# File 'lib/cloud_connect/dsl/nodes.rb', line 375

def self.sort2(data, options={})
  local_defaults = {
    :type           => EXT_SORT,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.trash2(data, options = {}) ⇒ Object



325
326
327
328
329
330
331
332
333
334
335
# File 'lib/cloud_connect/dsl/nodes.rb', line 325

def self.trash2(data, options={})
  local_defaults = {
    :type           => TRASH,
  }
  defaults = local_defaults.merge(options[:defaults] || {})
  base_node(defaults.merge(data), {
    :allowed => [],
    :defaults => defaults,
    :required => []
  })
end

.writer2(data, options = {}) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/cloud_connect/dsl/nodes.rb', line 98

def self.writer2(data, options={})
  local_defaults = {
    :type => WRITER,
    :quoteCharacter => "\"",
    :charset => "UTF-8",
    :quotedStrings => "true",
    :append => "false",
    :outputFieldNames => "false",
    :makeDirs => "true"
  }
  defaults = local_defaults.merge(options[:defaults] || {})

  base_node(defaults.merge(data), {
    :allowed => [:fileURL, :quotedStrings, :quoteCharacter, :charset, :outputFieldNames, :append, :makeDirs],
    :defaults => defaults,
    :required => [:fileURL]
  })
end