gooddata 0.6.7 → 0.6.8
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/CHANGELOG.md +19 -1
- data/README.md +10 -2
- data/TODO.md +32 -0
- data/gooddata.gemspec +5 -0
- data/lib/gooddata.rb +4 -0
- data/lib/gooddata/app/app.rb +12 -0
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +4 -3
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +2 -1
- data/lib/gooddata/cli/commands/console_cmd.rb +23 -5
- data/lib/gooddata/cli/commands/domain_cmd.rb +9 -10
- data/lib/gooddata/cli/commands/process_cmd.rb +11 -9
- data/lib/gooddata/cli/commands/project_cmd.rb +25 -27
- data/lib/gooddata/cli/commands/projects_cmd.rb +2 -2
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +1 -1
- data/lib/gooddata/cli/commands/user_cmd.rb +2 -2
- data/lib/gooddata/cli/hooks.rb +4 -2
- data/lib/gooddata/cli/shared.rb +1 -1
- data/lib/gooddata/cli/terminal.rb +1 -1
- data/lib/gooddata/commands/api.rb +1 -1
- data/lib/gooddata/commands/auth.rb +4 -28
- data/lib/gooddata/commands/domain.rb +9 -4
- data/lib/gooddata/commands/process.rb +26 -23
- data/lib/gooddata/commands/project.rb +74 -50
- data/lib/gooddata/commands/projects.rb +3 -2
- data/lib/gooddata/commands/role.rb +9 -3
- data/lib/gooddata/commands/user.rb +6 -4
- data/lib/gooddata/connection.rb +11 -45
- data/lib/gooddata/core/logging.rb +0 -1
- data/lib/gooddata/core/project.rb +22 -22
- data/lib/gooddata/core/rest.rb +9 -8
- data/lib/gooddata/core/user.rb +0 -11
- data/lib/gooddata/exceptions/project_not_found.rb +1 -0
- data/lib/gooddata/extensions/enumerable.rb +10 -0
- data/lib/gooddata/extensions/hash.rb +25 -0
- data/lib/gooddata/goodzilla/goodzilla.rb +4 -4
- data/lib/gooddata/helper/class_helper.rb +1 -0
- data/lib/gooddata/helper/helpers.rb +8 -0
- data/lib/gooddata/helpers/auth_helpers.rb +41 -0
- data/lib/gooddata/mixins/author.rb +1 -1
- data/lib/gooddata/mixins/contributor.rb +1 -1
- data/lib/gooddata/mixins/data_property_reader.rb +2 -0
- data/lib/gooddata/mixins/data_property_writer.rb +2 -0
- data/lib/gooddata/mixins/inspector.rb +49 -0
- data/lib/gooddata/mixins/md_finders.rb +16 -8
- data/lib/gooddata/mixins/md_id_to_uri.rb +12 -4
- data/lib/gooddata/mixins/md_object_indexer.rb +15 -4
- data/lib/gooddata/mixins/md_object_query.rb +42 -20
- data/lib/gooddata/mixins/md_relations.rb +21 -12
- data/lib/gooddata/mixins/meta_getter.rb +2 -0
- data/lib/gooddata/mixins/meta_property_reader.rb +2 -0
- data/lib/gooddata/mixins/meta_property_writer.rb +2 -0
- data/lib/gooddata/mixins/rest_resource.rb +32 -10
- data/lib/gooddata/mixins/root_key_getter.rb +1 -1
- data/lib/gooddata/models/data_result.rb +3 -1
- data/lib/gooddata/models/domain.rb +31 -22
- data/lib/gooddata/models/empty_result.rb +22 -0
- data/lib/gooddata/models/invitation.rb +11 -9
- data/lib/gooddata/models/links.rb +5 -3
- data/lib/gooddata/models/membership.rb +23 -28
- data/lib/gooddata/models/metadata.rb +35 -35
- data/lib/gooddata/models/metadata/attribute.rb +10 -8
- data/lib/gooddata/models/metadata/dashboard.rb +1 -1
- data/lib/gooddata/models/metadata/fact.rb +3 -3
- data/lib/gooddata/models/metadata/label.rb +4 -4
- data/lib/gooddata/models/metadata/metric.rb +76 -38
- data/lib/gooddata/models/metadata/report.rb +52 -17
- data/lib/gooddata/models/metadata/report_definition.rb +178 -28
- data/lib/gooddata/models/model.rb +13 -6
- data/lib/gooddata/models/process.rb +93 -30
- data/lib/gooddata/models/profile.rb +18 -20
- data/lib/gooddata/models/project.rb +344 -127
- data/lib/gooddata/models/project_creator.rb +32 -22
- data/lib/gooddata/models/project_metadata.rb +26 -14
- data/lib/gooddata/models/project_role.rb +15 -17
- data/lib/gooddata/models/report_data_result.rb +4 -0
- data/lib/gooddata/models/schedule.rb +51 -20
- data/lib/gooddata/models/schema_blueprint.rb +9 -3
- data/lib/gooddata/rest/README.md +37 -0
- data/lib/gooddata/rest/client.rb +318 -0
- data/lib/gooddata/rest/connection.rb +235 -0
- data/lib/gooddata/rest/connections/connections.rb +8 -0
- data/lib/gooddata/rest/connections/dummy_connection.rb +52 -0
- data/lib/gooddata/rest/connections/rest_client_connection.rb +177 -0
- data/lib/gooddata/rest/object.rb +32 -0
- data/lib/gooddata/rest/object_factory.rb +67 -0
- data/lib/gooddata/rest/resource.rb +17 -0
- data/lib/gooddata/rest/rest.rb +20 -0
- data/lib/gooddata/version.rb +1 -1
- data/spec/data/cc/data/source/commits.csv +4 -0
- data/spec/data/cc/data/source/devs.csv +4 -0
- data/spec/data/cc/data/source/repos.csv +3 -0
- data/spec/data/cc/devel.prm +0 -0
- data/spec/data/cc/graph/graph.grf +11 -0
- data/spec/data/cc/workspace.prm +19 -0
- data/spec/data/hello_world_process/hello_world.rb +1 -0
- data/spec/data/hello_world_process/hello_world.zip +0 -0
- data/spec/data/users.csv +12 -12
- data/spec/helpers/connection_helper.rb +6 -0
- data/spec/helpers/process_helper.rb +12 -0
- data/spec/helpers/project_helper.rb +2 -2
- data/spec/integration/command_projects_spec.rb +11 -9
- data/spec/integration/create_from_template_spec.rb +6 -2
- data/spec/integration/full_process_schedule_spec.rb +49 -36
- data/spec/integration/full_project_spec.rb +221 -256
- data/spec/integration/partial_md_export_import_spec.rb +18 -17
- data/spec/logging_in_logging_out_spec.rb +17 -8
- data/spec/spec_helper.rb +4 -2
- data/spec/unit/cli/commands/cmd_api_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_auth_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_domain_spec.rb +29 -3
- data/spec/unit/cli/commands/cmd_process_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_project_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_role_spec.rb +13 -2
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +1 -1
- data/spec/unit/cli/commands/cmd_user_spec.rb +1 -1
- data/spec/unit/commands/command_api_spec.rb +0 -19
- data/spec/unit/commands/command_auth_spec.rb +20 -13
- data/spec/unit/commands/command_dataset_spec.rb +2 -2
- data/spec/unit/commands/command_process_spec.rb +24 -21
- data/spec/unit/commands/command_projects_spec.rb +2 -2
- data/spec/unit/commands/command_scaffold_spec.rb +2 -2
- data/spec/unit/commands/command_user_spec.rb +3 -3
- data/spec/unit/core/connection_spec.rb +9 -10
- data/spec/unit/core/project_spec.rb +8 -4
- data/spec/unit/core/rest_spec.rb +6 -6
- data/spec/unit/models/domain_spec.rb +14 -7
- data/spec/unit/models/invitation_spec.rb +2 -2
- data/spec/unit/models/membership_spec.rb +5 -5
- data/spec/unit/models/metric_spec.rb +92 -0
- data/spec/unit/models/profile_spec.rb +25 -21
- data/spec/unit/models/project_blueprint_spec.rb +6 -6
- data/spec/unit/models/project_role_spec.rb +3 -5
- data/spec/unit/models/project_spec.rb +43 -37
- data/spec/unit/models/schedule_spec.rb +58 -107
- data/spec/unit/rest/resource_spec.rb +6 -0
- metadata +87 -10
- data/lib/gooddata/cli/commands/role_cmd.rb +0 -28
- data/lib/gooddata/core/connection.rb +0 -392
- data/lib/gooddata/core/threaded.rb +0 -14
- data/lib/gooddata/models/md_object.rb +0 -25
- data/lib/gooddata/models/metadata/folder.rb +0 -24
- data/spec/unit/models/md_object_spec.rb +0 -55
- data/spec/unit/models/metric.rb +0 -92
|
@@ -31,5 +31,27 @@ module GoodData
|
|
|
31
31
|
def diff(otherDataResult)
|
|
32
32
|
['empty']
|
|
33
33
|
end
|
|
34
|
+
|
|
35
|
+
def [](index, options = {})
|
|
36
|
+
to_table[index]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
alias_method :row, :[]
|
|
40
|
+
|
|
41
|
+
def empty?
|
|
42
|
+
true
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def column(index)
|
|
46
|
+
table[index]
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def include_row?(row = nil)
|
|
50
|
+
false
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def include_column?(row = nil)
|
|
54
|
+
false
|
|
55
|
+
end
|
|
34
56
|
end
|
|
35
57
|
end
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
+
require_relative '../rest/rest'
|
|
4
|
+
|
|
3
5
|
module GoodData
|
|
4
|
-
class Invitation
|
|
6
|
+
class Invitation < GoodData::Rest::Object
|
|
5
7
|
def initialize(json)
|
|
6
8
|
@json = json
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
def author
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
data = client.get @json['invitation']['meta']['author']
|
|
13
|
+
client.create GoodData::AccountSettings, data
|
|
12
14
|
end
|
|
13
15
|
|
|
14
16
|
def contributor
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
data = client.get @json['invitation']['meta']['contributor']
|
|
18
|
+
client.create GoodData::AccountSettings, data
|
|
17
19
|
end
|
|
18
20
|
|
|
19
21
|
def created
|
|
@@ -37,13 +39,13 @@ module GoodData
|
|
|
37
39
|
end
|
|
38
40
|
|
|
39
41
|
def profile
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
data = client.get @json['invitation']['links']['profile']
|
|
43
|
+
client.create GoodData::AccountSettings, data
|
|
42
44
|
end
|
|
43
45
|
|
|
44
46
|
def project
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
data = client.get @json['invitation']['links']['project']
|
|
48
|
+
client.create GoodData::Project, data
|
|
47
49
|
end
|
|
48
50
|
|
|
49
51
|
def project_name
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
+
require_relative '../rest/object'
|
|
4
|
+
|
|
3
5
|
module GoodData
|
|
4
|
-
class Links
|
|
6
|
+
class Links < GoodData::Rest::Object
|
|
5
7
|
attr_reader :data
|
|
6
8
|
|
|
7
9
|
def initialize(items)
|
|
@@ -20,8 +22,8 @@ module GoodData
|
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def links(category, identifier = nil)
|
|
23
|
-
return Links.new(
|
|
24
|
-
Links.new
|
|
25
|
+
return Links.new(client.get(self[category])) unless identifier
|
|
26
|
+
Links.new client.get(get(category, identifier))
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
def [](category)
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
3
|
require 'multi_json'
|
|
4
|
+
require 'pmap'
|
|
4
5
|
|
|
5
6
|
require_relative 'project'
|
|
6
7
|
require_relative 'project_role'
|
|
7
8
|
|
|
9
|
+
require_relative '../rest/object'
|
|
10
|
+
|
|
8
11
|
module GoodData
|
|
9
|
-
class Membership
|
|
12
|
+
class Membership < GoodData::Rest::Object
|
|
10
13
|
attr_reader :json
|
|
11
14
|
|
|
12
15
|
ASSIGNABLE_MEMBERS = [
|
|
@@ -128,8 +131,8 @@ module GoodData
|
|
|
128
131
|
# @return [String] Author
|
|
129
132
|
def author
|
|
130
133
|
url = @json['user']['meta']['author']
|
|
131
|
-
data =
|
|
132
|
-
GoodData::Membership
|
|
134
|
+
data = client.get url
|
|
135
|
+
client.factory.create(GoodData::Membership, data)
|
|
133
136
|
end
|
|
134
137
|
|
|
135
138
|
# Gets the contributor
|
|
@@ -137,8 +140,8 @@ module GoodData
|
|
|
137
140
|
# @return [String] Contributor
|
|
138
141
|
def contributor
|
|
139
142
|
url = @json['user']['meta']['contributor']
|
|
140
|
-
data =
|
|
141
|
-
GoodData::Membership
|
|
143
|
+
data = client.get url
|
|
144
|
+
client.factory.create(GoodData::Membership, data)
|
|
142
145
|
end
|
|
143
146
|
|
|
144
147
|
# Gets date when created
|
|
@@ -190,7 +193,7 @@ module GoodData
|
|
|
190
193
|
def invitations
|
|
191
194
|
res = []
|
|
192
195
|
|
|
193
|
-
tmp =
|
|
196
|
+
tmp = client.get @json['user']['links']['invitations']
|
|
194
197
|
tmp['invitations'].each do |invitation|
|
|
195
198
|
# TODO: Something is missing here
|
|
196
199
|
end
|
|
@@ -239,7 +242,7 @@ module GoodData
|
|
|
239
242
|
def permissions
|
|
240
243
|
res = {}
|
|
241
244
|
|
|
242
|
-
tmp =
|
|
245
|
+
tmp = client.get @json['user']['links']['permissions']
|
|
243
246
|
tmp['associatedPermissions']['permissions'].each do |permission_name, permission_value|
|
|
244
247
|
res[permission_name] = permission_value
|
|
245
248
|
end
|
|
@@ -263,8 +266,8 @@ module GoodData
|
|
|
263
266
|
|
|
264
267
|
# Gets profile of this membership
|
|
265
268
|
def profile
|
|
266
|
-
raw =
|
|
267
|
-
GoodData::Profile
|
|
269
|
+
raw = client.get @json['user']['links']['self']
|
|
270
|
+
client.factory.create(GoodData::Profile, raw)
|
|
268
271
|
end
|
|
269
272
|
|
|
270
273
|
# Gets URL of profile membership
|
|
@@ -274,8 +277,8 @@ module GoodData
|
|
|
274
277
|
|
|
275
278
|
# Gets project which this membership relates to
|
|
276
279
|
def project
|
|
277
|
-
raw =
|
|
278
|
-
GoodData::Project
|
|
280
|
+
raw = client.get project_url
|
|
281
|
+
client.factory.create(GoodData::Project, raw)
|
|
279
282
|
end
|
|
280
283
|
|
|
281
284
|
# Gets project id
|
|
@@ -292,16 +295,12 @@ module GoodData
|
|
|
292
295
|
#
|
|
293
296
|
# @return [Array<GoodData::Project>] Array of projets
|
|
294
297
|
def projects
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
tmp = GoodData.get @json['user']['links']['projects']
|
|
298
|
-
tmp['projects'].each do |project_meta|
|
|
298
|
+
tmp = client.get @json['user']['links']['projects']
|
|
299
|
+
tmp['projects'].map do |project_meta|
|
|
299
300
|
project_uri = project_meta['project']['links']['self']
|
|
300
|
-
project =
|
|
301
|
-
|
|
301
|
+
project = client.get project_uri
|
|
302
|
+
client.factory.create(GoodData::Project, project)
|
|
302
303
|
end
|
|
303
|
-
|
|
304
|
-
res
|
|
305
304
|
end
|
|
306
305
|
|
|
307
306
|
# Gets first role
|
|
@@ -313,15 +312,11 @@ module GoodData
|
|
|
313
312
|
#
|
|
314
313
|
# @return [Array<GoodData::ProjectRole>] Array of project roles
|
|
315
314
|
def roles
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
role = GoodData.get role_uri
|
|
321
|
-
res << GoodData::ProjectRole.new(role)
|
|
315
|
+
tmp = client.get @json['user']['links']['roles']
|
|
316
|
+
tmp['associatedRoles']['roles'].pmap do |role_uri|
|
|
317
|
+
role = client.get role_uri
|
|
318
|
+
client.factory.create(GoodData::ProjectRole, role)
|
|
322
319
|
end
|
|
323
|
-
|
|
324
|
-
res
|
|
325
320
|
end
|
|
326
321
|
|
|
327
322
|
# Gets the status
|
|
@@ -396,7 +391,7 @@ module GoodData
|
|
|
396
391
|
}
|
|
397
392
|
}
|
|
398
393
|
|
|
399
|
-
@json =
|
|
394
|
+
@json = client.post("/gdc/projects/#{project_id}/users", payload)
|
|
400
395
|
end
|
|
401
396
|
end
|
|
402
397
|
end
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
-
require_relative '../core/connection'
|
|
4
3
|
require_relative '../core/project'
|
|
5
4
|
|
|
6
5
|
require_relative '../mixins/mixins'
|
|
6
|
+
require_relative '../rest/object'
|
|
7
7
|
|
|
8
8
|
module GoodData
|
|
9
|
-
class MdObject
|
|
9
|
+
class MdObject < GoodData::Rest::Object
|
|
10
|
+
MD_OBJ_CTG = 'obj'
|
|
10
11
|
IDENTIFIERS_CFG = 'instance-identifiers'
|
|
11
12
|
|
|
12
13
|
attr_reader :json
|
|
@@ -14,30 +15,20 @@ module GoodData
|
|
|
14
15
|
alias_method :raw_data, :json
|
|
15
16
|
alias_method :to_hash, :json
|
|
16
17
|
|
|
17
|
-
include GoodData::Mixin::
|
|
18
|
-
include GoodData::Mixin::MdJson
|
|
19
|
-
include GoodData::Mixin::DataGetter
|
|
20
|
-
include GoodData::Mixin::MetaGetter
|
|
21
|
-
include GoodData::Mixin::ObjId
|
|
22
|
-
include GoodData::Mixin::ContentGetter
|
|
23
|
-
include GoodData::Mixin::Timestamps
|
|
24
|
-
include GoodData::Mixin::Links
|
|
25
|
-
include GoodData::Mixin::NotAttribute
|
|
26
|
-
include GoodData::Mixin::NotExportable
|
|
27
|
-
include GoodData::Mixin::NotFact
|
|
28
|
-
include GoodData::Mixin::NotMetric
|
|
29
|
-
include GoodData::Mixin::NotLabel
|
|
30
|
-
include GoodData::Mixin::MdRelations
|
|
18
|
+
include GoodData::Mixin::RestResource
|
|
31
19
|
|
|
32
20
|
class << self
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
def metadata_property_reader(*props)
|
|
22
|
+
props.each do |prop|
|
|
23
|
+
define_method prop, proc { meta[prop.to_s] }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def metadata_property_writer(*props)
|
|
28
|
+
props.each do |prop|
|
|
29
|
+
define_method "#{prop}=", proc { |val| meta[prop.to_s] = val }
|
|
30
|
+
end
|
|
31
|
+
end
|
|
41
32
|
end
|
|
42
33
|
|
|
43
34
|
metadata_property_reader :uri, :identifier, :title, :summary, :tags, :deprecated, :category
|
|
@@ -49,14 +40,14 @@ module GoodData
|
|
|
49
40
|
|
|
50
41
|
def delete
|
|
51
42
|
if saved?
|
|
52
|
-
|
|
43
|
+
client.delete(uri)
|
|
53
44
|
meta.delete('uri')
|
|
54
45
|
# ["uri"] = nil
|
|
55
46
|
end
|
|
56
47
|
end
|
|
57
48
|
|
|
58
49
|
def reload!
|
|
59
|
-
@json =
|
|
50
|
+
@json = client.get(uri) if saved?
|
|
60
51
|
self
|
|
61
52
|
end
|
|
62
53
|
|
|
@@ -77,7 +68,7 @@ module GoodData
|
|
|
77
68
|
end
|
|
78
69
|
|
|
79
70
|
def project
|
|
80
|
-
@project ||= Project[uri.gsub(%r{\/obj\/\d+$}, '')]
|
|
71
|
+
@project ||= Project[uri.gsub(%r{\/obj\/\d+$}, ''), :client => client, :project => project]
|
|
81
72
|
end
|
|
82
73
|
|
|
83
74
|
def saved?
|
|
@@ -88,17 +79,24 @@ module GoodData
|
|
|
88
79
|
def save
|
|
89
80
|
fail('Validation failed') unless validate
|
|
90
81
|
|
|
82
|
+
opts = {
|
|
83
|
+
:client => client,
|
|
84
|
+
:project => project
|
|
85
|
+
}
|
|
86
|
+
|
|
91
87
|
if saved?
|
|
92
|
-
|
|
88
|
+
client.put(uri, to_json)
|
|
93
89
|
else
|
|
94
90
|
explicit_identifier = meta['identifier']
|
|
95
91
|
# Pre-check to provide a user-friendly error rather than
|
|
96
92
|
# failing later
|
|
97
|
-
if explicit_identifier && MdObject[explicit_identifier]
|
|
93
|
+
if explicit_identifier && MdObject[explicit_identifier, opts]
|
|
98
94
|
fail "Identifier '#{explicit_identifier}' already in use"
|
|
99
95
|
end
|
|
100
|
-
|
|
101
|
-
|
|
96
|
+
|
|
97
|
+
req_uri = project.md['obj']
|
|
98
|
+
result = client.post(req_uri, to_json)
|
|
99
|
+
saved_object = self.class[result['uri'], opts]
|
|
102
100
|
# TODO: add test for explicitly provided identifier
|
|
103
101
|
|
|
104
102
|
@json = saved_object.json
|
|
@@ -108,11 +106,11 @@ module GoodData
|
|
|
108
106
|
# it explicitly with an extra PUT call.
|
|
109
107
|
meta['identifier'] = explicit_identifier
|
|
110
108
|
begin
|
|
111
|
-
|
|
109
|
+
client.put(uri, to_json)
|
|
112
110
|
rescue => e
|
|
113
111
|
# Cannot change the identifier (perhaps because it's in use
|
|
114
112
|
# already?), cleaning up.
|
|
115
|
-
|
|
113
|
+
client.delete(uri)
|
|
116
114
|
raise e
|
|
117
115
|
end
|
|
118
116
|
end
|
|
@@ -124,12 +122,14 @@ module GoodData
|
|
|
124
122
|
#
|
|
125
123
|
# @param new_title [String] New title. If not provided one is provided
|
|
126
124
|
# @return [GoodData::MdObject] MdObject that has been saved as
|
|
127
|
-
def save_as(new_title =
|
|
125
|
+
def save_as(new_title = nil)
|
|
126
|
+
new_title = "Clone of #{title}" if new_title.nil?
|
|
127
|
+
|
|
128
128
|
dupped = Marshal.load(Marshal.dump(json))
|
|
129
129
|
dupped[root_key]['meta'].delete('uri')
|
|
130
130
|
dupped[root_key]['meta'].delete('identifier')
|
|
131
131
|
dupped[root_key]['meta']['title'] = new_title
|
|
132
|
-
x = self.class
|
|
132
|
+
x = client.create(self.class, dupped, :project => project)
|
|
133
133
|
x.save
|
|
134
134
|
end
|
|
135
135
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
2
|
|
|
3
|
+
require_relative '../metadata'
|
|
4
|
+
|
|
3
5
|
require_relative 'metadata'
|
|
4
6
|
|
|
5
7
|
require_relative '../../mixins/is_attribute'
|
|
@@ -18,7 +20,7 @@ module GoodData
|
|
|
18
20
|
# @param options [Hash] the options hash
|
|
19
21
|
# @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
|
|
20
22
|
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
|
|
21
|
-
def all(options = {})
|
|
23
|
+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
|
|
22
24
|
query('attributes', Attribute, options)
|
|
23
25
|
end
|
|
24
26
|
|
|
@@ -26,16 +28,16 @@ module GoodData
|
|
|
26
28
|
#
|
|
27
29
|
# @param uri [String] Uri of the element. in the form of /gdc/md/PID/obj/OBJ_ID/elements?id=21
|
|
28
30
|
# @return [String] Textual representation of a particular attribute element
|
|
29
|
-
def find_element_value(uri)
|
|
31
|
+
def find_element_value(uri, opts = { :client => @client, :project => @project })
|
|
30
32
|
matches = uri.match(/(.*)\/elements\?id=(\d+)$/)
|
|
31
|
-
|
|
33
|
+
opts[:project].attributes(matches[1]).primary_label.find_element_value(uri)
|
|
32
34
|
end
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
# Returns the labels of an attribute
|
|
36
38
|
# @return [Array<GoodData::Label>]
|
|
37
39
|
def display_forms
|
|
38
|
-
content['displayForms'].map { |df| GoodData::Label[df['meta']['uri']] }
|
|
40
|
+
content['displayForms'].map { |df| GoodData::Label[df['meta']['uri'], :client => client, :project => project] }
|
|
39
41
|
end
|
|
40
42
|
alias_method :labels, :display_forms
|
|
41
43
|
|
|
@@ -57,9 +59,9 @@ module GoodData
|
|
|
57
59
|
fail "Suggested aggreagtion function (#{a_type}) does not exist for base metric created out of attribute. You can use only one of #{ATTRIBUTE_BASE_AGGREGATIONS.map { |x| ":" + x.to_s }.join(',')}" unless ATTRIBUTE_BASE_AGGREGATIONS.include?(a_type)
|
|
58
60
|
a_title = options[:title] || "#{a_type} of #{title}"
|
|
59
61
|
if an_attribute
|
|
60
|
-
Metric.xcreate(
|
|
62
|
+
Metric.xcreate("SELECT #{a_type.to_s.upcase}(![#{identifier}], ![#{an_attribute.identifier}])", :title => a_title, :client => client, :project => project)
|
|
61
63
|
else
|
|
62
|
-
Metric.xcreate(
|
|
64
|
+
Metric.xcreate("SELECT #{a_type.to_s.upcase}(![#{identifier}])", :title => a_title, :client => client, :project => project)
|
|
63
65
|
end
|
|
64
66
|
end
|
|
65
67
|
|
|
@@ -77,9 +79,9 @@ module GoodData
|
|
|
77
79
|
# @param [Hash] options the options to pass to the value list
|
|
78
80
|
# @option options [Number] :limit limits the number of values to certain number. Default is 100
|
|
79
81
|
# @return [Array]
|
|
80
|
-
def values
|
|
82
|
+
def values
|
|
81
83
|
results = labels.map do |label|
|
|
82
|
-
label.values
|
|
84
|
+
label.values
|
|
83
85
|
end
|
|
84
86
|
results.first.zip(*results[1..-1])
|
|
85
87
|
end
|
|
@@ -17,7 +17,7 @@ module GoodData
|
|
|
17
17
|
# @param options [Hash] the options hash
|
|
18
18
|
# @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
|
|
19
19
|
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
|
|
20
|
-
def all(options = {})
|
|
20
|
+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
|
|
21
21
|
query('projectdashboards', Dashboard, options)
|
|
22
22
|
end
|
|
23
23
|
|
|
@@ -21,7 +21,7 @@ module GoodData
|
|
|
21
21
|
# @param options [Hash] the options hash
|
|
22
22
|
# @option options [Boolean] :full if passed true the subclass can decide to pull in full objects. This is desirable from the usability POV but unfortunately has negative impact on performance so it is not the default
|
|
23
23
|
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
|
|
24
|
-
def all(options = {})
|
|
24
|
+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
|
|
25
25
|
query('facts', Fact, options)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -30,11 +30,11 @@ module GoodData
|
|
|
30
30
|
# @param [Hash] options the options to pass to the value list
|
|
31
31
|
# @option options [Symbol] :type type of aggregation function. Default is :sum
|
|
32
32
|
# @return [GoodData::Metric]
|
|
33
|
-
def create_metric(options = {})
|
|
33
|
+
def create_metric(options = { :type => :sum })
|
|
34
34
|
a_type = options[:type] || :sum
|
|
35
35
|
fail "Suggested aggreagtion function (#{a_type}) does not exist for base metric created out of fact. You can use only one of #{FACT_BASE_AGGREGATIONS.map { |x| ":" + x.to_s }.join(',')}" unless FACT_BASE_AGGREGATIONS.include?(a_type)
|
|
36
36
|
a_title = options[:title] || "#{a_type} of #{title}"
|
|
37
|
-
Metric.xcreate(
|
|
37
|
+
Metric.xcreate("SELECT #{a_type.to_s.upcase}(![#{identifier}])", :title => a_title, :client => client, :project => project)
|
|
38
38
|
end
|
|
39
39
|
end
|
|
40
40
|
end
|