Class: GeneratorReport
- Inherits:
-
Object
- Object
- GeneratorReport
- Defined in:
- lib/hatio-core/birt/birt_report.rb
Overview
require ‘birt_report’
obj = GeneratorReport.new
obj.create_report(2057,'pdf','reporte',:consulta_id=>"237")
Constant Summary collapse
- REPORT_TEMPLATE_PATH =
File.join(RAILS_ROOT,'app','reports')
- REPORT_REPOSITORY_VPATH =
File.join(RAILS_ROOT,'public','reports')
- BIRT_GENERATOR =
File.join(ENV['BIRT_HOME'], 'ReportEngine','genReport.sh')
Instance Method Summary collapse
Instance Method Details
#create_report(user_id, format, name_report, option = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/hatio-core/birt/birt_report.rb', line 15 def create_report(user_id , format , name_report, option={}) report_path = File.join(REPORT_TEMPLATE_PATH,"#{name_report}.rptdesign") report_repository_path = File.join(REPORT_REPOSITORY_VPATH,user_id.to_s,format.to_s) name_out_report = "#{name_report}_#{Time.now.strftime('%Y%m%d%H%M%S')}.#{format}" report_out_path = File.join(report_repository_path,name_out_report) commands = "sh #{BIRT_GENERATOR}" FileUtils.mkpath(report_repository_path) unless File.directory?(report_repository_path) parameters = option.inject("") do |r,e| %Q(#{r} -p #{e[0]}=#{e[1]}) end commands << " #{parameters} " commands << " -l es" commands << " -f #{format} " commands << " -o #{report_out_path}" commands << " #{report_path}" RAILS_DEFAULT_LOGGER.info("BIRT: #{commands}") result = %x(#{commands}) result = report_out_path if $?.exitstatus == 0 "[#{$?.exitstatus}] #{result}" return name_out_report end |