class TaskJuggler::Report

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.

Attributes

content[RW]
typeSpec[RW]

Public Class Methods

new(project, id, name, parent) click to toggle source

Create a new report object.

Calls superclass method TaskJuggler::PropertyTreeNode::new
# 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

Public Instance Methods

generate(requestedFormats = nil) click to toggle source

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.

  1. :html, :csv, etc.).

# 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() click to toggle source

Generate an output format agnostic version that can later be turned into the respective output formats.

# 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?() click to toggle source

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.

# File lib/taskjuggler/reports/Report.rb, line 159
def interactive?
  @project.reportContexts.first.report.get('interactive')
end
to_html() click to toggle source

Render the content of the report as HTML (without the framing).

# File lib/taskjuggler/reports/Report.rb, line 152
def to_html
  @content ? @content.to_html : nil
end