3 changed files with 43 additions and 55 deletions
@ -1,22 +0,0 @@
|
||||
module Imports |
||||
class CoreImportService < ImportService |
||||
|
||||
def start_import |
||||
|
||||
end |
||||
|
||||
private |
||||
|
||||
ARCHIVE_FOLDERS = { |
||||
organisation: "institution", |
||||
scheme: "mgmtgroups", |
||||
scheme_location: "schemes", |
||||
user: "user", |
||||
data_protection_confirmation: "dataprotect", |
||||
organisation_rent_periods: "rent-period", |
||||
case_log: "logs" |
||||
}.freeze |
||||
|
||||
|
||||
end |
||||
end |
@ -1,17 +1,26 @@
|
||||
Import = Struct.new("Import", :import_class, :import_method, :folder) |
||||
|
||||
namespace :core do |
||||
desc "Import all data XMLs from legacy CORE" |
||||
task :full_import, %i[path] => :environment do |_task, args| |
||||
path = args[:path] |
||||
raise "Usage: rake core:full_import['path/to/xml_files']" if path.blank? |
||||
raise "Usage: rake core:full_import['path/to/main_folder']" if path.blank? |
||||
|
||||
storage_service = StorageService.new(PaasConfigurationService.new, ENV["IMPORT_PAAS_INSTANCE"]) |
||||
|
||||
Imports::OrganisationImportService.new(storage_service).create_organisations(path) |
||||
Imports::SchemeImportService.new(storage_service).create_schemes(path) |
||||
Imports::SchemeLocationImportService.new(storage_service).create_scheme_locations(path) |
||||
Imports::UserImportService.new(storage_service).create_users(path) |
||||
Imports::DataProtectionConfirmationImportService.new(storage_service).create_data_protection_confirmations(path) |
||||
Imports::OrganisationRentPeriodImportService.new(storage_service).create_organisation_rent_periods(path) |
||||
Imports::CaseLogsImportService.new(storage_service).create_logs(path) |
||||
import_list = [ |
||||
Import.new(Imports::OrganisationImportService, :create_organisations, "institution"), |
||||
Import.new(Imports::SchemeImportService, :create_schemes, "mgmtgroups"), |
||||
Import.new(Imports::SchemeLocationImportService, :create_scheme_locations, "schemes"), |
||||
Import.new(Imports::UserImportService, :create_users, "user"), |
||||
Import.new(Imports::DataProtectionConfirmationImportService, :create_data_protection_confirmations, "dataprotect"), |
||||
Import.new(Imports::OrganisationRentPeriodImportService, :create_organisation_rent_periods, "rent-period"), |
||||
Import.new(Imports::CaseLogsImportService, :create_logs, "logs"), |
||||
] |
||||
|
||||
import_list.each do |import| |
||||
folder_path = File.join(path, import.folder, "") |
||||
import.import_class.new(storage_service).send(import.import_method, folder_path) |
||||
end |
||||
end |
||||
end |
||||
|
Loading…
Reference in new issue