class TaskJuggler::Resource

Public Class Methods

new(project, id, name, parent) click to toggle source
Calls superclass method TaskJuggler::PropertyTreeNode::new
# File lib/taskjuggler/Resource.rb, line 21
def initialize(project, id, name, parent)
  super(project.resources, id, name, parent)
  project.addResource(self)

  @data = Array.new(@project.scenarioCount, nil)
  @project.scenarioCount.times do |i|
    ResourceScenario.new(self, i, @scenarioAttributes[i])
  end
end

Public Instance Methods

book(scenarioIdx, sbIdx, task) click to toggle source

Just a shortcut to avoid the slower calls via method_missing.

# File lib/taskjuggler/Resource.rb, line 32
def book(scenarioIdx, sbIdx, task)
  @data[scenarioIdx].book(sbIdx, task)
end
method_missing(func, scenarioIdx = 0, *args, &block) click to toggle source

Many Resource functions are scenario specific. These functions are provided by the class ResourceScenario. In case we can't find a function called for the Resource class we try to find it in ResourceScenario.

# File lib/taskjuggler/Resource.rb, line 40
def method_missing(func, scenarioIdx = 0, *args, &block)
  @data[scenarioIdx].method(func).call(*args, &block)
end
query_dashboard(query) click to toggle source
# File lib/taskjuggler/Resource.rb, line 44
def query_dashboard(query)
  dashboard(query)
end

Private Instance Methods

dashboard(query) click to toggle source

Create a dashboard-like list of all task that have a current alert status.

# File lib/taskjuggler/Resource.rb, line 52
def dashboard(query)
  scenarioIdx = @project['trackingScenarioIdx']
  taskList = []
  unless scenarioIdx
    rText = "No 'trackingscenario' defined."
  else
    @project.tasks.each do |task|
      if task['responsible', scenarioIdx].include?(self) &&
        !@project['journal'].currentEntries(query.end, task,
                                            0, query.start,
                                            query.hideJournalEntry).empty?
        taskList << task
      end
    end
  end

  if taskList.empty?
    rText = "We have no current status for any task that #{name} " +
            "is responsible for."
  else
    # The components of the message are either UTF-8 text or RichText. For
    # the RichText components, we use the originally provided markup since
    # we compose the result as RichText markup first.
    rText = ''

    taskList.each do |task|
      rText += "=== <nowiki>[</nowiki>" +
               "#{task.query_alert(query).richText.inputText}" +
               "<nowiki>] Task: #{task.name}</nowiki> " +
               "(#{task.fullId}) ===\n\n"
      rText += task.query_journalmessages(query).richText.inputText + "\n\n"
    end
  end

  # Now convert the RichText markup String into RichTextIntermediate
  # format.
  unless (rti = RichText.new(rText, RTFHandlers.create(@project)).
          generateIntermediateFormat)
    warning('res_dashboard', 'Syntax error in dashboard text')
    return nil
  end
  # No section numbers, please!
  rti.sectionNumbers = false
  # We use a special class to allow CSS formating.
  rti.cssClass = 'tj_journal'
  query.rti = rti
end