Class: BulkImports::Entity
Overview
The BulkImport::Entity represents a Group or Project to be imported during the bulk import process. An entity is nested under the parent group when it is not a top level group.
A full bulk import entity structure might look like this, where the links are parents:
**Before Import** **After Import**
GroupEntity Group
| | | |
GroupEntity ProjectEntity Group Project
| |
ProjectEntity Project
The tree structure of the entities results in the same structure for imported Groups and Projects.
Constant Summary
collapse
- FailedError =
Class.new(StandardError)
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
#run_after_commit, #run_after_commit_or_now
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, sharding_keys, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Class Method Details
.all_human_statuses ⇒ Object
114
115
116
|
# File 'app/models/bulk_imports/entity.rb', line 114
def self.all_human_statuses
state_machine.states.map(&:human_name)
end
|
Instance Method Details
#base_resource_path ⇒ Object
155
156
157
158
159
160
161
|
# File 'app/models/bulk_imports/entity.rb', line 155
def base_resource_path
if source_xid.present?
base_xid_resource_url_path
else
base_resource_url_path
end
end
|
#base_resource_url_path ⇒ Object
147
148
149
|
# File 'app/models/bulk_imports/entity.rb', line 147
def base_resource_url_path
"/#{pluralized_name}/#{encoded_source_full_path}"
end
|
#base_xid_resource_url_path ⇒ Object
151
152
153
|
# File 'app/models/bulk_imports/entity.rb', line 151
def base_xid_resource_url_path
"/#{pluralized_name}/#{source_xid}"
end
|
#checksums ⇒ Object
226
227
228
229
230
231
232
233
234
|
# File 'app/models/bulk_imports/entity.rb', line 226
def checksums
trackers.each_with_object({}) do |tracker, checksums|
next unless tracker.
next if tracker.skipped?
next if tracker.checksums_empty?
checksums.merge!(tracker.checksums)
end
end
|
#default_visibility_level ⇒ Object
208
209
210
211
212
|
# File 'app/models/bulk_imports/entity.rb', line 208
def default_visibility_level
return default_group_visibility if group?
default_project_visibility
end
|
#encoded_source_full_path ⇒ Object
118
119
120
|
# File 'app/models/bulk_imports/entity.rb', line 118
def encoded_source_full_path
ERB::Util.url_encode(source_full_path)
end
|
#entity_type ⇒ Object
135
136
137
|
# File 'app/models/bulk_imports/entity.rb', line 135
def entity_type
source_type.gsub('_entity', '')
end
|
#export_relations_url_path ⇒ Object
167
168
169
170
171
172
173
|
# File 'app/models/bulk_imports/entity.rb', line 167
def export_relations_url_path
if bulk_import.supports_batched_export?
Gitlab::Utils.add_url_parameters(export_relations_url_path_base, batched: true)
else
export_relations_url_path_base
end
end
|
#export_relations_url_path_base ⇒ Object
163
164
165
|
# File 'app/models/bulk_imports/entity.rb', line 163
def export_relations_url_path_base
File.join(base_resource_path, 'export_relations')
end
|
#full_path ⇒ Object
200
201
202
|
# File 'app/models/bulk_imports/entity.rb', line 200
def full_path
project? ? project&.full_path : group&.full_path
end
|
#full_path_with_fallback ⇒ Object
204
205
206
|
# File 'app/models/bulk_imports/entity.rb', line 204
def full_path_with_fallback
full_path || Gitlab::Utils.append_path(destination_namespace, destination_slug)
end
|
#group? ⇒ Boolean
192
193
194
|
# File 'app/models/bulk_imports/entity.rb', line 192
def group?
source_type == 'group_entity'
end
|
#pipeline_exists?(name) ⇒ Boolean
131
132
133
|
# File 'app/models/bulk_imports/entity.rb', line 131
def pipeline_exists?(name)
pipelines.any? { _1[:pipeline].to_s == name.to_s }
end
|
#pluralized_name ⇒ Object
139
140
141
|
# File 'app/models/bulk_imports/entity.rb', line 139
def pluralized_name
entity_type.pluralize
end
|
#portable_class ⇒ Object
143
144
145
|
# File 'app/models/bulk_imports/entity.rb', line 143
def portable_class
entity_type.classify.constantize
end
|
#project? ⇒ Boolean
188
189
190
|
# File 'app/models/bulk_imports/entity.rb', line 188
def project?
source_type == 'project_entity'
end
|
#propagate_cancel ⇒ Object
236
237
238
|
# File 'app/models/bulk_imports/entity.rb', line 236
def propagate_cancel
trackers.each(&:cancel)
end
|
#relation_download_url_path(relation, batch_number = nil) ⇒ Object
175
176
177
178
179
180
181
182
|
# File 'app/models/bulk_imports/entity.rb', line 175
def relation_download_url_path(relation, batch_number = nil)
url = File.join(export_relations_url_path_base, 'download')
params = { relation: relation }
params.merge!(batched: true, batch_number: batch_number) if batch_number && bulk_import.supports_batched_export?
Gitlab::Utils.add_url_parameters(url, params)
end
|
#source_version ⇒ Object
222
223
224
|
# File 'app/models/bulk_imports/entity.rb', line 222
def source_version
@source_version ||= bulk_import.source_version_info
end
|
#update_has_failures ⇒ Object
214
215
216
217
218
219
220
|
# File 'app/models/bulk_imports/entity.rb', line 214
def update_has_failures
return if has_failures
return unless failures.any?
update!(has_failures: true)
bulk_import.update!(has_failures: true)
end
|
#update_service ⇒ Object
196
197
198
|
# File 'app/models/bulk_imports/entity.rb', line 196
def update_service
"::#{pluralized_name.capitalize}::UpdateService".constantize
end
|
#wikis_url_path ⇒ Object
184
185
186
|
# File 'app/models/bulk_imports/entity.rb', line 184
def wikis_url_path
"#{base_resource_path}/wikis"
end
|