Class: BatchLoad::Import::Otus::IdentifiersInterpreter
- Inherits:
-
BatchLoad::Import
- Object
- BatchLoad::Import
- BatchLoad::Import::Otus::IdentifiersInterpreter
- Defined in:
- lib/batch_load/import/otus/identifiers_interpreter.rb
Instance Attribute Summary
Attributes inherited from BatchLoad::Import
#create_attempted, #csv, #errors, #file, #file_errors, #import_level, #processed, #processed_rows, #project, #project_id, #successful_rows, #total_data_lines, #total_lines, #user, #user_header_map, #user_id
Instance Method Summary collapse
- #build ⇒ Boolean
- #build_otus ⇒ Integer
-
#initialize(**args) ⇒ IdentifiersInterpreter
constructor
A new instance of IdentifiersInterpreter.
Methods inherited from BatchLoad::Import
#all_objects, #create, #create_attempted?, #import_level_ok?, #line_strict_level_ok?, #processed?, #ready_to_create?, #save_order, #sorted_processed_rows, #strict_level_ok?, #total_records_created, #user_map, #valid?, #valid_objects, #warn_level_ok?
Constructor Details
#initialize(**args) ⇒ IdentifiersInterpreter
Returns a new instance of IdentifiersInterpreter.
5 6 7 |
# File 'lib/batch_load/import/otus/identifiers_interpreter.rb', line 5 def initialize(**args) super(**args) end |
Instance Method Details
#build ⇒ Boolean
51 52 53 54 55 56 |
# File 'lib/batch_load/import/otus/identifiers_interpreter.rb', line 51 def build if valid? build_otus @processed = true end end |
#build_otus ⇒ Integer
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/batch_load/import/otus/identifiers_interpreter.rb', line 10 def build_otus @total_data_lines = 0 i = 0 # loop through rows csv.each do |row| i += 1 parse_result = BatchLoad::RowParse.new parse_result.objects[:otu] = [] @processed_rows[i] = parse_result begin # processing otu_identifier_uri_text = row['uri'] otu_identifier_uri = { type: 'Identifier::Global::Uri', identifier: otu_identifier_uri_text } otu_identifiers = [] otu_identifiers.push(otu_identifier_uri) if otu_identifier_uri_text.present? otu_attributes = { name: row['name'], identifiers_attributes: otu_identifiers } otu = Otu.new(otu_attributes) parse_result.objects[:otu].push otu @total_data_lines += 1 if otu.present? rescue # .... end end @total_lines = i end |