gooddata 0.6.20 → 0.6.22
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 +29 -1
- data/DEPENDENCIES.md +816 -0
- data/LICENSE +1 -1
- data/LICENSE.rb +5 -0
- data/Rakefile +74 -22
- data/dependency_decisions.yml +102 -0
- data/gooddata.gemspec +39 -38
- data/lib/gooddata.rb +4 -0
- data/lib/gooddata/app/app.rb +4 -0
- data/lib/gooddata/bricks/base_downloader.rb +5 -1
- data/lib/gooddata/bricks/brick.rb +4 -0
- data/lib/gooddata/bricks/bricks.rb +5 -0
- data/lib/gooddata/bricks/middleware/aws_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/base_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/bench_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/decode_params_middleware.rb +6 -0
- data/lib/gooddata/bricks/middleware/fs_download_middleware.rb +6 -0
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +6 -0
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +6 -0
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +4 -0
- data/lib/gooddata/bricks/middleware/stdout_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/twitter_middleware.rb +5 -0
- data/lib/gooddata/bricks/middleware/undot_params_middleware.rb +4 -0
- data/lib/gooddata/bricks/pipeline.rb +4 -0
- data/lib/gooddata/bricks/utils.rb +4 -0
- data/lib/gooddata/cli/cli.rb +4 -0
- data/lib/gooddata/cli/commands/api_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/auth_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/console_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/domain_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/process_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/project_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/projects_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/run_ruby_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/scaffold_cmd.rb +4 -0
- data/lib/gooddata/cli/commands/user_cmd.rb +4 -0
- data/lib/gooddata/cli/hooks.rb +4 -0
- data/lib/gooddata/cli/shared.rb +4 -0
- data/lib/gooddata/cli/terminal.rb +4 -0
- data/lib/gooddata/client.rb +4 -0
- data/lib/gooddata/commands/api.rb +4 -0
- data/lib/gooddata/commands/auth.rb +4 -0
- data/lib/gooddata/commands/base.rb +4 -0
- data/lib/gooddata/commands/commands.rb +5 -0
- data/lib/gooddata/commands/datasets.rb +5 -1
- data/lib/gooddata/commands/datawarehouse.rb +4 -0
- data/lib/gooddata/commands/domain.rb +4 -0
- data/lib/gooddata/commands/process.rb +4 -0
- data/lib/gooddata/commands/project.rb +7 -9
- data/lib/gooddata/commands/projects.rb +4 -0
- data/lib/gooddata/commands/role.rb +4 -0
- data/lib/gooddata/commands/runners.rb +4 -0
- data/lib/gooddata/commands/scaffold.rb +4 -0
- data/lib/gooddata/commands/user.rb +4 -0
- data/lib/gooddata/connection.rb +83 -0
- data/lib/gooddata/core/core.rb +4 -0
- data/lib/gooddata/core/logging.rb +4 -0
- data/lib/gooddata/core/nil_logger.rb +4 -0
- data/lib/gooddata/core/project.rb +4 -0
- data/lib/gooddata/core/rest.rb +14 -16
- data/lib/gooddata/core/user.rb +4 -0
- data/lib/gooddata/data/data.rb +4 -0
- data/lib/gooddata/data/guesser.rb +4 -0
- data/lib/gooddata/exceptions/attr_element_not_found.rb +4 -0
- data/lib/gooddata/exceptions/command_failed.rb +4 -0
- data/lib/gooddata/exceptions/exceptions.rb +4 -0
- data/lib/gooddata/exceptions/execution_limit_exceeded.rb +4 -0
- data/lib/gooddata/exceptions/filter_maqlization.rb +16 -0
- data/lib/gooddata/exceptions/malformed_user.rb +15 -0
- data/lib/gooddata/exceptions/no_project_error.rb +4 -0
- data/lib/gooddata/exceptions/object_migration.rb +28 -0
- data/lib/gooddata/exceptions/project_not_found.rb +5 -0
- data/lib/gooddata/exceptions/uncomputable_report.rb +5 -0
- data/lib/gooddata/exceptions/user_in_different_domain.rb +4 -0
- data/lib/gooddata/exceptions/validation_error.rb +4 -0
- data/lib/gooddata/extensions/big_decimal.rb +4 -0
- data/lib/gooddata/extensions/enumerable.rb +4 -0
- data/lib/gooddata/extensions/extensions.rb +4 -0
- data/lib/gooddata/extensions/false.rb +4 -0
- data/lib/gooddata/extensions/hash.rb +4 -0
- data/lib/gooddata/extensions/nil.rb +4 -0
- data/lib/gooddata/extensions/numeric.rb +4 -0
- data/lib/gooddata/extensions/object.rb +4 -0
- data/lib/gooddata/extensions/symbol.rb +4 -0
- data/lib/gooddata/extensions/true.rb +4 -0
- data/lib/gooddata/extract.rb +4 -0
- data/lib/gooddata/goodzilla/goodzilla.rb +87 -77
- data/lib/gooddata/helpers/auth_helpers.rb +6 -2
- data/lib/gooddata/helpers/csv_helper.rb +4 -0
- data/lib/gooddata/helpers/data_helper.rb +4 -0
- data/lib/gooddata/helpers/global_helpers.rb +35 -6
- data/lib/gooddata/helpers/global_helpers_params.rb +34 -7
- data/lib/gooddata/helpers/helpers.rb +4 -0
- data/lib/gooddata/mixins/author.rb +4 -0
- data/lib/gooddata/mixins/content_getter.rb +4 -0
- data/lib/gooddata/mixins/content_property_reader.rb +4 -0
- data/lib/gooddata/mixins/content_property_writer.rb +4 -0
- data/lib/gooddata/mixins/contributor.rb +4 -0
- data/lib/gooddata/mixins/data_getter.rb +4 -0
- data/lib/gooddata/mixins/data_property_reader.rb +4 -0
- data/lib/gooddata/mixins/data_property_writer.rb +4 -0
- data/lib/gooddata/mixins/inspector.rb +4 -0
- data/lib/gooddata/mixins/is_attribute.rb +4 -0
- data/lib/gooddata/mixins/is_dimension.rb +4 -0
- data/lib/gooddata/mixins/is_fact.rb +4 -0
- data/lib/gooddata/mixins/is_label.rb +4 -0
- data/lib/gooddata/mixins/links.rb +4 -0
- data/lib/gooddata/mixins/md_finders.rb +4 -0
- data/lib/gooddata/mixins/md_id_to_uri.rb +4 -0
- data/lib/gooddata/mixins/md_json.rb +4 -0
- data/lib/gooddata/mixins/md_lock.rb +4 -0
- data/lib/gooddata/mixins/md_object_id.rb +5 -1
- data/lib/gooddata/mixins/md_object_indexer.rb +4 -0
- data/lib/gooddata/mixins/md_object_query.rb +4 -0
- data/lib/gooddata/mixins/md_relations.rb +4 -0
- data/lib/gooddata/mixins/meta_getter.rb +4 -0
- data/lib/gooddata/mixins/meta_property_reader.rb +4 -0
- data/lib/gooddata/mixins/meta_property_writer.rb +4 -0
- data/lib/gooddata/mixins/mixins.rb +4 -0
- data/lib/gooddata/mixins/not_attribute.rb +4 -0
- data/lib/gooddata/mixins/not_exportable.rb +4 -0
- data/lib/gooddata/mixins/not_fact.rb +4 -0
- data/lib/gooddata/mixins/not_label.rb +4 -0
- data/lib/gooddata/mixins/not_metric.rb +6 -0
- data/lib/gooddata/mixins/obj_id.rb +4 -0
- data/lib/gooddata/mixins/rest_getters.rb +4 -0
- data/lib/gooddata/mixins/rest_resource.rb +4 -0
- data/lib/gooddata/mixins/root_key_getter.rb +4 -0
- data/lib/gooddata/mixins/root_key_setter.rb +4 -0
- data/lib/gooddata/mixins/timestamps.rb +4 -0
- data/lib/gooddata/models/blueprint/anchor_field.rb +4 -0
- data/lib/gooddata/models/blueprint/attribute_field.rb +4 -0
- data/lib/gooddata/models/blueprint/blueprint.rb +4 -0
- data/lib/gooddata/models/blueprint/blueprint_field.rb +4 -0
- data/lib/gooddata/models/blueprint/dashboard_builder.rb +4 -0
- data/lib/gooddata/models/blueprint/dataset_blueprint.rb +6 -0
- data/lib/gooddata/models/blueprint/date_dimension.rb +4 -0
- data/lib/gooddata/models/blueprint/fact_field.rb +4 -0
- data/lib/gooddata/models/blueprint/label_field.rb +4 -0
- data/lib/gooddata/models/blueprint/project_blueprint.rb +6 -0
- data/lib/gooddata/models/blueprint/project_builder.rb +4 -0
- data/lib/gooddata/models/blueprint/reference_field.rb +4 -0
- data/lib/gooddata/models/blueprint/schema_blueprint.rb +4 -0
- data/lib/gooddata/models/blueprint/schema_builder.rb +4 -0
- data/lib/gooddata/models/blueprint/to_manifest.rb +17 -1
- data/lib/gooddata/models/blueprint/to_wire.rb +4 -0
- data/lib/gooddata/models/datawarehouse.rb +5 -0
- data/lib/gooddata/models/domain.rb +25 -7
- data/lib/gooddata/models/execution.rb +4 -0
- data/lib/gooddata/models/execution_detail.rb +4 -0
- data/lib/gooddata/models/from_wire.rb +4 -0
- data/lib/gooddata/models/invitation.rb +4 -0
- data/lib/gooddata/models/links.rb +4 -0
- data/lib/gooddata/models/membership.rb +4 -0
- data/lib/gooddata/models/metadata.rb +37 -10
- data/lib/gooddata/models/metadata/attribute.rb +6 -0
- data/lib/gooddata/models/metadata/dashboard.rb +54 -16
- data/lib/gooddata/models/metadata/dashboard/dashboard_item.rb +60 -0
- data/lib/gooddata/models/metadata/dashboard/filter_item.rb +15 -0
- data/lib/gooddata/models/metadata/dashboard/report_item.rb +51 -0
- data/lib/gooddata/models/metadata/dashboard_tab.rb +88 -0
- data/lib/gooddata/models/metadata/dataset.rb +4 -0
- data/lib/gooddata/models/metadata/dimension.rb +4 -0
- data/lib/gooddata/models/metadata/fact.rb +6 -0
- data/lib/gooddata/models/metadata/label.rb +15 -0
- data/lib/gooddata/models/metadata/metadata.rb +4 -0
- data/lib/gooddata/models/metadata/metric.rb +5 -4
- data/lib/gooddata/models/metadata/report.rb +62 -16
- data/lib/gooddata/models/metadata/report_definition.rb +44 -47
- data/lib/gooddata/models/metadata/variable.rb +4 -0
- data/lib/gooddata/models/model.rb +85 -36
- data/lib/gooddata/models/models.rb +4 -0
- data/lib/gooddata/models/module_constants.rb +4 -0
- data/lib/gooddata/models/process.rb +4 -0
- data/lib/gooddata/models/profile.rb +13 -0
- data/lib/gooddata/models/project.rb +173 -92
- data/lib/gooddata/models/project_creator.rb +18 -10
- data/lib/gooddata/models/project_metadata.rb +4 -0
- data/lib/gooddata/models/project_role.rb +4 -0
- data/lib/gooddata/models/report_data_result.rb +217 -125
- data/lib/gooddata/models/schedule.rb +140 -65
- data/lib/gooddata/models/tab_builder.rb +4 -0
- data/lib/gooddata/models/user_filters/mandatory_user_filter.rb +4 -0
- data/lib/gooddata/models/user_filters/user_filter.rb +4 -0
- data/lib/gooddata/models/user_filters/user_filter_builder.rb +98 -56
- data/lib/gooddata/models/user_filters/user_filters.rb +4 -0
- data/lib/gooddata/models/user_filters/variable_user_filter.rb +4 -0
- data/lib/gooddata/rest/client.rb +41 -38
- data/lib/gooddata/rest/connection.rb +91 -20
- data/lib/gooddata/rest/connections/rest_client_connection.rb +5 -1
- data/lib/gooddata/rest/object.rb +9 -1
- data/lib/gooddata/rest/object_factory.rb +5 -1
- data/lib/gooddata/rest/resource.rb +5 -1
- data/lib/gooddata/rest/rest.rb +4 -0
- data/lib/gooddata/version.rb +5 -1
- data/spec/bricks/bricks_spec.rb +4 -0
- data/spec/data/blueprints/test_project_model_spec.json +2 -2
- data/spec/data/gooddata_version_process/gooddata_version.rb +6 -0
- data/spec/data/hello_world_process/hello_world.rb +6 -0
- data/spec/data/manifests/test_project.json +5 -5
- data/spec/data/reports/left_attr_report.json +108 -0
- data/spec/data/reports/metric_only_one_line.json +83 -0
- data/spec/data/reports/report_1.json +197 -0
- data/spec/data/reports/top_attr_report.json +108 -0
- data/spec/data/ruby_params_process/ruby_params.rb +6 -0
- data/spec/data/ruby_process/process.rb +6 -0
- data/spec/environment/default.rb +5 -0
- data/spec/environment/develop.rb +10 -5
- data/spec/environment/environment.rb +4 -0
- data/spec/environment/hotfix.rb +5 -1
- data/spec/environment/production.rb +4 -0
- data/spec/environment/release.rb +4 -0
- data/spec/environment/staging.rb +30 -0
- data/spec/environment/staging_3.rb +37 -0
- data/spec/helpers/blueprint_helper.rb +4 -0
- data/spec/helpers/cli_helper.rb +4 -0
- data/spec/helpers/connection_helper.rb +24 -17
- data/spec/helpers/crypto_helper.rb +6 -0
- data/spec/helpers/csv_helper.rb +4 -0
- data/spec/helpers/process_helper.rb +5 -1
- data/spec/helpers/project_helper.rb +34 -29
- data/spec/helpers/schedule_helper.rb +4 -0
- data/spec/helpers/spec_helper.rb +4 -0
- data/spec/integration/blueprint_updates_spec.rb +28 -20
- data/spec/integration/command_datawarehouse_spec.rb +6 -0
- data/spec/integration/command_projects_spec.rb +6 -4
- data/spec/integration/create_from_template_spec.rb +6 -0
- data/spec/integration/create_project_spec.rb +6 -0
- data/spec/integration/deprecated_load_spec.rb +58 -0
- data/spec/integration/full_process_schedule_spec.rb +9 -0
- data/spec/integration/full_project_spec.rb +63 -9
- data/spec/integration/over_to_user_filters_spec.rb +7 -2
- data/spec/integration/partial_md_export_import_spec.rb +6 -0
- data/spec/integration/project_spec.rb +12 -6
- data/spec/integration/rest_spec.rb +6 -2
- data/spec/integration/schedule_spec.rb +627 -0
- data/spec/integration/user_filters_spec.rb +122 -21
- data/spec/integration/variables_spec.rb +8 -15
- data/spec/logging_in_logging_out_spec.rb +58 -0
- data/spec/spec_helper.rb +10 -5
- data/spec/unit/bricks/bricks_spec.rb +4 -0
- data/spec/unit/bricks/middleware/aws_middelware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/bench_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/logger_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +4 -0
- data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +4 -0
- data/spec/unit/cli/cli_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_api_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_auth_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_domain_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_process_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_project_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_role_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_run_ruby_spec.rb +4 -0
- data/spec/unit/cli/commands/cmd_scaffold_spec.rb +6 -0
- data/spec/unit/cli/commands/cmd_user_spec.rb +6 -0
- data/spec/unit/commands/command_api_spec.rb +6 -0
- data/spec/unit/commands/command_auth_spec.rb +6 -0
- data/spec/unit/commands/command_dataset_spec.rb +10 -4
- data/spec/unit/commands/command_process_spec.rb +6 -0
- data/spec/unit/commands/command_projects_spec.rb +6 -0
- data/spec/unit/commands/command_scaffold_spec.rb +6 -0
- data/spec/unit/commands/command_user_spec.rb +6 -0
- data/spec/unit/core/connection_spec.rb +6 -0
- data/spec/unit/core/logging_spec.rb +4 -0
- data/spec/unit/core/nil_logger_spec.rb +4 -0
- data/spec/unit/core/project_spec.rb +4 -0
- data/spec/unit/data/guesser_spec.rb +6 -2
- data/spec/unit/extensions/hash_spec.rb +4 -0
- data/spec/unit/godzilla/goodzilla_spec.rb +4 -0
- data/spec/unit/helpers/csv_helper_spec.rb +4 -0
- data/spec/unit/helpers/data_helper_spec.rb +4 -0
- data/spec/unit/helpers/global_helpers_spec.rb +54 -0
- data/spec/unit/helpers_spec.rb +6 -1
- data/spec/unit/models/blueprint/attributes_spec.rb +5 -0
- data/spec/unit/models/blueprint/dataset_spec.rb +5 -0
- data/spec/unit/models/blueprint/labels_spec.rb +5 -0
- data/spec/unit/models/blueprint/project_blueprint_spec.rb +5 -0
- data/spec/unit/models/blueprint/reference_spec.rb +5 -0
- data/spec/unit/models/blueprint/schema_builder_spec.rb +4 -0
- data/spec/unit/models/blueprint/to_wire_spec.rb +5 -0
- data/spec/unit/models/domain_spec.rb +9 -7
- data/spec/unit/models/execution_spec.rb +6 -0
- data/spec/unit/models/from_wire_spec.rb +4 -0
- data/spec/unit/models/invitation_spec.rb +4 -0
- data/spec/unit/models/membership_spec.rb +4 -0
- data/spec/unit/models/metadata_spec.rb +46 -0
- data/spec/unit/models/metric_spec.rb +4 -0
- data/spec/unit/models/model_spec.rb +4 -0
- data/spec/unit/models/params_spec.rb +4 -0
- data/spec/unit/models/profile_spec.rb +4 -0
- data/spec/unit/models/project_creator_spec.rb +127 -0
- data/spec/unit/models/project_role_spec.rb +4 -0
- data/spec/unit/models/project_spec.rb +4 -0
- data/spec/unit/models/report_result_data_spec.rb +193 -0
- data/spec/unit/models/schedule_spec.rb +241 -386
- data/spec/unit/models/to_manifest_spec.rb +21 -0
- data/spec/unit/models/{unit_project.rb → unit_project_spec.rb} +21 -18
- data/spec/unit/models/user_filters_spec.rb +7 -1
- data/spec/unit/models/variable_spec.rb +6 -0
- data/spec/unit/rest/polling_spec.rb +8 -5
- data/spec/unit/rest/resource_spec.rb +4 -0
- metadata +190 -129
- data/.autotest +0 -2
- data/.travis.yml +0 -22
- data/examples.rb +0 -69
- data/lib/gooddata/models/data_result.rb +0 -38
- data/lib/gooddata/models/empty_result.rb +0 -57
- data/spec/unit/models/project_creator.rb +0 -73
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
2
6
|
|
|
3
7
|
require_relative '../metadata'
|
|
4
8
|
require_relative 'metadata'
|
|
@@ -65,6 +69,33 @@ module GoodData
|
|
|
65
69
|
self
|
|
66
70
|
end
|
|
67
71
|
|
|
72
|
+
# Add a report definition to a report. This will show on a UI as a new version.
|
|
73
|
+
#
|
|
74
|
+
# @param report_definition [GoodData::ReportDefinition | String] Report definition to add. Either it can be a URI of a report definition or an actual report definition object.
|
|
75
|
+
# @return [GoodData::Report] Return self
|
|
76
|
+
def add_definition!(report_definition)
|
|
77
|
+
res = add_definition(report_definition)
|
|
78
|
+
res.save
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Returns the newest (current version) report definition as an object
|
|
82
|
+
#
|
|
83
|
+
# @return [GoodData::ReportDefinition] Returns the newest report defintion
|
|
84
|
+
def definition
|
|
85
|
+
project.report_definitions(latest_report_definition_uri)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
alias_method :latest_report_definition, :definition
|
|
89
|
+
|
|
90
|
+
# Returns the newest (current version) report definition uri
|
|
91
|
+
#
|
|
92
|
+
# @return [String] Returns uri of the newest report defintion
|
|
93
|
+
def definition_uri
|
|
94
|
+
definition_uris.last
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
alias_method :latest_report_definition_uri, :definition_uri
|
|
98
|
+
|
|
68
99
|
# Gets a report definitions (versions) of this report as objects.
|
|
69
100
|
#
|
|
70
101
|
# @return [Array<GoodData::ReportDefinition>] Returns list of report definitions. Oldest comes first
|
|
@@ -103,9 +134,9 @@ module GoodData
|
|
|
103
134
|
end
|
|
104
135
|
|
|
105
136
|
if result.empty?
|
|
106
|
-
client.create(
|
|
137
|
+
client.create(ReportDataResult, data: [], top: 0, left: 0, project: project)
|
|
107
138
|
else
|
|
108
|
-
|
|
139
|
+
ReportDataResult.from_xtab(result, client: client, project: project)
|
|
109
140
|
end
|
|
110
141
|
end
|
|
111
142
|
|
|
@@ -126,20 +157,6 @@ module GoodData
|
|
|
126
157
|
client.poll_on_code(result1['uri'], options.merge(process: false))
|
|
127
158
|
end
|
|
128
159
|
|
|
129
|
-
# Returns the newest (current version) report definition uri
|
|
130
|
-
#
|
|
131
|
-
# @return [String] Returns uri of the newest report defintion
|
|
132
|
-
def latest_report_definition_uri
|
|
133
|
-
definition_uris.last
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
# Returns the newest (current version) report definition as an object
|
|
137
|
-
#
|
|
138
|
-
# @return [GoodData::ReportDefinition] Returns the newest report defintion
|
|
139
|
-
def latest_report_definition
|
|
140
|
-
project.report_definitions(latest_report_definition_uri)
|
|
141
|
-
end
|
|
142
|
-
|
|
143
160
|
# Returns the newest (current version) report definition uri
|
|
144
161
|
#
|
|
145
162
|
# @return [String] Returns uri of the newest report defintion
|
|
@@ -191,5 +208,34 @@ module GoodData
|
|
|
191
208
|
new_defs.pmap(&:save)
|
|
192
209
|
self
|
|
193
210
|
end
|
|
211
|
+
|
|
212
|
+
## Update report definition and reflect the change in report
|
|
213
|
+
#
|
|
214
|
+
# @param [Hash] opts Options
|
|
215
|
+
# @option opts [Boolean] :new_definition (true) If true then new definition will be created
|
|
216
|
+
# @return [GoodData::ReportDefinition] Updated and saved report definition
|
|
217
|
+
def update_definition(opts = { :new_definition => true }, &block)
|
|
218
|
+
# TODO: Cache the latest report definition somehow
|
|
219
|
+
repdef = definition.dup
|
|
220
|
+
|
|
221
|
+
block.call(repdef, self) if block_given?
|
|
222
|
+
|
|
223
|
+
if opts[:new_definition]
|
|
224
|
+
new_def = GoodData::ReportDefinition.create(:client => client, :project => project)
|
|
225
|
+
|
|
226
|
+
rd = repdef.json['reportDefinition']
|
|
227
|
+
rd.delete('links')
|
|
228
|
+
%w(author uri created identifier updated contributor).each { |k| rd['meta'].delete(k) }
|
|
229
|
+
new_def.json['reportDefinition'] = rd
|
|
230
|
+
new_def.save
|
|
231
|
+
|
|
232
|
+
add_definition!(new_def)
|
|
233
|
+
return new_def
|
|
234
|
+
else
|
|
235
|
+
repdef.save
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
repdef
|
|
239
|
+
end
|
|
194
240
|
end
|
|
195
241
|
end
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
2
6
|
|
|
3
7
|
require_relative '../metadata'
|
|
4
8
|
require_relative 'metadata'
|
|
@@ -27,6 +31,8 @@ module GoodData
|
|
|
27
31
|
end
|
|
28
32
|
end
|
|
29
33
|
|
|
34
|
+
alias_method :create_measures_part, :create_metrics_part
|
|
35
|
+
|
|
30
36
|
def create_metric_part(metric)
|
|
31
37
|
{
|
|
32
38
|
'alias' => metric.title,
|
|
@@ -34,6 +40,8 @@ module GoodData
|
|
|
34
40
|
}
|
|
35
41
|
end
|
|
36
42
|
|
|
43
|
+
alias_method :create_measure_part, :create_metric_part
|
|
44
|
+
|
|
37
45
|
def create_attribute_part(attrib)
|
|
38
46
|
{
|
|
39
47
|
'attribute' => {
|
|
@@ -68,54 +76,41 @@ module GoodData
|
|
|
68
76
|
|
|
69
77
|
def find(stuff, opts = { :client => GoodData.connection, :project => GoodData.project })
|
|
70
78
|
client = opts[:client]
|
|
79
|
+
project = opts[:project]
|
|
71
80
|
fail ArgumentError, 'No :client specified' if client.nil?
|
|
81
|
+
fail ArgumentError, 'No :project specified' if project.nil?
|
|
72
82
|
|
|
73
83
|
stuff.map do |item|
|
|
74
|
-
if item.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
when 'attribute'
|
|
103
|
-
GoodData::Attribute.get_by_id(item[:id]).display_forms.first
|
|
104
|
-
when 'label'
|
|
105
|
-
GoodData::Label.get_by_id(item[:id])
|
|
106
|
-
end
|
|
107
|
-
elsif item.is_a?(Hash) && (item.keys.include?(:identifier))
|
|
108
|
-
case item[:type].to_s
|
|
109
|
-
when 'metric'
|
|
110
|
-
GoodData::Metric.get_by_id(item[:identifier])
|
|
111
|
-
when 'attribute'
|
|
112
|
-
result = GoodData::Attribute.get_by_id(item[:identifier])
|
|
113
|
-
result.display_forms.first
|
|
114
|
-
when 'label'
|
|
115
|
-
GoodData::Label.get_by_id(item[:identifier])
|
|
116
|
-
end
|
|
84
|
+
obj = if item.is_a?(String)
|
|
85
|
+
begin
|
|
86
|
+
project.objects(item)
|
|
87
|
+
rescue RestClient::ResourceNotFound
|
|
88
|
+
raise "Object given by id \"#{item}\" could not be found"
|
|
89
|
+
end
|
|
90
|
+
elsif item.is_a?(Hash) && item.keys.include?(:title)
|
|
91
|
+
case item[:type].to_s
|
|
92
|
+
when 'metric'
|
|
93
|
+
GoodData::Metric.find_first_by_title(item[:title], opts)
|
|
94
|
+
when 'attribute'
|
|
95
|
+
GoodData::Attribute.find_first_by_title(item[:title], opts)
|
|
96
|
+
end
|
|
97
|
+
elsif item.is_a?(Hash) && (item.keys.include?(:id) || item.keys.include?(:identifier))
|
|
98
|
+
id = item[:id] || item[:identifier]
|
|
99
|
+
case item[:type].to_s
|
|
100
|
+
when 'metric'
|
|
101
|
+
project.metrics(id)
|
|
102
|
+
when 'attribute'
|
|
103
|
+
project.attributes(id)
|
|
104
|
+
when 'label'
|
|
105
|
+
projects.labels(id)
|
|
106
|
+
end
|
|
107
|
+
else
|
|
108
|
+
item
|
|
109
|
+
end
|
|
110
|
+
if obj.respond_to?(:attribute?) && obj.attribute?
|
|
111
|
+
obj.display_forms.first
|
|
117
112
|
else
|
|
118
|
-
|
|
113
|
+
obj
|
|
119
114
|
end
|
|
120
115
|
end
|
|
121
116
|
end
|
|
@@ -223,6 +218,8 @@ module GoodData
|
|
|
223
218
|
content['grid']['metrics']
|
|
224
219
|
end
|
|
225
220
|
|
|
221
|
+
alias_method :measure_parts, :metric_parts
|
|
222
|
+
|
|
226
223
|
def metrics
|
|
227
224
|
metric_parts.map { |i| project.metrics(i['uri']) }
|
|
228
225
|
end
|
|
@@ -307,7 +304,7 @@ module GoodData
|
|
|
307
304
|
content['grid']['columnWidths'] = widths.map do |item|
|
|
308
305
|
if item.is_a?(Hash)
|
|
309
306
|
GoodData::Helpers.deep_dup(item).tap do |i|
|
|
310
|
-
if i['locator'][0].key?('attributeHeaderLocator')
|
|
307
|
+
if i['locator'].length > 0 && ['locator'][0].key?('attributeHeaderLocator')
|
|
311
308
|
i['locator'][0]['attributeHeaderLocator']['uri'].gsub!("[#{uri_what}]", "[#{uri_for_what}]")
|
|
312
309
|
end
|
|
313
310
|
end
|
|
@@ -374,9 +371,9 @@ module GoodData
|
|
|
374
371
|
end
|
|
375
372
|
|
|
376
373
|
if result.empty?
|
|
377
|
-
client.create(
|
|
374
|
+
client.create(ReportDataResult, data: [], top: 0, left: 0, project: project)
|
|
378
375
|
else
|
|
379
|
-
|
|
376
|
+
ReportDataResult.from_xtab(result, client: client, project: project)
|
|
380
377
|
end
|
|
381
378
|
end
|
|
382
379
|
end
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
# encoding: UTF-8
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2010-2015 GoodData Corporation. All rights reserved.
|
|
4
|
+
# This source code is licensed under the BSD-style license found in the
|
|
5
|
+
# LICENSE file in the root directory of this source tree.
|
|
2
6
|
|
|
3
7
|
require_relative '../core/rest'
|
|
4
8
|
|
|
@@ -131,6 +135,22 @@ module GoodData
|
|
|
131
135
|
|
|
132
136
|
# Load given file into a data set described by the given schema
|
|
133
137
|
def upload_data(path, project_blueprint, dataset, options = { :client => GoodData.connection, :project => GoodData.project })
|
|
138
|
+
data = [
|
|
139
|
+
{
|
|
140
|
+
data: path,
|
|
141
|
+
dataset: dataset,
|
|
142
|
+
options: options
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
GoodData::Model.upload_multiple_data(data, project_blueprint, options)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Uploads multiple data sets using batch upload interface
|
|
149
|
+
# @param data [String|Array] Input data
|
|
150
|
+
# @param project_blueprint [ProjectBlueprint] Project blueprint
|
|
151
|
+
# @param options [Hash] Additional options
|
|
152
|
+
# @return [Hash] Batch upload result
|
|
153
|
+
def upload_multiple_data(data, project_blueprint, options = { :client => GoodData.connection, :project => GoodData.project })
|
|
134
154
|
client = options[:client]
|
|
135
155
|
fail ArgumentError, 'No :client specified' if client.nil?
|
|
136
156
|
|
|
@@ -139,25 +159,18 @@ module GoodData
|
|
|
139
159
|
|
|
140
160
|
project = GoodData::Project[p, options]
|
|
141
161
|
fail ArgumentError, 'Wrong :project specified' if project.nil?
|
|
142
|
-
|
|
143
|
-
# Tempfile.open('remote_file') do |temp|
|
|
144
|
-
# temp << open(path).read
|
|
145
|
-
# temp.flush
|
|
146
|
-
# # GoodData::Model.upload_data(path, to_manifest(mode))
|
|
147
|
-
# end
|
|
148
|
-
#
|
|
149
|
-
# else
|
|
150
|
-
# # GoodData::Model.upload_data(path, to_manifest(mode))
|
|
151
|
-
# # upload_data(path, mode)
|
|
152
|
-
# end
|
|
153
|
-
|
|
154
|
-
mode = options[:mode] || 'FULL'
|
|
155
|
-
manifest = GoodData::Model::ToManifest.dataset_to_manifest(project_blueprint, dataset, mode)
|
|
162
|
+
|
|
156
163
|
project = options[:project] || GoodData.project
|
|
157
164
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
165
|
+
manifest = {
|
|
166
|
+
|
|
167
|
+
'dataSetSLIManifestList' => data.map do |d|
|
|
168
|
+
mode = d[:options] && d[:options][:mode] ? d[:options][:mode] : options[:mode] || 'FULL'
|
|
169
|
+
GoodData::Model::ToManifest.dataset_to_manifest(project_blueprint, d[:dataset], mode)
|
|
170
|
+
end
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
csv_headers = []
|
|
161
174
|
|
|
162
175
|
# create a temporary zip file
|
|
163
176
|
dir = Dir.mktmpdir
|
|
@@ -165,16 +178,28 @@ module GoodData
|
|
|
165
178
|
Zip::File.open("#{dir}/upload.zip", Zip::File::CREATE) do |zip|
|
|
166
179
|
# TODO: make sure schema columns match CSV column names
|
|
167
180
|
zip.get_output_stream('upload_info.json') { |f| f.puts JSON.pretty_generate(manifest) }
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
|
|
182
|
+
data.zip(manifest['dataSetSLIManifestList']).each do |item|
|
|
183
|
+
path = item[0][:data]
|
|
184
|
+
path = item[0][:data].path if item[0][:data].respond_to? :path
|
|
185
|
+
inline_data = path.is_a?(String) ? false : true
|
|
186
|
+
csv_header = nil
|
|
187
|
+
|
|
188
|
+
filename = item[1]['dataSetSLIManifest']['file']
|
|
189
|
+
|
|
190
|
+
if inline_data
|
|
191
|
+
csv_header = path.first
|
|
192
|
+
zip.get_output_stream(filename) do |f|
|
|
193
|
+
path.each do |row|
|
|
194
|
+
f.puts row.to_csv
|
|
195
|
+
end
|
|
173
196
|
end
|
|
197
|
+
else
|
|
198
|
+
csv_header = File.open(path, &:gets).split(',')
|
|
199
|
+
zip.add(filename, path)
|
|
174
200
|
end
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
zip.add('data.csv', path)
|
|
201
|
+
|
|
202
|
+
csv_headers << csv_header
|
|
178
203
|
end
|
|
179
204
|
end
|
|
180
205
|
|
|
@@ -183,40 +208,64 @@ module GoodData
|
|
|
183
208
|
ensure
|
|
184
209
|
FileUtils.rm_rf dir
|
|
185
210
|
end
|
|
211
|
+
csv_headers.flatten!
|
|
186
212
|
|
|
187
213
|
# kick the load
|
|
188
214
|
pull = { 'pullIntegration' => File.basename(dir) }
|
|
189
215
|
link = project.md.links('etl')['pull2']
|
|
190
|
-
|
|
216
|
+
|
|
217
|
+
# TODO: List uploaded datasets
|
|
218
|
+
task = client.post(link, pull, :info_message => 'Starting the data load from user storage to dataset.')
|
|
191
219
|
|
|
192
220
|
res = client.poll_on_response(task['pull2Task']['links']['poll'], :info_message => 'Getting status of the dataload task.') do |body|
|
|
193
221
|
body['wTaskStatus']['status'] == 'RUNNING' || body['wTaskStatus']['status'] == 'PREPARED'
|
|
194
222
|
end
|
|
195
223
|
|
|
196
|
-
if res['wTaskStatus']['status'] == 'ERROR'
|
|
224
|
+
if res['wTaskStatus']['status'] == 'ERROR'
|
|
197
225
|
s = StringIO.new
|
|
198
|
-
|
|
226
|
+
|
|
227
|
+
messages = res['wTaskStatus']['messages'] || []
|
|
228
|
+
messages.each do |msg|
|
|
229
|
+
GoodData.logger.error(JSON.pretty_generate(msg))
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
begin
|
|
233
|
+
client.download_from_user_webdav(File.basename(dir) + '/upload_status.json', s, :client => client, :project => project)
|
|
234
|
+
rescue => e
|
|
235
|
+
raise "Unable to download upload_status.json from remote server, reason: #{e.message}"
|
|
236
|
+
end
|
|
237
|
+
|
|
199
238
|
js = MultiJson.load(s.string)
|
|
200
|
-
|
|
239
|
+
manifests = manifest['dataSetSLIManifestList'].map do |m|
|
|
240
|
+
m['dataSetSLIManifest']
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
parts = manifests.map do |m|
|
|
244
|
+
m['parts']
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
manifest_cols = parts.flatten.map { |c| c['columnName'] }
|
|
201
248
|
|
|
202
249
|
# extract some human readable error message from the webdav file
|
|
203
|
-
manifest_extra = manifest_cols -
|
|
204
|
-
csv_extra =
|
|
250
|
+
manifest_extra = manifest_cols - csv_headers
|
|
251
|
+
csv_extra = csv_headers - manifest_cols
|
|
205
252
|
|
|
206
253
|
error_message = begin
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
254
|
+
js['error']['message'] % js['error']['parameters']
|
|
255
|
+
rescue NoMethodError, ArgumentError
|
|
256
|
+
''
|
|
257
|
+
end
|
|
211
258
|
m = "Load failed with error '#{error_message}'.\n"
|
|
212
259
|
m += "Columns that should be there (manifest) but aren't in uploaded csv: #{manifest_extra}\n" unless manifest_extra.empty?
|
|
213
260
|
m += "Columns that are in csv but shouldn't be there (manifest): #{csv_extra}\n" unless csv_extra.empty?
|
|
214
|
-
m += "Columns in the uploaded csv: #{
|
|
261
|
+
m += "Columns in the uploaded csv: #{csv_headers}\n"
|
|
215
262
|
m += "Columns in the manifest: #{manifest_cols}\n"
|
|
216
263
|
m += "Original message:\n#{JSON.pretty_generate(js)}\n"
|
|
217
264
|
m += "Manifest used for uploading:\n#{JSON.pretty_generate(manifest)}"
|
|
218
265
|
fail m
|
|
219
266
|
end
|
|
267
|
+
|
|
268
|
+
res
|
|
220
269
|
end
|
|
221
270
|
|
|
222
271
|
def merge_dataset_columns(a_schema_blueprint, b_schema_blueprint)
|