Class: PULDspaceMigrate

Inherits:
Object
  • Object
show all
Defined in:
app/services/pul_dspace_migrate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#arkObject (readonly)

Returns the value of attribute ark.



3
4
5
# File 'app/services/pul_dspace_migrate.rb', line 3

def ark
  @ark
end

#aws_connectorObject (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_directoriesObject (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_userObject (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_keysObject (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_filesObject (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_keysObject (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_snapshotObject (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

#workObject (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_connectorObject



30
31
32
# File 'app/services/pul_dspace_migrate.rb', line 30

def dspace_connector
  @dspace_connector ||= PULDspaceConnector.new(work)
end

#migrateObject



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 migration_message(input_file_keys = file_keys, input_directory_keys = directory_keys)
  message = []
  # rubocop:disable Layout/LineLength
  message << "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
  message.join(" ")
end