def call(params)
results = []
client = params.gdc_gd_client
development_client = params.development_client
gdc_logger = params.gdc_logger
collect_synced_status = collect_synced_status(params)
failed_projects = ThreadSafe::Array.new
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
from_pid = from.pid
from_title = from.title
from_ldm_layout = from.ldm_layout
if from_ldm_layout&.dig('ldmLayout', 'layout').nil? || from_ldm_layout['ldmLayout']['layout'].empty?
gdc_logger.info "Project: '#{from_title}', PID: '#{from_pid}' has no ldm layout, skip synchronizing ldm layout."
else
to_projects.peach do |to|
pid = to[:pid]
to_project = client.projects(pid)
unless to_project
process_failed_project(pid, "Invalid 'from' project specified - '#{pid}'", failed_projects, collect_synced_status)
next
end
next if sync_failed_project(pid, params)
gdc_logger.info "Transferring ldm layout, from project: '#{from_title}', PID: '#{from_pid}', to project: '#{to_project.title}', PID: '#{to_project.pid}'"
res = to_project.save_ldm_layout(from_ldm_layout)
if res[:status] == 'OK' || !collect_synced_status
res[:from] = from_pid
results << res
else
warning_message = "Failed to transfer ldm layout from project: '#{from_pid}' to project: '#{to_project.title}'"
process_failed_project(pid, warning_message, failed_projects, collect_synced_status)
end
end
end
end
process_failed_projects(failed_projects, short_name, params) if collect_synced_status
results.flatten
end