Class: Hyrax::Collections::MigrationService

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/collections/migration_service.rb

Overview

Responsible for migrating legacy collections. Legacy collections are those created before Hyrax 2.1.0 and are identified by the lack of the collection having a collection type gid.

Class Method Summary collapse

Class Method Details

.migrate_all_collectionsObject

Migrate all legacy collections to extended collections with collection type assigned. Legacy collections are those created before Hyrax 2.1.0 and are identified by the lack of the collection having a collection type gid.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/services/hyrax/collections/migration_service.rb', line 10

def self.migrate_all_collections
  Rails.logger.info "*** Migrating #{Collection.count} collections"
  Collection.all.each do |col|
    migrate_collection(col)
    Rails.logger.info "  migrating collection - id: #{col.id}, title: #{col.title}"
  end

  AdminSet.all.each do |adminset|
    migrate_adminset(adminset)
    Rails.logger.info "  migrating adminset - id: #{adminset.id}, title: #{adminset.title}"
  end
  Rails.logger.info "--- Migration Complete"
end

.repair_migrated_collectionsObject

Validate that migrated collections have both the collection type gid assigned and the permission template with access created and associated with the collection. Any collection without collection type gid as nil or assigned the default collection type are ignored.



57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/services/hyrax/collections/migration_service.rb', line 57

def self.repair_migrated_collections
  Rails.logger.info "*** Repairing migrated collections"
  Collection.all.each do |col|
    repair_migrated_collection(col)
    Rails.logger.info "  repairing collection - id: #{col.id}, title: #{col.title}"
  end
  AdminSet.all.each do |adminset|
    migrate_adminset(adminset)
    Rails.logger.info "  repairing adminset - id: #{adminset.id}, title: #{adminset.title}"
  end
  Rails.logger.info "--- Repairing Complete"
end