Class: AbstractReport

Inherits:
Object
  • Object
show all
Defined in:
backend/app/model/reports/abstract_report.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, job, db) ⇒ AbstractReport

Returns a new instance of AbstractReport.



18
19
20
21
22
23
24
25
26
# File 'backend/app/model/reports/abstract_report.rb', line 18

def initialize(params, job, db)
  @repo_id = params[:repo_id] if params.has_key?(:repo_id) && params[:repo_id] != ''
  @format = params[:format] if params.has_key?(:format) && params[:format] != ''
  @expand_csv = !(params.has_key?('csv_show_json') ? params['csv_show_json'] : false)
  @params = params
  @db = db
  @job = job
  @info = {}
end

Instance Attribute Details

#dbObject

Returns the value of attribute db



12
13
14
# File 'backend/app/model/reports/abstract_report.rb', line 12

def db
  @db
end

#expand_csvObject

Returns the value of attribute expand_csv



16
17
18
# File 'backend/app/model/reports/abstract_report.rb', line 16

def expand_csv
  @expand_csv
end

#formatObject

Returns the value of attribute format



10
11
12
# File 'backend/app/model/reports/abstract_report.rb', line 10

def format
  @format
end

#infoObject

Returns the value of attribute info



14
15
16
# File 'backend/app/model/reports/abstract_report.rb', line 14

def info
  @info
end

#jobObject

Returns the value of attribute job



13
14
15
# File 'backend/app/model/reports/abstract_report.rb', line 13

def job
  @job
end

#page_breakObject

Returns the value of attribute page_break



15
16
17
# File 'backend/app/model/reports/abstract_report.rb', line 15

def page_break
  @page_break
end

#paramsObject

Returns the value of attribute params



11
12
13
# File 'backend/app/model/reports/abstract_report.rb', line 11

def params
  @params
end

#repo_idObject

Returns the value of attribute repo_id



9
10
11
# File 'backend/app/model/reports/abstract_report.rb', line 9

def repo_id
  @repo_id
end

Class Method Details

.codeObject



76
77
78
# File 'backend/app/model/reports/abstract_report.rb', line 76

def self.code
  self.name.gsub(/(.)([A-Z])/, '\1_\2').downcase
end

Instance Method Details

#after_tasksObject



70
# File 'backend/app/model/reports/abstract_report.rb', line 70

def after_tasks; end

#codeObject



72
73
74
# File 'backend/app/model/reports/abstract_report.rb', line 72

def code
  self.class.code
end

#current_userObject



44
45
46
# File 'backend/app/model/reports/abstract_report.rb', line 44

def current_user
  @job.owner
end

#fix_row(row) ⇒ Object



68
# File 'backend/app/model/reports/abstract_report.rb', line 68

def fix_row(row) end

#get_contentObject



48
49
50
51
52
53
54
55
56
57
58
# File 'backend/app/model/reports/abstract_report.rb', line 48

def get_content
  array = []
  query.each do |result|
    row = result.to_hash
    fix_row(row)
    array.push(row)
  end
  info[:repository] = repository
  after_tasks
  array
end

#identifier_fieldObject



80
81
82
# File 'backend/app/model/reports/abstract_report.rb', line 80

def identifier_field
  nil
end

#layoutObject



40
41
42
# File 'backend/app/model/reports/abstract_report.rb', line 40

def layout
  AppConfig[:report_page_layout]
end

#orientationObject



36
37
38
# File 'backend/app/model/reports/abstract_report.rb', line 36

def orientation
  'portrait'
end

#queryObject



60
61
62
# File 'backend/app/model/reports/abstract_report.rb', line 60

def query
  db.fetch(query_string)
end

#query_stringObject



64
65
66
# File 'backend/app/model/reports/abstract_report.rb', line 64

def query_string
  raise 'Please specify a query string to return your reportable results'
end

#repositoryObject



84
85
86
# File 'backend/app/model/reports/abstract_report.rb', line 84

def repository
  Repository.get_or_die(repo_id).name
end

#special_translation(key, subreport_code) ⇒ Object



88
89
90
# File 'backend/app/model/reports/abstract_report.rb', line 88

def special_translation(key, subreport_code)
  nil
end

#titleObject



32
33
34
# File 'backend/app/model/reports/abstract_report.rb', line 32

def title
  I18n.t("reports.#{code}.title", :default => code)
end