gooddata 0.6.0 → 0.6.2

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 (208) hide show
  1. checksums.yaml +13 -5
  2. data/.rubocop.yml +23 -0
  3. data/.travis.yml +9 -4
  4. data/CLI.md +439 -0
  5. data/Gemfile +0 -1
  6. data/README.md +2 -2
  7. data/Rakefile +60 -8
  8. data/doc/templates/default/module/setup.rb +1 -1
  9. data/examples.rb +2 -0
  10. data/gooddata +2 -0
  11. data/gooddata.gemspec +12 -8
  12. data/lib/gooddata.rb +0 -2
  13. data/lib/gooddata/bricks/base_downloader.rb +52 -47
  14. data/lib/gooddata/bricks/brick.rb +20 -31
  15. data/lib/gooddata/bricks/bricks.rb +1 -1
  16. data/lib/gooddata/bricks/middleware/base_middleware.rb +9 -7
  17. data/lib/gooddata/bricks/middleware/bench_middleware.rb +12 -10
  18. data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +28 -28
  19. data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +20 -16
  20. data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +21 -19
  21. data/lib/gooddata/bricks/middleware/logger_middleware.rb +10 -8
  22. data/lib/gooddata/bricks/middleware/restforce_middleware.rb +36 -34
  23. data/lib/gooddata/bricks/middleware/stdout_middleware.rb +11 -9
  24. data/lib/gooddata/bricks/middleware/twitter_middleware.rb +14 -12
  25. data/lib/gooddata/bricks/pipeline.rb +28 -0
  26. data/lib/gooddata/bricks/utils.rb +10 -8
  27. data/lib/gooddata/cli/cli.rb +1 -6
  28. data/lib/gooddata/cli/commands/auth_cmd.rb +1 -1
  29. data/lib/gooddata/cli/commands/console_cmd.rb +7 -5
  30. data/lib/gooddata/cli/commands/domain_cmd.rb +45 -0
  31. data/lib/gooddata/cli/commands/process_cmd.rb +42 -5
  32. data/lib/gooddata/cli/commands/project_cmd.rb +96 -36
  33. data/lib/gooddata/cli/commands/projects_cmd.rb +21 -0
  34. data/lib/gooddata/cli/commands/role_cmd.rb +28 -0
  35. data/lib/gooddata/cli/commands/run_ruby_cmd.rb +5 -5
  36. data/lib/gooddata/cli/commands/scaffold_cmd.rb +1 -1
  37. data/lib/gooddata/cli/commands/{profile_cmd.rb → user_cmd.rb} +7 -9
  38. data/lib/gooddata/cli/shared.rb +3 -2
  39. data/lib/gooddata/client.rb +16 -304
  40. data/lib/gooddata/commands/api.rb +13 -5
  41. data/lib/gooddata/commands/auth.rb +47 -40
  42. data/lib/gooddata/commands/base.rb +4 -2
  43. data/lib/gooddata/commands/commands.rb +1 -1
  44. data/lib/gooddata/commands/datasets.rb +20 -7
  45. data/lib/gooddata/commands/domain.rb +23 -0
  46. data/lib/gooddata/commands/process.rb +23 -117
  47. data/lib/gooddata/commands/project.rb +147 -0
  48. data/lib/gooddata/commands/projects.rb +8 -102
  49. data/lib/gooddata/commands/role.rb +26 -0
  50. data/lib/gooddata/commands/runners.rb +41 -38
  51. data/lib/gooddata/commands/scaffold.rb +46 -43
  52. data/lib/gooddata/commands/user.rb +33 -0
  53. data/lib/gooddata/connection.rb +43 -353
  54. data/lib/gooddata/core/connection.rb +389 -0
  55. data/lib/gooddata/core/core.rb +5 -4
  56. data/lib/gooddata/core/logging.rb +48 -0
  57. data/lib/gooddata/core/nil_logger.rb +13 -0
  58. data/lib/gooddata/core/project.rb +70 -0
  59. data/lib/gooddata/core/rest.rb +120 -0
  60. data/lib/gooddata/core/threaded.rb +14 -0
  61. data/lib/gooddata/core/user.rb +19 -0
  62. data/lib/gooddata/data/data.rb +2 -1
  63. data/lib/gooddata/data/guesser.rb +16 -12
  64. data/lib/gooddata/exceptions/command_failed.rb +1 -1
  65. data/lib/gooddata/exceptions/exceptions.rb +2 -1
  66. data/lib/gooddata/exceptions/no_project_error.rb +11 -0
  67. data/lib/gooddata/exceptions/project_not_found.rb +1 -1
  68. data/lib/gooddata/extensions/big_decimal.rb +6 -2
  69. data/lib/gooddata/extract.rb +10 -8
  70. data/lib/gooddata/goodzilla/goodzilla.rb +61 -59
  71. data/lib/gooddata/helpers.rb +15 -9
  72. data/lib/gooddata/models/account_settings.rb +124 -0
  73. data/lib/gooddata/models/attributes/anchor.rb +37 -0
  74. data/lib/gooddata/models/attributes/attributes.rb +8 -0
  75. data/lib/gooddata/models/attributes/date_attribute.rb +25 -0
  76. data/lib/gooddata/models/attributes/time_attribute.rb +24 -0
  77. data/lib/gooddata/models/columns/attribute.rb +71 -0
  78. data/lib/gooddata/models/columns/columns.rb +8 -0
  79. data/lib/gooddata/models/columns/date_column.rb +63 -0
  80. data/lib/gooddata/models/columns/fact_model.rb +54 -0
  81. data/lib/gooddata/models/columns/label.rb +55 -0
  82. data/lib/gooddata/models/columns/reference.rb +57 -0
  83. data/lib/gooddata/models/dashboard_builder.rb +26 -0
  84. data/lib/gooddata/models/data_result.rb +10 -9
  85. data/lib/gooddata/models/domain.rb +131 -0
  86. data/lib/gooddata/models/empty_result.rb +5 -8
  87. data/lib/gooddata/models/facts/facts.rb +8 -0
  88. data/lib/gooddata/models/facts/time_fact.rb +20 -0
  89. data/lib/gooddata/models/folders/attribute_folder.rb +20 -0
  90. data/lib/gooddata/models/folders/fact_folder.rb +20 -0
  91. data/lib/gooddata/models/folders/folders.rb +8 -0
  92. data/lib/gooddata/models/invitation.rb +78 -0
  93. data/lib/gooddata/models/links.rb +6 -6
  94. data/lib/gooddata/models/md_object.rb +25 -0
  95. data/lib/gooddata/models/metadata.rb +160 -62
  96. data/lib/gooddata/models/metadata/attribute.rb +81 -0
  97. data/lib/gooddata/models/metadata/column.rb +61 -0
  98. data/lib/gooddata/models/{dashboard.rb → metadata/dashboard.rb} +12 -7
  99. data/lib/gooddata/models/{data_set.rb → metadata/data_set.rb} +5 -4
  100. data/lib/gooddata/models/metadata/date_dimension.rb +26 -0
  101. data/lib/gooddata/models/metadata/display_form.rb +61 -0
  102. data/lib/gooddata/models/metadata/fact.rb +36 -0
  103. data/lib/gooddata/models/metadata/folder.rb +24 -0
  104. data/lib/gooddata/models/metadata/metadata.rb +8 -0
  105. data/lib/gooddata/models/metadata/metric.rb +197 -0
  106. data/lib/gooddata/models/metadata/report.rb +115 -0
  107. data/lib/gooddata/models/{report_definition.rb → metadata/report_definition.rb} +16 -10
  108. data/lib/gooddata/models/metadata/schema.rb +227 -0
  109. data/lib/gooddata/models/model.rb +38 -1339
  110. data/lib/gooddata/models/models.rb +5 -2
  111. data/lib/gooddata/models/module_constants.rb +29 -0
  112. data/lib/gooddata/models/process.rb +142 -13
  113. data/lib/gooddata/models/profile.rb +4 -6
  114. data/lib/gooddata/models/project.rb +406 -136
  115. data/lib/gooddata/models/project_blueprint.rb +221 -0
  116. data/lib/gooddata/models/project_builder.rb +136 -0
  117. data/lib/gooddata/models/project_creator.rb +138 -0
  118. data/lib/gooddata/models/project_metadata.rb +11 -10
  119. data/lib/gooddata/models/project_role.rb +92 -0
  120. data/lib/gooddata/models/references/date_reference.rb +44 -0
  121. data/lib/gooddata/models/references/references.rb +8 -0
  122. data/lib/gooddata/models/references/time_reference.rb +13 -0
  123. data/lib/gooddata/models/report_data_result.rb +11 -11
  124. data/lib/gooddata/models/schedule.rb +284 -0
  125. data/lib/gooddata/models/schema_blueprint.rb +158 -0
  126. data/lib/gooddata/models/schema_builder.rb +81 -0
  127. data/lib/gooddata/models/tab_builder.rb +23 -0
  128. data/lib/gooddata/models/user.rb +165 -0
  129. data/lib/gooddata/version.rb +1 -1
  130. data/lib/templates/project/data/devs.csv +1 -1
  131. data/lib/templates/project/data/repos.csv +1 -1
  132. data/lib/templates/project/model/model.rb.erb +7 -11
  133. data/spec/bricks/bricks_spec.rb +2 -0
  134. data/spec/data/test-ci-data.csv +2 -0
  135. data/spec/data/test_project_model_spec.json +7 -27
  136. data/spec/helpers/blueprint_helper.rb +2 -0
  137. data/spec/helpers/cli_helper.rb +2 -0
  138. data/spec/helpers/connection_helper.rb +14 -1
  139. data/spec/helpers/project_helper.rb +16 -0
  140. data/spec/helpers/schema_helper.rb +16 -0
  141. data/spec/integration/command_projects_spec.rb +7 -7
  142. data/spec/integration/create_from_template_spec.rb +2 -2
  143. data/spec/integration/full_project_spec.rb +160 -7
  144. data/spec/integration/partial_md_export_import_spec.rb +3 -3
  145. data/spec/logging_in_logging_out_spec.rb +2 -1
  146. data/spec/spec_helper.rb +26 -4
  147. data/spec/unit/bricks/bricks_spec.rb +15 -7
  148. data/spec/unit/bricks/middleware/bench_middleware_spec.rb +2 -0
  149. data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +2 -0
  150. data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +2 -0
  151. data/spec/unit/bricks/middleware/logger_middleware_spec.rb +2 -0
  152. data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +2 -0
  153. data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +2 -0
  154. data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +2 -0
  155. data/spec/unit/cli/cli_spec.rb +2 -0
  156. data/spec/unit/cli/commands/cmd_api_spec.rb +23 -15
  157. data/spec/unit/cli/commands/cmd_auth_spec.rb +8 -4
  158. data/spec/unit/cli/commands/cmd_domain_spec.rb +82 -0
  159. data/spec/unit/cli/commands/cmd_process_spec.rb +29 -13
  160. data/spec/unit/cli/commands/cmd_project_spec.rb +51 -30
  161. data/spec/unit/cli/commands/cmd_role_spec.rb +44 -0
  162. data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +8 -4
  163. data/spec/unit/cli/commands/cmd_scaffold_spec.rb +48 -11
  164. data/spec/unit/cli/commands/cmd_user_spec.rb +29 -0
  165. data/spec/unit/commands/command_api_spec.rb +1 -1
  166. data/spec/unit/commands/command_auth_spec.rb +100 -18
  167. data/spec/unit/commands/command_dataset_spec.rb +4 -0
  168. data/spec/unit/commands/command_process_spec.rb +9 -4
  169. data/spec/unit/commands/command_projects_spec.rb +10 -6
  170. data/spec/unit/commands/command_scaffold_spec.rb +5 -1
  171. data/spec/unit/commands/command_user_spec.rb +22 -0
  172. data/spec/unit/core/connection_spec.rb +35 -6
  173. data/spec/unit/core/logging_spec.rb +65 -0
  174. data/spec/unit/core/nil_logger_spec.rb +9 -0
  175. data/spec/unit/core/project_spec.rb +51 -0
  176. data/spec/unit/core/rest_spec.rb +33 -0
  177. data/spec/unit/data/guesser_spec.rb +5 -0
  178. data/spec/unit/godzilla/goodzilla_spec.rb +2 -0
  179. data/spec/unit/models/account_settings_spec.rb +28 -0
  180. data/spec/unit/models/anchor_spec.rb +32 -0
  181. data/spec/unit/models/attribute_column_spec.rb +7 -0
  182. data/spec/unit/models/domain_spec.rb +45 -0
  183. data/spec/unit/models/invitation_spec.rb +13 -0
  184. data/spec/unit/models/md_object_spec.rb +47 -0
  185. data/spec/unit/models/metric.rb +92 -0
  186. data/spec/unit/{model → models}/model_spec.rb +9 -7
  187. data/spec/unit/models/project_blueprint_spec.rb +202 -0
  188. data/spec/unit/models/project_creator.rb +73 -0
  189. data/spec/unit/models/project_role_spec.rb +90 -0
  190. data/spec/unit/models/project_spec.rb +143 -0
  191. data/spec/unit/models/schedule_spec.rb +491 -0
  192. data/spec/unit/{model → models}/schema_builder_spec.rb +2 -0
  193. data/spec/unit/{model → models}/tools_spec.rb +13 -7
  194. data/spec/unit/models/user_spec.rb +16 -0
  195. data/test/test_upload.rb +2 -0
  196. metadata +189 -86
  197. data/lib/gooddata/commands/profile.rb +0 -11
  198. data/lib/gooddata/models/attribute.rb +0 -29
  199. data/lib/gooddata/models/display_form.rb +0 -9
  200. data/lib/gooddata/models/fact.rb +0 -19
  201. data/lib/gooddata/models/metric.rb +0 -99
  202. data/lib/gooddata/models/report.rb +0 -89
  203. data/spec/data/blueprint_valid.json +0 -37
  204. data/spec/unit/cli/commands/cmd_profile_spec.rb +0 -16
  205. data/spec/unit/commands/command_profile_spec.rb +0 -18
  206. data/spec/unit/core/core_spec.rb +0 -7
  207. data/spec/unit/model/blueprint_spec.rb +0 -132
  208. data/spec/unit/model/project_blueprint_spec.rb +0 -44
@@ -1,6 +1,6 @@
1
1
  # encoding: UTF-8
2
2
 
3
- require 'active_support/inflections'
3
+ require 'active_support/all'
4
4
  require 'pathname'
5
5
 
6
6
  module GoodData
@@ -23,16 +23,16 @@ module GoodData
23
23
  exit 1
24
24
  end
25
25
 
26
- def find_goodfile(pwd=`pwd`.strip!, options={})
26
+ # FIXME: Windows incompatible
27
+ def find_goodfile(pwd = `pwd`.strip!, options = {})
27
28
  root = Pathname(options[:root] || '/')
28
29
  pwd = Pathname(pwd).expand_path
29
- begin
30
+ loop do
30
31
  gf = pwd + 'Goodfile'
31
- if gf.exist?
32
- return gf
33
- end
32
+ return gf if gf.exist?
34
33
  pwd = pwd.parent
35
- end until root == pwd
34
+ break unless root == pwd
35
+ end
36
36
  nil
37
37
  end
38
38
 
@@ -50,9 +50,15 @@ module GoodData
50
50
  end
51
51
  end
52
52
 
53
- def sanitize_string(str)
53
+ # TODO: Implement without using ActiveSupport
54
+ def sanitize_string(str, filter = /[^a-z_]/, replacement = '')
54
55
  str = ActiveSupport::Inflector.transliterate(str).downcase
55
- str.gsub(/[^a-z]/, '')
56
+ str.gsub(filter, replacement)
57
+ end
58
+
59
+ # TODO: Implement without using ActiveSupport
60
+ def humanize(str)
61
+ ActiveSupport::Inflector.humanize(str)
56
62
  end
57
63
  end
58
64
  end
@@ -0,0 +1,124 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative 'project'
4
+
5
+ module GoodData
6
+ # Account settings representation with some added sugar
7
+ class AccountSettings
8
+ attr_reader :json
9
+
10
+ # Creates new instance
11
+ #
12
+ # @return [AccountSettings] New AccountSettings instance
13
+ def initialize(json)
14
+ @json = json
15
+ end
16
+
17
+ # Gets the company name
18
+ #
19
+ # @return [String] Company name
20
+ def company
21
+ @json['accountSetting']['companyName'] || ''
22
+ end
23
+
24
+ # Gets the country
25
+ #
26
+ # @return [String] Country
27
+ def country
28
+ @json['accountSetting']['country'] || ''
29
+ end
30
+
31
+ # Gets date when created
32
+ #
33
+ # @return [DateTime] Created date
34
+ def created
35
+ DateTime.parse(@json['accountSetting']['created'])
36
+ end
37
+
38
+ # Gets the email
39
+ #
40
+ # @return [String] Email address
41
+ def email
42
+ @json['accountSetting']['email'] || ''
43
+ end
44
+
45
+ # Gets the first name
46
+ #
47
+ # @return [String] First name
48
+ def first_name
49
+ @json['accountSetting']['firstName'] || ''
50
+ end
51
+
52
+ # Gets the last name
53
+ #
54
+ # @return [String] Last name
55
+ def last_name
56
+ @json['accountSetting']['lastName'] || ''
57
+ end
58
+
59
+ # Gets the login
60
+ #
61
+ # @return [String] Login
62
+ def login
63
+ @json['accountSetting']['login'] || ''
64
+ end
65
+
66
+ # Gets the resource identifier
67
+ #
68
+ # @return [String] Resource identifier
69
+ def obj_id
70
+ uri.split('/').last
71
+ end
72
+
73
+ alias_method :account_setting_id, :obj_id
74
+
75
+ # Gets the phone
76
+ #
77
+ # @return [String] Phone
78
+ def phone
79
+ @json['accountSetting']['phone'] || ''
80
+ end
81
+
82
+ # Gets the position in company
83
+ #
84
+ # @return [String] Position in company
85
+ def position
86
+ @json['accountSetting']['position'] || ''
87
+ end
88
+
89
+ # Gets the array of projects
90
+ #
91
+ # @return [Array<GoodData::Project>] Array of project where account settings belongs to
92
+ def projects
93
+ res = []
94
+
95
+ projects = GoodData.get @json['accountSetting']['links']['projects']
96
+ projects['projects'].each do |project|
97
+ res << GoodData::Project.new(project)
98
+ end
99
+
100
+ res
101
+ end
102
+
103
+ # Gets the preferred timezone
104
+ #
105
+ # @return [String] Preferred timezone
106
+ def timezone
107
+ @json['accountSetting']['timezone'] || ''
108
+ end
109
+
110
+ # Gets the date when updated
111
+ #
112
+ # @return [DateTime] Updated date
113
+ def updated
114
+ DateTime.parse(@json['accountSetting']['updated'])
115
+ end
116
+
117
+ # Gets the resource REST URI
118
+ #
119
+ # @return [String] Resource URI
120
+ def uri
121
+ DateTime.parse(@json['accountSetting']['links']['self'])
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,37 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../columns/attribute'
4
+
5
+ module GoodData
6
+ module Model
7
+ ##
8
+ # A GoodData attribute that represents a data set's connection point or a data set
9
+ # without a connection point
10
+ #
11
+ class Anchor < Attribute
12
+ def initialize(column, schema)
13
+ if column
14
+ super
15
+ else
16
+ super({ :type => 'anchor', :name => 'id' }, schema)
17
+ @labels = []
18
+ @primary_label = nil
19
+ end
20
+ end
21
+
22
+ def table
23
+ @table ||= 'f_' + @schema.name
24
+ end
25
+
26
+ def to_maql_create
27
+ maql = super
28
+ maql += "\n# Connect '#{title}' to all attributes of this data set\n"
29
+ @schema.attributes.values.each do |c|
30
+ maql += "ALTER ATTRIBUTE {#{c.identifier}} ADD KEYS " \
31
+ + "{#{table}.#{c.key}};\n"
32
+ end
33
+ maql
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'pathname'
4
+
5
+ base = Pathname(__FILE__).dirname.expand_path
6
+ Dir.glob(base + '*.rb').each do |file|
7
+ require file
8
+ end
@@ -0,0 +1,25 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../columns/attribute'
4
+
5
+ module GoodData
6
+ module Model
7
+ ##
8
+ # Date field that's not connected to a date dimension
9
+ #
10
+ class DateAttribute < Attribute
11
+ def key
12
+ "#{DATE_COLUMN_PREFIX}#{super}"
13
+ end
14
+
15
+ def to_manifest_part(mode)
16
+ {
17
+ 'populates' => ['label.stuff.mmddyy'],
18
+ 'format' => 'unknown',
19
+ 'mode' => mode,
20
+ 'referenceKey' => 1
21
+ }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../columns/attribute'
4
+
5
+ module GoodData
6
+ module Model
7
+ ##
8
+ # Time field that's not connected to a time-of-a-day dimension
9
+ #
10
+ class TimeAttribute < Attribute
11
+ def type_prefix
12
+ TIME_ATTRIBUTE_PREFIX
13
+ end
14
+
15
+ def key
16
+ "#{TIME_COLUMN_PREFIX}#{super}"
17
+ end
18
+
19
+ def table
20
+ @table ||= "#{super}_tm"
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,71 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../metadata/column'
4
+ require_relative 'label'
5
+
6
+ module GoodData
7
+ module Model
8
+ ##
9
+ # GoodData attribute abstraction
10
+ #
11
+ class Attribute < Column
12
+ attr_reader :primary_label, :labels
13
+
14
+ def type_prefix
15
+ ATTRIBUTE_PREFIX
16
+ end
17
+
18
+ def folder_prefix
19
+ ATTRIBUTE_FOLDER_PREFIX
20
+ end
21
+
22
+ def initialize(hash, schema)
23
+ super hash, schema
24
+ @labels = []
25
+ @primary_label = Label.new hash, self, schema
26
+ end
27
+
28
+ def table
29
+ @table ||= 'd_' + @schema.name + '_' + name
30
+ end
31
+
32
+ def key
33
+ "#{@name}#{FK_SUFFIX}"
34
+ end
35
+
36
+ def to_maql_create
37
+ maql = "CREATE ATTRIBUTE {#{identifier}} VISUAL (#{visual})" \
38
+ + " AS KEYS {#{table}.#{Model::FIELD_PK}} FULLSET;\n"
39
+ maql += @primary_label.to_maql_create if @primary_label
40
+ maql
41
+ end
42
+
43
+ def to_manifest_part(mode)
44
+ {
45
+ 'referenceKey' => 1,
46
+ 'populates' => [@primary_label.identifier],
47
+ 'mode' => mode,
48
+ 'columnName' => name
49
+ }
50
+ end
51
+
52
+ def to_wire_model
53
+ {
54
+ 'attribute' => {
55
+ 'identifier' => identifier,
56
+ 'title' => title,
57
+ 'labels' => labels.map do |l|
58
+ {
59
+ 'label' => {
60
+ 'identifier' => l.identifier,
61
+ 'title' => l.title,
62
+ 'type' => 'GDC.text'
63
+ }
64
+ }
65
+ end
66
+ }
67
+ }
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'pathname'
4
+
5
+ base = Pathname(__FILE__).dirname.expand_path
6
+ Dir.glob(base + '*.rb').each do |file|
7
+ require file
8
+ end
@@ -0,0 +1,63 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../attributes/attributes'
4
+ require_relative '../metadata/column'
5
+ require_relative '../references/references'
6
+
7
+ module GoodData
8
+ module Model
9
+ ##
10
+ # Date column. A container holding the following
11
+ # parts: date fact, a date reference or attribute and an optional time component
12
+ # that contains a time fact and a time reference or attribute.
13
+ #
14
+ class DateColumn < Column
15
+ attr_reader :parts, :facts, :attributes, :references
16
+
17
+ def initialize(column, schema)
18
+ super column, schema
19
+ @parts = {}
20
+ @facts = []
21
+ @attributes = []
22
+ @references = []
23
+
24
+ # @facts << @parts[:date_fact] = DateFact.new(column, schema)
25
+ if column[:dataset]
26
+ @parts[:date_ref] = DateReference.new column, schema
27
+ @references << @parts[:date_ref]
28
+ else
29
+ @attributes << @parts[:date_attr] = DateAttribute.new(column, schema)
30
+ end
31
+ # if column['datetime'] then
32
+ # puts "*** datetime"
33
+ # @facts << @parts[:time_fact] = TimeFact.new(column, schema)
34
+ # if column['schema_reference'] then
35
+ # @parts[:time_ref] = TimeReference.new column, schema
36
+ # else
37
+ # @attributes << @parts[:time_attr] = TimeAttribute.new(column, schema)
38
+ # end
39
+ # end
40
+ end
41
+
42
+ def to_maql_create
43
+ @parts.values.map { |v| v.to_maql_create }.join "\n"
44
+ end
45
+
46
+ def to_maql_drop
47
+ @parts.values.map { |v| v.to_maql_drop }.join "\n"
48
+ end
49
+
50
+ def to_csv_header(row)
51
+ SKIP_FIELD
52
+ end
53
+
54
+ def to_csv_data(headers, row)
55
+ SKIP_FIELD
56
+ end
57
+
58
+ def to_manifest_part(mode)
59
+ nil
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,54 @@
1
+ # encoding: UTF-8
2
+
3
+ require_relative '../metadata/column'
4
+
5
+ module GoodData
6
+ module Model
7
+ ##
8
+ # GoodData fact abstraction
9
+ #
10
+ class Fact < Column
11
+ def type_prefix
12
+ FACT_PREFIX
13
+ end
14
+
15
+ def column_prefix
16
+ FACT_COLUMN_PREFIX
17
+ end
18
+
19
+ def folder_prefix
20
+ FACT_FOLDER_PREFIX
21
+ end
22
+
23
+ def table
24
+ @schema.table
25
+ end
26
+
27
+ def column
28
+ @column ||= table + '.' + column_prefix + name
29
+ end
30
+
31
+ def to_maql_create
32
+ "CREATE FACT {#{identifier}} VISUAL (#{visual})" \
33
+ + " AS {#{column}};\n"
34
+ end
35
+
36
+ def to_manifest_part(mode)
37
+ {
38
+ 'populates' => [identifier],
39
+ 'mode' => mode,
40
+ 'columnName' => name
41
+ }
42
+ end
43
+
44
+ def to_wire_model
45
+ {
46
+ 'fact' => {
47
+ 'identifier' => identifier,
48
+ 'title' => title
49
+ }
50
+ }
51
+ end
52
+ end
53
+ end
54
+ end