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?, #conversion_options, #forced?, #not_forced?

Constructor Details

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

Returns a new instance of RepositoryMigrator.



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

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

Instance Attribute Details

#namespaceObject

Returns the value of attribute namespace.



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

def namespace
  @namespace
end

#reportObject

Returns the value of attribute report.



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

def report
  @report
end

#source_objectsObject

Returns the value of attribute source_objects.



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

def source_objects
  @source_objects
end

Instance Method Details

#failuresObject



35
36
37
# File 'lib/fedora_migrate/repository_migrator.rb', line 35

def failures
  report.failed_objects.count
end

#get_source_objectsObject



27
28
29
30
31
32
33
# File 'lib/fedora_migrate/repository_migrator.rb', line 27

def get_source_objects
  if report.empty?
    FedoraMigrate.source.connection.search(nil).collect { |o| qualifying_object(o) }.compact
  else
    report.failed_objects.map { |o| FedoraMigrate.source.connection.find(o) }
  end
end

#migrate_objectsObject



18
19
20
# File 'lib/fedora_migrate/repository_migrator.rb', line 18

def migrate_objects
  source_objects.each { |source| migrate_object(source) }
end

#migrate_relationshipsObject



22
23
24
25
# File 'lib/fedora_migrate/repository_migrator.rb', line 22

def migrate_relationships
  return "Relationship migration halted because #{failures.to_s} objects didn't migrate successfully." if failures > 0 && not_forced?
  source_objects.each { |source| migrate_relationship(source) }
end