Sha256: f438ab8900fa0ba758effa9a646456e6786bc86a2a9e48414783227f3362de9d

Contents?: true

Size: 1.7 KB

Versions: 30

Compression:

Stored size: 1.7 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_middleware'

require 'gooddata_datawarehouse' if RUBY_PLATFORM == 'java'

module GoodData
  module Bricks
    # Connects to the warehouse (ADS) and enriches parameters with GoodData::Datawarehouse
    class WarehouseMiddleware < Bricks::Middleware
      def call(params)
        if params.key?('ads_client')
          GoodData.logger.info "Setting up ADS connection to #{params['ads_client']['ads_id'] || params['ads_client']['jdbc_url']}"

          username = params['ads_client']['username'] || params['GDC_USERNAME']
          password = params['ads_client']['password'] || params['GDC_PASSWORD']
          instance_id = params['ads_client']['ads_id']
          jdbc_url = params['ads_client']['jdbc_url']
          sst_token = params['ads_client']['sst'] || params['GDC_SST']

          ads = if username.nil? || password.nil?
                  GoodData.logger.info 'Using SST for ADS connection'
                  GoodData::Datawarehouse.new_instance(
                    instance_id: instance_id,
                    jdbc_url: jdbc_url,
                    sst: sst_token
                  )
                else
                  GoodData::Datawarehouse.new(
                    username,
                    password,
                    instance_id,
                    jdbc_url: jdbc_url
                  )
                end
          @app.call(params.merge('ads_client' => ads, :ads_client => ads))
        else
          @app.call(params)
        end
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
gooddata-2.3.1-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.3.1 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.3.0-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.3.0 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.2.0-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.2.0 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.19-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.19 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.17-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.17 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.15-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.15 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.14-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.14 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.13-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.13 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.12-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.12 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.11-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.11 lib/gooddata/bricks/middleware/dwh_middleware.rb