Class: ReportBuilder::FulltextReport
- Inherits:
-
Object
- Object
- ReportBuilder::FulltextReport
- Defined in:
- lib/report_builder/fulltext_report.rb
Instance Attribute Summary collapse
-
#analysis_rs ⇒ Object
readonly
Returns the value of attribute analysis_rs.
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#ars ⇒ Object
readonly
Returns the value of attribute ars.
-
#cd_h ⇒ Object
readonly
Returns the value of attribute cd_h.
-
#fields ⇒ Object
readonly
Returns the value of attribute fields.
-
#sr ⇒ Object
readonly
Returns the value of attribute sr.
Instance Method Summary collapse
- #get_inline_codes ⇒ Object
- #html_field(field_name, user_id) ⇒ Object
- #html_field_multiple(field_name, user_id) ⇒ Object
- #html_field_select(field_name, user_id) ⇒ Object
-
#initialize(sr, app) ⇒ FulltextReport
constructor
A new instance of FulltextReport.
- #multiple_info(field_name, user_id) ⇒ Object
- #output(format) ⇒ Object
- #select_info(field_name, user_id) ⇒ Object
Constructor Details
#initialize(sr, app) ⇒ FulltextReport
Returns a new instance of FulltextReport
33 34 35 36 37 38 39 40 |
# File 'lib/report_builder/fulltext_report.rb', line 33 def initialize(sr,app) @sr=sr @app=app @ars=AnalysisSystematicReview.new(sr) @cd_h=CanonicalDocument.where(:id=>@sr.cd_id_by_stage(:report)).to_hash @analysis_rs=@sr.analysis_cd @fields=@sr.fields.to_hash(:name) end |
Instance Attribute Details
#analysis_rs ⇒ Object (readonly)
Returns the value of attribute analysis_rs
32 33 34 |
# File 'lib/report_builder/fulltext_report.rb', line 32 def analysis_rs @analysis_rs end |
#app ⇒ Object (readonly)
Returns the value of attribute app
32 33 34 |
# File 'lib/report_builder/fulltext_report.rb', line 32 def app @app end |
#ars ⇒ Object (readonly)
Returns the value of attribute ars
32 33 34 |
# File 'lib/report_builder/fulltext_report.rb', line 32 def ars @ars end |
#cd_h ⇒ Object (readonly)
Returns the value of attribute cd_h
32 33 34 |
# File 'lib/report_builder/fulltext_report.rb', line 32 def cd_h @cd_h end |
#fields ⇒ Object (readonly)
Returns the value of attribute fields
32 33 34 |
# File 'lib/report_builder/fulltext_report.rb', line 32 def fields @fields end |
#sr ⇒ Object (readonly)
Returns the value of attribute sr
32 33 34 |
# File 'lib/report_builder/fulltext_report.rb', line 32 def sr @sr end |
Instance Method Details
#get_inline_codes ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/report_builder/fulltext_report.rb', line 97 def get_inline_codes cd_ids = @cd_h.keys codes=@fields.keys.inject({}) {|ac,v| ac[v]={}; ac} @analysis_rs.where(:canonical_document_id => cd_ids).each do |an| @fields.keys.each do |field| codes_an=an[field.to_sym].to_s.scan(/\[(.+?)\]/) if codes_an.length>0 codes_an.uniq.each {|code| # Busquemos el párrafo donde está el text uses=an[field.to_sym].scan(/^.+#{code[0]}.+$/) codes[field][code[0]]||=[] codes[field][code[0]].push({cd_id:an[:canonical_document_id], uses:uses}) } end end end codes end |
#html_field(field_name, user_id) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/report_builder/fulltext_report.rb', line 47 def html_field(field_name,user_id) type=@fields[field_name].type if type=='select' html_field_select(field_name,user_id) elsif type=='multiple' html_field_multiple(field_name,user_id) else raise 'not implemented' end end |
#html_field_multiple(field_name, user_id) ⇒ Object
92 93 94 95 |
# File 'lib/report_builder/fulltext_report.rb', line 92 def html_field_multiple(field_name,user_id) info=multiple_info(field_name, user_id) app.partial("reports/fulltext_table_multiple", :locals=>{info:info, cd_h:@cd_h, options_h:@fields[field_name].}) end |
#html_field_select(field_name, user_id) ⇒ Object
88 89 90 91 |
# File 'lib/report_builder/fulltext_report.rb', line 88 def html_field_select(field_name, user_id) info=select_info(field_name, user_id) app.partial("reports/fulltext_table_select", :locals=>{info:info, cd_h:@cd_h}) end |
#multiple_info(field_name, user_id) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/report_builder/fulltext_report.rb', line 74 def multiple_info(field_name,user_id) field_sym=field_name.to_sym values=@analysis_rs.select(:canonical_document_id, field_sym).where(user_id:user_id, :canonical_document_id=>@cd_h.keys) =@fields[field_name]. values.inject({}) {|ac,v| values_included=v[field_sym].nil? ? [] : v[field_sym].split(",") ac[v[:canonical_document_id]]=.keys.sort.inject({}) {|ac2,key_opt| ac2[key_opt]=values_included.include? key_opt ac2 } ac } end |
#output(format) ⇒ Object
42 43 44 |
# File 'lib/report_builder/fulltext_report.rb', line 42 def output(format) send("output_#{format}".to_sym) end |
#select_info(field_name, user_id) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/report_builder/fulltext_report.rb', line 59 def select_info(field_name,user_id) field_sym=field_name.to_sym values=@analysis_rs.select(:canonical_document_id, field_sym).where(user_id:user_id, :canonical_document_id=>@cd_h.keys).to_hash_groups(field_sym) =@fields[field_name]. #$log.info(options_h) values.inject({}) {|ac,v| ac[v[0]]={ key:v[0], text:[v[0]], canonical_documents_id:v[1].map {|vv| vv[:canonical_document_id]} } ac } end |