Class: TaskJuggler::ReportBase

Inherits:
Object
  • Object
show all
Defined in:
lib/taskjuggler/reports/ReportBase.rb

Overview

This is the abstract base class for all kinds of reports. The derived classes must implement the generateIntermediateFormat function as well as the to_* members.

Instance Method Summary collapse

Constructor Details

#initialize(report) ⇒ ReportBase

Returns a new instance of ReportBase.



21
22
23
24
# File 'lib/taskjuggler/reports/ReportBase.rb', line 21

def initialize(report)
  @report = report
  @project = report.project
end

Instance Method Details

#a(attribute) ⇒ Object

Convenience function to access a report attribute



27
28
29
# File 'lib/taskjuggler/reports/ReportBase.rb', line 27

def a(attribute)
  @report.get(attribute)
end

#filterAccountList(list_, hideExpr, rollupExpr, openNodes) ⇒ Object

Take the complete account list and remove all accounts that are matching the hide expression, the rollup Expression or are not a descendent of accountroot.



44
45
46
47
48
49
50
51
52
53
# File 'lib/taskjuggler/reports/ReportBase.rb', line 44

def filterAccountList(list_, hideExpr, rollupExpr, openNodes)
  list = PropertyList.new(list_)
  if (accountroot = a('accountroot'))
    # Remove all accounts that are not descendents of the accountroot.
    list.delete_if { || !.isChildOf?(accountroot) }
  end

  standardFilterOps(list, hideExpr, rollupExpr, openNodes, nil,
                    accountroot)
end

#filterResourceList(list_, task, hideExpr, rollupExpr, openNodes) ⇒ Object

Take the complete resource list and remove all resources that are matching the hide expression, the rollup Expression or are not a descendent of resourceroot. In case task is not nil, a resource is only included if it is assigned to the task in any of the reported scenarios.



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/taskjuggler/reports/ReportBase.rb', line 91

def filterResourceList(list_, task, hideExpr, rollupExpr, openNodes)
  list = PropertyList.new(list_)
  if (resourceRoot = a('resourceroot'))
    # Remove all resources that are not descendents of the resourceRoot.
    list.delete_if { |resource| !resource.isChildOf?(resourceRoot) }
  end

  if task
    # If we have a task we need to check that the resources are assigned
    # to the task in any of the reported scenarios.
    iv = TimeInterval.new(a('start'), a('end'))
    list.delete_if do |resource|
      delete = true
      a('scenarios').each do |scenarioIdx|
        if task.hasResourceAllocated?(scenarioIdx, iv, resource)
          delete = false
          break;
        end
      end
      delete
    end
  end

  standardFilterOps(list, hideExpr, rollupExpr, openNodes, task,
                    resourceRoot)
end

#filterTaskList(list_, resource, hideExpr, rollupExpr, openNodes) ⇒ Object

Take the complete task list and remove all tasks that are matching the hide expression, the rollup Expression or are not a descendent of taskroot. In case resource is not nil, a task is only included if the resource is allocated to it in any of the reported scenarios.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/taskjuggler/reports/ReportBase.rb', line 59

def filterTaskList(list_, resource, hideExpr, rollupExpr, openNodes)
  list = PropertyList.new(list_)
  if (taskRoot = a('taskroot'))
    # Remove all tasks that are not descendents of the taskRoot.
    list.delete_if { |task| !task.isChildOf?(taskRoot) }
  end

  if resource
    # If we have a resource we need to check that the resource is allocated
    # to the tasks in any of the reported scenarios within the report time
    # frame.
    list.delete_if do |task|
      delete = true
      a('scenarios').each do |scenarioIdx|
        iv = TimeInterval.new(a('start'), a('end'))
        if task.hasResourceAllocated?(scenarioIdx, iv, resource)
          delete = false
          break;
        end
      end
      delete
    end
  end

  standardFilterOps(list, hideExpr, rollupExpr, openNodes, resource,
                    taskRoot)
end

#generateIntermediateFormatObject



31
32
33
34
35
36
37
38
39
# File 'lib/taskjuggler/reports/ReportBase.rb', line 31

def generateIntermediateFormat
  query = @report.project.reportContexts.last.query
  %w( header left center right footer
      prolog headline caption epilog ).each do |name|
    next unless (text = a(name))

    text.setQuery(query)
  end
end