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 |
namespace :core do |
||||||
desc "Import all data XMLs from legacy CORE" |
desc "Import all data XMLs from legacy CORE" |
||||||
task :full_import, %i[path] => :environment do |_task, args| |
task :full_import, %i[path] => :environment do |_task, args| |
||||||
path = args[:path] |
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"]) |
storage_service = StorageService.new(PaasConfigurationService.new, ENV["IMPORT_PAAS_INSTANCE"]) |
||||||
|
|
||||||
Imports::OrganisationImportService.new(storage_service).create_organisations(path) |
import_list = [ |
||||||
Imports::SchemeImportService.new(storage_service).create_schemes(path) |
Import.new(Imports::OrganisationImportService, :create_organisations, "institution"), |
||||||
Imports::SchemeLocationImportService.new(storage_service).create_scheme_locations(path) |
Import.new(Imports::SchemeImportService, :create_schemes, "mgmtgroups"), |
||||||
Imports::UserImportService.new(storage_service).create_users(path) |
Import.new(Imports::SchemeLocationImportService, :create_scheme_locations, "schemes"), |
||||||
Imports::DataProtectionConfirmationImportService.new(storage_service).create_data_protection_confirmations(path) |
Import.new(Imports::UserImportService, :create_users, "user"), |
||||||
Imports::OrganisationRentPeriodImportService.new(storage_service).create_organisation_rent_periods(path) |
Import.new(Imports::DataProtectionConfirmationImportService, :create_data_protection_confirmations, "dataprotect"), |
||||||
Imports::CaseLogsImportService.new(storage_service).create_logs(path) |
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 |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue