class GoodData::LCM2::SynchronizeDataSetMapping
Constants
- DESCRIPTION
- PARAMS
- RESULT_HEADER
Public Class Methods
call(params)
click to toggle source
# File lib/gooddata/lcm/actions/synchronize_dataset_mappings.rb, line 41 def call(params) results = [] collect_synced_status = collect_synced_status(params) failed_projects = ThreadSafe::Array.new client = params.gdc_gd_client development_client = params.development_client params.synchronize.peach do |info| from_project = info.from to_projects = info.to from = development_client.projects(from_project) unless from process_failed_project(from_project, "Invalid 'from' project specified - '#{from_project}'", failed_projects, collect_synced_status) next end dataset_mapping = from.dataset_mapping if dataset_mapping&.dig('datasetMappings', 'items').nil? || dataset_mapping['datasetMappings']['items'].empty? params.gdc_logger.info "Project: '#{from.title}', PID: '#{from.pid}' has no model mapping, skip synchronizing model mapping." else to_projects.peach do |to| pid = to[:pid] next if sync_failed_project(pid, params) to_project = client.projects(pid) process_failed_project(pid, "Invalid 'to' project specified - '#{pid}'", failed_projects, collect_synced_status) unless to_project message_to_project = "to project: '#{to_project.title}', PID: '#{to_project.pid}'" params.gdc_logger.info "Transferring model mapping, from project: '#{from.title}', PID: '#{from.pid}', #{message_to_project}" res = to_project.update_dataset_mapping(dataset_mapping) res[:from] = from.pid results << res failed_message = "Failed to transfer model mapping from project '#{from.pid}' to project '#{to_project.pid}'" process_failed_project(pid, failed_message, failed_projects, collect_synced_status) if collect_synced_status && res[:status] != 'OK' end end end process_failed_projects(failed_projects, short_name, params) if collect_synced_status # Return results results.flatten end