Class: InstanceData

Inherits:
Struct
  • Object
show all
Includes:
JSONModel
Defined in:
backend/app/lib/user_defined_field_migrator.rb

Constant Summary collapse

UNKNOWN_DIMENSION =
'99999999'

Constants included from JSONModel

JSONModel::REFERENCE_KEY_REGEX

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from JSONModel

JSONModel, #JSONModel, add_error_handler, all, allow_unmapped_enum_value, backend_url, check_valid_refs, 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_publish_flags!, set_repository, strict_mode, strict_mode?, validate_schema, with_repository

Instance Attribute Details

#box_typeObject

Returns the value of attribute box_type

Returns:

  • (Object)

    the current value of box_type



333
334
335
# File 'backend/app/lib/user_defined_field_migrator.rb', line 333

def box_type
  @box_type
end

#exported_to_voyagerObject

Returns the value of attribute exported_to_voyager

Returns:

  • (Object)

    the current value of exported_to_voyager



333
334
335
# File 'backend/app/lib/user_defined_field_migrator.rb', line 333

def exported_to_voyager
  @exported_to_voyager
end

#restrictedObject

Returns the value of attribute restricted

Returns:

  • (Object)

    the current value of restricted



333
334
335
# File 'backend/app/lib/user_defined_field_migrator.rb', line 333

def restricted
  @restricted
end

#voyager_infoObject

Returns the value of attribute voyager_info

Returns:

  • (Object)

    the current value of voyager_info



333
334
335
# File 'backend/app/lib/user_defined_field_migrator.rb', line 333

def voyager_info
  @voyager_info
end

Class Method Details

.from_row(row) ⇒ Object



339
340
341
342
# File 'backend/app/lib/user_defined_field_migrator.rb', line 339

def self.from_row(row)
  new(row[:userDefinedString1], row[:userDefinedString2],
      row[:userDefinedBoolean1], row[:userDefinedBoolean2])
end

Instance Method Details

#container_profileObject



357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'backend/app/lib/user_defined_field_migrator.rb', line 357

def container_profile
  if !box_type || box_type.empty?
    return nil
  end

  profile = ContainerProfile[:name => box_type]

  if !profile
    profile = ContainerProfile.create_from_json(JSONModel(:container_profile).from_hash('name' => box_type,
                                                                                        'dimension_units' => 'inches',
                                                                                        'extent_dimension' => 'width',
                                                                                        'height' => UNKNOWN_DIMENSION,
                                                                                        'width' => UNKNOWN_DIMENSION,
                                                                                        'depth' => UNKNOWN_DIMENSION))
  end

  profile
end

#empty?Boolean

Returns:

  • (Boolean)


377
378
379
# File 'backend/app/lib/user_defined_field_migrator.rb', line 377

def empty?
  voyager_info.empty? && box_type.empty? && restricted.nil? && exported_to_voyager.nil?
end

#voyager_bib_idObject



345
346
347
348
349
# File 'backend/app/lib/user_defined_field_migrator.rb', line 345

def voyager_bib_id
  if voyager_info && !voyager_info.empty?
    self[:voyager_info].split("_")[0]
  end
end

#voyager_holding_idObject



351
352
353
354
355
# File 'backend/app/lib/user_defined_field_migrator.rb', line 351

def voyager_holding_id
  if voyager_info && !voyager_info.empty?
    self[:voyager_info].split("_")[1]
  end
end