Class: BulkImportReport

Inherits:
Object
  • Object
show all
Defined in:
backend/app/lib/bulk_import/bulk_import_report.rb

Defined Under Namespace

Classes: Row

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBulkImportReport

Returns a new instance of BulkImportReport.



2
3
4
5
6
7
8
9
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 2

def initialize
  @rows = []
  @current_row = nil
  @terminal_error = ""
  @file_name = nil
  @error_rows = 0
  @terminal_error = nil
end

Instance Attribute Details

#file_nameObject (readonly)

Returns the value of attribute file_name



47
48
49
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 47

def file_name
  @file_name
end

#rowsObject (readonly)

Returns the value of attribute rows



62
63
64
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 62

def rows
  @rows
end

#terminal_errorObject (readonly)

Returns the value of attribute terminal_error



64
65
66
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 64

def terminal_error
  @terminal_error
end

Instance Method Details

#add_archival_object(ao) ⇒ Object



20
21
22
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 20

def add_archival_object(ao)
  @current_row.archival_object(ao) if ao
end

#add_errors(errors) ⇒ Object



11
12
13
14
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 11

def add_errors(errors)
  @error_rows += 1 if @current_row.errors.empty?
  @current_row.add_errors(errors)
end

#add_info(info) ⇒ Object



16
17
18
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 16

def add_info(info)
  @current_row.add_info(info)
end

#add_terminal_error(error, counter) ⇒ Object

If we stop processing before getting to the end of the spreadsheet, we want that reported out special



25
26
27
28
29
30
31
32
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 25

def add_terminal_error(error, counter)
  if counter
    @terminal_error = I18n.t("bulk_import.error.stopped", row: counter, msg: error)
  else
    @terminal_error = I18n.t("bulk_import.error.initialize", msg: error)
  end
  end_row
end

#current_rowObject



34
35
36
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 34

def current_row
  @current_row
end

#end_rowObject



38
39
40
41
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 38

def end_row
  @rows.push @current_row if @current_row
  @current_row = nil
end

#in_errors(what) ⇒ Object



43
44
45
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 43

def in_errors(what)
  @current_row.errors.include?(what)
end

#new_row(row_number) ⇒ Object



49
50
51
52
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 49

def new_row(row_number)
  @rows.push @current_row if @current_row
  @current_row = Row.new(row_number)
end

#row_countObject



54
55
56
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 54

def row_count
  @rows.length
end

#set_file_name(file_name) ⇒ Object



58
59
60
# File 'backend/app/lib/bulk_import/bulk_import_report.rb', line 58

def set_file_name(file_name)
  @file_name = file_name || I18n.t("bulk_import.error.file_name")
end