Class: TaskJuggler::Report
- Inherits:
-
PropertyTreeNode
- Object
- PropertyTreeNode
- TaskJuggler::Report
- Defined in:
- lib/taskjuggler/reports/Report.rb
Overview
The Report class holds the fundamental description and functionality to turn the scheduled project into a user readable form. A report may contain other reports.
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#typeSpec ⇒ Object
Returns the value of attribute typeSpec.
Attributes inherited from PropertyTreeNode
#adoptees, #children, #data, #id, #name, #parent, #project, #propertySet, #sequenceNo, #sourceFileInfo, #subId
Instance Method Summary collapse
-
#generate(requestedFormats = nil) ⇒ Object
The generate function is where the action happens in this class.
-
#generateIntermediateFormat ⇒ Object
Generate an output format agnostic version that can later be turned into the respective output formats.
-
#initialize(project, id, name, parent) ⇒ Report
constructor
Create a new report object.
-
#interactive? ⇒ Boolean
Return true if the report should be rendered in the interactive version, false if not.
-
#to_html ⇒ Object
Render the content of the report as HTML (without the framing).
Methods inherited from PropertyTreeNode
#[], #[]=, #addChild, #adopt, #all, #allLeaves, #ancestors, #attributeDefinition, #backupAttributes, #checkFailsAndWarnings, #container?, #deep_clone, #force, #fullId, #get, #getAdopted, #getAttribute, #getBSIndicies, #getIndicies, #inheritAttributes, #inherited, #isChildOf?, #kids, #leaf?, #level, #levelSeqNo, #logicalId, #method_missing, #modified?, #parents, #provided, #ptn, #query_alert, #query_alertmessages, #query_alertsummaries, #query_alerttrend, #query_children, #query_journal, #query_journalmessages, #query_journalsummaries, #removeReferences, #restoreAttributes, #root, #set, #to_s
Methods included from MessageHandler
#critical, #debug, #error, #fatal, #info, #warning
Constructor Details
#initialize(project, id, name, parent) ⇒ Report
Create a new report object.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/taskjuggler/reports/Report.rb', line 47 def initialize(project, id, name, parent) super(project.reports, id, name, parent) @messageHandler = MessageHandlerInstance.instance checkFileName(name) project.addReport(self) # The type specifier must be set for every report. It tells whether this # is a task, resource, text or other report. @typeSpec = nil # Reports don't really have any scenario specific attributes. But the # flag handling code assumes they are. To use flags, we need them as # well. @data = Array.new(@project.scenarioCount, nil) @project.scenarioCount.times do |i| ReportScenario.new(self, i, @scenarioAttributes[i]) end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class TaskJuggler::PropertyTreeNode
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
44 45 46 |
# File 'lib/taskjuggler/reports/Report.rb', line 44 def content @content end |
#typeSpec ⇒ Object
Returns the value of attribute typeSpec.
44 45 46 |
# File 'lib/taskjuggler/reports/Report.rb', line 44 def typeSpec @typeSpec end |
Instance Method Details
#generate(requestedFormats = nil) ⇒ Object
The generate function is where the action happens in this class. The report defined by all the class attributes and report elements is generated according the the requested output format(s). requestedFormats can be a list of formats that should be generated (e.
-
:html, :csv, etc.).
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/taskjuggler/reports/Report.rb', line 70 def generate(requestedFormats = nil) oldTimeZone = TjTime.setTimeZone(get('timezone')) generateIntermediateFormat # We either generate the requested formats or the list of formats that # was specified in the report definition. (requestedFormats || get('formats')).each do |format| if @name.empty? error('empty_report_file_name', "Report #{@id} has output formats requested, but the " + "file name is empty.", sourceFileInfo) end case format when :iCal generateICal when :html generateHTML copyAuxiliaryFiles when :csv generateCSV when :ctags generateCTags when :niku generateNiku when :tjp generateTJP when :mspxml generateMspXml else raise 'Unknown report output format #{format}.' end end TjTime.setTimeZone(oldTimeZone) 0 end |
#generateIntermediateFormat ⇒ Object
Generate an output format agnostic version that can later be turned into the respective output formats.
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/taskjuggler/reports/Report.rb', line 111 def generateIntermediateFormat if get('scenarios').empty? warning('all_scenarios_disabled', "The report #{fullId} has only disabled scenarios. The " + "report will possibly be empty.") end @content = nil case @typeSpec when :accountreport @content = AccountListRE.new(self) when :export @content = ExportRE.new(self) when :iCal @content = ICalReport.new(self) when :niku @content = NikuReport.new(self) when :resourcereport @content = ResourceListRE.new(self) when :tagfile @content = TagFile.new(self) when :textreport @content = TextReport.new(self) when :taskreport @content = TaskListRE.new(self) when :tracereport @content = TraceReport.new(self) when :statusSheet @content = StatusSheetReport.new(self) when :timeSheet @content = TimeSheetReport.new(self) else raise "Unknown report type" end # Most output format can be generated from a common intermediate # representation of the elements. We generate that IR first. @content.generateIntermediateFormat if @content end |
#interactive? ⇒ Boolean
Return true if the report should be rendered in the interactive version, false if not. The top-level report defines the output format and the interactive setting.
159 160 161 |
# File 'lib/taskjuggler/reports/Report.rb', line 159 def interactive? @project.reportContexts.first.report.get('interactive') end |
#to_html ⇒ Object
Render the content of the report as HTML (without the framing).
152 153 154 |
# File 'lib/taskjuggler/reports/Report.rb', line 152 def to_html @content ? @content.to_html : nil end |