Sha256: 017c0c983040ee5702e88c854be79262edff4012aa4f9913caa3b06b1a0a6486

Contents?: true

Size: 1.57 KB

Versions: 1

Compression:

Stored size: 1.57 KB

Contents

require "fileutils"

#  require 'birt_report'
#  obj = GeneratorReport.new
#  obj.create_report(2057,'pdf','reporte',:consulta_id=>"237")
#

class GeneratorReport

 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')


  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

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hatio-core-0.0.6 lib/hatio-core/birt/birt_report.rb