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.



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

#resultObject

Returns the value of attribute result.



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

def result
  @result
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
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



51
52
53
# File 'lib/fedora_migrate/repository_migrator.rb', line 51

def failures
  report.failed_objects.count
end

#get_source_objectsObject



47
48
49
# File 'lib/fedora_migrate/repository_migrator.rb', line 47

def get_source_objects
  FedoraMigrate.source.connection.search(nil).collect { |o| qualifying_object(o) }.compact
end

#initialize_reportObject



32
33
34
35
36
# File 'lib/fedora_migrate/repository_migrator.rb', line 32

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

#migrate_current_objectObject



26
27
28
29
30
# File 'lib/fedora_migrate/repository_migrator.rb', line 26

def migrate_current_object
  return unless migration_required?
  initialize_report
  migrate_object
end

#migrate_objectsObject



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

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

#migrate_relationshipsObject



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

def migrate_relationships
  return "Relationship migration halted because #{failures.to_s} 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