Sha256: 0cc58737c423efe57255d88fea9690ae2626a1fd94a2eb0ae4d5814ad2252062

Contents?: true

Size: 1.45 KB

Versions: 4

Compression:

Stored size: 1.45 KB

Contents

module GoodData
  module LCM2
    # Contains code shared by Users Brick and User Filters Brick
    class UserBricksHelper
      class << self
        def resolve_client_id(domain, project, data_product)
          md = project.metadata
          goodot_id = md['GOODOT_CUSTOM_PROJECT_ID'].to_s

          client = domain.clients(:all, data_product).find do |c|
            c.project_uri == project.uri
          end
          if goodot_id.empty? && client.nil?
            fail "Project \"#{project.pid}\" metadata does not contain key " \
                 "GOODOT_CUSTOM_PROJECT_ID neither is it mapped to a " \
                 "client_id in LCM metadata. We are unable to get the " \
                 "values for user filters."
          end

          unless goodot_id.empty? || client.nil? || (goodot_id == client.id)
            fail "GOODOT_CUSTOM_PROJECT_ID metadata key is provided for " \
                 "project \"#{project.pid}\" but doesn't match client id " \
                 "assigned to the project in LCM metadata. " \
                 "Please resolve the conflict."
          end

          goodot_id.empty? ? client.id : goodot_id
        end

        def non_working_clients(domain_clients, working_client_ids)
          non_working_clients = []
          domain_clients.each do |c|
            non_working_clients << c unless working_client_ids.include?(c.client_id.to_s)
          end

          non_working_clients
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gooddata-2.3.1-java lib/gooddata/lcm/user_bricks_helper.rb
gooddata-2.3.1 lib/gooddata/lcm/user_bricks_helper.rb
gooddata-2.3.0-java lib/gooddata/lcm/user_bricks_helper.rb
gooddata-2.3.0 lib/gooddata/lcm/user_bricks_helper.rb