Class: FedoraMigrate::RepositoryMigrator

Inherits:
Object
  • Object
show all
Includes:
MigrationOptions
Defined in:
lib/fedora_migrate/repository_migrator.rb

Defined Under Namespace

Classes: SingleObjectReport

Instance Attribute Summary collapse

Attributes included from MigrationOptions

#conversions, #options

Instance Method Summary collapse

Methods included from MigrationOptions

#application_creates_versions?, #blacklist, #conversion_options, #forced?, #not_forced?

Constructor Details

#initialize(namespace = nil, options = {}) ⇒ RepositoryMigrator

Returns a new instance of RepositoryMigrator.



9
10
11
12
13
14
# File 'lib/fedora_migrate/repository_migrator.rb', line 9

def initialize(namespace = nil, options = {})
  @namespace = namespace || repository_namespace
  @options = options
  @report = MigrationReport.new(@options.fetch(:report, nil))
  conversion_options
end

Instance Attribute Details

#namespaceObject

Returns the value of attribute namespace.



5
6
7
# File 'lib/fedora_migrate/repository_migrator.rb', line 5

def namespace
  @namespace
end

#reportObject

Returns the value of attribute report.



5
6
7
# File 'lib/fedora_migrate/repository_migrator.rb', line 5

def report
  @report
end

#resultObject

Returns the value of attribute result.



5
6
7
# File 'lib/fedora_migrate/repository_migrator.rb', line 5

def result
  @result
end

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/fedora_migrate/repository_migrator.rb', line 5

def source
  @source
end

#source_objectsObject

Returns the value of attribute source_objects.



5
6
7
# File 'lib/fedora_migrate/repository_migrator.rb', line 5

def source_objects
  @source_objects
end

Instance Method Details

#failuresObject



49
50
51
# File 'lib/fedora_migrate/repository_migrator.rb', line 49

def failures
  report.failed_objects.count
end

#initialize_reportObject



30
31
32
33
34
# File 'lib/fedora_migrate/repository_migrator.rb', line 30

def initialize_report
  @result = SingleObjectReport.new
  @result.status = false
  report.save(source.pid, @result)
end

#migrate_current_objectObject



24
25
26
27
28
# File 'lib/fedora_migrate/repository_migrator.rb', line 24

def migrate_current_object
  return unless migration_required?
  initialize_report
  migrate_object
end

#migrate_objectsObject



16
17
18
19
20
21
22
# File 'lib/fedora_migrate/repository_migrator.rb', line 16

def migrate_objects
  source_objects.each do |object|
    @source = object
    migrate_current_object
  end
  report.reload
end

#migrate_relationshipsObject



36
37
38
39
40
41
42
43
# File 'lib/fedora_migrate/repository_migrator.rb', line 36

def migrate_relationships
  return "Relationship migration halted because #{failures} objects didn't migrate successfully." if failures > 0 && not_forced?
  source_objects.each do |object|
    @source = object
    @result = find_or_create_single_object_report
    migrate_relationship unless blacklist.include?(source.pid)
  end
end