gooddata 0.6.51 → 0.6.52
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/CHANGELOG.md +13 -1
- data/CONTRIBUTING.md +25 -0
- data/PULL_REQUEST_TEMPLATE.md +5 -0
- data/README.md +7 -4
- data/gooddata.gemspec +2 -3
- data/lib/gooddata.rb +1 -0
- data/lib/gooddata/bricks/base_downloader.rb +6 -6
- data/lib/gooddata/bricks/middleware/aws_middleware.rb +15 -5
- data/lib/gooddata/bricks/middleware/dwh_middleware.rb +15 -3
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +13 -4
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +3 -0
- data/lib/gooddata/exceptions/no_project_error.rb +5 -1
- data/lib/gooddata/goodzilla/goodzilla.rb +7 -6
- data/lib/gooddata/helpers/data_helper.rb +4 -4
- data/lib/gooddata/helpers/global_helpers_params.rb +61 -39
- data/lib/gooddata/lcm/actions/apply_custom_maql.rb +9 -0
- data/lib/gooddata/lcm/actions/associate_clients.rb +23 -4
- data/lib/gooddata/lcm/actions/collect_attrs.rb +56 -0
- data/lib/gooddata/lcm/actions/collect_ca_metrics.rb +53 -0
- data/lib/gooddata/lcm/actions/collect_clients.rb +25 -3
- data/lib/gooddata/lcm/actions/collect_meta.rb +83 -0
- data/lib/gooddata/lcm/actions/collect_segment_clients.rb +12 -4
- data/lib/gooddata/lcm/actions/collect_segments.rb +4 -4
- data/lib/gooddata/lcm/actions/collect_tagged_objects.rb +74 -0
- data/lib/gooddata/lcm/actions/create_segment_masters.rb +16 -30
- data/lib/gooddata/lcm/actions/ensure_release_table.rb +0 -3
- data/lib/gooddata/lcm/actions/ensure_segments.rb +1 -4
- data/lib/gooddata/lcm/actions/ensure_technical_users_domain.rb +5 -5
- data/lib/gooddata/lcm/actions/ensure_technical_users_project.rb +8 -5
- data/lib/gooddata/lcm/actions/hello_world.rb +0 -3
- data/lib/gooddata/lcm/actions/import_object_collections.rb +60 -0
- data/lib/gooddata/lcm/actions/print_actions.rb +0 -3
- data/lib/gooddata/lcm/actions/print_modes.rb +0 -3
- data/lib/gooddata/lcm/actions/print_types.rb +1 -4
- data/lib/gooddata/lcm/actions/provision_clients.rb +5 -5
- data/lib/gooddata/lcm/actions/purge_clients.rb +4 -10
- data/lib/gooddata/lcm/actions/segments_filter.rb +0 -6
- data/lib/gooddata/lcm/actions/synchronize_attribute_drillpaths.rb +8 -4
- data/lib/gooddata/lcm/actions/synchronize_cas.rb +61 -0
- data/lib/gooddata/lcm/actions/synchronize_clients.rb +9 -3
- data/lib/gooddata/lcm/actions/synchronize_color_palette.rb +13 -5
- data/lib/gooddata/lcm/actions/synchronize_etls_in_segment.rb +71 -17
- data/lib/gooddata/lcm/actions/synchronize_label_types.rb +8 -5
- data/lib/gooddata/lcm/actions/synchronize_ldm.rb +17 -8
- data/lib/gooddata/lcm/actions/synchronize_meta.rb +0 -3
- data/lib/gooddata/lcm/actions/synchronize_new_segments.rb +9 -4
- data/lib/gooddata/lcm/actions/synchronize_processes.rb +9 -5
- data/lib/gooddata/lcm/actions/synchronize_schedules.rb +15 -5
- data/lib/gooddata/lcm/actions/synchronize_tag_objects.rb +61 -0
- data/lib/gooddata/lcm/actions/update_release_table.rb +0 -3
- data/lib/gooddata/lcm/helpers/tags_helper.rb +35 -0
- data/lib/gooddata/lcm/lcm.rb +22 -4
- data/lib/gooddata/lcm/lcm2.rb +66 -13
- data/lib/gooddata/lcm/types/complex/update_preference.rb +1 -1
- data/lib/gooddata/mixins/md_finders.rb +4 -2
- data/lib/gooddata/mixins/md_object_indexer.rb +13 -3
- data/lib/gooddata/mixins/md_object_query.rb +8 -2
- data/lib/gooddata/models/blueprint/date_dimension.rb +6 -0
- data/lib/gooddata/models/blueprint/project_blueprint.rb +41 -11
- data/lib/gooddata/models/blueprint/project_builder.rb +20 -0
- data/lib/gooddata/models/blueprint/to_wire.rb +7 -0
- data/lib/gooddata/models/client.rb +6 -0
- data/lib/gooddata/models/domain.rb +6 -6
- data/lib/gooddata/models/from_wire.rb +5 -1
- data/lib/gooddata/models/metadata.rb +55 -9
- data/lib/gooddata/models/metadata/attribute.rb +19 -4
- data/lib/gooddata/models/metadata/dashboard.rb +15 -3
- data/lib/gooddata/models/metadata/dataset.rb +5 -2
- data/lib/gooddata/models/metadata/dimension.rb +4 -1
- data/lib/gooddata/models/metadata/fact.rb +9 -2
- data/lib/gooddata/models/metadata/folder.rb +4 -1
- data/lib/gooddata/models/metadata/metric.rb +11 -3
- data/lib/gooddata/models/metadata/report.rb +7 -2
- data/lib/gooddata/models/metadata/report_definition.rb +11 -4
- data/lib/gooddata/models/metadata/scheduled_mail.rb +4 -1
- data/lib/gooddata/models/metadata/variable.rb +7 -2
- data/lib/gooddata/models/model.rb +14 -3
- data/lib/gooddata/models/process.rb +10 -9
- data/lib/gooddata/models/project.rb +134 -36
- data/lib/gooddata/models/project_creator.rb +43 -20
- data/lib/gooddata/models/report_data_result.rb +6 -2
- data/lib/gooddata/models/schedule.rb +6 -3
- data/lib/gooddata/models/subscription.rb +8 -1
- data/lib/gooddata/models/user_filters/user_filter.rb +1 -0
- data/lib/gooddata/models/user_filters/user_filter_builder.rb +18 -4
- data/lib/gooddata/models/user_filters/variable_user_filter.rb +3 -1
- data/lib/gooddata/rest/client.rb +4 -6
- data/lib/gooddata/rest/connection.rb +10 -2
- data/lib/gooddata/version.rb +1 -1
- data/spec/data/blueprints/test_blueprint.json +1 -0
- data/spec/data/wire_models/test_blueprint.json +3 -0
- data/spec/data/workspace_table.csv +3 -0
- data/spec/environment/development.rb +4 -1
- data/spec/environment/environment.rb +1 -1
- data/spec/environment/staging.rb +5 -1
- data/spec/environment/testing.rb +5 -2
- data/spec/integration/blueprint_with_ca_spec.rb +56 -0
- data/spec/integration/clients_spec.rb +21 -0
- data/spec/integration/command_datawarehouse_spec.rb +7 -1
- data/spec/integration/create_from_template_spec.rb +9 -3
- data/spec/integration/project_spec.rb +7 -0
- data/spec/integration/segments_spec.rb +0 -53
- data/spec/integration/subscription_spec.rb +29 -4
- data/spec/integration/urn_date_dim_spec.rb +53 -0
- data/spec/integration/user_filters_spec.rb +6 -0
- data/spec/integration/variables_spec.rb +1 -2
- data/spec/spec_helper.rb +5 -30
- data/spec/unit/actions/collect_clients_spec.rb +38 -0
- data/spec/unit/actions/collect_meta_spec.rb +87 -0
- data/spec/unit/actions/collect_segment_clients_spec.rb +40 -0
- data/spec/unit/actions/collect_tagged_objects_spec.rb +110 -0
- data/spec/unit/actions/synchronize_etls_in_segment_spec.rb +51 -0
- data/spec/unit/bricks/middleware/aws_middelware_spec.rb +55 -1
- data/spec/unit/bricks/middleware/logger_middleware_spec.rb +15 -0
- data/spec/unit/helpers/data_helper_spec.rb +3 -5
- data/spec/unit/helpers/global_helpers_spec.rb +29 -0
- data/spec/unit/helpers_spec.rb +18 -1
- data/spec/unit/models/blueprint/project_blueprint_spec.rb +1 -23
- data/spec/unit/models/domain_spec.rb +19 -0
- data/spec/unit/models/metadata_spec.rb +34 -0
- data/spec/unit/models/schedule_spec.rb +31 -0
- data/spec/unit/models/to_manifest_spec.rb +10 -2
- data/spec/unit/models/unit_project_spec.rb +6 -1
- data/spec/unit/rest/polling_spec.rb +13 -1
- metadata +49 -31
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
#
|
3
|
+
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
6
|
+
|
7
|
+
module GoodData
|
8
|
+
module LCM2
|
9
|
+
class Helpers
|
10
|
+
class << self
|
11
|
+
# @param Array of segments as in release brick parameters
|
12
|
+
# @return Hash of segments and production tags
|
13
|
+
# @example { { segment: 'tag1, tag1' } }
|
14
|
+
def segment_production_tags(segments)
|
15
|
+
return {} unless segments
|
16
|
+
segments
|
17
|
+
.reject { |s| s.production_tag.nil? }
|
18
|
+
.map { |s| [s.segment_id, s.production_tag] }
|
19
|
+
.to_h
|
20
|
+
end
|
21
|
+
|
22
|
+
# @param production_tags Global production tags
|
23
|
+
# @param segment_production_tags Segment-specific production tags
|
24
|
+
# @return Array of production tags
|
25
|
+
# @example ['tag1', 'tag2']
|
26
|
+
def parse_production_tags(production_tags, segment_production_tags)
|
27
|
+
separator = ','
|
28
|
+
tags = segment_production_tags || production_tags
|
29
|
+
return [] unless tags
|
30
|
+
tags.split(separator).map(&:strip)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/gooddata/lcm/lcm.rb
CHANGED
@@ -259,20 +259,22 @@ module GoodData
|
|
259
259
|
attributes = source_project.attributes
|
260
260
|
|
261
261
|
# Generate transfer table
|
262
|
-
drill_paths = attributes.
|
262
|
+
drill_paths = attributes.pmap do |attribute|
|
263
263
|
drill_label_uri = attribute.content['drillDownStepAttributeDF']
|
264
264
|
if drill_label_uri
|
265
265
|
drill_label = source_project.labels(drill_label_uri)
|
266
|
-
[attribute.meta['identifier'], drill_label.identifier]
|
266
|
+
[attribute.uri, attribute.meta['identifier'], drill_label_uri, drill_label.identifier]
|
267
267
|
else
|
268
268
|
[]
|
269
269
|
end
|
270
270
|
end
|
271
|
-
|
271
|
+
drill_paths.reject!(&:empty?)
|
272
272
|
|
273
273
|
# Transfer to target projects
|
274
274
|
targets.peach do |target|
|
275
|
-
|
275
|
+
drill_paths.peach do |drill_path_info|
|
276
|
+
src_attr_uri, attr_identifier, drill_label_uri, drill_path_identifier = drill_path_info
|
277
|
+
|
276
278
|
attr_uri = GoodData::MdObject.identifier_to_uri({ project: target, client: target.client }, attr_identifier)
|
277
279
|
next unless attr_uri
|
278
280
|
|
@@ -284,6 +286,22 @@ module GoodData
|
|
284
286
|
|
285
287
|
if !attribute.content['drillDownStepAttributeDF'] || attribute.content['drillDownStepAttributeDF'] != drill_path
|
286
288
|
semaphore.synchronize do
|
289
|
+
GoodData.logger.debug <<-DEBUG
|
290
|
+
Transfer from:
|
291
|
+
{
|
292
|
+
attr_uri: #{src_attr_uri},
|
293
|
+
attr_identifier: #{attr_identifier},
|
294
|
+
drill_label_uri: #{drill_label_uri},
|
295
|
+
drill_label_identifier: #{drill_path_identifier}
|
296
|
+
}
|
297
|
+
To:
|
298
|
+
{
|
299
|
+
attr_uri: #{attr_uri},
|
300
|
+
attr_identifier: #{attr_identifier},
|
301
|
+
drill_label_uri: #{drill_path},
|
302
|
+
drill_label_identifier: #{drill_path_identifier}
|
303
|
+
}
|
304
|
+
DEBUG
|
287
305
|
GoodData.logger.info "Updating drill path of #{attr_identifier} -> #{drill_path} in '#{target.title}'"
|
288
306
|
end
|
289
307
|
|
data/lib/gooddata/lcm/lcm2.rb
CHANGED
@@ -85,9 +85,12 @@ module GoodData
|
|
85
85
|
EnsureTechnicalUsersDomain,
|
86
86
|
EnsureTechnicalUsersProject,
|
87
87
|
SynchronizeLdm,
|
88
|
-
|
89
|
-
|
90
|
-
|
88
|
+
CollectAttributes,
|
89
|
+
CollectMeta,
|
90
|
+
CollectTaggedObjects,
|
91
|
+
CollectComputedAttributeMetrics,
|
92
|
+
ImportObjectCollections,
|
93
|
+
SynchronizeComputedAttributes,
|
91
94
|
SynchronizeProcesses,
|
92
95
|
SynchronizeSchedules,
|
93
96
|
SynchronizeColorPalette,
|
@@ -98,31 +101,25 @@ module GoodData
|
|
98
101
|
provision: [
|
99
102
|
EnsureReleaseTable,
|
100
103
|
CollectSegments,
|
101
|
-
SegmentsFilter,
|
102
104
|
PurgeClients,
|
103
105
|
CollectClients,
|
104
106
|
AssociateClients,
|
105
107
|
ProvisionClients,
|
106
108
|
EnsureTechnicalUsersDomain,
|
107
109
|
EnsureTechnicalUsersProject,
|
108
|
-
|
109
|
-
SynchronizeETLsInSegment,
|
110
|
-
SynchronizeColorPalette
|
110
|
+
SynchronizeETLsInSegment
|
111
111
|
],
|
112
112
|
|
113
113
|
rollout: [
|
114
114
|
EnsureReleaseTable,
|
115
115
|
CollectSegments,
|
116
|
-
SegmentsFilter,
|
117
116
|
CollectSegmentClients,
|
118
117
|
EnsureTechnicalUsersDomain,
|
119
118
|
EnsureTechnicalUsersProject,
|
120
119
|
SynchronizeLdm,
|
121
|
-
# SynchronizeLabelTypes,
|
122
|
-
SynchronizeAttributeDrillpath,
|
123
120
|
ApplyCustomMaql,
|
124
|
-
SynchronizeColorPalette,
|
125
121
|
SynchronizeClients,
|
122
|
+
SynchronizeComputedAttributes,
|
126
123
|
SynchronizeETLsInSegment
|
127
124
|
]
|
128
125
|
}
|
@@ -198,6 +195,10 @@ module GoodData
|
|
198
195
|
headings = keys.map(&:upcase)
|
199
196
|
|
200
197
|
rows = messages && messages.map do |message|
|
198
|
+
unless message
|
199
|
+
GoodData.logger.warn("Found an empty message in the results of the #{action.name} action")
|
200
|
+
next
|
201
|
+
end
|
201
202
|
row = []
|
202
203
|
keys.each do |heading|
|
203
204
|
row << message[heading]
|
@@ -206,10 +207,11 @@ module GoodData
|
|
206
207
|
end
|
207
208
|
|
208
209
|
rows ||= []
|
210
|
+
rows.compact!
|
209
211
|
|
210
212
|
table = Terminal::Table.new :title => title, :headings => headings do |t|
|
211
213
|
rows.each_with_index do |row, index|
|
212
|
-
t << row
|
214
|
+
t << (row || [])
|
213
215
|
t.add_separator if index < rows.length - 1
|
214
216
|
end
|
215
217
|
end
|
@@ -242,6 +244,8 @@ module GoodData
|
|
242
244
|
end
|
243
245
|
end
|
244
246
|
|
247
|
+
check_unused_params(actions, params)
|
248
|
+
|
245
249
|
# Print name of actions to be performed for debug purposes
|
246
250
|
print_action_names(mode, actions)
|
247
251
|
|
@@ -261,6 +265,11 @@ module GoodData
|
|
261
265
|
true
|
262
266
|
end
|
263
267
|
|
268
|
+
skip_actions = (params.skip_actions || [])
|
269
|
+
actions = actions.reject do |action|
|
270
|
+
skip_actions.include?(action.to_s)
|
271
|
+
end
|
272
|
+
|
264
273
|
# Run actions
|
265
274
|
errors = []
|
266
275
|
results = []
|
@@ -269,15 +278,22 @@ module GoodData
|
|
269
278
|
|
270
279
|
# Invoke action
|
271
280
|
begin
|
281
|
+
# Check if all required parameters were passed
|
282
|
+
BaseAction.check_params(action.const_get('PARAMS'), params)
|
283
|
+
|
272
284
|
out = action.send(:call, params)
|
273
285
|
rescue => e
|
274
286
|
errors << {
|
275
287
|
action: action,
|
276
|
-
err: e
|
288
|
+
err: e,
|
289
|
+
backtrace: e.backtrace
|
277
290
|
}
|
278
291
|
break if fail_early
|
279
292
|
end
|
280
293
|
|
294
|
+
# in case fail_early = false, we need to execute another action
|
295
|
+
next unless out
|
296
|
+
|
281
297
|
# Handle output results and params
|
282
298
|
res = out.is_a?(Array) ? out : out[:results]
|
283
299
|
out_params = out.is_a?(Hash) ? out[:params] || {} : {}
|
@@ -317,6 +333,43 @@ module GoodData
|
|
317
333
|
params: params
|
318
334
|
}
|
319
335
|
end
|
336
|
+
|
337
|
+
def check_unused_params(actions, params)
|
338
|
+
default_params = [
|
339
|
+
:client_gdc_hostname,
|
340
|
+
:client_gdc_protocol,
|
341
|
+
:fail_early,
|
342
|
+
:gdc_logger,
|
343
|
+
:gdc_password,
|
344
|
+
:gdc_username,
|
345
|
+
:strict
|
346
|
+
]
|
347
|
+
|
348
|
+
action_params = actions.map do |action|
|
349
|
+
action.const_get(:PARAMS).keys.map(&:downcase)
|
350
|
+
end
|
351
|
+
|
352
|
+
action_params.flatten!.uniq!
|
353
|
+
|
354
|
+
param_names = params.keys.map(&:downcase)
|
355
|
+
|
356
|
+
unused_params = param_names - (action_params + default_params)
|
357
|
+
|
358
|
+
if unused_params.any?
|
359
|
+
GoodData.logger.warn("Following params are not used by any action: #{JSON.pretty_generate(unused_params)}")
|
360
|
+
|
361
|
+
rows = []
|
362
|
+
actions.each do |action|
|
363
|
+
action_params = action.const_get(:PARAMS)
|
364
|
+
action_params.each do |_k, v|
|
365
|
+
rows << [action.short_name, v[:name], v[:description], v[:type].class.short_name]
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
table = Terminal::Table.new :headings => ['Action', 'Parameter', 'Description', 'Parameter Type'], :rows => rows
|
370
|
+
puts table.to_s
|
371
|
+
end
|
372
|
+
end
|
320
373
|
end
|
321
374
|
end
|
322
375
|
end
|
@@ -17,7 +17,7 @@ module GoodData
|
|
17
17
|
|
18
18
|
PARAMS = define_type(self) do
|
19
19
|
description 'Cascade Drop'
|
20
|
-
param :
|
20
|
+
param :cascade_drops, instance_of(Type::BooleanType), required: false, default: nil
|
21
21
|
|
22
22
|
description 'Preserve Data'
|
23
23
|
param :preserve_data, instance_of(Type::BooleanType), required: false, default: nil
|
@@ -37,10 +37,12 @@ module GoodData
|
|
37
37
|
items.pmap { |item| self[item.uri, options] unless item.nil? }
|
38
38
|
end
|
39
39
|
|
40
|
-
def find_by_tag(
|
40
|
+
def find_by_tag(tags, opts = { :client => GoodData.connection, :project => GoodData.project })
|
41
41
|
client, project = GoodData.get_client_and_project(opts)
|
42
|
+
tags = tags.split(',').map(&:strip) unless tags.is_a?(Array)
|
42
43
|
|
43
|
-
self[:all, client: client, project: project]
|
44
|
+
self[:all, client: client, project: project]
|
45
|
+
.select { |r| (r.tag_set & tags).any? }
|
44
46
|
end
|
45
47
|
|
46
48
|
# Finds a specific type of the object by title. Returns first match. Returns full object.
|
@@ -9,12 +9,22 @@ module GoodData
|
|
9
9
|
module MdObjectIndexer
|
10
10
|
MD_OBJ_CTG = 'obj'
|
11
11
|
|
12
|
-
# Returns either list of objects or a specific object.
|
12
|
+
# Returns either list of objects or a specific object.
|
13
|
+
# This method is reimplemented in subclasses to leverage specific
|
14
|
+
# implementation for specific type of objects. Options is used in
|
15
|
+
# subclasses specifically to provide shorthand for getting a full
|
16
|
+
# objects after getting a list of hashes from query resource.
|
13
17
|
# @param [Object] id id can be either a number a String (as a URI). Subclasses should also be abel to deal with getting the instance of MdObject already and a :all symbol
|
14
18
|
# @param [Hash] options the options hash
|
15
|
-
# @option options [Boolean] :full if passed true the subclass can decide
|
19
|
+
# @option options [Boolean] :full if passed true the subclass can decide
|
20
|
+
# to pull in full objects. This is desirable from the usability POV
|
21
|
+
# but unfortunately has negative impact on performance so it is not
|
22
|
+
# the default.
|
16
23
|
# @return [MdObject] if id is a String or number single object is returned
|
17
|
-
# @return [Array] if :all was provided as an id, list of objects should
|
24
|
+
# @return [Array] if :all was provided as an id, list of objects should
|
25
|
+
# be returned. Note that this is implemented only in the subclasses.
|
26
|
+
# MdObject does not support this since API has no means to return list
|
27
|
+
# of all types of objects.
|
18
28
|
def [](id, options = { :client => GoodData.connection, :project => GoodData.project })
|
19
29
|
client, project = GoodData.get_client_and_project(options)
|
20
30
|
|
@@ -10,7 +10,10 @@ module GoodData
|
|
10
10
|
# Method intended to get all objects of that type in a specified project
|
11
11
|
#
|
12
12
|
# @param options [Hash] the options hash
|
13
|
-
# @option options [Boolean] :full if passed true the subclass can decide
|
13
|
+
# @option options [Boolean] :full if passed true the subclass can decide
|
14
|
+
# to pull in full objects. This is desirable from the usability POV
|
15
|
+
# but unfortunately has negative impact on performance so it is not
|
16
|
+
# the default.
|
14
17
|
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
|
15
18
|
def all(_options = { :client => GoodData.connection, :project => GoodData.project })
|
16
19
|
fail NotImplementedError, 'Method should be implemented in subclass. Currently there is no way how to get all metadata objects on API.'
|
@@ -25,7 +28,10 @@ module GoodData
|
|
25
28
|
# @param query_obj_type [String] string used in URI to distinguish different query resources for different objects
|
26
29
|
# @param klass [Class] A class used for instantiating the returned data
|
27
30
|
# @param options [Hash] the options hash
|
28
|
-
# @option options [Boolean] :full if passed true the subclass can
|
31
|
+
# @option options [Boolean] :full if passed true the subclass can
|
32
|
+
# decide to pull in full objects. This is desirable from the usability
|
33
|
+
# POV but unfortunately has negative impact on performance so it is
|
34
|
+
# not the default.
|
29
35
|
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
|
30
36
|
def query(query_obj_type, klass, options = { :client => GoodData.connection, :project => GoodData.project })
|
31
37
|
client = options[:client]
|
@@ -51,9 +51,12 @@ module GoodData
|
|
51
51
|
#
|
52
52
|
# @param project [Hash | GoodData::Model::ProjectBlueprint] Project blueprint
|
53
53
|
# @param dataset_name [GoodData::Model::DatasetBlueprint | String | Hash] Dataset to be removed
|
54
|
+
# @param options [Hash] options
|
55
|
+
# @option options [Boolean] :include_date_dimensions Specifies whether to include date dimensions
|
56
|
+
# @option options [Boolean] :dd Specifies whether to include date dimensions
|
54
57
|
# @return [Hash] new project with removed dataset
|
55
|
-
def self.remove_dataset(project, dataset_id)
|
56
|
-
dataset = dataset_id.is_a?(String) ? find_dataset(project, dataset_id) : dataset_name
|
58
|
+
def self.remove_dataset(project, dataset_id, options = {})
|
59
|
+
dataset = dataset_id.is_a?(String) ? find_dataset(project, dataset_id, options) : dataset_name
|
57
60
|
index = project[:datasets].index(dataset)
|
58
61
|
dupped_project = GoodData::Helpers.deep_dup(project)
|
59
62
|
dupped_project[:datasets].delete_at(index)
|
@@ -66,10 +69,13 @@ module GoodData
|
|
66
69
|
#
|
67
70
|
# @param project [Hash | GoodData::Model::ProjectBlueprint] Project blueprint
|
68
71
|
# @param dataset_name [GoodData::Model::DatasetBlueprint | String | Hash] Dataset to be removed
|
72
|
+
# @param options [Hash] options
|
73
|
+
# @option options [Boolean] :include_date_dimensions Specifies whether to include date dimensions
|
74
|
+
# @option options [Boolean] :dd Specifies whether to include date dimensions
|
69
75
|
# @return [Hash] project with removed dataset
|
70
|
-
def self.remove_dataset!(project, dataset_id)
|
76
|
+
def self.remove_dataset!(project, dataset_id, options = {})
|
71
77
|
project = project.to_hash
|
72
|
-
dataset = dataset_id.is_a?(String) ? find_dataset(project, dataset_id) : dataset_id
|
78
|
+
dataset = dataset_id.is_a?(String) ? find_dataset(project, dataset_id, options) : dataset_id
|
73
79
|
index = project[:datasets].index(dataset)
|
74
80
|
project[:datasets].delete_at(index)
|
75
81
|
project
|
@@ -80,6 +86,8 @@ module GoodData
|
|
80
86
|
#
|
81
87
|
# @param project [GoodData::Model::ProjectBlueprint | Hash] Project blueprint
|
82
88
|
# @param options [Hash] options
|
89
|
+
# @option options [Boolean] :include_date_dimensions Specifies whether to include date dimensions
|
90
|
+
# @option options [Boolean] :dd Specifies whether to include date dimensions
|
83
91
|
# @return [Array<Hash>]
|
84
92
|
def self.datasets(project_blueprint, options = {})
|
85
93
|
project_blueprint = project_blueprint.to_hash
|
@@ -110,6 +118,9 @@ module GoodData
|
|
110
118
|
#
|
111
119
|
# @param project [GoodData::Model::ProjectBlueprint | Hash] Project blueprint
|
112
120
|
# @param name [GoodData::Model::DatasetBlueprint | String | Hash] Dataset
|
121
|
+
# @param options [Hash] options
|
122
|
+
# @option options [Boolean] :include_date_dimensions Specifies whether to include date dimensions
|
123
|
+
# @option options [Boolean] :dd Specifies whether to include date dimensions
|
113
124
|
# @return [Boolean]
|
114
125
|
def self.dataset?(project, name, options = {})
|
115
126
|
find_dataset(project, name, options)
|
@@ -123,6 +134,8 @@ module GoodData
|
|
123
134
|
# @param project [GoodData::Model::ProjectBlueprint | Hash] Project blueprint
|
124
135
|
# @param obj [GoodData::Model::DatasetBlueprint | String | Hash] Dataset
|
125
136
|
# @param options [Hash] options
|
137
|
+
# @option options [Boolean] :include_date_dimensions Specifies whether to include date dimensions
|
138
|
+
# @option options [Boolean] :dd Specifies whether to include date dimensions
|
126
139
|
# @return [GoodData::Model::DatasetBlueprint]
|
127
140
|
def self.find_dataset(project_blueprint, obj, options = {})
|
128
141
|
return obj.to_hash if DatasetBlueprint.dataset_blueprint?(obj)
|
@@ -189,6 +202,8 @@ module GoodData
|
|
189
202
|
# date dimensions
|
190
203
|
#
|
191
204
|
# @param options [Hash] options
|
205
|
+
# @option options [Boolean] :include_date_dimensions Specifies whether to include date dimensions
|
206
|
+
# @option options [Boolean] :dd Specifies whether to include date dimensions
|
192
207
|
# @return [Array<GoodData::Model::DatasetBlueprint>]
|
193
208
|
def datasets(id = :all, options = {})
|
194
209
|
id = id.respond_to?(:id) ? id.id : id
|
@@ -335,6 +350,9 @@ module GoodData
|
|
335
350
|
# Returns true if a dataset contains a particular dataset false otherwise
|
336
351
|
#
|
337
352
|
# @param name [GoodData::Model::DatasetBlueprint | String | Hash] Dataset
|
353
|
+
# @param options [Hash] options
|
354
|
+
# @option options [Boolean] :include_date_dimensions Specifies whether to include date dimensions
|
355
|
+
# @option options [Boolean] :dd Specifies whether to include date dimensions
|
338
356
|
# @return [Boolean]
|
339
357
|
def dataset?(name, options = {})
|
340
358
|
ProjectBlueprint.dataset?(to_hash, name, options)
|
@@ -377,6 +395,8 @@ module GoodData
|
|
377
395
|
#
|
378
396
|
# @param name [GoodData::Model::DatasetBlueprint | String | Hash] Dataset
|
379
397
|
# @param options [Hash] options
|
398
|
+
# @option options [Boolean] :include_date_dimensions Specifies whether to include date dimensions
|
399
|
+
# @option options [Boolean] :dd Specifies whether to include date dimensions
|
380
400
|
# @return [GoodData::Model::DatasetBlueprint]
|
381
401
|
def find_dataset(name, options = {})
|
382
402
|
ds = datasets(name, options)
|
@@ -404,7 +424,10 @@ module GoodData
|
|
404
424
|
|
405
425
|
# Constructor
|
406
426
|
#
|
407
|
-
# @param init_data [ProjectBlueprint | Hash] Blueprint or a blueprint
|
427
|
+
# @param init_data [ProjectBlueprint | Hash] Blueprint or a blueprint
|
428
|
+
# definition. If passed a hash it is used as data for new instance.
|
429
|
+
# If there is a ProjectBlueprint passed it is duplicated and a new
|
430
|
+
# instance is created.
|
408
431
|
# @return [ProjectBlueprint] A new project blueprint instance
|
409
432
|
def initialize(init_data)
|
410
433
|
some_data = if init_data.respond_to?(:project_blueprint?) && init_data.project_blueprint?
|
@@ -424,6 +447,7 @@ module GoodData
|
|
424
447
|
(@data[:date_dimensions] || []).each do |d|
|
425
448
|
d[:type] = d[:type].to_sym
|
426
449
|
end
|
450
|
+
@data[:include_ca] = true if @data[:include_ca].nil?
|
427
451
|
end
|
428
452
|
|
429
453
|
def id
|
@@ -510,9 +534,12 @@ module GoodData
|
|
510
534
|
# or a DatasetBlueprint or a Hash representation.
|
511
535
|
#
|
512
536
|
# @param dataset_name [GoodData::Model::DatasetBlueprint | String | Hash] Dataset to be removed
|
537
|
+
# @param options [Hash] options
|
538
|
+
# @option options [Boolean] :include_date_dimensions Specifies whether to include date dimensions
|
539
|
+
# @option options [Boolean] :dd Specifies whether to include date dimensions
|
513
540
|
# @return [Hash] project with removed dataset
|
514
|
-
def remove_dataset(dataset_name)
|
515
|
-
ProjectBlueprint.remove_dataset(to_hash, dataset_name)
|
541
|
+
def remove_dataset(dataset_name, options = {})
|
542
|
+
ProjectBlueprint.remove_dataset(to_hash, dataset_name, options)
|
516
543
|
self
|
517
544
|
end
|
518
545
|
|
@@ -520,9 +547,12 @@ module GoodData
|
|
520
547
|
# or a DatasetBlueprint or a Hash representation.
|
521
548
|
#
|
522
549
|
# @param dataset_name [GoodData::Model::DatasetBlueprint | String | Hash] Dataset to be removed
|
550
|
+
# @param options [Hash] options
|
551
|
+
# @option options [Boolean] :include_date_dimensions Specifies whether to include date dimensions
|
552
|
+
# @option options [Boolean] :dd Specifies whether to include date dimensions
|
523
553
|
# @return [Hash] project with removed dataset
|
524
|
-
def remove_dataset!(dataset_id)
|
525
|
-
ProjectBlueprint.remove_dataset!(to_hash, dataset_id)
|
554
|
+
def remove_dataset!(dataset_id, options = {})
|
555
|
+
ProjectBlueprint.remove_dataset!(to_hash, dataset_id, options)
|
526
556
|
self
|
527
557
|
end
|
528
558
|
|
@@ -640,8 +670,8 @@ module GoodData
|
|
640
670
|
end
|
641
671
|
a_blueprint.date_dimensions.each do |dd|
|
642
672
|
if temp_blueprint.dataset?(dd.id, dd: true)
|
643
|
-
local_dim = temp_blueprint.
|
644
|
-
|
673
|
+
local_dim = temp_blueprint.data[:date_dimensions].find { |d| d[:id] == dd.id }
|
674
|
+
local_dim[:urn] = dd.urn
|
645
675
|
else
|
646
676
|
temp_blueprint.add_date_dimension!(dd.dup)
|
647
677
|
end
|