Class TaskJuggler::ReportContext
In: lib/taskjuggler/reports/ReportContext.rb
Parent: Object

The ReportContext objects provide some settings that are used during the generation of a report. Reports can be nested, so multiple objects can exist at a time. But there is only one current ReportContext that is always accessable via Project.reportContexts.last().

Methods

new  

Attributes

attributeBackup  [RW] 
childReportCounter  [RW] 
dynamicReportId  [R] 
project  [R] 
query  [R] 
report  [R] 
resources  [RW] 
tasks  [RW] 

Public Class methods

[Source]

# File lib/taskjuggler/reports/ReportContext.rb, line 25
    def initialize(project, report)
      @project = project
      @report = report
      @childReportCounter = 0
      @attributeBackup = nil
      queryAttrs = {
        'project' => @project,
        'loadUnit' => @report.get('loadUnit'),
        'numberFormat' => @report.get('numberFormat'),
        'timeFormat' => @report.get('timeFormat'),
        'currencyFormat' => @report.get('currencyFormat'),
        'start' => @report.get('start'), 'end' => @report.get('end'),
        'hideJournalEntry' => @report.get('hideJournalEntry'),
        'journalMode' => @report.get('journalMode'),
        'journalAttributes' => @report.get('journalAttributes'),
        'sortJournalEntries' => @report.get('sortJournalEntries'),
        'costAccount' => @report.get('costaccount'),
        'revenueAccount' => @report.get('revenueaccount')
      }
      @query = Query.new(queryAttrs)
      if (@parent = @project.reportContexts.last)
        # For interactive reports we need some ID that uniquely identifies the
        # report within the composed report. Since a project report can be
        # included multiple times in the same report, we need to generate
        # another ID for each instantiated report. We create this report by
        # using a counter for the number of child reports that each report
        # has. The unique ID is then the concatenated list of counters from
        # parent to leaf, separating each value by a '.'.
        @dynamicReportId = @parent.dynamicReportId +
                           ".#{@parent.childReportCounter}"
        @parent.childReportCounter += 1
        # If the new ReportContext is created from within an existing context,
        # this is used as parent context and the settings are copied as
        # default initial values.
        @tasks = @parent.tasks.dup
        @resources = @parent.resources.dup
      else
        # The ID of the root report is always "0". The first child will then
        # be "0.0", the seconds "0.1" and so on.
        @dynamicReportId = "0"
        # There is no existing ReportContext yet, so we create one based on
        # the settings of the report.
        @tasks = @project.tasks.dup
        @resources = @project.resources.dup
      end
    end

[Validate]