gooddata 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.markdown +4 -0
  3. data/README.md +1 -0
  4. data/lib/gooddata/cli/commands/project_cmd.rb +2 -7
  5. data/lib/gooddata/client.rb +0 -2
  6. data/lib/gooddata/commands/project.rb +10 -0
  7. data/lib/gooddata/core/rest.rb +12 -2
  8. data/lib/gooddata/exceptions/attr_element_not_found.rb +12 -0
  9. data/lib/gooddata/extensions/enumerable.rb +12 -0
  10. data/lib/gooddata/helpers/global_helpers.rb +20 -0
  11. data/lib/gooddata/mixins/author.rb +16 -0
  12. data/lib/gooddata/mixins/content_getter.rb +11 -0
  13. data/lib/gooddata/mixins/content_property_reader.rb +13 -0
  14. data/lib/gooddata/mixins/content_property_writer.rb +13 -0
  15. data/lib/gooddata/mixins/contributor.rb +16 -0
  16. data/lib/gooddata/mixins/data_getter.rb +11 -0
  17. data/lib/gooddata/mixins/data_property_reader.rb +13 -0
  18. data/lib/gooddata/mixins/data_property_writer.rb +13 -0
  19. data/lib/gooddata/mixins/is_attribute.rb +13 -0
  20. data/lib/gooddata/mixins/is_fact.rb +13 -0
  21. data/lib/gooddata/mixins/is_label.rb +15 -0
  22. data/lib/gooddata/mixins/links.rb +11 -0
  23. data/lib/gooddata/mixins/md_finders.rb +36 -0
  24. data/lib/gooddata/mixins/md_id_to_uri.rb +29 -0
  25. data/lib/gooddata/mixins/md_json.rb +11 -0
  26. data/lib/gooddata/mixins/md_object_id.rb +11 -0
  27. data/lib/gooddata/mixins/md_object_indexer.rb +36 -0
  28. data/lib/gooddata/mixins/md_object_query.rb +83 -0
  29. data/lib/gooddata/mixins/md_relations.rb +39 -0
  30. data/lib/gooddata/mixins/meta_getter.rb +11 -0
  31. data/lib/gooddata/mixins/meta_property_reader.rb +13 -0
  32. data/lib/gooddata/mixins/meta_property_writer.rb +13 -0
  33. data/lib/gooddata/mixins/mixins.rb +15 -0
  34. data/lib/gooddata/mixins/not_attribute.rb +13 -0
  35. data/lib/gooddata/mixins/not_exportable.rb +11 -0
  36. data/lib/gooddata/mixins/not_fact.rb +13 -0
  37. data/lib/gooddata/mixins/not_label.rb +15 -0
  38. data/lib/gooddata/mixins/not_metric.rb +13 -0
  39. data/lib/gooddata/mixins/obj_id.rb +11 -0
  40. data/lib/gooddata/mixins/rest_getters.rb +13 -0
  41. data/lib/gooddata/mixins/rest_resource.rb +19 -0
  42. data/lib/gooddata/mixins/root_key_getter.rb +11 -0
  43. data/lib/gooddata/mixins/root_key_setter.rb +11 -0
  44. data/lib/gooddata/mixins/timestamps.rb +15 -0
  45. data/lib/gooddata/models/from_wire.rb +153 -0
  46. data/lib/gooddata/models/metadata.rb +28 -230
  47. data/lib/gooddata/models/metadata/attribute.rb +4 -6
  48. data/lib/gooddata/models/metadata/fact.rb +4 -6
  49. data/lib/gooddata/models/metadata/{display_form.rb → label.rb} +17 -11
  50. data/lib/gooddata/models/metadata/metric.rb +1 -1
  51. data/lib/gooddata/models/metadata/report_definition.rb +2 -2
  52. data/lib/gooddata/models/model.rb +55 -23
  53. data/lib/gooddata/models/models.rb +0 -2
  54. data/lib/gooddata/models/module_constants.rb +0 -2
  55. data/lib/gooddata/models/process.rb +1 -1
  56. data/lib/gooddata/models/project.rb +117 -76
  57. data/lib/gooddata/models/project_blueprint.rb +322 -42
  58. data/lib/gooddata/models/project_creator.rb +5 -4
  59. data/lib/gooddata/models/project_role.rb +20 -55
  60. data/lib/gooddata/models/schema_blueprint.rb +287 -84
  61. data/lib/gooddata/models/schema_builder.rb +0 -4
  62. data/lib/gooddata/models/to_manifest.rb +160 -0
  63. data/lib/gooddata/models/to_wire.rb +150 -0
  64. data/lib/gooddata/version.rb +1 -1
  65. data/spec/data/blueprint_invalid.json +3 -1
  66. data/spec/data/gd_gse_data_blueprint.json +1370 -0
  67. data/spec/data/gd_gse_data_manifest.json +1424 -0
  68. data/spec/data/gd_gse_data_model.json +1772 -0
  69. data/spec/data/manifest_test_project.json +116 -0
  70. data/spec/data/model_view.json +1772 -0
  71. data/spec/data/superfluous_titles_view.json +81 -0
  72. data/spec/data/test_project_model_spec.json +7 -4
  73. data/spec/data/wire_test_project.json +143 -0
  74. data/spec/helpers/crypto_helper.rb +9 -0
  75. data/spec/helpers/project_helper.rb +2 -0
  76. data/spec/integration/command_projects_spec.rb +4 -2
  77. data/spec/integration/full_project_spec.rb +51 -18
  78. data/spec/integration/partial_md_export_import_spec.rb +1 -1
  79. data/spec/spec_helper.rb +2 -1
  80. data/spec/unit/models/attribute_column_spec.rb +7 -7
  81. data/spec/unit/models/domain_spec.rb +2 -2
  82. data/spec/unit/models/from_wire_spec.rb +119 -0
  83. data/spec/unit/models/metadata_spec.rb +4 -2
  84. data/spec/unit/models/project_blueprint_spec.rb +32 -16
  85. data/spec/unit/models/project_role_spec.rb +6 -4
  86. data/spec/unit/models/project_spec.rb +26 -3
  87. data/spec/unit/models/schema_builder_spec.rb +5 -6
  88. data/spec/unit/models/to_manifest_spec.rb +24 -0
  89. data/spec/unit/models/to_wire_spec.rb +63 -0
  90. metadata +53 -29
  91. data/lib/gooddata/models/attributes/anchor.rb +0 -37
  92. data/lib/gooddata/models/attributes/attributes.rb +0 -8
  93. data/lib/gooddata/models/attributes/date_attribute.rb +0 -25
  94. data/lib/gooddata/models/attributes/time_attribute.rb +0 -24
  95. data/lib/gooddata/models/columns/attribute.rb +0 -71
  96. data/lib/gooddata/models/columns/columns.rb +0 -8
  97. data/lib/gooddata/models/columns/date_column.rb +0 -63
  98. data/lib/gooddata/models/columns/fact_model.rb +0 -54
  99. data/lib/gooddata/models/columns/label.rb +0 -55
  100. data/lib/gooddata/models/columns/reference.rb +0 -57
  101. data/lib/gooddata/models/facts/facts.rb +0 -8
  102. data/lib/gooddata/models/facts/time_fact.rb +0 -20
  103. data/lib/gooddata/models/folders/attribute_folder.rb +0 -20
  104. data/lib/gooddata/models/folders/fact_folder.rb +0 -20
  105. data/lib/gooddata/models/folders/folders.rb +0 -8
  106. data/lib/gooddata/models/metadata/column.rb +0 -61
  107. data/lib/gooddata/models/metadata/data_set.rb +0 -32
  108. data/lib/gooddata/models/metadata/date_dimension.rb +0 -26
  109. data/lib/gooddata/models/metadata/schema.rb +0 -227
  110. data/lib/gooddata/models/references/date_reference.rb +0 -44
  111. data/lib/gooddata/models/references/references.rb +0 -8
  112. data/lib/gooddata/models/references/time_reference.rb +0 -13
  113. data/spec/helpers/schema_helper.rb +0 -16
  114. data/spec/unit/models/anchor_spec.rb +0 -32
  115. data/spec/unit/models/tools_spec.rb +0 -95
  116. data/test/test_upload.rb +0 -79
@@ -1,44 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require_relative '../columns/reference'
4
-
5
- module GoodData
6
- module Model
7
- ##
8
- # Date as a reference to a date dimension
9
- #
10
- class DateReference < Reference
11
- attr_accessor :format, :output_format, :urn
12
-
13
- def initialize(column, schema)
14
- super column, schema
15
- @output_format = column['format'] || 'dd/MM/yyyy'
16
- @format = @output_format.gsub('yyyy', '%Y').gsub('MM', '%m').gsub('dd', '%d')
17
- @urn = column[:urn] || 'URN:GOODDATA:DATE'
18
- end
19
-
20
- def identifier
21
- @identifier ||= "#{@schema_ref}.#{DATE_ATTRIBUTE}"
22
- end
23
-
24
- def to_manifest_part(mode)
25
- {
26
- 'populates' => ["#{identifier}.#{DATE_ATTRIBUTE_DEFAULT_DISPLAY_FORM}"],
27
- 'mode' => mode,
28
- 'constraints' => { 'date' => output_format },
29
- 'columnName' => name,
30
- 'referenceKey' => 1
31
- }
32
- end
33
-
34
- # def to_maql_create
35
- # # urn:chefs_warehouse_fiscal:date
36
- # super_maql = super
37
- # maql = ""
38
- # # maql = "# Include date dimensions\n"
39
- # # maql += "INCLUDE TEMPLATE \"#{urn}\" MODIFY (IDENTIFIER \"#{name}\", TITLE \"#{title || name}\");\n"
40
- # maql += super_maql
41
- # end
42
- end
43
- end
44
- end
@@ -1,8 +0,0 @@
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
@@ -1,13 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require_relative '../columns/reference'
4
-
5
- module GoodData
6
- module Model
7
- ##
8
- # Time as a reference to a time-of-a-day dimension
9
- #
10
- class TimeReference < Reference
11
- end
12
- end
13
- end
@@ -1,16 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'gooddata/models/metadata/schema'
4
-
5
- module SchemaHelper
6
- COLUMNS = [
7
- {:type => :anchor, :name => 'cp', 'title' => 'CP', 'folder' => 'test'},
8
- {:type => :attribute, :name => 'a1', 'title' => 'A1', 'folder' => 'test'},
9
- {:type => :attribute, :name => 'a2', 'title' => 'A2', 'folder' => 'test'},
10
- {:type => :date, :name => 'event', 'title' => 'Event', 'folder' => 'test'},
11
- {:type => :fact, :name => 'f1', 'title' => 'F1', 'folder' => 'test'},
12
- {:type => :fact, :name => 'f2', 'title' => 'F2', 'folder' => 'test'},
13
- ]
14
-
15
- SCHEMA = GoodData::Model::Schema.new :name => 'test', :title => 'test', :columns => COLUMNS
16
- end
@@ -1,32 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'gooddata/models/attributes/anchor'
4
-
5
- describe GoodData::Model::Anchor do
6
- SCHEMA = []
7
-
8
- describe '#initialize' do
9
- it 'Creates new instance' do
10
- instance = GoodData::Model::Anchor.new(nil, SchemaHelper::SCHEMA)
11
- instance.should_not == nil
12
- end
13
- end
14
-
15
- describe '#table' do
16
- it 'Returns Table ' do
17
- instance = GoodData::Model::Anchor.new(nil, SchemaHelper::SCHEMA)
18
- result = instance.table
19
- result.should_not == nil
20
- end
21
- end
22
-
23
- describe '#to_maql_create' do
24
- it 'Returns MAQL string for schema' do
25
- pending('Not working, investigate')
26
- instance = GoodData::Model::Anchor.new(nil, SchemaHelper::SCHEMA)
27
- result = instance.to_maql_create
28
- result.should_not == nil
29
- result.should be_an_instance_of(String)
30
- end
31
- end
32
- end
@@ -1,95 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'gooddata/client'
4
- require 'gooddata/models/model'
5
-
6
- describe GoodData::Model do
7
- COLUMNS = [
8
- {:type =>:anchor, :name =>'cp', 'title' => 'CP', 'folder' => 'test'},
9
- {:type =>:attribute, :name =>'a1', 'title' => 'A1', 'folder' => 'test'},
10
- {:type =>:attribute, :name =>'a2', 'title' => 'A2', 'folder' => 'test'},
11
- {:type =>:date, :name =>'event', 'title' => 'Event', 'folder' => 'test'},
12
- {:type =>:fact, :name =>'f1', 'title' => 'F1', 'folder' => 'test'},
13
- {:type =>:fact, :name =>'f2', 'title' => 'F2', 'folder' => 'test'},
14
- ] unless const_defined?(:COLUMNS)
15
-
16
- SCHEMA = GoodData::Model::Schema.new :name => 'test', :title => 'test', :columns => COLUMNS unless const_defined?(:SCHEMA)
17
-
18
- before(:all) do
19
- GoodData::connect
20
- end
21
-
22
- after(:all) do
23
- GoodData.disconnect
24
- end
25
-
26
- it 'generate identifiers starting with letters and without ugly characters' do
27
- pending "We need o figure out what is the right way to do it"
28
-
29
- expect = 'fact.test.blah'
30
- result = GoodData::Model::Fact.new({:name =>'blah'}, SchemaHelper::SCHEMA).identifier
31
- result.should == expect
32
-
33
- expect = 'attr.test.blah'
34
- result = GoodData::Model::Attribute.new({:name =>'1_2_3 blah'}, SchemaHelper::SCHEMA).identifier
35
- result.should == expect
36
-
37
- expect = 'dim.blaz'
38
- result = GoodData::Model::AttributeFolder.new(' b*ĺ*á#ž$').identifier
39
- result.should == expect
40
- end
41
-
42
- it "create a simple model in a sandbox project using project.model.add_dataset" do
43
- pending "Throws 400 - Bad request now"
44
-
45
- project = GoodData::Project.create :title => "gooddata-ruby test #{Time.new.to_i}"
46
- objects = project.add_dataset 'Mrkev', SchemaHelper::COLUMNS
47
-
48
- uris = objects['uris']
49
- uris[0].should == "#{project.md['obj']}/1"
50
- # fetch last object (temporary objects can be placed at the begining of the list)
51
- GoodData.get uris[uris.length - 1]
52
- project.delete
53
- end
54
-
55
- it "create a simple model in a sandbox project using Model.add_dataset" do
56
- pending "Throws 400 - Bad request now"
57
-
58
- project = GoodData::Project.create :title => "gooddata-ruby test #{Time.new.to_i}"
59
- GoodData.use project
60
- objects = GoodData::Model.add_dataset 'Mrkev', SchemaHelper::COLUMNS
61
-
62
- uris = objects['uris']
63
- uris[0].should == "#{project.md['obj']}/1"
64
-
65
- # fetch last object (temporary objects can be placed at the begining of the list)
66
- GoodData.get uris[uris.length - 1]
67
-
68
- # created model should define SLI interface on the 'Mrkev' data set
69
- # TODO move this into a standalone test covering gooddata/metadata.rb
70
- ds = GoodData::DataSet['dataset.mrkev']
71
- ds.should_not be_nil
72
-
73
- project.delete
74
- end
75
-
76
- it "create a simple model with no CP in a sandbox project using Model.add_dataset" do
77
- pending "Throws 400 - Bad request now"
78
-
79
- project = GoodData::Project.create :title => "gooddata-ruby test #{Time.new.to_i}"
80
- GoodData.use project
81
-
82
- # create a similar data set but without the connection point column
83
- cols_no_cp = SchemaHelper::COLUMNS.select { |c| c['type'] != 'CONNECTION_POINT' }
84
- objects = GoodData::Model.add_dataset 'No CP', cols_no_cp
85
- uris = objects['uris']
86
-
87
- # Repeat check of metadata objects expected to be created on the server side
88
- GoodData.get uris[uris.length - 1]
89
- ds = GoodData::DataSet['dataset.nocp']
90
- ds.should_not be_nil
91
-
92
- # clean-up
93
- project.delete
94
- end
95
- end
@@ -1,79 +0,0 @@
1
- # encoding: UTF-8
2
-
3
- require 'logger'
4
- require 'tempfile'
5
-
6
- require 'helper'
7
- require 'gooddata/model'
8
- require 'gooddata/command'
9
-
10
- GoodData.logger = Logger.new(STDOUT)
11
-
12
- class TestModel < Test::Unit::TestCase
13
- FILE = [
14
- %w(cp a1 a2 f1 f2),
15
- [1, 'a1.1', 'a2.1', '0', '5'],
16
- [2, 'a1.2', 'a2.1', nil, 10],
17
- [3, 'a1.2', 'a2.2', 1, nil],
18
- [4, 'a1.3', 'a2.2', 0, 0]
19
- ]
20
- COLUMNS = [
21
- {
22
- 'type' => 'CONNECTION_POINT',
23
- 'name' => 'cp',
24
- 'title' => 'CP',
25
- 'folder' => 'test'
26
- },
27
- {
28
- 'type' => 'ATTRIBUTE',
29
- 'name' => 'a1', 'title' => 'A1',
30
- 'folder' => 'test'
31
- },
32
- {
33
- 'type' => 'ATTRIBUTE',
34
- 'name' => 'a2',
35
- 'title' => 'A2',
36
- 'folder' => 'test'
37
- },
38
- {
39
- 'type' => 'FACT',
40
- 'name' => 'f1',
41
- 'title' => 'F1',
42
- 'folder' => 'test'
43
- },
44
- {
45
- 'type' => 'FACT',
46
- 'name' => 'f2',
47
- 'title' => 'F2',
48
- 'folder' => 'test'
49
- },
50
- ]
51
- SCHEMA = GoodData::Model::Schema.new 'title' => 'test', 'columns' => COLUMNS
52
-
53
- context 'GoodData model tools' do
54
- # Initialize a GoodData connection using the credential
55
- # stored in ~/.gooddata
56
- #
57
- # And create a temporary CSV file to test the upload
58
- setup do
59
- GoodData::Command::connect
60
- @file = Tempfile.open 'test_csv'
61
- FasterCSV.open @file.path, 'w' do |csv|
62
- FILE.each { |row| csv << row }
63
- end
64
- @project = GoodData::Project.create :title => "gooddata-ruby test #{Time.now.to_i}"
65
- end
66
-
67
- teardown do
68
- @file.unlink
69
- @project.delete
70
- end
71
-
72
- should 'upload CSV in a full mode' do
73
- @project.add_dataset SCHEMA
74
- assert_equal 1, @project.datasets.size
75
- assert_equal 'test', @project.datasets.first.title
76
- @project.upload @file.path, SCHEMA, 'FULL'
77
- end
78
- end
79
- end