Class Index [+]

Quicksearch

TaskJuggler::Resource

Public Class Methods

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

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

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.