gooddata 0.6.0.pre11 → 0.6.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +12 -1
- data/.yardopts +2 -0
- data/README.md +6 -3
- data/Rakefile +24 -7
- data/gooddata +2 -2
- data/gooddata.gemspec +4 -3
- data/lib/gooddata.rb +17 -12
- data/lib/gooddata/bricks/base_downloader.rb +7 -7
- data/lib/gooddata/bricks/brick.rb +7 -8
- data/lib/gooddata/bricks/bricks.rb +4 -1
- data/lib/gooddata/bricks/middleware/base_middleware.rb +2 -2
- data/lib/gooddata/bricks/middleware/bench_middleware.rb +5 -6
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +21 -22
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +3 -4
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +14 -14
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +6 -6
- data/lib/gooddata/bricks/middleware/middleware.rb +4 -1
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +29 -32
- data/lib/gooddata/bricks/middleware/stdout_middleware.rb +5 -5
- data/lib/gooddata/bricks/middleware/twitter_middleware.rb +6 -8
- data/lib/gooddata/bricks/utils.rb +3 -3
- data/lib/gooddata/cli/cli.rb +4 -2
- data/lib/gooddata/cli/commands/api_cmd.rb +6 -4
- data/lib/gooddata/cli/commands/auth_cmd.rb +5 -3
- data/lib/gooddata/cli/commands/console_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/process_cmd.rb +6 -4
- data/lib/gooddata/cli/commands/profile_cmd.rb +5 -3
- data/lib/gooddata/cli/commands/project_cmd.rb +24 -22
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +12 -10
- data/lib/gooddata/cli/commands/scaffold_cmd.rb +8 -6
- data/lib/gooddata/cli/hooks.rb +4 -2
- data/lib/gooddata/cli/shared.rb +3 -1
- data/lib/gooddata/cli/terminal.rb +16 -0
- data/lib/gooddata/client.rb +28 -22
- data/lib/gooddata/commands/api.rb +43 -26
- data/lib/gooddata/commands/auth.rb +22 -53
- data/lib/gooddata/commands/base.rb +2 -0
- data/lib/gooddata/commands/commands.rb +3 -0
- data/lib/gooddata/commands/datasets.rb +39 -136
- data/lib/gooddata/commands/process.rb +134 -130
- data/lib/gooddata/commands/profile.rb +2 -0
- data/lib/gooddata/commands/projects.rb +91 -129
- data/lib/gooddata/commands/runners.rb +11 -11
- data/lib/gooddata/commands/scaffold.rb +28 -26
- data/lib/gooddata/connection.rb +61 -68
- data/lib/gooddata/core/core.rb +1 -2
- data/lib/gooddata/data/data.rb +7 -0
- data/lib/gooddata/data/guesser.rb +114 -0
- data/lib/gooddata/exceptions/command_failed.rb +7 -0
- data/lib/gooddata/exceptions/exceptions.rb +7 -0
- data/lib/gooddata/{exceptions.rb → exceptions/project_not_found.rb} +2 -2
- data/lib/gooddata/extensions/big_decimal.rb +5 -0
- data/lib/gooddata/extract.rb +2 -0
- data/lib/gooddata/goodzilla/goodzilla.rb +11 -12
- data/lib/gooddata/helpers.rb +49 -35
- data/lib/gooddata/models/attribute.rb +7 -5
- data/lib/gooddata/models/dashboard.rb +44 -45
- data/lib/gooddata/models/data_result.rb +10 -13
- data/lib/gooddata/models/data_set.rb +6 -6
- data/lib/gooddata/models/display_form.rb +4 -4
- data/lib/gooddata/models/empty_result.rb +4 -3
- data/lib/gooddata/models/fact.rb +5 -5
- data/lib/gooddata/models/links.rb +3 -1
- data/lib/gooddata/models/metadata.rb +34 -32
- data/lib/gooddata/models/metric.rb +33 -34
- data/lib/gooddata/models/model.rb +165 -173
- data/lib/gooddata/models/models.rb +3 -0
- data/lib/gooddata/models/process.rb +18 -17
- data/lib/gooddata/models/profile.rb +3 -1
- data/lib/gooddata/models/project.rb +107 -35
- data/lib/gooddata/models/project_metadata.rb +12 -12
- data/lib/gooddata/models/report.rb +31 -30
- data/lib/gooddata/models/report_data_result.rb +22 -19
- data/lib/gooddata/models/report_definition.rb +101 -80
- data/lib/gooddata/version.rb +5 -3
- data/lib/templates/bricks/brick.rb.erb +3 -3
- data/lib/templates/bricks/main.rb.erb +3 -2
- data/lib/templates/project/Goodfile.erb +2 -2
- data/lib/templates/project/model/model.rb.erb +19 -19
- data/spec/data/.gooddata +4 -0
- data/spec/helpers/blueprint_helper.rb +2 -2
- data/spec/helpers/cli_helper.rb +28 -0
- data/spec/helpers/connection_helper.rb +2 -2
- data/spec/integration/command_projects_spec.rb +1 -1
- data/spec/integration/create_from_template_spec.rb +12 -0
- data/spec/integration/full_project_spec.rb +2 -2
- data/spec/integration/partial_md_export_import_spec.rb +36 -0
- data/spec/logging_in_logging_out_spec.rb +1 -1
- data/spec/spec_helper.rb +29 -2
- data/spec/unit/cli/cli_spec.rb +3 -3
- data/spec/unit/cli/commands/cmd_api_spec.rb +21 -4
- data/spec/unit/cli/commands/cmd_auth_spec.rb +2 -4
- data/spec/unit/cli/commands/cmd_process_spec.rb +20 -4
- data/spec/unit/cli/commands/cmd_profile_spec.rb +9 -4
- data/spec/unit/cli/commands/cmd_project_spec.rb +53 -4
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +2 -4
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +14 -4
- data/spec/unit/commands/command_api_spec.rb +21 -2
- data/spec/unit/commands/command_auth_spec.rb +62 -1
- data/spec/unit/commands/command_dataset_spec.rb +31 -3
- data/spec/unit/commands/command_process_spec.rb +75 -1
- data/spec/unit/commands/command_profile_spec.rb +7 -1
- data/spec/unit/commands/command_projects_spec.rb +1 -1
- data/spec/unit/commands/command_scaffold_spec.rb +46 -1
- data/spec/unit/core/connection_spec.rb +1 -0
- data/spec/unit/data/guesser_spec.rb +54 -0
- data/spec/unit/helpers_spec.rb +47 -0
- data/spec/unit/model/schema_builder_spec.rb +2 -0
- data/spec/unit/model/tools_spec.rb +89 -0
- data/test/test_upload.rb +39 -15
- metadata +98 -75
- data/test/test_commands.rb +0 -85
- data/test/test_guessing.rb +0 -46
- data/test/test_model.rb +0 -81
- data/test/test_rest_api_basic.rb +0 -41
|
@@ -1,15 +1,17 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
require 'pry'
|
|
2
|
-
require 'highline'
|
|
3
4
|
|
|
4
5
|
module GoodData
|
|
5
6
|
class Process
|
|
6
|
-
|
|
7
7
|
class << self
|
|
8
8
|
def [](id)
|
|
9
9
|
if id == :all
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
uri = "/gdc/projects/#{GoodData.project.pid}/dataload/processes"
|
|
11
|
+
GoodData.get(uri)
|
|
12
|
+
else
|
|
13
|
+
uri = "/gdc/projects/#{GoodData.project.pid}/dataload/processes/#{id}"
|
|
14
|
+
self.new(GoodData.get(uri))
|
|
13
15
|
end
|
|
14
16
|
end
|
|
15
17
|
end
|
|
@@ -19,36 +21,35 @@ module GoodData
|
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
def links
|
|
22
|
-
@data[
|
|
24
|
+
@data['process']['links']
|
|
23
25
|
end
|
|
24
|
-
|
|
26
|
+
|
|
25
27
|
def link
|
|
26
|
-
links[
|
|
28
|
+
links['self']
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def executions_link
|
|
30
|
-
links[
|
|
32
|
+
links['executions']
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
def execute_process(graph, options={})
|
|
35
|
+
def execute_process(graph, options = {})
|
|
34
36
|
result = GoodData.post(executions_link, {
|
|
35
37
|
:execution => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
:graph => graph,
|
|
39
|
+
:params => {}
|
|
38
40
|
}
|
|
39
41
|
})
|
|
40
42
|
begin
|
|
41
|
-
GoodData.poll(result,
|
|
43
|
+
GoodData.poll(result, 'executionTask')
|
|
42
44
|
rescue RestClient::RequestFailed => e
|
|
43
45
|
|
|
44
46
|
ensure
|
|
45
|
-
result = GoodData.get(result[
|
|
46
|
-
if result[
|
|
47
|
-
fail "Runing process failed. You can look at a log here #{result[
|
|
47
|
+
result = GoodData.get(result['executionTask']['links']['detail'])
|
|
48
|
+
if result['executionDetail']['status'] == 'ERROR'
|
|
49
|
+
fail "Runing process failed. You can look at a log here #{result['executionDetail']['logFileName']}"
|
|
48
50
|
end
|
|
49
51
|
end
|
|
50
52
|
result
|
|
51
53
|
end
|
|
52
|
-
|
|
53
54
|
end
|
|
54
55
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
module GoodData
|
|
2
4
|
class Profile
|
|
3
5
|
private_class_method :new
|
|
@@ -26,7 +28,7 @@ module GoodData
|
|
|
26
28
|
|
|
27
29
|
def initialize
|
|
28
30
|
@json = GoodData.get GoodData.connection.user['profile']
|
|
29
|
-
@user = @json['accountSetting']['firstName'] +
|
|
31
|
+
@user = @json['accountSetting']['firstName'] + ' ' + @json['accountSetting']['lastName']
|
|
30
32
|
end
|
|
31
33
|
end
|
|
32
34
|
end
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
require 'zip'
|
|
2
4
|
require 'fileutils'
|
|
3
5
|
|
|
4
6
|
module GoodData
|
|
5
|
-
class NoProjectError < RuntimeError
|
|
7
|
+
class NoProjectError < RuntimeError;
|
|
8
|
+
end
|
|
6
9
|
|
|
7
10
|
class Project
|
|
8
11
|
USERSPROJECTS_PATH = '/gdc/account/profile/%s/projects'
|
|
@@ -34,7 +37,7 @@ module GoodData
|
|
|
34
37
|
Project.all
|
|
35
38
|
else
|
|
36
39
|
if id.to_s !~ /^(\/gdc\/(projects|md)\/)?[a-zA-Z\d]+$/
|
|
37
|
-
raise ArgumentError.new(
|
|
40
|
+
raise ArgumentError.new('wrong type of argument. Should be either project ID or path')
|
|
38
41
|
end
|
|
39
42
|
|
|
40
43
|
id = id.match(/[a-zA-Z\d]+$/)[0] if id =~ /\//
|
|
@@ -54,23 +57,35 @@ module GoodData
|
|
|
54
57
|
GoodData.logger.info "Creating project #{attributes[:title]}"
|
|
55
58
|
|
|
56
59
|
auth_token = attributes[:auth_token] || GoodData.connection.auth_token
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
fail "You have to provide your token for creating projects as :auth_token parameter" if auth_token.nil? || auth_token.empty?
|
|
61
|
+
|
|
62
|
+
json = {"project" =>
|
|
63
|
+
{
|
|
64
|
+
'meta' => {
|
|
65
|
+
'title' => attributes[:title],
|
|
66
|
+
'summary' => attributes[:summary] || 'No summary'
|
|
67
|
+
},
|
|
68
|
+
'content' => {
|
|
69
|
+
'guidedNavigation' => 1,
|
|
70
|
+
'authorizationToken' => auth_token,
|
|
71
|
+
'driver' => 'Pg'
|
|
72
|
+
}
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
|
-
json['meta']['projectTemplate'] = attributes[:template] if attributes[:template] && !attributes[:template].empty?
|
|
75
|
+
json["project"]['meta']['projectTemplate'] = attributes[:template] if attributes[:template] && !attributes[:template].empty?
|
|
72
76
|
project = Project.new json
|
|
73
77
|
project.save
|
|
78
|
+
|
|
79
|
+
# until it is enabled or deleted, recur. This should still end if there is a exception thrown out from RESTClient. This sometimes happens from WebApp when request is too long
|
|
80
|
+
while project.state.to_s != "enabled"
|
|
81
|
+
if project.state.to_s == "deleted"
|
|
82
|
+
# if project is switched to deleted state, fail. This is usually problem of creating a template which is invalid.
|
|
83
|
+
fail "Project was marked as deleted during creation. This usually means you were trying to create from template and it failed."
|
|
84
|
+
end
|
|
85
|
+
sleep(3)
|
|
86
|
+
project.reload!
|
|
87
|
+
end
|
|
88
|
+
|
|
74
89
|
if block
|
|
75
90
|
GoodData::with_project(project) do |p|
|
|
76
91
|
block.call(p)
|
|
@@ -78,6 +93,7 @@ module GoodData
|
|
|
78
93
|
end
|
|
79
94
|
project
|
|
80
95
|
end
|
|
96
|
+
|
|
81
97
|
end
|
|
82
98
|
|
|
83
99
|
def initialize(json)
|
|
@@ -92,6 +108,18 @@ module GoodData
|
|
|
92
108
|
end
|
|
93
109
|
end
|
|
94
110
|
|
|
111
|
+
def saved?
|
|
112
|
+
!!uri
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def reload!
|
|
116
|
+
if saved?
|
|
117
|
+
response = GoodData.get(uri)
|
|
118
|
+
@json = response
|
|
119
|
+
end
|
|
120
|
+
self
|
|
121
|
+
end
|
|
122
|
+
|
|
95
123
|
def delete
|
|
96
124
|
raise "Project '#{title}' with id #{uri} is already deleted" if state == :deleted
|
|
97
125
|
GoodData.delete(uri)
|
|
@@ -104,7 +132,7 @@ module GoodData
|
|
|
104
132
|
def browser_uri(options={})
|
|
105
133
|
ui = options[:ui]
|
|
106
134
|
if ui
|
|
107
|
-
GoodData.connection.url +
|
|
135
|
+
GoodData.connection.url + '#s=' + uri
|
|
108
136
|
else
|
|
109
137
|
GoodData.connection.url + uri
|
|
110
138
|
end
|
|
@@ -113,8 +141,8 @@ module GoodData
|
|
|
113
141
|
def obj_id
|
|
114
142
|
uri.split('/').last
|
|
115
143
|
end
|
|
116
|
-
alias :pid :obj_id
|
|
117
144
|
|
|
145
|
+
alias :pid :obj_id
|
|
118
146
|
|
|
119
147
|
def title
|
|
120
148
|
data['meta']['title'] if data['meta']
|
|
@@ -136,20 +164,20 @@ module GoodData
|
|
|
136
164
|
#
|
|
137
165
|
def add_dataset(schema_def, columns = nil, &block)
|
|
138
166
|
schema = if block
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
167
|
+
builder = block.call(Model::SchemaBuilder.new(schema_def))
|
|
168
|
+
builder.to_schema
|
|
169
|
+
else
|
|
170
|
+
sch = {:title => schema_def, :columns => columns} if columns
|
|
171
|
+
sch = Model::Schema.new schema_def if schema_def.is_a? Hash
|
|
172
|
+
sch = schema_def if schema_def.is_a?(Model::Schema)
|
|
173
|
+
raise ArgumentError.new('Required either schema object or title plus columns array') unless schema_def.is_a? Model::Schema
|
|
174
|
+
sch
|
|
175
|
+
end
|
|
148
176
|
Model.add_schema(schema, self)
|
|
149
177
|
end
|
|
150
178
|
|
|
151
179
|
def add_metric(options={})
|
|
152
|
-
expression = options[:expression] || fail(
|
|
180
|
+
expression = options[:expression] || fail('Metric has to have its expression defined')
|
|
153
181
|
m1 = GoodData::Metric.create(options)
|
|
154
182
|
m1.save
|
|
155
183
|
end
|
|
@@ -165,23 +193,25 @@ module GoodData
|
|
|
165
193
|
end
|
|
166
194
|
|
|
167
195
|
def add_user(email_address, domain)
|
|
168
|
-
|
|
196
|
+
raise 'Not implemented'
|
|
169
197
|
end
|
|
170
198
|
|
|
171
|
-
def upload(file, schema, mode =
|
|
199
|
+
def upload(file, schema, mode = 'FULL')
|
|
172
200
|
schema.upload file, self, mode
|
|
173
201
|
end
|
|
174
202
|
|
|
175
203
|
def slis
|
|
176
204
|
link = "#{data['links']['metadata']}#{SLIS_PATH}"
|
|
205
|
+
|
|
206
|
+
# TODO: Review what to do with passed extra argument
|
|
177
207
|
Metadata.new GoodData.get(link)
|
|
178
208
|
end
|
|
179
209
|
|
|
180
210
|
def datasets
|
|
181
|
-
datasets_uri
|
|
182
|
-
response
|
|
211
|
+
datasets_uri = "#{md['data']}/sets"
|
|
212
|
+
response = GoodData.get datasets_uri
|
|
183
213
|
response['dataSetsInfo']['sets'].map do |ds|
|
|
184
|
-
DataSet[ds[
|
|
214
|
+
DataSet[ds['meta']['uri']]
|
|
185
215
|
end
|
|
186
216
|
end
|
|
187
217
|
|
|
@@ -190,11 +220,11 @@ module GoodData
|
|
|
190
220
|
end
|
|
191
221
|
|
|
192
222
|
def data
|
|
193
|
-
raw_data[
|
|
223
|
+
raw_data['project']
|
|
194
224
|
end
|
|
195
225
|
|
|
196
226
|
def links
|
|
197
|
-
data[
|
|
227
|
+
data['links']
|
|
198
228
|
end
|
|
199
229
|
|
|
200
230
|
def to_json
|
|
@@ -205,5 +235,47 @@ module GoodData
|
|
|
205
235
|
true
|
|
206
236
|
end
|
|
207
237
|
|
|
238
|
+
def partial_md_export(objects, options={})
|
|
239
|
+
# TODO: refactor polling to md_polling in client
|
|
240
|
+
|
|
241
|
+
fail "Nothing to migrate. You have to pass list of objects, ids or uris that you would like to migrate" if objects.nil? || objects.empty?
|
|
242
|
+
target_project = options[:project]
|
|
243
|
+
fail "You have to provide a project instance or project pid to migrate to" if target_project.nil?
|
|
244
|
+
target_project = GoodData::Project[target_project]
|
|
245
|
+
objects = objects.map {|obj| GoodData::MdObject[obj]}
|
|
246
|
+
GoodData.logging_on
|
|
247
|
+
export_payload = {
|
|
248
|
+
:partialMDExport => {
|
|
249
|
+
:uris => objects.map {|obj| obj.uri}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
result = GoodData.post("#{GoodData.project.md['maintenance']}/partialmdexport", export_payload)
|
|
253
|
+
polling_url = result["partialMDArtifact"]["status"]["uri"]
|
|
254
|
+
token = result["partialMDArtifact"]["token"]
|
|
255
|
+
|
|
256
|
+
polling_result = GoodData.get(polling_url)
|
|
257
|
+
while polling_result["wTaskStatus"]["poll"]["status"] == "RUNNING"
|
|
258
|
+
polling_result = GoodData.get(polling_url)
|
|
259
|
+
end
|
|
260
|
+
fail "Exporting objects failed" if polling_result["wTaskStatus"]["poll"]["status"] == "ERROR"
|
|
261
|
+
|
|
262
|
+
import_payload = {
|
|
263
|
+
:partialMDImport => {
|
|
264
|
+
:token => token,
|
|
265
|
+
:overwriteNewer => "1",
|
|
266
|
+
:updateLDMObjects => "0"
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
result = GoodData.post("#{target_project.md['maintenance']}/partialmdimport", import_payload)
|
|
271
|
+
polling_uri = result["uri"]
|
|
272
|
+
polling_result = GoodData.get(polling_url)
|
|
273
|
+
while polling_result["wTaskStatus"]["poll"]["status"] == "RUNNING"
|
|
274
|
+
polling_result = GoodData.get(polling_url)
|
|
275
|
+
end
|
|
276
|
+
fail "Exporting objects failed" if polling_result["wTaskStatus"]["poll"]["status"] == "ERROR"
|
|
277
|
+
|
|
278
|
+
end
|
|
279
|
+
|
|
208
280
|
end
|
|
209
281
|
end
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
1
3
|
module GoodData
|
|
2
4
|
class ProjectMetadata
|
|
3
|
-
|
|
4
5
|
class << self
|
|
5
|
-
|
|
6
6
|
def keys
|
|
7
7
|
ProjectMetadata[:all].keys
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def [](key)
|
|
11
11
|
if key == :all
|
|
12
|
-
|
|
13
|
-
res
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
uri = "/gdc/projects/#{GoodData.project.pid}/dataload/metadata"
|
|
13
|
+
res = GoodData.get(uri)
|
|
14
|
+
res['metadataItems']['items'].reduce({}) { |memo, i| memo[i['metadataItem']['key']] = i['metadataItem']['value']; memo }
|
|
15
|
+
else
|
|
16
|
+
uri = "/gdc/projects/#{GoodData.project.pid}/dataload/metadata/#{key}"
|
|
17
|
+
res = GoodData.get(uri)
|
|
18
|
+
res['metadataItem']['value']
|
|
17
19
|
end
|
|
18
20
|
end
|
|
19
21
|
|
|
@@ -32,9 +34,9 @@ module GoodData
|
|
|
32
34
|
def []=(key, val)
|
|
33
35
|
data = {
|
|
34
36
|
:metadataItem => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
:key => key,
|
|
38
|
+
:value => val
|
|
39
|
+
}
|
|
38
40
|
}
|
|
39
41
|
uri = "/gdc/projects/#{GoodData.project.pid}/dataload/metadata/"
|
|
40
42
|
update_uri = uri + key
|
|
@@ -45,8 +47,6 @@ module GoodData
|
|
|
45
47
|
GoodData.post(uri, data)
|
|
46
48
|
end
|
|
47
49
|
end
|
|
48
|
-
|
|
49
50
|
end
|
|
50
|
-
|
|
51
51
|
end
|
|
52
52
|
end
|
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
class Report < GoodData::MdObject
|
|
3
|
+
require_relative 'metadata'
|
|
5
4
|
|
|
5
|
+
module GoodData
|
|
6
|
+
class Report < GoodData::MdObject
|
|
6
7
|
root_key :report
|
|
7
8
|
|
|
8
9
|
class << self
|
|
9
10
|
def [](id)
|
|
10
11
|
if id == :all
|
|
11
|
-
GoodData.
|
|
12
|
-
|
|
12
|
+
uri = GoodData.project.md['query'] + '/reports/'
|
|
13
|
+
GoodData.get(uri)['query']['entries']
|
|
14
|
+
else
|
|
13
15
|
super
|
|
14
16
|
end
|
|
15
17
|
end
|
|
16
|
-
|
|
18
|
+
|
|
17
19
|
def create(options={})
|
|
18
20
|
title = options[:title]
|
|
19
|
-
summary = options[:summary] ||
|
|
21
|
+
summary = options[:summary] || ''
|
|
20
22
|
rd = options[:rd] || ReportDefinition.create(:top => options[:top], :left => options[:left])
|
|
21
23
|
rd.save
|
|
22
24
|
|
|
23
25
|
report = Report.new({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
'report' => {
|
|
27
|
+
'content' => {
|
|
28
|
+
'domains' => [],
|
|
29
|
+
'definitions' => [rd.uri]
|
|
30
|
+
},
|
|
31
|
+
'meta' => {
|
|
32
|
+
'tags' => '',
|
|
33
|
+
'deprecated' => '0',
|
|
34
|
+
'summary' => summary,
|
|
35
|
+
'title' => title
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
})
|
|
37
39
|
end
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
def results
|
|
41
|
-
content[
|
|
43
|
+
content['results']
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
def get_latest_report_definition_uri
|
|
45
47
|
report_result = get_latest_report_result
|
|
46
|
-
report_result.content[
|
|
48
|
+
report_result.content['reportDefinition']
|
|
47
49
|
end
|
|
48
50
|
|
|
49
51
|
def get_latest_report_definition
|
|
@@ -59,13 +61,13 @@ module GoodData
|
|
|
59
61
|
end
|
|
60
62
|
|
|
61
63
|
def execute
|
|
62
|
-
result = GoodData.post '/gdc/xtab2/executor3', {
|
|
63
|
-
data_result_uri = result[
|
|
64
|
+
result = GoodData.post '/gdc/xtab2/executor3', {'report_req' => {'report' => uri}}
|
|
65
|
+
data_result_uri = result['execResult']['dataResult']
|
|
64
66
|
result = GoodData.get data_result_uri
|
|
65
|
-
while result[
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
while result['taskState'] && result['taskState']['status'] == 'WAIT' do
|
|
68
|
+
sleep 10
|
|
69
|
+
result = GoodData.get data_result_uri
|
|
70
|
+
end
|
|
69
71
|
ReportDataResult.new(GoodData.get data_result_uri)
|
|
70
72
|
end
|
|
71
73
|
|
|
@@ -74,7 +76,7 @@ module GoodData
|
|
|
74
76
|
end
|
|
75
77
|
|
|
76
78
|
def export(format)
|
|
77
|
-
result = GoodData.post('/gdc/xtab2/executor3', {
|
|
79
|
+
result = GoodData.post('/gdc/xtab2/executor3', {'report_req' => {'report' => uri}})
|
|
78
80
|
result1 = GoodData.post('/gdc/exporter/executor', {:result_req => {:format => format, :result => result}})
|
|
79
81
|
png = GoodData.get(result1['uri'], :process => false)
|
|
80
82
|
while (png.code == 202) do
|
|
@@ -83,6 +85,5 @@ module GoodData
|
|
|
83
85
|
end
|
|
84
86
|
png
|
|
85
87
|
end
|
|
86
|
-
|
|
87
88
|
end
|
|
88
89
|
end
|