Sha256: 3b234758c15e4a7ba15fa9e6952c8c78f028522b77c51b95d60988008a1d3049

Contents?: true

Size: 1.55 KB

Versions: 36

Compression:

Stored size: 1.55 KB

Contents

# encoding: UTF-8
#
# Copyright (c) 2010-2017 GoodData Corporation. All rights reserved.
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

require_relative 'base_action'

module GoodData
  module LCM2
    class EnsureReleaseTable < BaseAction
      DESCRIPTION = 'Ensures presence of LCM_RELEASE table'

      PARAMS = define_params(self) do
        description 'ADS Client'
        param :ads_client, instance_of(Type::AdsClientType), required: false

        description 'Table Name'
        param :release_table_name, instance_of(Type::StringType), required: false
      end

      RESULT_HEADER = [
        :table_name,
        :status
      ]

      DEFAULT_TABLE_NAME = 'LCM_RELEASE'

      class << self
        def call(params)
          if params.ads_client
            replacements = {
              table_name: params.release_table_name || DEFAULT_TABLE_NAME
            }

            path = File.expand_path('../data/create_lcm_release.sql.erb', __dir__)
            query = GoodData::Helpers::ErbHelper.template_file(path, replacements)

            sql_result = params.ads_client.execute(query)

            # TODO: Format
            GoodData.logger.info(JSON.pretty_generate(sql_result))

            [
              {
                table_name: replacements[:table_name],
                status: 'ok'
              }
            ]
          else
            [
              {
                status: 'ok'
              }
            ]
          end
        end
      end
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
gooddata-2.3.1-java lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.3.1 lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.3.0-java lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.3.0 lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.2.0-java lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.2.0 lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.19-java lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.19 lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.17-java lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.17 lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.15-java lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.15 lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.14-java lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.14 lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.13-java lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.13 lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.12-java lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.12 lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.11-java lib/gooddata/lcm/actions/ensure_release_table.rb
gooddata-2.1.11 lib/gooddata/lcm/actions/ensure_release_table.rb