Class: GoodData::LCM2::UserBricksHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/gooddata/lcm/user_bricks_helper.rb

Overview

Contains code shared by Users Brick and User Filters Brick

Class Method Summary collapse

Class Method Details

.non_working_clients(domain_clients, working_client_ids) ⇒ Object



30
31
32
33
34
35
36
37
# 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) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/gooddata/lcm/user_bricks_helper.rb', line 6

def resolve_client_id(domain, project, data_product)
  md = project.
  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