gooddata-edge 0.6.27.edge
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.gitignore +36 -0
- data/.rspec +3 -0
- data/.rubocop.yml +89 -0
- data/.yardopts +22 -0
- data/CHANGELOG.md +196 -0
- data/CLI.md +439 -0
- data/DEPENDENCIES.md +817 -0
- data/Gemfile +4 -0
- data/Guardfile +5 -0
- data/LICENSE +22 -0
- data/LICENSE.rb +5 -0
- data/README.md +75 -0
- data/Rakefile +179 -0
- data/TODO.md +32 -0
- data/authors.sh +4 -0
- data/bin/gooddata +7 -0
- data/dependency_decisions.yml +104 -0
- data/gooddata +9 -0
- data/gooddata.gemspec +63 -0
- data/lib/gooddata.rb +31 -0
- data/lib/gooddata/app/app.rb +16 -0
- data/lib/gooddata/bricks/base_downloader.rb +86 -0
- data/lib/gooddata/bricks/brick.rb +38 -0
- data/lib/gooddata/bricks/bricks.rb +15 -0
- data/lib/gooddata/bricks/middleware/aws_middleware.rb +29 -0
- data/lib/gooddata/bricks/middleware/base_middleware.rb +56 -0
- data/lib/gooddata/bricks/middleware/bench_middleware.rb +24 -0
- data/lib/gooddata/bricks/middleware/bulk_salesforce_middleware.rb +37 -0
- data/lib/gooddata/bricks/middleware/decode_params_middleware.rb +20 -0
- data/lib/gooddata/bricks/middleware/fs_download_middleware.rb +48 -0
- data/lib/gooddata/bricks/middleware/fs_upload_middleware.rb +36 -0
- data/lib/gooddata/bricks/middleware/gooddata_middleware.rb +39 -0
- data/lib/gooddata/bricks/middleware/logger_middleware.rb +29 -0
- data/lib/gooddata/bricks/middleware/middleware.rb +12 -0
- data/lib/gooddata/bricks/middleware/restforce_middleware.rb +61 -0
- data/lib/gooddata/bricks/middleware/stdout_middleware.rb +23 -0
- data/lib/gooddata/bricks/middleware/twitter_middleware.rb +29 -0
- data/lib/gooddata/bricks/middleware/undot_params_middleware.rb +37 -0
- data/lib/gooddata/bricks/pipeline.rb +32 -0
- data/lib/gooddata/bricks/utils.rb +18 -0
- data/lib/gooddata/cli/cli.rb +27 -0
- data/lib/gooddata/cli/commands/auth_cmd.rb +29 -0
- data/lib/gooddata/cli/commands/domain_cmd.rb +28 -0
- data/lib/gooddata/cli/commands/project_cmd.rb +45 -0
- data/lib/gooddata/cli/hooks.rb +57 -0
- data/lib/gooddata/cli/shared.rb +61 -0
- data/lib/gooddata/cli/terminal.rb +20 -0
- data/lib/gooddata/client.rb +67 -0
- data/lib/gooddata/commands/api.rb +64 -0
- data/lib/gooddata/commands/auth.rb +107 -0
- data/lib/gooddata/commands/base.rb +12 -0
- data/lib/gooddata/commands/commands.rb +12 -0
- data/lib/gooddata/commands/datasets.rb +148 -0
- data/lib/gooddata/commands/datawarehouse.rb +20 -0
- data/lib/gooddata/commands/domain.rb +40 -0
- data/lib/gooddata/commands/process.rb +67 -0
- data/lib/gooddata/commands/project.rb +175 -0
- data/lib/gooddata/commands/projects.rb +20 -0
- data/lib/gooddata/commands/role.rb +36 -0
- data/lib/gooddata/commands/runners.rb +47 -0
- data/lib/gooddata/commands/scaffold.rb +69 -0
- data/lib/gooddata/commands/user.rb +39 -0
- data/lib/gooddata/connection.rb +127 -0
- data/lib/gooddata/core/core.rb +12 -0
- data/lib/gooddata/core/logging.rb +105 -0
- data/lib/gooddata/core/nil_logger.rb +23 -0
- data/lib/gooddata/core/project.rb +74 -0
- data/lib/gooddata/core/rest.rb +149 -0
- data/lib/gooddata/core/user.rb +20 -0
- data/lib/gooddata/data/data.rb +12 -0
- data/lib/gooddata/data/guesser.rb +122 -0
- data/lib/gooddata/exceptions/attr_element_not_found.rb +16 -0
- data/lib/gooddata/exceptions/command_failed.rb +11 -0
- data/lib/gooddata/exceptions/exceptions.rb +12 -0
- data/lib/gooddata/exceptions/execution_limit_exceeded.rb +13 -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 +15 -0
- data/lib/gooddata/exceptions/object_migration.rb +32 -0
- data/lib/gooddata/exceptions/project_not_found.rb +13 -0
- data/lib/gooddata/exceptions/segment_not_empty.rb +18 -0
- data/lib/gooddata/exceptions/uncomputable_report.rb +13 -0
- data/lib/gooddata/exceptions/user_in_different_domain.rb +15 -0
- data/lib/gooddata/exceptions/validation_error.rb +16 -0
- data/lib/gooddata/extensions/big_decimal.rb +17 -0
- data/lib/gooddata/extensions/enumerable.rb +39 -0
- data/lib/gooddata/extensions/extensions.rb +10 -0
- data/lib/gooddata/extensions/false.rb +15 -0
- data/lib/gooddata/extensions/hash.rb +38 -0
- data/lib/gooddata/extensions/nil.rb +15 -0
- data/lib/gooddata/extensions/numeric.rb +15 -0
- data/lib/gooddata/extensions/object.rb +27 -0
- data/lib/gooddata/extensions/symbol.rb +15 -0
- data/lib/gooddata/extensions/true.rb +15 -0
- data/lib/gooddata/extract.rb +21 -0
- data/lib/gooddata/goodzilla/goodzilla.rb +159 -0
- data/lib/gooddata/helpers/auth_helpers.rb +75 -0
- data/lib/gooddata/helpers/csv_helper.rb +61 -0
- data/lib/gooddata/helpers/data_helper.rb +116 -0
- data/lib/gooddata/helpers/global_helpers.rb +331 -0
- data/lib/gooddata/helpers/global_helpers_params.rb +172 -0
- data/lib/gooddata/helpers/helpers.rb +10 -0
- data/lib/gooddata/mixins/author.rb +26 -0
- data/lib/gooddata/mixins/content_getter.rb +15 -0
- data/lib/gooddata/mixins/content_property_reader.rb +17 -0
- data/lib/gooddata/mixins/content_property_writer.rb +17 -0
- data/lib/gooddata/mixins/contributor.rb +20 -0
- data/lib/gooddata/mixins/data_getter.rb +15 -0
- data/lib/gooddata/mixins/data_property_reader.rb +19 -0
- data/lib/gooddata/mixins/data_property_writer.rb +19 -0
- data/lib/gooddata/mixins/inspector.rb +53 -0
- data/lib/gooddata/mixins/is_attribute.rb +17 -0
- data/lib/gooddata/mixins/is_dimension.rb +17 -0
- data/lib/gooddata/mixins/is_fact.rb +17 -0
- data/lib/gooddata/mixins/is_label.rb +19 -0
- data/lib/gooddata/mixins/links.rb +15 -0
- data/lib/gooddata/mixins/md_finders.rb +77 -0
- data/lib/gooddata/mixins/md_grantees.rb +42 -0
- data/lib/gooddata/mixins/md_id_to_uri.rb +34 -0
- data/lib/gooddata/mixins/md_json.rb +15 -0
- data/lib/gooddata/mixins/md_lock.rb +87 -0
- data/lib/gooddata/mixins/md_object_id.rb +15 -0
- data/lib/gooddata/mixins/md_object_indexer.rb +64 -0
- data/lib/gooddata/mixins/md_object_query.rb +128 -0
- data/lib/gooddata/mixins/md_relations.rb +43 -0
- data/lib/gooddata/mixins/meta_getter.rb +17 -0
- data/lib/gooddata/mixins/meta_property_reader.rb +19 -0
- data/lib/gooddata/mixins/meta_property_writer.rb +19 -0
- data/lib/gooddata/mixins/mixins.rb +19 -0
- data/lib/gooddata/mixins/not_attribute.rb +17 -0
- data/lib/gooddata/mixins/not_exportable.rb +15 -0
- data/lib/gooddata/mixins/not_fact.rb +17 -0
- data/lib/gooddata/mixins/not_group.rb +17 -0
- data/lib/gooddata/mixins/not_label.rb +19 -0
- data/lib/gooddata/mixins/not_metric.rb +19 -0
- data/lib/gooddata/mixins/obj_id.rb +15 -0
- data/lib/gooddata/mixins/rest_getters.rb +17 -0
- data/lib/gooddata/mixins/rest_resource.rb +47 -0
- data/lib/gooddata/mixins/root_key_getter.rb +15 -0
- data/lib/gooddata/mixins/root_key_setter.rb +15 -0
- data/lib/gooddata/mixins/timestamps.rb +19 -0
- data/lib/gooddata/mixins/to_json.rb +11 -0
- data/lib/gooddata/mixins/uri_getter.rb +9 -0
- data/lib/gooddata/models/blueprint/anchor_field.rb +64 -0
- data/lib/gooddata/models/blueprint/attribute_field.rb +29 -0
- data/lib/gooddata/models/blueprint/blueprint.rb +11 -0
- data/lib/gooddata/models/blueprint/blueprint_field.rb +70 -0
- data/lib/gooddata/models/blueprint/dashboard_builder.rb +30 -0
- data/lib/gooddata/models/blueprint/dataset_blueprint.rb +449 -0
- data/lib/gooddata/models/blueprint/date_dimension.rb +14 -0
- data/lib/gooddata/models/blueprint/fact_field.rb +20 -0
- data/lib/gooddata/models/blueprint/label_field.rb +43 -0
- data/lib/gooddata/models/blueprint/project_blueprint.rb +746 -0
- data/lib/gooddata/models/blueprint/project_builder.rb +83 -0
- data/lib/gooddata/models/blueprint/reference_field.rb +43 -0
- data/lib/gooddata/models/blueprint/schema_blueprint.rb +160 -0
- data/lib/gooddata/models/blueprint/schema_builder.rb +89 -0
- data/lib/gooddata/models/blueprint/to_manifest.rb +181 -0
- data/lib/gooddata/models/blueprint/to_wire.rb +154 -0
- data/lib/gooddata/models/client.rb +182 -0
- data/lib/gooddata/models/client_synchronization_result.rb +31 -0
- data/lib/gooddata/models/client_synchronization_result_details.rb +41 -0
- data/lib/gooddata/models/datawarehouse.rb +92 -0
- data/lib/gooddata/models/domain.rb +479 -0
- data/lib/gooddata/models/execution.rb +115 -0
- data/lib/gooddata/models/execution_detail.rb +81 -0
- data/lib/gooddata/models/from_wire.rb +160 -0
- data/lib/gooddata/models/invitation.rb +75 -0
- data/lib/gooddata/models/links.rb +50 -0
- data/lib/gooddata/models/membership.rb +441 -0
- data/lib/gooddata/models/metadata.rb +272 -0
- data/lib/gooddata/models/metadata/attribute.rb +134 -0
- data/lib/gooddata/models/metadata/dashboard.rb +108 -0
- data/lib/gooddata/models/metadata/dashboard/dashboard_item.rb +76 -0
- data/lib/gooddata/models/metadata/dashboard/filter_apply_item.rb +37 -0
- data/lib/gooddata/models/metadata/dashboard/filter_item.rb +64 -0
- data/lib/gooddata/models/metadata/dashboard/geo_chart_item.rb +56 -0
- data/lib/gooddata/models/metadata/dashboard/headline_item.rb +56 -0
- data/lib/gooddata/models/metadata/dashboard/iframe_item.rb +46 -0
- data/lib/gooddata/models/metadata/dashboard/report_item.rb +92 -0
- data/lib/gooddata/models/metadata/dashboard/text_item.rb +55 -0
- data/lib/gooddata/models/metadata/dashboard_tab.rb +141 -0
- data/lib/gooddata/models/metadata/dataset.rb +64 -0
- data/lib/gooddata/models/metadata/dimension.rb +54 -0
- data/lib/gooddata/models/metadata/fact.rb +44 -0
- data/lib/gooddata/models/metadata/label.rb +128 -0
- data/lib/gooddata/models/metadata/metadata.rb +12 -0
- data/lib/gooddata/models/metadata/metric.rb +198 -0
- data/lib/gooddata/models/metadata/report.rb +247 -0
- data/lib/gooddata/models/metadata/report_definition.rb +264 -0
- data/lib/gooddata/models/metadata/scheduled_mail.rb +274 -0
- data/lib/gooddata/models/metadata/scheduled_mail/dashboard_attachment.rb +62 -0
- data/lib/gooddata/models/metadata/scheduled_mail/report_attachment.rb +64 -0
- data/lib/gooddata/models/metadata/variable.rb +91 -0
- data/lib/gooddata/models/model.rb +282 -0
- data/lib/gooddata/models/models.rb +12 -0
- data/lib/gooddata/models/module_constants.rb +31 -0
- data/lib/gooddata/models/process.rb +316 -0
- data/lib/gooddata/models/profile.rb +426 -0
- data/lib/gooddata/models/project.rb +1514 -0
- data/lib/gooddata/models/project_creator.rb +126 -0
- data/lib/gooddata/models/project_metadata.rb +67 -0
- data/lib/gooddata/models/project_role.rb +79 -0
- data/lib/gooddata/models/report_data_result.rb +266 -0
- data/lib/gooddata/models/schedule.rb +518 -0
- data/lib/gooddata/models/segment.rb +201 -0
- data/lib/gooddata/models/tab_builder.rb +27 -0
- data/lib/gooddata/models/user_filters/mandatory_user_filter.rb +76 -0
- data/lib/gooddata/models/user_filters/user_filter.rb +100 -0
- data/lib/gooddata/models/user_filters/user_filter_builder.rb +512 -0
- data/lib/gooddata/models/user_filters/user_filters.rb +13 -0
- data/lib/gooddata/models/user_filters/variable_user_filter.rb +31 -0
- data/lib/gooddata/models/user_group.rb +241 -0
- data/lib/gooddata/rest/README.md +37 -0
- data/lib/gooddata/rest/client.rb +389 -0
- data/lib/gooddata/rest/connection.rb +765 -0
- data/lib/gooddata/rest/object.rb +69 -0
- data/lib/gooddata/rest/object_factory.rb +76 -0
- data/lib/gooddata/rest/resource.rb +27 -0
- data/lib/gooddata/rest/rest.rb +24 -0
- data/lib/gooddata/version.rb +23 -0
- data/lib/templates/bricks/brick.rb.erb +7 -0
- data/lib/templates/bricks/main.rb.erb +5 -0
- data/lib/templates/project/Goodfile.erb +4 -0
- data/lib/templates/project/data/commits.csv +4 -0
- data/lib/templates/project/data/devs.csv +4 -0
- data/lib/templates/project/data/repos.csv +3 -0
- data/lib/templates/project/model/model.rb.erb +20 -0
- data/spec/bricks/bricks_spec.rb +112 -0
- data/spec/bricks/default-config.json +8 -0
- data/spec/data/.gooddata +4 -0
- data/spec/data/blueprints/additional_dataset_module.json +32 -0
- data/spec/data/blueprints/big_blueprint_not_pruned.json +2079 -0
- data/spec/data/blueprints/invalid_blueprint.json +103 -0
- data/spec/data/blueprints/m_n_model.json +104 -0
- data/spec/data/blueprints/model_module.json +25 -0
- data/spec/data/blueprints/test_blueprint.json +38 -0
- data/spec/data/blueprints/test_project_model_spec.json +106 -0
- 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/column_based_permissions.csv +7 -0
- data/spec/data/column_based_permissions2.csv +6 -0
- data/spec/data/gd_gse_data_blueprint.json +1371 -0
- data/spec/data/gd_gse_data_manifest.json +1424 -0
- data/spec/data/gd_gse_data_model.json +1772 -0
- data/spec/data/gooddata_version_process/gooddata_version.rb +9 -0
- data/spec/data/gooddata_version_process/gooddata_version.zip +0 -0
- data/spec/data/hello_world_process/hello_world.rb +9 -0
- data/spec/data/hello_world_process/hello_world.zip +0 -0
- data/spec/data/line_based_permissions.csv +3 -0
- data/spec/data/manifests/test_blueprint.json +32 -0
- data/spec/data/manifests/test_project.json +107 -0
- 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 +9 -0
- data/spec/data/ruby_process/deep_files/deep_stuff.txt +1 -0
- data/spec/data/ruby_process/process.rb +8 -0
- data/spec/data/ruby_process/stuff.txt +1 -0
- data/spec/data/superfluous_titles_view.json +81 -0
- data/spec/data/test-ci-data.csv +2 -0
- data/spec/data/users.csv +12 -0
- data/spec/data/wire_models/model_view.json +1775 -0
- data/spec/data/wire_models/nu_model.json +3046 -0
- data/spec/data/wire_models/test_blueprint.json +63 -0
- data/spec/data/wire_test_project.json +150 -0
- data/spec/environment/default.rb +41 -0
- data/spec/environment/develop.rb +31 -0
- data/spec/environment/environment.rb +18 -0
- data/spec/environment/hotfix.rb +21 -0
- data/spec/environment/production.rb +35 -0
- data/spec/environment/release.rb +21 -0
- data/spec/environment/staging.rb +30 -0
- data/spec/environment/staging_3.rb +36 -0
- data/spec/helpers/blueprint_helper.rb +26 -0
- data/spec/helpers/cli_helper.rb +36 -0
- data/spec/helpers/connection_helper.rb +41 -0
- data/spec/helpers/crypto_helper.rb +17 -0
- data/spec/helpers/csv_helper.rb +18 -0
- data/spec/helpers/process_helper.rb +33 -0
- data/spec/helpers/project_helper.rb +59 -0
- data/spec/helpers/schedule_helper.rb +31 -0
- data/spec/helpers/spec_helper.rb +15 -0
- data/spec/integration/blueprint_updates_spec.rb +101 -0
- data/spec/integration/blueprint_with_grain_spec.rb +72 -0
- data/spec/integration/clients_spec.rb +134 -0
- data/spec/integration/command_datawarehouse_spec.rb +39 -0
- data/spec/integration/command_projects_spec.rb +32 -0
- data/spec/integration/create_from_template_spec.rb +22 -0
- data/spec/integration/create_project_spec.rb +24 -0
- data/spec/integration/date_dim_switch_spec.rb +142 -0
- data/spec/integration/deprecated_load_spec.rb +58 -0
- data/spec/integration/full_process_schedule_spec.rb +298 -0
- data/spec/integration/full_project_spec.rb +569 -0
- data/spec/integration/over_to_user_filters_spec.rb +94 -0
- data/spec/integration/partial_md_export_import_spec.rb +42 -0
- data/spec/integration/project_spec.rb +264 -0
- data/spec/integration/rest_spec.rb +213 -0
- data/spec/integration/schedule_spec.rb +626 -0
- data/spec/integration/segments_spec.rb +141 -0
- data/spec/integration/user_filters_spec.rb +290 -0
- data/spec/integration/user_group_spec.rb +127 -0
- data/spec/integration/variables_spec.rb +188 -0
- data/spec/logging_in_logging_out_spec.rb +93 -0
- data/spec/spec_helper.rb +95 -0
- data/spec/unit/bricks/bricks_spec.rb +35 -0
- data/spec/unit/bricks/middleware/aws_middelware_spec.rb +51 -0
- data/spec/unit/bricks/middleware/bench_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/bulk_salesforce_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/gooddata_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/logger_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/restforce_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/stdout_middleware_spec.rb +15 -0
- data/spec/unit/bricks/middleware/twitter_middleware_spec.rb +15 -0
- data/spec/unit/cli/cli_spec.rb +17 -0
- data/spec/unit/cli/commands/cmd_auth_spec.rb +17 -0
- data/spec/unit/commands/command_projects_spec.rb +22 -0
- data/spec/unit/core/connection_spec.rb +57 -0
- data/spec/unit/core/logging_spec.rb +133 -0
- data/spec/unit/core/nil_logger_spec.rb +13 -0
- data/spec/unit/core/project_spec.rb +54 -0
- data/spec/unit/extensions/hash_spec.rb +23 -0
- data/spec/unit/godzilla/goodzilla_spec.rb +78 -0
- data/spec/unit/helpers/csv_helper_spec.rb +22 -0
- data/spec/unit/helpers/data_helper_spec.rb +61 -0
- data/spec/unit/helpers/global_helpers_spec.rb +111 -0
- data/spec/unit/helpers_spec.rb +86 -0
- data/spec/unit/models/blueprint/attributes_spec.rb +29 -0
- data/spec/unit/models/blueprint/dataset_spec.rb +121 -0
- data/spec/unit/models/blueprint/labels_spec.rb +44 -0
- data/spec/unit/models/blueprint/project_blueprint_spec.rb +648 -0
- data/spec/unit/models/blueprint/reference_spec.rb +29 -0
- data/spec/unit/models/blueprint/schema_builder_spec.rb +38 -0
- data/spec/unit/models/blueprint/to_wire_spec.rb +174 -0
- data/spec/unit/models/domain_spec.rb +144 -0
- data/spec/unit/models/execution_spec.rb +108 -0
- data/spec/unit/models/from_wire_spec.rb +296 -0
- data/spec/unit/models/invitation_spec.rb +17 -0
- data/spec/unit/models/membership_spec.rb +132 -0
- data/spec/unit/models/metadata_spec.rb +104 -0
- data/spec/unit/models/metric_spec.rb +117 -0
- data/spec/unit/models/model_spec.rb +82 -0
- data/spec/unit/models/params_spec.rb +118 -0
- data/spec/unit/models/profile_spec.rb +215 -0
- data/spec/unit/models/project_creator_spec.rb +127 -0
- data/spec/unit/models/project_role_spec.rb +94 -0
- data/spec/unit/models/project_spec.rb +162 -0
- data/spec/unit/models/report_result_data_spec.rb +199 -0
- data/spec/unit/models/schedule_spec.rb +418 -0
- data/spec/unit/models/to_manifest_spec.rb +63 -0
- data/spec/unit/models/unit_project_spec.rb +125 -0
- data/spec/unit/models/user_filters_spec.rb +95 -0
- data/spec/unit/models/variable_spec.rb +265 -0
- data/spec/unit/rest/polling_spec.rb +89 -0
- data/spec/unit/rest/resource_spec.rb +10 -0
- data/yard-server.sh +3 -0
- metadata +1125 -0
@@ -0,0 +1,264 @@
|
|
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.
|
6
|
+
|
7
|
+
require_relative '../metadata'
|
8
|
+
require_relative 'metadata'
|
9
|
+
|
10
|
+
# GoodData Module
|
11
|
+
module GoodData
|
12
|
+
# Report Definition
|
13
|
+
# TODO: Add more doc ...
|
14
|
+
class ReportDefinition < GoodData::MdObject
|
15
|
+
class << self
|
16
|
+
# Method intended to get all objects of that type in a specified project
|
17
|
+
#
|
18
|
+
# @param options [Hash] the options hash
|
19
|
+
# @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
|
+
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
|
21
|
+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
|
22
|
+
query('reportDefinition', ReportDefinition, options)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create_metrics_part(left, top)
|
26
|
+
stuff = Array(left) + Array(top)
|
27
|
+
stuff.select { |item| item.respond_to?(:metric?) && item.metric? }.map do |metric|
|
28
|
+
create_metric_part(metric)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
alias_method :create_measures_part, :create_metrics_part
|
33
|
+
|
34
|
+
def create_metric_part(metric)
|
35
|
+
{
|
36
|
+
'alias' => metric.title,
|
37
|
+
'uri' => metric.uri
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
alias_method :create_measure_part, :create_metric_part
|
42
|
+
|
43
|
+
def create_attribute_part(attrib)
|
44
|
+
{
|
45
|
+
'attribute' => {
|
46
|
+
'alias' => '',
|
47
|
+
'totals' => [],
|
48
|
+
'uri' => attrib.uri
|
49
|
+
}
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
# Method creates the list of filter representaion suitable for posting on the api. It can currently recognize 2 types of filters. Variable filters and attribute filters. Method for internal usage
|
54
|
+
#
|
55
|
+
# @param filters [GoodData::Variable|Array<Array>]
|
56
|
+
# @param options [Hash] the options hash
|
57
|
+
# @return [Array<Hash>] Returns the structure that is stored internally in the report definition and later psted on the API
|
58
|
+
def create_filters_part(filters, options = {})
|
59
|
+
project = options[:project]
|
60
|
+
vars = filters.select { |f| f.is_a?(GoodData::Variable) }.map { |v| { expression: "[#{v.uri}]" } }
|
61
|
+
category = filters.select { |f| f.is_a?(Array) }.map { |v| GoodData::SmallGoodZilla.create_category_filter(v, project) }
|
62
|
+
vars + category
|
63
|
+
end
|
64
|
+
|
65
|
+
def create_part(stuff)
|
66
|
+
stuff = Array(stuff)
|
67
|
+
parts = stuff.reduce([]) do |memo, item|
|
68
|
+
if item.respond_to?(:metric?) && item.metric?
|
69
|
+
memo
|
70
|
+
else
|
71
|
+
memo << create_attribute_part(item)
|
72
|
+
end
|
73
|
+
memo
|
74
|
+
end
|
75
|
+
if stuff.any? { |item| item.respond_to?(:metric?) && item.metric? }
|
76
|
+
parts << 'metricGroup'
|
77
|
+
end
|
78
|
+
parts
|
79
|
+
end
|
80
|
+
|
81
|
+
def find(stuff, opts = { :client => GoodData.connection, :project => GoodData.project })
|
82
|
+
_client, project = GoodData.get_client_and_project(opts)
|
83
|
+
|
84
|
+
stuff.map do |item|
|
85
|
+
obj = if item.is_a?(String)
|
86
|
+
begin
|
87
|
+
project.objects(item)
|
88
|
+
rescue RestClient::ResourceNotFound
|
89
|
+
raise "Object given by id \"#{item}\" could not be found"
|
90
|
+
end
|
91
|
+
elsif item.is_a?(Hash) && item.keys.include?(:title)
|
92
|
+
case item[:type].to_s
|
93
|
+
when 'metric'
|
94
|
+
GoodData::Metric.find_first_by_title(item[:title], opts)
|
95
|
+
when 'attribute'
|
96
|
+
GoodData::Attribute.find_first_by_title(item[:title], opts)
|
97
|
+
end
|
98
|
+
elsif item.is_a?(Hash) && (item.keys.include?(:id) || item.keys.include?(:identifier))
|
99
|
+
id = item[:id] || item[:identifier]
|
100
|
+
case item[:type].to_s
|
101
|
+
when 'metric'
|
102
|
+
project.metrics(id)
|
103
|
+
when 'attribute'
|
104
|
+
project.attributes(id)
|
105
|
+
when 'label'
|
106
|
+
projects.labels(id)
|
107
|
+
end
|
108
|
+
else
|
109
|
+
item
|
110
|
+
end
|
111
|
+
if obj.respond_to?(:attribute?) && obj.attribute?
|
112
|
+
obj.display_forms.first
|
113
|
+
else
|
114
|
+
obj
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def execute(options = {})
|
120
|
+
left = Array(options[:left])
|
121
|
+
top = Array(options[:top])
|
122
|
+
|
123
|
+
metrics = (left + top).select { |item| item.respond_to?(:metric?) && item.metric? }
|
124
|
+
|
125
|
+
unsaved_metrics = metrics.reject(&:saved?)
|
126
|
+
unsaved_metrics.each { |m| m.title = 'Untitled metric' unless m.title }
|
127
|
+
|
128
|
+
begin
|
129
|
+
unsaved_metrics.each(&:save)
|
130
|
+
GoodData::ReportDefinition.create(options).execute
|
131
|
+
ensure
|
132
|
+
unsaved_metrics.each { |m| m.delete if m && m.saved? }
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def create(options = { :client => GoodData.connection, :project => GoodData.project })
|
137
|
+
client, project = GoodData.get_client_and_project(options)
|
138
|
+
|
139
|
+
left = Array(options[:left])
|
140
|
+
top = Array(options[:top])
|
141
|
+
filters = options[:filters] || []
|
142
|
+
|
143
|
+
left = ReportDefinition.find(left, options)
|
144
|
+
top = ReportDefinition.find(top, options)
|
145
|
+
|
146
|
+
# TODO: Put somewhere for i18n
|
147
|
+
fail_msg = 'All metrics in report definition must be saved'
|
148
|
+
fail fail_msg unless (left + top).all?(&:saved?)
|
149
|
+
|
150
|
+
pars = {
|
151
|
+
'reportDefinition' => {
|
152
|
+
'content' => {
|
153
|
+
'grid' => {
|
154
|
+
'sort' => {
|
155
|
+
'columns' => [],
|
156
|
+
'rows' => []
|
157
|
+
},
|
158
|
+
'columnWidths' => [],
|
159
|
+
'columns' => ReportDefinition.create_part(top),
|
160
|
+
'metrics' => ReportDefinition.create_metrics_part(left, top),
|
161
|
+
'rows' => ReportDefinition.create_part(left)
|
162
|
+
},
|
163
|
+
'format' => 'grid',
|
164
|
+
'filters' => ReportDefinition.create_filters_part(filters, :project => project)
|
165
|
+
},
|
166
|
+
'meta' => {
|
167
|
+
'tags' => '',
|
168
|
+
'summary' => '',
|
169
|
+
'title' => 'Untitled report definition'
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
# TODO: write test for report definitions with explicit identifiers
|
174
|
+
pars['reportDefinition']['meta']['identifier'] = options[:identifier] if options[:identifier]
|
175
|
+
|
176
|
+
client.create(ReportDefinition, pars, :project => project)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
def attribute_parts
|
181
|
+
cols = content['grid']['columns'] || []
|
182
|
+
rows = content['grid']['rows'] || []
|
183
|
+
items = cols + rows
|
184
|
+
items.select { |item| item.is_a?(Hash) && item.keys.first == 'attribute' }
|
185
|
+
end
|
186
|
+
|
187
|
+
def attributes
|
188
|
+
labels.map(&:attribute)
|
189
|
+
end
|
190
|
+
|
191
|
+
# Removes the color mapping from report definition
|
192
|
+
#
|
193
|
+
# @return [GoodData::ReportDefinition] Returns self
|
194
|
+
def reset_color_mapping!
|
195
|
+
global_chart_options = GoodData::Helpers.get_path(content, %w(chart styles global))
|
196
|
+
global_chart_options['colorMapping'] = [] if global_chart_options
|
197
|
+
self
|
198
|
+
end
|
199
|
+
|
200
|
+
# Return true if the report definition is a chart
|
201
|
+
#
|
202
|
+
# @return [Boolean] Return true if report definition is a chart
|
203
|
+
def chart?
|
204
|
+
!table?
|
205
|
+
end
|
206
|
+
|
207
|
+
def labels
|
208
|
+
attribute_parts.map { |part| project.labels(part['attribute']['uri']) }
|
209
|
+
end
|
210
|
+
|
211
|
+
def metric_parts
|
212
|
+
content['grid']['metrics']
|
213
|
+
end
|
214
|
+
|
215
|
+
alias_method :measure_parts, :metric_parts
|
216
|
+
|
217
|
+
def metrics
|
218
|
+
metric_parts.map { |i| project.metrics(i['uri']) }
|
219
|
+
end
|
220
|
+
|
221
|
+
def execute(opts = {})
|
222
|
+
result = if saved?
|
223
|
+
pars = {
|
224
|
+
'report_req' => { 'reportDefinition' => uri }
|
225
|
+
}
|
226
|
+
client.post '/gdc/xtab2/executor3', pars
|
227
|
+
else
|
228
|
+
data = {
|
229
|
+
report_req: {
|
230
|
+
definitionContent: {
|
231
|
+
content: to_hash,
|
232
|
+
projectMetadata: project.links['metadata']
|
233
|
+
}
|
234
|
+
}
|
235
|
+
}
|
236
|
+
uri = "/gdc/app/projects/#{project.pid}/execute"
|
237
|
+
client.post(uri, data)
|
238
|
+
end
|
239
|
+
GoodData::Report.data_result(result, opts.merge(client: client))
|
240
|
+
end
|
241
|
+
|
242
|
+
def filters
|
243
|
+
content['filters'].map { |f| f['expression'] }
|
244
|
+
end
|
245
|
+
|
246
|
+
# Method used for replacing values in their state according to mapping. Can be used to replace any values but it is typically used to replace the URIs. Returns a new object of the same type.
|
247
|
+
#
|
248
|
+
# @param [Array<Array>]Mapping specifying what should be exchanged for what. As mapping should be used output of GoodData::Helpers.prepare_mapping.
|
249
|
+
# @return [GoodData::ReportDefinition]
|
250
|
+
def replace(mapping)
|
251
|
+
x = GoodData::MdObject.replace_quoted(self, mapping)
|
252
|
+
x = GoodData::MdObject.replace_bracketed(x, mapping)
|
253
|
+
vals = GoodData::MdObject.find_replaceable_values(self, mapping)
|
254
|
+
GoodData::MdObject.replace_bracketed(x, vals)
|
255
|
+
end
|
256
|
+
|
257
|
+
# Return true if the report definition is a table
|
258
|
+
#
|
259
|
+
# @return [Boolean] Return true if report definition is a table
|
260
|
+
def table?
|
261
|
+
content['format'] == 'grid'
|
262
|
+
end
|
263
|
+
end
|
264
|
+
end
|
@@ -0,0 +1,274 @@
|
|
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.
|
6
|
+
|
7
|
+
require_relative 'scheduled_mail/dashboard_attachment'
|
8
|
+
require_relative 'scheduled_mail/report_attachment'
|
9
|
+
|
10
|
+
require_relative '../../helpers/global_helpers'
|
11
|
+
|
12
|
+
require_relative '../../core/core'
|
13
|
+
require_relative '../metadata'
|
14
|
+
require_relative 'metadata'
|
15
|
+
require_relative 'report'
|
16
|
+
|
17
|
+
require 'multi_json'
|
18
|
+
|
19
|
+
module GoodData
|
20
|
+
class ScheduledMail < GoodData::MdObject
|
21
|
+
root_key :scheduledMail
|
22
|
+
|
23
|
+
include GoodData::Mixin::Lockable
|
24
|
+
|
25
|
+
DEFAULT_OPTS = {
|
26
|
+
# Meta options
|
27
|
+
:title => 'Scheduled report example',
|
28
|
+
:summary => 'Daily at 12:00pm PT',
|
29
|
+
:tags => '',
|
30
|
+
:deprecated => 0,
|
31
|
+
|
32
|
+
# Content When options
|
33
|
+
:recurrency => '0:0:0:12:0:0',
|
34
|
+
:startDate => '2012-06-05',
|
35
|
+
:timeZone => 'America/Los_Angeles',
|
36
|
+
|
37
|
+
# Content Email options
|
38
|
+
:to => [],
|
39
|
+
:bcc => [],
|
40
|
+
:subject => 'Scheduled Report',
|
41
|
+
:body => "Hey, I'm sending you new Reports and Dashboards!",
|
42
|
+
|
43
|
+
# Attachments
|
44
|
+
:attachments => []
|
45
|
+
}
|
46
|
+
|
47
|
+
class << self
|
48
|
+
# Method intended to get all objects of that type in a specified project
|
49
|
+
#
|
50
|
+
# @param options [Hash] the options hash
|
51
|
+
# @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
|
52
|
+
# @return [Array<GoodData::MdObject> | Array<Hash>] Return the appropriate metadata objects or their representation
|
53
|
+
def all(options = { :client => GoodData.connection, :project => GoodData.project })
|
54
|
+
query('scheduledMail', ScheduledMail, options)
|
55
|
+
end
|
56
|
+
|
57
|
+
def convert_attachment(item, opts)
|
58
|
+
if item.is_a?(GoodData::Dashboard)
|
59
|
+
{
|
60
|
+
dashboardAttachment: GoodData::DashboardAttachment::DEFAULT_OPTS.merge(opts.merge(:uri => item.uri))
|
61
|
+
}
|
62
|
+
elsif item.is_a?(GoodData::Report)
|
63
|
+
{
|
64
|
+
reportAttachment: GoodData::ReportAttachment::DEFAULT_OPTS.merge(opts.merge(:uri => item.uri))
|
65
|
+
}
|
66
|
+
elsif item.is_a?(GoodData::DashboardAttachment)
|
67
|
+
item.json
|
68
|
+
elsif item.is_a?(GoodData::ReportAttachment)
|
69
|
+
item.json
|
70
|
+
elsif item.is_a?(Hash)
|
71
|
+
item
|
72
|
+
elsif item == 'dashboardAttachment'
|
73
|
+
{
|
74
|
+
dashboardAttachment: GoodData::DashboardAttachment::DEFAULT_OPTS.merge(opts)
|
75
|
+
}
|
76
|
+
elsif item == 'reportAttachment'
|
77
|
+
{
|
78
|
+
reportAttachment: GoodData::ReportAttachment::DEFAULT_OPTS.merge(opts)
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def create(options = { :client => GoodData.connection, :project => GoodData.project })
|
84
|
+
client = options[:client]
|
85
|
+
fail ArgumentError, 'No :client specified' if client.nil?
|
86
|
+
|
87
|
+
p = options[:project]
|
88
|
+
fail ArgumentError, 'No :project specified' if p.nil?
|
89
|
+
|
90
|
+
project = client.projects(p)
|
91
|
+
fail ArgumentError, 'Wrong :project specified' if project.nil?
|
92
|
+
|
93
|
+
opts = GoodData::ScheduledMail::DEFAULT_OPTS.merge(GoodData::Helpers.symbolize_keys(options))
|
94
|
+
|
95
|
+
scheduled_mail = {
|
96
|
+
:scheduledMail => {
|
97
|
+
:meta => {
|
98
|
+
:title => opts[:title],
|
99
|
+
:summary => opts[:summary],
|
100
|
+
:tags => opts[:tags],
|
101
|
+
:deprecated => opts[:deprecated]
|
102
|
+
},
|
103
|
+
:content => {
|
104
|
+
:when => {
|
105
|
+
:recurrency => opts[:recurrency],
|
106
|
+
:startDate => opts[:startDate] || opts[:start_date],
|
107
|
+
:timeZone => opts[:timeZone] || opts[:time_zone] || opts[:timezone]
|
108
|
+
},
|
109
|
+
:to => opts[:to].is_a?(Array) ? opts[:to] : [opts[:to]],
|
110
|
+
:bcc => opts[:bcc].is_a?(Array) ? opts[:bcc] : [opts[:bcc]],
|
111
|
+
:subject => opts[:subject],
|
112
|
+
:body => opts[:body]
|
113
|
+
}
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
attachments = opts[:attachments].map do |attachment|
|
118
|
+
key = attachment.keys.first
|
119
|
+
body = attachment[key]
|
120
|
+
|
121
|
+
ScheduledMail.convert_attachment(key, body)
|
122
|
+
end
|
123
|
+
|
124
|
+
scheduled_mail[:scheduledMail][:content][:attachments] = attachments
|
125
|
+
|
126
|
+
client.create(ScheduledMail, GoodData::Helpers.deep_stringify_keys(scheduled_mail), :project => project)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# Add attachment
|
131
|
+
#
|
132
|
+
# @param [String | Object] item Schedule to add
|
133
|
+
# @param [Hash] opts Optional schedule options
|
134
|
+
# @return [Array] New list of attachments
|
135
|
+
def add_attachment(item, opts)
|
136
|
+
attachment = ScheduledMail.convert_attachment(item, opts)
|
137
|
+
fail ArgumentError unless attachment
|
138
|
+
|
139
|
+
content['attachments'] << attachment
|
140
|
+
end
|
141
|
+
|
142
|
+
# Add attachment and save
|
143
|
+
#
|
144
|
+
# @param [String | Object] item Schedule to add
|
145
|
+
# @param [Hash] opts Optional schedule options
|
146
|
+
# @return [Array] New list of attachments
|
147
|
+
def add_attachment!(item, opts)
|
148
|
+
add_attachment(item, opts)
|
149
|
+
save!
|
150
|
+
end
|
151
|
+
|
152
|
+
# Get attachments as objects
|
153
|
+
#
|
154
|
+
# @return [Array<GoodData::DashboardAttachment | GoodData::ReportAttachment>] Array of attachments
|
155
|
+
def attachments
|
156
|
+
content['attachments'].map do |attachment|
|
157
|
+
key = attachment.keys.first
|
158
|
+
|
159
|
+
if key == 'dashboardAttachment'
|
160
|
+
GoodData::DashboardAttachment.new(self, attachment)
|
161
|
+
elsif key == 'reportAttachment'
|
162
|
+
GoodData::ReportAttachment.new(self, attachment)
|
163
|
+
else
|
164
|
+
RuntimeError "Unsupported attachment type: #{key}"
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
# Get body
|
170
|
+
#
|
171
|
+
# @return [String] Scheduled email body
|
172
|
+
def body
|
173
|
+
content['body']
|
174
|
+
end
|
175
|
+
|
176
|
+
# Set body
|
177
|
+
#
|
178
|
+
# @param [String] new_body New body to be set
|
179
|
+
# @return [String] New body
|
180
|
+
def body=(new_body)
|
181
|
+
content['body'] = new_body
|
182
|
+
end
|
183
|
+
|
184
|
+
# Get recurrency string
|
185
|
+
#
|
186
|
+
# @return [String] Recurrency (cron) string
|
187
|
+
def recurrency
|
188
|
+
content['when']['recurrency']
|
189
|
+
end
|
190
|
+
|
191
|
+
# Set recurrency
|
192
|
+
#
|
193
|
+
# @param [String] new_recurrency New recurrency to be set
|
194
|
+
# @return [Hash] New recurrency
|
195
|
+
def recurrency=(new_recurrency)
|
196
|
+
content['when']['recurrency'] = new_recurrency
|
197
|
+
end
|
198
|
+
|
199
|
+
# Get start date
|
200
|
+
#
|
201
|
+
# @return [String] Start date
|
202
|
+
def start_date
|
203
|
+
content['when']['startDate']
|
204
|
+
end
|
205
|
+
|
206
|
+
# Set start date
|
207
|
+
#
|
208
|
+
# @param [String] new_start_date New start date to be set
|
209
|
+
# @return [String] New start date
|
210
|
+
def start_date=(new_start_date)
|
211
|
+
content['when']['startDate'] = new_start_date
|
212
|
+
end
|
213
|
+
|
214
|
+
# Get subject
|
215
|
+
#
|
216
|
+
# @return [String] Subject of scheduled email
|
217
|
+
def subject
|
218
|
+
content['subject']
|
219
|
+
end
|
220
|
+
|
221
|
+
# Set subject
|
222
|
+
#
|
223
|
+
# @param [String] new_subject New subject to be set
|
224
|
+
# @return [String] New subject
|
225
|
+
def subject=(new_subject)
|
226
|
+
content['subject'] = new_subject
|
227
|
+
end
|
228
|
+
|
229
|
+
# Get timezone
|
230
|
+
#
|
231
|
+
# @return [String] Timezone
|
232
|
+
def timezone
|
233
|
+
content['when']['timeZone']
|
234
|
+
end
|
235
|
+
|
236
|
+
# Set timezone
|
237
|
+
#
|
238
|
+
# @param [String] new_timezone New timezone string to be set
|
239
|
+
# @return [String] New timezone
|
240
|
+
def timezone=(new_timezone)
|
241
|
+
content['when']['timeZone'] = new_timezone
|
242
|
+
end
|
243
|
+
|
244
|
+
# Get recipients
|
245
|
+
#
|
246
|
+
# @return [String] Recipients of email
|
247
|
+
def to
|
248
|
+
content['to']
|
249
|
+
end
|
250
|
+
|
251
|
+
# Set recipients
|
252
|
+
#
|
253
|
+
# @param [String|Array<String>] new_to New recipients to be set
|
254
|
+
# @return [Array<String>] New recipient list
|
255
|
+
def to=(new_to)
|
256
|
+
content['to'] = new_to.is_a?(Array) ? new_to : [new_to]
|
257
|
+
end
|
258
|
+
|
259
|
+
# Get 'when' section
|
260
|
+
#
|
261
|
+
# @return [Hash] 'when' section from json
|
262
|
+
def when
|
263
|
+
content['when']
|
264
|
+
end
|
265
|
+
|
266
|
+
# Set 'when' section
|
267
|
+
#
|
268
|
+
# @param [Hash] new_when New 'when' section to be set
|
269
|
+
# @return [Hash] New 'when' section
|
270
|
+
def when=(new_when)
|
271
|
+
content['when'] = new_when
|
272
|
+
end
|
273
|
+
end
|
274
|
+
end
|