Class: GoodData::LCM2::RenameExistingClientProjects
- Inherits:
-
BaseAction
- Object
- BaseAction
- GoodData::LCM2::RenameExistingClientProjects
- Defined in:
- lib/gooddata/lcm/actions/rename_existing_client_projects.rb
Constant Summary collapse
- DESCRIPTION =
'Rename Existing Client Projects'
- PARAMS =
define_params(self) do description 'Clients' param :clients, array_of(instance_of(Type::HashType)), required: true, generated: true description 'Client projects' param :client_projects, instance_of(Type::GdSmartHashType), required: false end
- RESULT_HEADER =
[ :id, :pid, :old_title, :new_title ]
Constants inherited from BaseAction
BaseAction::FAILED_CLIENTS, BaseAction::FAILED_PROJECTS, BaseAction::FAILED_SEGMENTS, BaseAction::SYNC_FAILED_LIST
Constants included from Dsl::Dsl
Dsl::Dsl::DEFAULT_OPTS, Dsl::Dsl::TYPES
Class Method Summary collapse
Methods inherited from BaseAction
add_failed_client, add_failed_project, add_failed_segment, add_new_clients_to_project_client_mapping, check_params, collect_synced_status, continue_on_error, print_result, process_failed_project, process_failed_projects, sync_failed_client, sync_failed_project, sync_failed_segment, without_check
Methods included from Dsl::Dsl
#define_params, #define_type, #process
Class Method Details
.call(params) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/gooddata/lcm/actions/rename_existing_client_projects.rb', line 30 def call(params) client_projects = params.client_projects results = [] params.clients.each do |c| info = client_projects[c[:id]] next unless info segment_client = info[:segment_client] project = info[:project] # If he is an existing client but has no project, he will be purged and then re-created again # so his project absolutely does not need to be updated title next unless project # If his project is existing, we do not know this is a correct project or not because user # can associate this client with another project and we need to check and update its title. # If this is a new project, we do not need to verify its status because we already did it in # CollectClients action project = segment_client.project new_title = c[:settings].find { |setting| setting[:name] == 'lcm.title' }[:value] next unless new_title old_title = project.title next if new_title == old_title project.title = new_title project.save results << { id: c[:id], pid: project.pid, old_title: old_title, new_title: new_title } end results end |