Created
December 21, 2012 19:22
-
-
Save anonymous/4355113 to your computer and use it in GitHub Desktop.
compiling jasper subreports, gem jasper-rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.compile_subreports(jasper_file) | |
sub_reports_path = Dir.new File.dirname(jasper_file) | |
load_jrxml_files = sub_reports_path.entries.select { |entry| File.extname(entry) == ".jrxml" } | |
load_jrxml_files.each do |subreport_jrxml_file| | |
subreport_jasper_file = "#{File.basename(subreport_jrxml_file, '.jrxml')}.jasper" | |
file_exists = !File.exist?(subreport_jasper_file) || (File.exist?(subreport_jrxml_file) | |
file_outdated = File.mtime(subreport_jrxml_file) > File.mtime(subreport_jasper_file)) | |
if file_exists && file_outdated | |
JasperCompileManager.compileReportToFile(subreport_jrxml_file, subreport_jasper_file) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment