Class: ContainerManagementMigration::MigrationMapper

Inherits:
AspaceJsonToManagedContainerMapper show all
Defined in:
backend/app/lib/container_management_migration.rb

Overview

An extension of the standard mapper which gets handed hashes of all top containers used in the current resource and series. Uses those to avoid expensive SQL queries to search back up the tree.

Instance Method Summary (collapse)

Methods inherited from AspaceJsonToManagedContainerMapper

#call

Methods included from JSONModel

JSONModel, #JSONModel, add_error_handler, all, allow_unmapped_enum_value, backend_url, client_mode?, custom_validations, destroy_model, enum_default_value, enum_values, handle_error, init, load_schema, #models, models, parse_jsonmodel_ref, parse_reference, repository, repository_for, schema_src, set_repository, strict_mode, strict_mode?, with_repository

Constructor Details

- (MigrationMapper) initialize(json, new_record, resource_top_containers)

Returns a new instance of MigrationMapper



112
113
114
115
116
# File 'backend/app/lib/container_management_migration.rb', line 112

def initialize(json, new_record, resource_top_containers)
  super(json, new_record)

  @resource_top_containers = resource_top_containers
end

Instance Method Details

- (Object) ensure_harmonious_values(*)



125
126
127
128
129
130
131
132
# File 'backend/app/lib/container_management_migration.rb', line 125

def ensure_harmonious_values(*)
  begin
    super
  rescue ValidationException => e
    Log.error("A ValidationException was raised while the container migration took place.  Please investigate this, as it likely indicates data issues that will need to be resolved by hand")
    Log.exception(e)
  end
end

- (Object) try_matching_indicator_within_collection(container)



119
120
121
122
# File 'backend/app/lib/container_management_migration.rb', line 119

def try_matching_indicator_within_collection(container)
  indicator = container['indicator_1']
  @resource_top_containers.values.find {|top_container| top_container.indicator == indicator}
end