Class: JasperServer::ReportRequest
- Inherits:
-
Object
- Object
- JasperServer::ReportRequest
- Defined in:
- lib/jasper_server/report_request.rb
Overview
Represents a request for a report, to be sent to the JasperServer via the JasperServer::Client.
Instance Attribute Summary collapse
-
#output_format ⇒ Object
Returns the value of attribute output_format.
-
#report_params ⇒ Object
Returns the value of attribute report_params.
-
#report_unit ⇒ Object
Returns the value of attribute report_unit.
Class Method Summary collapse
-
.convert_time_to_jasper_timestamp(time) ⇒ Object
Converts the given Time/DateTime/Date into a timestamp integer acceptable by JasperServer.
Instance Method Summary collapse
-
#initialize(report_unit, output_format, report_params = {}) ⇒ ReportRequest
constructor
The request consists of three arguments:.
Constructor Details
#initialize(report_unit, output_format, report_params = {}) ⇒ ReportRequest
The request consists of three arguments:
- report_unit
-
The path on the JasperServer to the “report unit” (i.e. a bundle consisting of the JRXML file and other resources used in the report). E.g.:
/example/my-report
- output_format
-
The desired output format. E.g.:
PDF
,CSV
,HTML
, etc. - report_params
-
Hash of parameters to be fed into the report. The client will take care of performing the appropriate type conversions (for example, Time values are turned into integer timestamps and are automatically adjusted for timezone). E.g.
{ 'fruit' => "Apple", 'date' => Time.now}
20 21 22 23 24 25 |
# File 'lib/jasper_server/report_request.rb', line 20 def initialize(report_unit, output_format, report_params = {}) raise ArgumentError, "Missing output_format in report request!" if output_format.nil? || output_format.empty? @report_unit = report_unit @output_format = output_format.upcase @report_params = report_params end |
Instance Attribute Details
#output_format ⇒ Object
Returns the value of attribute output_format.
6 7 8 |
# File 'lib/jasper_server/report_request.rb', line 6 def output_format @output_format end |
#report_params ⇒ Object
Returns the value of attribute report_params.
6 7 8 |
# File 'lib/jasper_server/report_request.rb', line 6 def report_params @report_params end |
#report_unit ⇒ Object
Returns the value of attribute report_unit.
6 7 8 |
# File 'lib/jasper_server/report_request.rb', line 6 def report_unit @report_unit end |
Class Method Details
.convert_time_to_jasper_timestamp(time) ⇒ Object
Converts the given Time/DateTime/Date into a timestamp integer acceptable by JasperServer. The timezone adjustment is performed (converted to UTC).
29 30 31 32 33 34 35 36 37 |
# File 'lib/jasper_server/report_request.rb', line 29 def self.(time) time = Time.parse(time.to_s) unless time.kind_of?(Time) # convert to milisecond timestamp ts = time.to_i * 1000 # adjust for timezone ts -= time.utc_offset * 1000 return ts end |