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
ResetOnUnionError::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
cached_column_list, #create_or_load_association, declarative_enum, default_select_columns, id_in, id_not_in, iid_in, 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
#serializable_hash
Class Method Details
.all_human_statuses ⇒ Object
98
99
100
|
# File 'app/models/bulk_imports/entity.rb', line 98
def self.all_human_statuses
state_machine.states.map(&:human_name)
end
|
Instance Method Details
#base_resource_path ⇒ Object
135
136
137
138
139
140
141
|
# File 'app/models/bulk_imports/entity.rb', line 135
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
127
128
129
|
# File 'app/models/bulk_imports/entity.rb', line 127
def base_resource_url_path
"/#{pluralized_name}/#{encoded_source_full_path}"
end
|
#base_xid_resource_url_path ⇒ Object
131
132
133
|
# File 'app/models/bulk_imports/entity.rb', line 131
def base_xid_resource_url_path
"/#{pluralized_name}/#{source_xid}"
end
|
#default_visibility_level ⇒ Object
186
187
188
189
190
|
# File 'app/models/bulk_imports/entity.rb', line 186
def default_visibility_level
return default_group_visibility if group?
default_project_visibility
end
|
#encoded_source_full_path ⇒ Object
102
103
104
|
# File 'app/models/bulk_imports/entity.rb', line 102
def encoded_source_full_path
ERB::Util.url_encode(source_full_path)
end
|
#entity_type ⇒ Object
119
120
121
|
# File 'app/models/bulk_imports/entity.rb', line 119
def entity_type
source_type.gsub('_entity', '')
end
|
#export_relations_url_path(batched: false) ⇒ Object
147
148
149
150
151
152
153
|
# File 'app/models/bulk_imports/entity.rb', line 147
def export_relations_url_path(batched: false)
if batched && bulk_import.supports_batched_export?
Gitlab::Utils.add_url_parameters(export_relations_url_path_base, batched: batched)
else
export_relations_url_path_base
end
end
|
#export_relations_url_path_base ⇒ Object
143
144
145
|
# File 'app/models/bulk_imports/entity.rb', line 143
def export_relations_url_path_base
File.join(base_resource_path, 'export_relations')
end
|
#full_path ⇒ Object
182
183
184
|
# File 'app/models/bulk_imports/entity.rb', line 182
def full_path
project? ? project&.full_path : group&.full_path
end
|
#group? ⇒ Boolean
174
175
176
|
# File 'app/models/bulk_imports/entity.rb', line 174
def group?
source_type == 'group_entity'
end
|
#pipeline_exists?(name) ⇒ Boolean
115
116
117
|
# File 'app/models/bulk_imports/entity.rb', line 115
def pipeline_exists?(name)
pipelines.any? { _1[:pipeline].to_s == name.to_s }
end
|
#pluralized_name ⇒ Object
123
124
125
|
# File 'app/models/bulk_imports/entity.rb', line 123
def pluralized_name
entity_type.pluralize
end
|
#project? ⇒ Boolean
170
171
172
|
# File 'app/models/bulk_imports/entity.rb', line 170
def project?
source_type == 'project_entity'
end
|
#relation_download_url_path(relation, batch_number = nil) ⇒ Object
155
156
157
158
159
160
161
162
163
164
|
# File 'app/models/bulk_imports/entity.rb', line 155
def relation_download_url_path(relation, batch_number = nil)
url = File.join(export_relations_url_path_base, 'download')
params = { relation: relation }
if batch_number && bulk_import.supports_batched_export?
params.merge!(batched: true, batch_number: batch_number)
end
Gitlab::Utils.add_url_parameters(url, params)
end
|
#source_version ⇒ Object
199
200
201
|
# File 'app/models/bulk_imports/entity.rb', line 199
def source_version
@source_version ||= bulk_import.source_version_info
end
|
#update_has_failures ⇒ Object
192
193
194
195
196
197
|
# File 'app/models/bulk_imports/entity.rb', line 192
def update_has_failures
return if has_failures
return unless failures.any?
update!(has_failures: true)
end
|
#update_service ⇒ Object
178
179
180
|
# File 'app/models/bulk_imports/entity.rb', line 178
def update_service
"::#{pluralized_name.capitalize}::UpdateService".constantize
end
|
#wikis_url_path ⇒ Object
166
167
168
|
# File 'app/models/bulk_imports/entity.rb', line 166
def wikis_url_path
"#{base_resource_path}/wikis"
end
|