gooddata 0.6.18 → 0.6.19

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.
Files changed (133) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/.travis.yml +8 -19
  4. data/Guardfile +5 -0
  5. data/README.md +1 -3
  6. data/bin/gooddata +1 -1
  7. data/gooddata.gemspec +6 -4
  8. data/lib/gooddata.rb +1 -1
  9. data/lib/gooddata/bricks/middleware/aws_middleware.rb +24 -0
  10. data/lib/gooddata/cli/commands/console_cmd.rb +1 -1
  11. data/lib/gooddata/cli/commands/project_cmd.rb +29 -9
  12. data/lib/gooddata/cli/hooks.rb +9 -3
  13. data/lib/gooddata/commands/datawarehouse.rb +1 -7
  14. data/lib/gooddata/commands/project.rb +4 -3
  15. data/lib/gooddata/core/logging.rb +14 -2
  16. data/lib/gooddata/exceptions/execution_limit_exceeded.rb +9 -0
  17. data/lib/gooddata/exceptions/uncomputable_report.rb +8 -0
  18. data/lib/gooddata/exceptions/validation_error.rb +1 -1
  19. data/lib/gooddata/goodzilla/goodzilla.rb +5 -1
  20. data/lib/gooddata/helpers/data_helper.rb +40 -9
  21. data/lib/gooddata/mixins/md_finders.rb +35 -0
  22. data/lib/gooddata/models/blueprint/anchor_field.rb +46 -0
  23. data/lib/gooddata/models/blueprint/attribute_field.rb +25 -0
  24. data/lib/gooddata/models/blueprint/blueprint.rb +7 -0
  25. data/lib/gooddata/models/blueprint/blueprint_field.rb +66 -0
  26. data/lib/gooddata/models/{dashboard_builder.rb → blueprint/dashboard_builder.rb} +0 -0
  27. data/lib/gooddata/models/{schema_blueprint.rb → blueprint/dataset_blueprint.rb} +176 -117
  28. data/lib/gooddata/models/blueprint/date_dimension.rb +10 -0
  29. data/lib/gooddata/models/blueprint/fact_field.rb +16 -0
  30. data/lib/gooddata/models/blueprint/label_field.rb +39 -0
  31. data/lib/gooddata/models/{project_blueprint.rb → blueprint/project_blueprint.rb} +366 -168
  32. data/lib/gooddata/models/blueprint/project_builder.rb +79 -0
  33. data/lib/gooddata/models/blueprint/reference_field.rb +39 -0
  34. data/lib/gooddata/models/blueprint/schema_blueprint.rb +156 -0
  35. data/lib/gooddata/models/blueprint/schema_builder.rb +85 -0
  36. data/lib/gooddata/models/{to_manifest.rb → blueprint/to_manifest.rb} +25 -20
  37. data/lib/gooddata/models/{to_wire.rb → blueprint/to_wire.rb} +33 -52
  38. data/lib/gooddata/models/datawarehouse.rb +2 -2
  39. data/lib/gooddata/models/domain.rb +3 -2
  40. data/lib/gooddata/models/execution.rb +2 -2
  41. data/lib/gooddata/models/execution_detail.rb +7 -2
  42. data/lib/gooddata/models/from_wire.rb +60 -71
  43. data/lib/gooddata/models/from_wire_parse.rb +125 -125
  44. data/lib/gooddata/models/metadata.rb +14 -0
  45. data/lib/gooddata/models/metadata/dashboard.rb +2 -2
  46. data/lib/gooddata/models/metadata/label.rb +1 -1
  47. data/lib/gooddata/models/metadata/report.rb +6 -5
  48. data/lib/gooddata/models/metadata/report_definition.rb +44 -59
  49. data/lib/gooddata/models/model.rb +131 -43
  50. data/lib/gooddata/models/process.rb +13 -11
  51. data/lib/gooddata/models/profile.rb +12 -1
  52. data/lib/gooddata/models/project.rb +223 -19
  53. data/lib/gooddata/models/project_creator.rb +4 -15
  54. data/lib/gooddata/models/schedule.rb +1 -0
  55. data/lib/gooddata/models/user_filters/user_filter_builder.rb +2 -2
  56. data/lib/gooddata/rest/client.rb +18 -18
  57. data/lib/gooddata/rest/connection.rb +113 -94
  58. data/lib/gooddata/version.rb +1 -1
  59. data/lib/templates/project/model/model.rb.erb +15 -16
  60. data/spec/data/blueprints/additional_dataset_module.json +32 -0
  61. data/spec/data/blueprints/big_blueprint_not_pruned.json +2079 -0
  62. data/spec/data/blueprints/invalid_blueprint.json +103 -0
  63. data/spec/data/blueprints/m_n_model.json +104 -0
  64. data/spec/data/blueprints/model_module.json +25 -0
  65. data/spec/data/blueprints/test_blueprint.json +38 -0
  66. data/spec/data/blueprints/test_project_model_spec.json +106 -0
  67. data/spec/data/gd_gse_data_manifest.json +34 -34
  68. data/spec/data/manifests/test_blueprint.json +32 -0
  69. data/spec/data/{manifest_test_project.json → manifests/test_project.json} +9 -18
  70. data/spec/data/wire_models/test_blueprint.json +63 -0
  71. data/spec/data/wire_test_project.json +5 -5
  72. data/spec/environment/default.rb +33 -0
  73. data/spec/environment/develop.rb +26 -0
  74. data/spec/environment/environment.rb +14 -0
  75. data/spec/environment/hotfix.rb +17 -0
  76. data/spec/environment/production.rb +31 -0
  77. data/spec/environment/release.rb +17 -0
  78. data/spec/helpers/blueprint_helper.rb +10 -7
  79. data/spec/helpers/cli_helper.rb +24 -22
  80. data/spec/helpers/connection_helper.rb +27 -25
  81. data/spec/helpers/crypto_helper.rb +7 -5
  82. data/spec/helpers/csv_helper.rb +5 -3
  83. data/spec/helpers/process_helper.rb +15 -10
  84. data/spec/helpers/project_helper.rb +40 -33
  85. data/spec/helpers/schedule_helper.rb +15 -9
  86. data/spec/helpers/spec_helper.rb +11 -0
  87. data/spec/integration/blueprint_updates_spec.rb +93 -0
  88. data/spec/integration/command_datawarehouse_spec.rb +2 -1
  89. data/spec/integration/command_projects_spec.rb +9 -8
  90. data/spec/integration/create_from_template_spec.rb +1 -1
  91. data/spec/integration/create_project_spec.rb +1 -1
  92. data/spec/integration/full_process_schedule_spec.rb +1 -1
  93. data/spec/integration/full_project_spec.rb +91 -30
  94. data/spec/integration/over_to_user_filters_spec.rb +24 -28
  95. data/spec/integration/partial_md_export_import_spec.rb +4 -4
  96. data/spec/integration/project_spec.rb +1 -1
  97. data/spec/integration/rest_spec.rb +1 -1
  98. data/spec/integration/user_filters_spec.rb +19 -24
  99. data/spec/integration/variables_spec.rb +7 -9
  100. data/spec/logging_in_logging_out_spec.rb +1 -1
  101. data/spec/spec_helper.rb +10 -1
  102. data/spec/unit/bricks/middleware/aws_middelware_spec.rb +47 -0
  103. data/spec/unit/core/connection_spec.rb +2 -2
  104. data/spec/unit/core/logging_spec.rb +12 -4
  105. data/spec/unit/helpers/data_helper_spec.rb +60 -0
  106. data/spec/unit/models/blueprint/attributes_spec.rb +24 -0
  107. data/spec/unit/models/blueprint/dataset_spec.rb +116 -0
  108. data/spec/unit/models/blueprint/labels_spec.rb +39 -0
  109. data/spec/unit/models/blueprint/project_blueprint_spec.rb +643 -0
  110. data/spec/unit/models/blueprint/reference_spec.rb +24 -0
  111. data/spec/unit/models/{schema_builder_spec.rb → blueprint/schema_builder_spec.rb} +12 -4
  112. data/spec/unit/models/blueprint/to_wire_spec.rb +169 -0
  113. data/spec/unit/models/domain_spec.rb +13 -2
  114. data/spec/unit/models/from_wire_spec.rb +277 -98
  115. data/spec/unit/models/metadata_spec.rb +22 -4
  116. data/spec/unit/models/model_spec.rb +49 -39
  117. data/spec/unit/models/profile_spec.rb +1 -0
  118. data/spec/unit/models/project_spec.rb +7 -7
  119. data/spec/unit/models/schedule_spec.rb +20 -0
  120. data/spec/unit/models/to_manifest_spec.rb +31 -11
  121. data/spec/unit/rest/polling_spec.rb +86 -0
  122. metadata +102 -30
  123. data/lib/gooddata/models/project_builder.rb +0 -136
  124. data/lib/gooddata/models/schema_builder.rb +0 -77
  125. data/out.txt +0 -0
  126. data/spec/data/additional_dataset_module.json +0 -18
  127. data/spec/data/blueprint_invalid.json +0 -38
  128. data/spec/data/m_n_model/blueprint.json +0 -76
  129. data/spec/data/model_module.json +0 -18
  130. data/spec/data/test_project_model_spec.json +0 -76
  131. data/spec/unit/models/attribute_column_spec.rb +0 -7
  132. data/spec/unit/models/project_blueprint_spec.rb +0 -239
  133. data/spec/unit/models/to_wire_spec.rb +0 -71
@@ -0,0 +1,79 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative 'dashboard_builder'
4
+ require_relative 'schema_builder'
5
+
6
+ module GoodData
7
+ module Model
8
+ class ProjectBuilder
9
+ attr_accessor :data
10
+
11
+ class << self
12
+ def create_from_data(blueprint, title = 'Title')
13
+ pb = ProjectBuilder.new(title)
14
+ pb.data = blueprint.to_hash
15
+ pb
16
+ end
17
+
18
+ def create(title, _options = {}, &block)
19
+ pb = ProjectBuilder.new(title)
20
+ block.call(pb)
21
+ pb
22
+ end
23
+ end
24
+
25
+ def initialize(title, options = {})
26
+ @data = {}
27
+ @data[:title] = title
28
+ @data[:datasets] = []
29
+ @data[:date_dimensions] = []
30
+ @data.merge(options)
31
+ end
32
+
33
+ def add_date_dimension(id, options = {})
34
+ dimension = {
35
+ type: :date_dimension,
36
+ urn: options[:urn],
37
+ id: id,
38
+ title: options[:title]
39
+ }
40
+
41
+ data[:date_dimensions] << dimension
42
+ end
43
+
44
+ def add_dataset(id, options = {}, &block)
45
+ builder = GoodData::Model::SchemaBuilder.new(id, options)
46
+ block.call(builder) if block
47
+ fail 'Dataset has to have id defined' if id.blank?
48
+ datasets = data[:datasets]
49
+ if datasets.any? { |item| item[:id] == id }
50
+ ds = datasets.find { |item| item[:id] == id }
51
+ index = datasets.index(ds)
52
+ stuff = GoodData::Model.merge_dataset_columns(ds, builder.to_hash)
53
+ datasets.delete_at(index)
54
+ datasets.insert(index, stuff)
55
+ else
56
+ datasets << builder.to_hash
57
+ end
58
+ end
59
+
60
+ def to_json(options = {})
61
+ eliminate_empty = options[:eliminate_empty] || false
62
+
63
+ if eliminate_empty
64
+ JSON.pretty_generate(to_hash.reject { |_k, v| v.is_a?(Enumerable) && v.empty? })
65
+ else
66
+ JSON.pretty_generate(to_hash)
67
+ end
68
+ end
69
+
70
+ def to_blueprint
71
+ GoodData::Model::ProjectBlueprint.new(to_hash)
72
+ end
73
+
74
+ def to_hash
75
+ data
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,39 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative 'blueprint_field'
4
+
5
+ module GoodData
6
+ module Model
7
+ class ReferenceBlueprintField < BlueprintField
8
+ # Returns the schema that is referenced by this ref
9
+ #
10
+ # @return [GoodData::Model::SchemaBlueprint] the referencesd schema
11
+ def dataset
12
+ dataset_blueprint.find_dataset(reference, include_date_dimensions: true)
13
+ end
14
+
15
+ # Returns the string reference of the ref which is string Id of dataset that is referenced.
16
+ #
17
+ # @return [String] Id of the referenced dataset
18
+ def reference
19
+ data[:dataset]
20
+ end
21
+
22
+ # Validates the fields in the ref
23
+ #
24
+ # @return [Array] returns list of the errors represented by hash structures
25
+ def validate
26
+ validate_presence_of(:dataset).map do |e|
27
+ { type: :error, message: "Field \"#{e}\" is not defined or empty for reference \"#{data}\"" }
28
+ end
29
+ end
30
+
31
+ # Returns the md object in associated project or throws error if not present
32
+ #
33
+ # @return [GoodData::MdObject] md object that is represented in the blueprint
34
+ def in_project(_project)
35
+ fail NotImplementedError, 'Reference does not have representation as an object in datamart'
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,156 @@
1
+ # encoding: UTF-8
2
+
3
+ module GoodData
4
+ module Model
5
+ class SchemaBlueprint
6
+ attr_accessor :data, :project_blueprint
7
+
8
+ def initialize(dim, blueprint)
9
+ @data = dim
10
+ @project_blueprint = blueprint
11
+ end
12
+
13
+ # Returns true if anchor is present. Currently returns always true. Probably good to remove
14
+ #
15
+ # @return [Boolean] is anchor on schema?l70
16
+ def anchor?
17
+ true
18
+ end
19
+
20
+ # Returns anchor
21
+ #
22
+ # @return [GoodData::Model::AnchorBlueprintField] anchor on schema
23
+ def anchor
24
+ nil
25
+ end
26
+
27
+ # Returns list of all references defined on the schema.
28
+ #
29
+ # @return [Array<GoodData::Model::ReferenceBlueprintField>] refs on schema
30
+ def references
31
+ []
32
+ end
33
+
34
+ # Returns list of all facts defined on the schema.
35
+ #
36
+ # @return [Array<GoodData::Model::FactBlueprintField>] facts on schema
37
+ def facts(_id = :all, _options = {})
38
+ []
39
+ end
40
+
41
+ # Returns list of all attributes defined on the schema.
42
+ #
43
+ # @return [Array<GoodData::Model::AttributeBlueprintField>] attributes on schema
44
+ def attributes(_id = :all, _options = {})
45
+ []
46
+ end
47
+
48
+ # Returns list of all labels defined on the schema.
49
+ #
50
+ # @return [Array<GoodData::Model::LabelBlueprintField>] labels on schema
51
+ def labels(_id = :all, _options = {})
52
+ []
53
+ end
54
+
55
+ # Returns list of all fields defined on the schema.
56
+ #
57
+ # @return [Array<GoodData::Model::BlueprintField>] all fields on schema
58
+ def fields
59
+ []
60
+ end
61
+
62
+ # Returns list of attributes and anchor.
63
+ #
64
+ # @return [Array<GoodData::Model::AnchorBlueprintField | GoodData::Model::AttributeBlueprintField>]
65
+ def attributes_and_anchors
66
+ []
67
+ end
68
+
69
+ # Returns list of attributes that can break facts in a given dataset.
70
+ # This basically means that it is giving you all attributes from this
71
+ # dataset and datasets that are referenced by given dataset transitively.
72
+ # Includes only anchors that have labels.
73
+ #
74
+ # @return [Array<GoodData::Model::BlueprintField>]
75
+ def broken_by
76
+ attrs = attributes_and_anchors.reject { |a| a.labels.empty? }
77
+ attrs + references.map(&:dataset).flat_map(&:broken_by)
78
+ end
79
+
80
+ # Returns list of attributes that are broken by attributes in this dataset. This means
81
+ # all anchors and attributes from this dataset and the ones that are referenced by any
82
+ # dataset. It works transitively. Includes only anchors that have labels.
83
+ #
84
+ # @return [Array<GoodData::Model::AnchorBlueprintField | GoodData::Model::AttributeBlueprintField>]
85
+ def breaks
86
+ attrs = attributes_and_anchors.reject { |a| a.labels.empty? }
87
+ referenced_by.empty? ? attrs : attrs + referenced_by.flat_map(&:breaks)
88
+ end
89
+
90
+ # Relays request on finding a dataset in the associated project blueprint. Used by reference fields
91
+ #
92
+ # @param dataset [String] Name of a dataset
93
+ # @param options [Hash] additional options. See ProjectBlueprint form more
94
+ # @return [GoodData::Model::DatasetBlueprint] returns matching dataset or throws an error
95
+ def find_dataset(dataset, options = {})
96
+ project_blueprint.find_dataset(dataset, options)
97
+ end
98
+
99
+ # Returns id of the schema
100
+ #
101
+ # @return [String] returns id
102
+ def id
103
+ data[:id]
104
+ end
105
+
106
+ # Returns dataset that are referencing this dataset (directly through references not transitively).
107
+ #
108
+ # @return [Array<GoodData::Model::SchemaBlueprint>] returns id
109
+ def referenced_by
110
+ @project_blueprint.referencing(self)
111
+ end
112
+
113
+ # Returns dataset that are referenced by this dataset (directly through references not transitively).
114
+ #
115
+ # @return [Array<GoodData::Model::SchemaBlueprint>] returns id
116
+ def referencing
117
+ references.map(&:dataset)
118
+ end
119
+
120
+ # Returns title of the dataset. If it is not set up. It is generated for you
121
+ # based on the name which is titleized
122
+ #
123
+ # @return [String]
124
+ def title
125
+ data[:title] || data[:id].titleize
126
+ end
127
+
128
+ # Validates the blueprint and returns true if model is valid. False otherwise.
129
+ #
130
+ # @return [Boolean] is model valid?
131
+ def valid?
132
+ validate.empty?
133
+ end
134
+
135
+ # Validates the blueprint and returns array of errors.
136
+ #
137
+ # @return [Array<Hash>] returns array of errors or empty array
138
+ def validate
139
+ fields.flat_map(&:validate)
140
+ end
141
+
142
+ # Compares two blueprints. This is done by comapring the hash represenatation.
143
+ # It has to be exacty identical including the order of the columns
144
+ #
145
+ # @param name [GoodData::Model::DatasetBlueprint] Name of a field
146
+ # @return [Boolean] matching fields
147
+ def ==(other)
148
+ to_hash == other.to_hash
149
+ end
150
+
151
+ def to_hash
152
+ @data
153
+ end
154
+ end
155
+ end
156
+ end
@@ -0,0 +1,85 @@
1
+ # encoding: UTF-8
2
+
3
+ module GoodData
4
+ module Model
5
+ class SchemaBuilder
6
+ attr_accessor :data
7
+
8
+ class << self
9
+ def create_from_data(blueprint)
10
+ sc = SchemaBuilder.new
11
+ sc.data = blueprint.to_hash
12
+ sc
13
+ end
14
+
15
+ def create(id, options = {}, &block)
16
+ pb = SchemaBuilder.new(id, options)
17
+ block.call(pb)
18
+ pb
19
+ end
20
+ end
21
+
22
+ def initialize(id = nil, options = {})
23
+ @data = {
24
+ id: id,
25
+ type: :dataset,
26
+ columns: []
27
+ }.merge(options)
28
+ end
29
+
30
+ def name
31
+ data[:name]
32
+ end
33
+
34
+ def columns
35
+ data[:columns]
36
+ end
37
+
38
+ def add_column(column_def)
39
+ columns.push(column_def)
40
+ self
41
+ end
42
+
43
+ def add_anchor(id, options = {})
44
+ add_column({ type: :anchor, id: id }.merge(options))
45
+ self
46
+ end
47
+
48
+ def add_attribute(id, options = {})
49
+ add_column({ type: :attribute, id: id }.merge(options))
50
+ self
51
+ end
52
+
53
+ def add_fact(id, options = {})
54
+ data = { type: :fact, id: id }.merge(options)
55
+ add_column(data)
56
+ self
57
+ end
58
+
59
+ def add_label(id, options = {})
60
+ add_column({ type: :label, id: id }.merge(options))
61
+ self
62
+ end
63
+
64
+ def add_date(dataset_id, options = {})
65
+ add_column({ type: :date, dataset: dataset_id, format: GoodData::Model::DEFAULT_DATE_FORMAT }.merge(options))
66
+ end
67
+
68
+ def add_reference(dataset, options = {})
69
+ add_column({ type: :reference, dataset: dataset }.merge(options))
70
+ end
71
+
72
+ def to_json
73
+ JSON.pretty_generate(to_hash)
74
+ end
75
+
76
+ def to_hash
77
+ data
78
+ end
79
+
80
+ def to_blueprint
81
+ GoodData::Model::ProjectBlueprint.new(datasets: [to_hash])
82
+ end
83
+ end
84
+ end
85
+ end
@@ -11,11 +11,12 @@ module GoodData
11
11
  # @param mode [String] Mode of the load. Either FULL or INCREMENTAL
12
12
  # @return [Hash] Manifest for a particular reference
13
13
  def self.attribute_to_manifest(_project, dataset, a, mode)
14
+ labels = DatasetBlueprint.labels_for_attribute(dataset, a)
14
15
  [{
15
16
  'referenceKey' => 1,
16
- 'populates' => [GoodData::Model.identifier_for(dataset, a.merge(type: :primary_label))],
17
+ 'populates' => [labels.first[:id]],
17
18
  'mode' => mode,
18
- 'columnName' => a[:name]
19
+ 'columnName' => labels.first[:column_name] || labels.first[:id]
19
20
  }]
20
21
  end
21
22
 
@@ -29,12 +30,8 @@ module GoodData
29
30
  #
30
31
  def self.column_to_manifest(project, dataset, c, mode)
31
32
  case c[:type].to_sym
32
- when :attribute
33
- attribute_to_manifest(project, dataset, c, mode)
34
33
  when :label
35
34
  label_to_manifest(project, dataset, c, mode)
36
- when :anchor
37
- attribute_to_manifest(project, dataset, c, mode)
38
35
  when :fact
39
36
  fact_to_manifest(project, dataset, c, mode)
40
37
  when :reference
@@ -73,11 +70,14 @@ module GoodData
73
70
  # @return [Hash] Manifest for a particular date reference
74
71
  def self.date_ref_to_manifest(project, _dataset, reference, mode)
75
72
  referenced_dataset = ProjectBlueprint.find_date_dimension(project, reference[:dataset])
73
+ ref = "#{referenced_dataset[:id]}.date.mdyy"
74
+ format = reference[:format] || GoodData::Model::DEFAULT_DATE_FORMAT
75
+ GoodData.logger.info("Using date format \"#{format}\" for referencing attribute \"#{ref}\" of date dimension \"#{referenced_dataset[:id]}\"")
76
76
  [{
77
- 'populates' => [GoodData::Model.identifier_for(referenced_dataset, type: :date_ref)],
77
+ 'populates' => [ref],
78
78
  'mode' => mode,
79
- 'constraints' => { 'date' => 'dd/MM/yyyy' },
80
- 'columnName' => reference[:name],
79
+ 'constraints' => { 'date' => format },
80
+ 'columnName' => reference[:column_name] || reference[:dataset],
81
81
  'referenceKey' => 1
82
82
  }]
83
83
  end
@@ -89,11 +89,11 @@ module GoodData
89
89
  # @param fact [Hash] Fact
90
90
  # @param mode [String] Mode of the load. Either FULL or INCREMENTAL
91
91
  # @return [Hash] Manifest for a particular fact
92
- def self.fact_to_manifest(_project, dataset, fact, mode)
92
+ def self.fact_to_manifest(_project, _dataset, fact, mode)
93
93
  [{
94
- 'populates' => [GoodData::Model.identifier_for(dataset, fact)],
94
+ 'populates' => [fact[:id]],
95
95
  'mode' => mode,
96
- 'columnName' => fact[:name]
96
+ 'columnName' => fact[:column_name] || fact[:id]
97
97
  }]
98
98
  end
99
99
 
@@ -106,11 +106,15 @@ module GoodData
106
106
  # @return [Hash] Manifest for a particular label
107
107
  def self.label_to_manifest(_project, dataset, label, mode)
108
108
  a = DatasetBlueprint.attribute_for_label(dataset, label)
109
- [{
110
- 'populates' => [GoodData::Model.identifier_for(dataset, label, a)],
111
- 'mode' => mode,
112
- 'columnName' => label[:name]
113
- }]
109
+ labels = DatasetBlueprint.labels_for_attribute(dataset, a)
110
+
111
+ label = {}.tap do |l|
112
+ l['referenceKey'] = 1 if labels.first == label
113
+ l['populates'] = [label[:id]]
114
+ l['mode'] = mode
115
+ l['columnName'] = label[:column_name] || label[:id]
116
+ end
117
+ [label]
114
118
  end
115
119
 
116
120
  # The entry function of the module. Converts the ProjectBlueprint to manifest
@@ -125,7 +129,7 @@ module GoodData
125
129
  {
126
130
  'dataSetSLIManifest' => {
127
131
  'parts' => columns.mapcat { |c| column_to_manifest(project, dataset, c, mode) },
128
- 'dataSet' => GoodData::Model.identifier_for(dataset),
132
+ 'dataSet' => dataset[:id],
129
133
  'file' => 'data.csv', # should be configurable
130
134
  'csvParams' => {
131
135
  'quoteChar' => '"',
@@ -148,10 +152,11 @@ module GoodData
148
152
  def self.reference_to_manifest(project, _dataset, reference, mode)
149
153
  referenced_dataset = ProjectBlueprint.find_dataset(project, reference[:dataset])
150
154
  anchor = DatasetBlueprint.anchor(referenced_dataset)
155
+ label = DatasetBlueprint.labels_for_attribute(referenced_dataset, anchor).first
151
156
  [{
152
- 'populates' => [GoodData::Model.identifier_for(referenced_dataset, anchor.merge(type: :primary_label))],
157
+ 'populates' => [label[:id]],
153
158
  'mode' => mode,
154
- 'columnName' => reference[:name],
159
+ 'columnName' => reference[:column_name] || reference[:dataset],
155
160
  'referenceKey' => 1
156
161
  }]
157
162
  end