Class: JasperReport
- Inherits:
-
Object
- Object
- JasperReport
- Includes:
- Java, ReportManager::Mixin
- Defined in:
- backend/app/model/reports/jasper_report.rb
Direct Known Subclasses
Instance Attribute Summary (collapse)
-
- (Object) data_source
Returns the value of attribute data_source.
-
- (Object) export_file
Returns the value of attribute export_file.
-
- (Object) format
Returns the value of attribute format.
-
- (Object) jrprint
Returns the value of attribute jrprint.
Class Method Summary (collapse)
-
+ (Object) compile
this method compiles our jrxml files into jasper files.
-
+ (Object) finalize(obj)
this makes sure all our tempfiles get unlinked…
-
+ (Object) report
-
+ (Object) report_base
Instance Method Summary (collapse)
-
- (JasperReport) initialize(params = {})
constructor
A new instance of JasperReport.
-
- (Object) report
the convention is that the compiled primary report will be located in AS_BASE/reports/ClassNameReport/ClassNameReport.jasper.
-
- (Object) title
Methods included from ReportManager::Mixin
Constructor Details
- (JasperReport) initialize(params = {})
Returns a new instance of JasperReport
36 37 38 39 40 41 |
# File 'backend/app/model/reports/jasper_report.rb', line 36 def initialize(params = {}) @repo_id = params[:repo_id] if params.has_key?(:repo_id) && params[:repo_id] != "" @base_path = File.dirname(self.class.report) @format = params[:format] if params.has_key?(:format) && params[:format] != "" ObjectSpace.define_finalizer( self, self.class.finalize(self) ) end |
Instance Attribute Details
- (Object) data_source
Returns the value of attribute data_source
33 34 35 |
# File 'backend/app/model/reports/jasper_report.rb', line 33 def data_source @data_source end |
- (Object) export_file
Returns the value of attribute export_file
32 33 34 |
# File 'backend/app/model/reports/jasper_report.rb', line 32 def export_file @export_file end |
- (Object) format
Returns the value of attribute format
34 35 36 |
# File 'backend/app/model/reports/jasper_report.rb', line 34 def format @format end |
- (Object) jrprint
Returns the value of attribute jrprint
31 32 33 |
# File 'backend/app/model/reports/jasper_report.rb', line 31 def jrprint @jrprint end |
Class Method Details
+ (Object) compile
this method compiles our jrxml files into jasper files
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'backend/app/model/reports/jasper_report.rb', line 57 def self.compile StaticAssetFinder.new('reports').find_by_extension(".jrxml").each do |jrxml| begin JasperCompileManager.compile_report_to_file(jrxml, jrxml.gsub(".jrxml", ".jasper")) rescue => e $stderr.puts "*" * 100 $stderr.puts "*** JASPER REPORTS ERROR :" $stderr.puts "*** Unable to compile #{jrxml}" $stderr.puts "*** #{e.inspect}" $stderr.puts "*" * 100 end end end |
+ (Object) finalize(obj)
this makes sure all our tempfiles get unlinked…
73 74 75 76 77 78 79 80 |
# File 'backend/app/model/reports/jasper_report.rb', line 73 def self.finalize(obj) proc { unless obj.export_file.nil? obj.export_file.close! end obj.datasource.close! } end |
+ (Object) report
82 83 84 85 86 |
# File 'backend/app/model/reports/jasper_report.rb', line 82 def self.report StaticAssetFinder.new(report_base).find_all( self.name + ".jasper").find do |f| File.basename(f, '.jasper') == self.name end end |
+ (Object) report_base
88 89 90 |
# File 'backend/app/model/reports/jasper_report.rb', line 88 def self.report_base "reports" end |
Instance Method Details
- (Object) report
the convention is that the compiled primary report will be located in AS_BASE/reports/ClassNameReport/ClassNameReport.jasper
52 53 54 |
# File 'backend/app/model/reports/jasper_report.rb', line 52 def report self.class.report end |
- (Object) title
43 44 45 |
# File 'backend/app/model/reports/jasper_report.rb', line 43 def title self.class.name end |