Sha256: 688ff2fd24169e68c831accc8ed21c8eea365bb48cce489700cad3ee190d6eba

Contents?: true

Size: 1.61 KB

Versions: 23

Compression:

Stored size: 1.61 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') && (RUBY_PLATFORM == 'java')
          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

23 entries across 23 versions & 1 rubygems

Version Path
gooddata-1.3.3-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.3 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.2-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.2 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.1-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.1 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.0-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.3.0 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.2.1-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.2.1 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.2.0-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.2.0 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.1.0-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.1.0 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.0.2-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.0.2 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.0.1 lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.0.1-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.0.0-java lib/gooddata/bricks/middleware/dwh_middleware.rb
gooddata-1.0.0 lib/gooddata/bricks/middleware/dwh_middleware.rb