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, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, nullable_column?, pluck_primary_key, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #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
113
114
115
|
# File 'app/models/bulk_imports/entity.rb', line 113
def self.all_human_statuses
state_machine.states.map(&:human_name)
end
|
Instance Method Details
#base_resource_path ⇒ Object
154
155
156
157
158
159
160
|
# File 'app/models/bulk_imports/entity.rb', line 154
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
146
147
148
|
# File 'app/models/bulk_imports/entity.rb', line 146
def base_resource_url_path
"/#{pluralized_name}/#{encoded_source_full_path}"
end
|
#base_xid_resource_url_path ⇒ Object
150
151
152
|
# File 'app/models/bulk_imports/entity.rb', line 150
def base_xid_resource_url_path
"/#{pluralized_name}/#{source_xid}"
end
|
#checksums ⇒ Object
225
226
227
228
229
230
231
232
233
|
# File 'app/models/bulk_imports/entity.rb', line 225
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
207
208
209
210
211
|
# File 'app/models/bulk_imports/entity.rb', line 207
def default_visibility_level
return default_group_visibility if group?
default_project_visibility
end
|
#encoded_source_full_path ⇒ Object
117
118
119
|
# File 'app/models/bulk_imports/entity.rb', line 117
def encoded_source_full_path
ERB::Util.url_encode(source_full_path)
end
|
#entity_type ⇒ Object
134
135
136
|
# File 'app/models/bulk_imports/entity.rb', line 134
def entity_type
source_type.gsub('_entity', '')
end
|
#export_relations_url_path ⇒ Object
166
167
168
169
170
171
172
|
# File 'app/models/bulk_imports/entity.rb', line 166
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
162
163
164
|
# File 'app/models/bulk_imports/entity.rb', line 162
def export_relations_url_path_base
File.join(base_resource_path, 'export_relations')
end
|
#full_path ⇒ Object
199
200
201
|
# File 'app/models/bulk_imports/entity.rb', line 199
def full_path
project? ? project&.full_path : group&.full_path
end
|
#full_path_with_fallback ⇒ Object
203
204
205
|
# File 'app/models/bulk_imports/entity.rb', line 203
def full_path_with_fallback
full_path || Gitlab::Utils.append_path(destination_namespace, destination_slug)
end
|
#group? ⇒ Boolean
191
192
193
|
# File 'app/models/bulk_imports/entity.rb', line 191
def group?
source_type == 'group_entity'
end
|
#pipeline_exists?(name) ⇒ Boolean
130
131
132
|
# File 'app/models/bulk_imports/entity.rb', line 130
def pipeline_exists?(name)
pipelines.any? { _1[:pipeline].to_s == name.to_s }
end
|
#pluralized_name ⇒ Object
138
139
140
|
# File 'app/models/bulk_imports/entity.rb', line 138
def pluralized_name
entity_type.pluralize
end
|
#portable_class ⇒ Object
142
143
144
|
# File 'app/models/bulk_imports/entity.rb', line 142
def portable_class
entity_type.classify.constantize
end
|
#project? ⇒ Boolean
187
188
189
|
# File 'app/models/bulk_imports/entity.rb', line 187
def project?
source_type == 'project_entity'
end
|
#propagate_cancel ⇒ Object
235
236
237
|
# File 'app/models/bulk_imports/entity.rb', line 235
def propagate_cancel
trackers.each(&:cancel)
end
|
#relation_download_url_path(relation, batch_number = nil) ⇒ Object
174
175
176
177
178
179
180
181
|
# File 'app/models/bulk_imports/entity.rb', line 174
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
221
222
223
|
# File 'app/models/bulk_imports/entity.rb', line 221
def source_version
@source_version ||= bulk_import.source_version_info
end
|
#update_has_failures ⇒ Object
213
214
215
216
217
218
219
|
# File 'app/models/bulk_imports/entity.rb', line 213
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
195
196
197
|
# File 'app/models/bulk_imports/entity.rb', line 195
def update_service
"::#{pluralized_name.capitalize}::UpdateService".constantize
end
|
#wikis_url_path ⇒ Object
183
184
185
|
# File 'app/models/bulk_imports/entity.rb', line 183
def wikis_url_path
"#{base_resource_path}/wikis"
end
|