Class: AbstractReport
- Inherits:
-
Object
- Object
- AbstractReport
- Defined in:
- backend/app/model/reports/abstract_report.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
-
#expand_csv ⇒ Object
Returns the value of attribute expand_csv.
-
#format ⇒ Object
Returns the value of attribute format.
-
#info ⇒ Object
Returns the value of attribute info.
-
#job ⇒ Object
Returns the value of attribute job.
-
#page_break ⇒ Object
Returns the value of attribute page_break.
-
#params ⇒ Object
Returns the value of attribute params.
-
#repo_id ⇒ Object
Returns the value of attribute repo_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#after_tasks ⇒ Object
-
#code ⇒ Object
-
#current_user ⇒ Object
-
#fix_row(row) ⇒ Object
-
#get_content ⇒ Object
-
#identifier_field ⇒ Object
-
#initialize(params, job, db) ⇒ AbstractReport
constructor
A new instance of AbstractReport.
-
#layout ⇒ Object
-
#orientation ⇒ Object
-
#query ⇒ Object
-
#query_string ⇒ Object
-
#repository ⇒ Object
-
#special_translation(key, subreport_code) ⇒ Object
-
#title ⇒ Object
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] != '' = !(params.has_key?('csv_show_json') ? params['csv_show_json'] : false) @params = params @db = db @job = job @info = {} end |
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db
12 13 14 |
# File 'backend/app/model/reports/abstract_report.rb', line 12 def db @db end |
#expand_csv ⇒ Object
Returns the value of attribute expand_csv
16 17 18 |
# File 'backend/app/model/reports/abstract_report.rb', line 16 def end |
#format ⇒ Object
Returns the value of attribute format
10 11 12 |
# File 'backend/app/model/reports/abstract_report.rb', line 10 def format @format end |
#info ⇒ Object
Returns the value of attribute info
14 15 16 |
# File 'backend/app/model/reports/abstract_report.rb', line 14 def info @info end |
#job ⇒ Object
Returns the value of attribute job
13 14 15 |
# File 'backend/app/model/reports/abstract_report.rb', line 13 def job @job end |
#page_break ⇒ Object
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 |
#params ⇒ Object
Returns the value of attribute params
11 12 13 |
# File 'backend/app/model/reports/abstract_report.rb', line 11 def params @params end |
#repo_id ⇒ Object
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
.code ⇒ Object
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_tasks ⇒ Object
70 |
# File 'backend/app/model/reports/abstract_report.rb', line 70 def after_tasks; end |
#code ⇒ Object
72 73 74 |
# File 'backend/app/model/reports/abstract_report.rb', line 72 def code self.class.code end |
#current_user ⇒ Object
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_content ⇒ Object
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_field ⇒ Object
80 81 82 |
# File 'backend/app/model/reports/abstract_report.rb', line 80 def identifier_field nil end |
#layout ⇒ Object
40 41 42 |
# File 'backend/app/model/reports/abstract_report.rb', line 40 def layout AppConfig[:report_page_layout] end |
#orientation ⇒ Object
36 37 38 |
# File 'backend/app/model/reports/abstract_report.rb', line 36 def orientation 'portrait' end |
#query ⇒ Object
60 61 62 |
# File 'backend/app/model/reports/abstract_report.rb', line 60 def query db.fetch(query_string) end |
#query_string ⇒ Object
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 |
#repository ⇒ Object
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 |
#title ⇒ Object
32 33 34 |
# File 'backend/app/model/reports/abstract_report.rb', line 32 def title I18n.t("reports.#{code}.title", :default => code) end |