In Files

Class Index [+]

Quicksearch

TaskJuggler::Resource

Public Class Methods

new(project, id, name, parent) click to toggle source
    # File lib/Resource.rb, line 22
22:     def initialize(project, id, name, parent)
23:       super(project.resources, id, name, parent)
24:       project.addResource(self)
25: 
26:       @data = Array.new(@project.scenarioCount, nil)
27:       @project.scenarioCount.times do |i|
28:         @data[i] = ResourceScenario.new(self, i, @scenarioAttributes[i])
29:       end
30:     end

Public Instance Methods

method_missing(func, scenarioIdx, *args) 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/Resource.rb, line 36
36:     def method_missing(func, scenarioIdx, *args)
37:       @data[scenarioIdx].method(func).call(*args)
38:     end
query_dashboard(query) click to toggle source
    # File lib/Resource.rb, line 44
44:     def query_dashboard(query)
45:       dashboard(query)
46:     end
query_journal(query) click to toggle source
    # File lib/Resource.rb, line 40
40:     def query_journal(query)
41:       journalText(query, true)
42:     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/Resource.rb, line 146
146:     def dashboard(query)
147:       scenarioIdx = @project['trackingScenarioIdx']
148:       taskList = []
149:       @project.tasks.each do |task|
150:         if task['responsible', scenarioIdx].include?(self) &&
151:            !@project['journal'].currentEntries(query.end, task,
152:                                               0, query.start).empty?
153:           taskList << task
154:         end
155:       end
156: 
157:       if taskList.empty?
158:         rText = "We have no current status for any task that #{name} " +
159:                 "is responsible for."
160:       else
161:         # The components of the message are either UTF-8 text or RichText. For
162:         # the RichText components, we use the originally provided markup since
163:         # we compose the result as RichText markup first.
164:         rText = ''
165: 
166:         taskList.each do |task|
167:           rText += "=== <nowiki>[#{task.query_alert(query)}] Task: " +
168:             "#{task.name}</nowiki> (#{task.fullId}) ===\n\n"
169:           rText += task.query_journalmessages(query).richText.inputText + "\n\n"
170:         end
171:       end
172: 
173:       # Now convert the RichText markup String into RichTextIntermediate
174:       # format.
175:       unless (rti = RichText.new(rText, RTFHandlers.create(@project),
176:                                  @project.messageHandler).
177:                                  generateIntermediateFormat)
178:         @project.messageHandler.warning(
179:           'res_dashboard', 'Syntax error in dashboard text')
180:         return nil
181:       end
182:       # No section numbers, please!
183:       rti.sectionNumbers = false
184:       # We use a special class to allow CSS formating.
185:       rti.cssClass = 'tj_journal'
186:       query.rti = rti
187:     end
journalText(query, longVersion) click to toggle source

Create a blog-style list of all alert messages that match the Query.

     # File lib/Resource.rb, line 51
 51:     def journalText(query, longVersion)
 52:       # The components of the message are either UTF-8 text or RichText. For
 53:       # the RichText components, we use the originally provided markup since
 54:       # we compose the result as RichText markup first.
 55:       rText = ''
 56:       list = @project['journal'].entriesByResource(self, query.start, query.end)
 57:       # Sort all entries in buckets by their alert level.
 58:       numberOfLevels = project['alertLevels'].length
 59:       listByLevel = []
 60:       numberOfLevels.times { |i| listByLevel[i] = [] }
 61:       list.each do |entry|
 62:         listByLevel[entry.alertLevel] << entry
 63:       end
 64:       (numberOfLevels - 1).downto(0) do |level|
 65:         levelList = listByLevel[level]
 66:         levelRecord = @project['alertLevels'][level]
 67:         if query.selfContained
 68:           alertName = "<nowiki>[#{levelRecord[1]}]</nowiki>"
 69:         else
 70:           alertName = "[[File:icons/flag-#{levelRecord[0]}.png|" +
 71:           "alt=[#{levelRecord[1]}]|text-bottom]]"
 72:         end
 73:         levelList.each do |entry|
 74:           tsRecord = entry.timeSheetRecord
 75: 
 76:           if entry.property.is_a?(Task)
 77:             rText += "=== #{alertName} <nowiki>#{entry.property.name}" +
 78:                      "</nowiki> (ID: #{entry.property.fullId}) ===\n\n"
 79:             if tsRecord
 80:               rText += "'''Work:''' #{tsRecord.actualWorkPercent.to_i}% "
 81:               if tsRecord.actualWorkPercent != tsRecord.planWorkPercent
 82:                 rText += "(#{tsRecord.planWorkPercent.to_i}%) "
 83:               end
 84:               if tsRecord.remaining
 85:                 rText += "'''Remaining:''' #{tsRecord.actualRemaining}d "
 86:                 if tsRecord.actualRemaining !=  tsRecord.planRemaining
 87:                   rText += "(#{tsRecord.planRemaining}d) "
 88:                 end
 89:               else
 90:                 rText += "'''End:''' " +
 91:                          "#{tsRecord.actualEnd.to_s(query.timeFormat)} "
 92:                 if tsRecord.actualEnd != tsRecord.planEnd
 93:                   rText += "(#{tsRecord.planEnd.to_s(query.timeFormat)}) "
 94:                 end
 95:               end
 96:               rText += "\n\n"
 97:             end
 98:           elsif !(tsRecord = entry.timeSheetRecord).nil? &&
 99:                 entry.timeSheetRecord.task.is_a?(String)
100:             rText += "== #{alertName} <nowiki>[New Task] #{tsRecord.name} " +
101:                      "</nowiki> "+
102:               "(ID: #{tsRecord.task}) ==\n\n"
103:             if tsRecord
104:               rText += "'''Work:''' #{tsRecord.actualWorkPercent}% "
105:               if tsRecord.remaining
106:                 rText += "'''Remaining:''' #{tsRecord.actualRemaining}d "
107:               else
108:                 rText += "'''End:''' " +
109:                          "#{tsRecord.actualEnd.to_s(query.timeFormat)} "
110:               end
111:               rText += "\n\n"
112:             end
113:           else
114:             rText += "== #{alertName} Personal Notes ==\n\n"
115:           end
116:           unless entry.headline.empty?
117:             rText += "'''<nowiki>#{entry.headline}</nowiki>'''\n\n"
118:           end
119:           if entry.summary
120:             rText += entry.summary.richText.inputText + "\n\n"
121:           end
122:           if longVersion && entry.details
123:             rText += entry.details.richText.inputText + "\n\n"
124:           end
125:         end
126:       end
127: 
128:       # Now convert the RichText markup String into RichTextIntermediate
129:       # format.
130:       unless (rti = RichText.new(rText, RTFHandlers.create(@project),
131:                                  @project.messageHandler).
132:                                  generateIntermediateFormat)
133:         @project.messageHandler.warning(
134:           'res_journal_text', 'Syntax error in journal text')
135:         return nil
136:       end
137:       # No section numbers, please!
138:       rti.sectionNumbers = false
139:       # We use a special class to allow CSS formating.
140:       rti.cssClass = 'tj_journal'
141:       query.rti = rti
142:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.