Sha256: 097aaa81309941eb26cf782a872f60c6978569c65562e5bc8079e26df20fd5d4

Contents?: true

Size: 1.58 KB

Versions: 22

Compression:

Stored size: 1.58 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']}"
          unless params['ads_client']['username'] || params['GDC_USERNAME']
            raise "ADS middleware needs username either as part of " \
                  "ads_client spec or as a global 'GDC_USERNAME' parameter"
          end

          unless params['ads_client']['password'] || params['GDC_PASSWORD']
            raise "ADS middleware needs password either as part of " \
                  "ads_client spec or as a global 'GDC_PASSWORD' parameter"
          end

          ads = GoodData::Datawarehouse.new(
            params['ads_client']['username'] || params['GDC_USERNAME'],
            params['ads_client']['password'] || params['GDC_PASSWORD'],
            params['ads_client']['ads_id'],
            jdbc_url: params['ads_client']['jdbc_url']
          )
          @app.call(params.merge('ads_client' => ads, :ads_client => ads))
        else
          @app.call(params)
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
gooddata-2.1.5-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.5 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.4-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.4 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.3-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.3 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.2-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.2 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.1-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.1 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.0-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.1.0 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.0.1-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.0.1 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.0.0-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-2.0.0 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.6-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.6 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.5-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.5 lib/gooddata/bricks/middleware/dwh_middleware.rb