Class: PULDspaceMigrate
- Inherits:
-
Object
- Object
- PULDspaceMigrate
- Defined in:
- app/services/pul_dspace_migrate.rb
Instance Attribute Summary collapse
-
#ark ⇒ Object
readonly
Returns the value of attribute ark.
-
#aws_connector ⇒ Object
readonly
Returns the value of attribute aws_connector.
-
#aws_files_and_directories ⇒ Object
readonly
Returns the value of attribute aws_files_and_directories.
-
#current_user ⇒ Object
readonly
Returns the value of attribute current_user.
-
#directory_keys ⇒ Object
readonly
Returns the value of attribute directory_keys.
-
#dspace_files ⇒ Object
readonly
Returns the value of attribute dspace_files.
-
#file_keys ⇒ Object
readonly
Returns the value of attribute file_keys.
-
#migration_snapshot ⇒ Object
readonly
Returns the value of attribute migration_snapshot.
-
#work ⇒ Object
readonly
Returns the value of attribute work.
Instance Method Summary collapse
- #dspace_connector ⇒ Object
-
#initialize(work, current_user) ⇒ PULDspaceMigrate
constructor
A new instance of PULDspaceMigrate.
- #migrate ⇒ Object
- #migration_message(input_file_keys = file_keys, input_directory_keys = directory_keys) ⇒ Object
Constructor Details
#initialize(work, current_user) ⇒ PULDspaceMigrate
Returns a new instance of PULDspaceMigrate.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'app/services/pul_dspace_migrate.rb', line 8 def initialize(work, current_user) @work = work @ark = work.ark&.gsub("ark:/", "") @file_keys = [] @directory_keys = [] @aws_connector = PULDspaceAwsConnector.new(work, work.doi) @migration_snapshot = nil @aws_files_and_directories = nil @dspace_files = [] @current_user = current_user end |
Instance Attribute Details
#ark ⇒ Object (readonly)
Returns the value of attribute ark.
3 4 5 |
# File 'app/services/pul_dspace_migrate.rb', line 3 def ark @ark end |
#aws_connector ⇒ Object (readonly)
Returns the value of attribute aws_connector.
3 4 5 |
# File 'app/services/pul_dspace_migrate.rb', line 3 def aws_connector @aws_connector end |
#aws_files_and_directories ⇒ Object (readonly)
Returns the value of attribute aws_files_and_directories.
3 4 5 |
# File 'app/services/pul_dspace_migrate.rb', line 3 def aws_files_and_directories @aws_files_and_directories end |
#current_user ⇒ Object (readonly)
Returns the value of attribute current_user.
3 4 5 |
# File 'app/services/pul_dspace_migrate.rb', line 3 def current_user @current_user end |
#directory_keys ⇒ Object (readonly)
Returns the value of attribute directory_keys.
3 4 5 |
# File 'app/services/pul_dspace_migrate.rb', line 3 def directory_keys @directory_keys end |
#dspace_files ⇒ Object (readonly)
Returns the value of attribute dspace_files.
3 4 5 |
# File 'app/services/pul_dspace_migrate.rb', line 3 def dspace_files @dspace_files end |
#file_keys ⇒ Object (readonly)
Returns the value of attribute file_keys.
3 4 5 |
# File 'app/services/pul_dspace_migrate.rb', line 3 def file_keys @file_keys end |
#migration_snapshot ⇒ Object (readonly)
Returns the value of attribute migration_snapshot.
3 4 5 |
# File 'app/services/pul_dspace_migrate.rb', line 3 def migration_snapshot @migration_snapshot end |
#work ⇒ Object (readonly)
Returns the value of attribute work.
3 4 5 |
# File 'app/services/pul_dspace_migrate.rb', line 3 def work @work end |
Instance Method Details
#dspace_connector ⇒ Object
30 31 32 |
# File 'app/services/pul_dspace_migrate.rb', line 30 def dspace_connector @dspace_connector ||= PULDspaceConnector.new(work) end |
#migrate ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/services/pul_dspace_migrate.rb', line 20 def migrate return if ark.nil? work.resource.migrated = true work.save @aws_files_and_directories = aws_connector.aws_files migrate_dspace aws_copy(aws_files_and_directories) end |
#migration_message(input_file_keys = file_keys, input_directory_keys = directory_keys) ⇒ Object
34 35 36 37 38 39 40 |
# File 'app/services/pul_dspace_migrate.rb', line 34 def (input_file_keys = file_keys, input_directory_keys = directory_keys) = [] # rubocop:disable Layout/LineLength << "Migration for #{input_file_keys.count} #{'file'.pluralize(input_file_keys.count)} and #{input_directory_keys.count} #{'directory'.pluralize(input_directory_keys.count)} is running in the background. Depending on the file sizes this may take some time." # rubocop:enable Layout/LineLength .join(" ") end |