class GoodData::LCM2::UserBricksHelper

Contains code shared by Users Brick and User Filters Brick

Public Class Methods

non_working_clients(domain_clients, working_client_ids) click to toggle source
# File lib/gooddata/lcm/user_bricks_helper.rb, line 30
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
resolve_client_id(domain, project, data_product) click to toggle source
# File lib/gooddata/lcm/user_bricks_helper.rb, line 6
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