doc/TaskJuggler/NikuReport.html in taskjuggler-0.0.5 vs doc/TaskJuggler/NikuReport.html in taskjuggler-0.0.6

- old
+ new

@@ -67,34 +67,36 @@ <div id="method-list-section" class="section"> <h3 class="section-header">Methods</h3> <ul class="link-list"> - <li><a href="#M000907">::new</a></li> + <li><a href="#method-c-new">::new</a></li> - <li><a href="#M000917">#collectProjects</a></li> + <li><a href="#method-i-collectProjects">#collectProjects</a></li> - <li><a href="#M000918">#computeProjectAllocations</a></li> + <li><a href="#method-i-computeProjectAllocations">#computeProjectAllocations</a></li> - <li><a href="#M000916">#computeResourceTotals</a></li> + <li><a href="#method-i-computeResourceTotals">#computeResourceTotals</a></li> - <li><a href="#M000908">#generateIntermediateFormat</a></li> + <li><a href="#method-i-generateIntermediateFormat">#generateIntermediateFormat</a></li> - <li><a href="#M000915">#htmlTabCell</a></li> + <li><a href="#method-i-htmlTabCell">#htmlTabCell</a></li> - <li><a href="#M000913">#projectTotal</a></li> + <li><a href="#method-i-projectTotal">#projectTotal</a></li> - <li><a href="#M000912">#resourceTotal</a></li> + <li><a href="#method-i-resourceTotal">#resourceTotal</a></li> - <li><a href="#M000911">#sum</a></li> + <li><a href="#method-i-sum">#sum</a></li> - <li><a href="#M000909">#to_html</a></li> + <li><a href="#method-i-to_csv">#to_csv</a></li> - <li><a href="#M000910">#to_niku</a></li> + <li><a href="#method-i-to_html">#to_html</a></li> - <li><a href="#M000914">#total</a></li> + <li><a href="#method-i-to_niku">#to_niku</a></li> + <li><a href="#method-i-total">#total</a></li> + </ul> </div> <!-- Included Modules --> @@ -106,10 +108,12 @@ <div id="fileindex-section" class="section project-section"> <h3 class="section-header">Files</h3> <ul> + <li class="file"><a href="../CHANGELOG.html">CHANGELOG</a></li> + <li class="file"><a href="../COPYING.html">COPYING</a></li> <li class="file"><a href="../README.html">README</a></li> </ul> @@ -275,10 +279,12 @@ <li><a href="../TaskJuggler/NikuReport.html">TaskJuggler::NikuReport</a></li> <li><a href="../TaskJuggler/NikuResource.html">TaskJuggler::NikuResource</a></li> + <li><a href="../TaskJuggler/NodeListAttribute.html">TaskJuggler::NodeListAttribute</a></li> + <li><a href="../TaskJuggler/OnShiftCache.html">TaskJuggler::OnShiftCache</a></li> <li><a href="../TaskJuggler/ProcessIntercom.html">TaskJuggler::ProcessIntercom</a></li> <li><a href="../TaskJuggler/ProcessIntercomIface.html">TaskJuggler::ProcessIntercomIface</a></li> @@ -289,10 +295,12 @@ <li><a href="../TaskJuggler/ProjectBrokerIface.html">TaskJuggler::ProjectBrokerIface</a></li> <li><a href="../TaskJuggler/ProjectFileParser.html">TaskJuggler::ProjectFileParser</a></li> + <li><a href="../TaskJuggler/ProjectFileScanner.html">TaskJuggler::ProjectFileScanner</a></li> + <li><a href="../TaskJuggler/ProjectRecord.html">TaskJuggler::ProjectRecord</a></li> <li><a href="../TaskJuggler/ProjectServer.html">TaskJuggler::ProjectServer</a></li> <li><a href="../TaskJuggler/ProjectServerIface.html">TaskJuggler::ProjectServerIface</a></li> @@ -305,16 +313,20 @@ <li><a href="../TaskJuggler/PropertyTreeNode.html">TaskJuggler::PropertyTreeNode</a></li> <li><a href="../TaskJuggler/Query.html">TaskJuggler::Query</a></li> + <li><a href="../TaskJuggler/RTFHandlers.html">TaskJuggler::RTFHandlers</a></li> + <li><a href="../TaskJuggler/RTFNavigator.html">TaskJuggler::RTFNavigator</a></li> <li><a href="../TaskJuggler/RTFQuery.html">TaskJuggler::RTFQuery</a></li> <li><a href="../TaskJuggler/RTFReport.html">TaskJuggler::RTFReport</a></li> + <li><a href="../TaskJuggler/RTFReportLink.html">TaskJuggler::RTFReportLink</a></li> + <li><a href="../TaskJuggler/RealFormat.html">TaskJuggler::RealFormat</a></li> <li><a href="../TaskJuggler/RealFormatAttribute.html">TaskJuggler::RealFormatAttribute</a></li> <li><a href="../TaskJuggler/ReferenceAttribute.html">TaskJuggler::ReferenceAttribute</a></li> @@ -329,10 +341,12 @@ <li><a href="../TaskJuggler/ReportServerIface.html">TaskJuggler::ReportServerIface</a></li> <li><a href="../TaskJuggler/ReportServerRecord.html">TaskJuggler::ReportServerRecord</a></li> + <li><a href="../TaskJuggler/ReportServlet.html">TaskJuggler::ReportServlet</a></li> + <li><a href="../TaskJuggler/ReportTable.html">TaskJuggler::ReportTable</a></li> <li><a href="../TaskJuggler/ReportTableCell.html">TaskJuggler::ReportTableCell</a></li> <li><a href="../TaskJuggler/ReportTableColumn.html">TaskJuggler::ReportTableColumn</a></li> @@ -457,10 +471,12 @@ <li><a href="../TaskJuggler/TextScanner/BufferStreamHandle.html">TaskJuggler::TextScanner::BufferStreamHandle</a></li> <li><a href="../TaskJuggler/TextScanner/FileStreamHandle.html">TaskJuggler::TextScanner::FileStreamHandle</a></li> + <li><a href="../TaskJuggler/TextScanner/MacroStackEntry.html">TaskJuggler::TextScanner::MacroStackEntry</a></li> + <li><a href="../TaskJuggler/TextScanner/StreamHandle.html">TaskJuggler::TextScanner::StreamHandle</a></li> <li><a href="../TaskJuggler/TimeSheet.html">TaskJuggler::TimeSheet</a></li> <li><a href="../TaskJuggler/TimeSheetReceiver.html">TaskJuggler::TimeSheetReceiver</a></li> @@ -501,12 +517,16 @@ <li><a href="../TaskJuggler/TjpExportRE.html">TaskJuggler::TjpExportRE</a></li> <li><a href="../TaskJuggler/TjpSyntaxRules.html">TaskJuggler::TjpSyntaxRules</a></li> + <li><a href="../TaskJuggler/URLParameter.html">TaskJuggler::URLParameter</a></li> + <li><a href="../TaskJuggler/UserManual.html">TaskJuggler::UserManual</a></li> + <li><a href="../TaskJuggler/WebServer.html">TaskJuggler::WebServer</a></li> + <li><a href="../TaskJuggler/WorkingHours.html">TaskJuggler::WorkingHours</a></li> <li><a href="../TaskJuggler/WorkingHoursAttribute.html">TaskJuggler::WorkingHoursAttribute</a></li> <li><a href="../TaskJuggler/XMLBlob.html">TaskJuggler::XMLBlob</a></li> @@ -529,10 +549,12 @@ <li><a href="../RuntimeConfig.html">RuntimeConfig</a></li> <li><a href="../String.html">String</a></li> + <li><a href="../StringIO.html">StringIO</a></li> + </ul> <div id="no-class-search-results" style="display: none;">No matching classes.</div> </div> @@ -568,11 +590,11 @@ <div id="public-class-method-details" class="method-section section"> <h3 class="section-header">Public Class Methods</h3> <div id="new-method" class="method-detail "> - <a name="M000907"></a> + <a name="method-c-new"></a> <div class="method-heading"> <span class="method-name">new</span><span class="method-args">(report)</span> @@ -619,11 +641,11 @@ <div id="public-instance-method-details" class="method-section section"> <h3 class="section-header">Public Instance Methods</h3> <div id="generate-ntermediate-ormat-method" class="method-detail "> - <a name="M000908"></a> + <a name="method-i-generateIntermediateFormat"></a> <div class="method-heading"> <span class="method-name">generateIntermediateFormat</span><span class="method-args">()</span> @@ -658,12 +680,71 @@ </div> + <div id="to-csv-method" class="method-detail "> + <a name="method-i-to_csv"></a> + + <div class="method-heading"> + + <span class="method-name">to_csv</span><span + class="method-args">()</span> + <span class="method-click-advice">click to toggle source</span> + + </div> + + <div class="method-description"> + + + + + + <div class="method-source-code" + id="to-csv-source"> +<pre> + <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 196</span> +196: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_csv</span> +197: <span class="ruby-identifier">table</span> = [] +198: <span class="ruby-comment cmt"># Header line with project names</span> +199: <span class="ruby-identifier">table</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">row</span> = []) +200: <span class="ruby-comment cmt"># First column is the resource name and ID.</span> +201: <span class="ruby-identifier">row</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;&quot;</span> +202: <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">projectId</span><span class="ruby-operator">|</span> +203: <span class="ruby-identifier">row</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-ivar">@projects</span>[<span class="ruby-identifier">projectId</span>].<span class="ruby-identifier">name</span> +204: <span class="ruby-keyword kw">end</span> +205: +206: <span class="ruby-comment cmt"># Header line with project IDs</span> +207: <span class="ruby-identifier">table</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">row</span> = []) +208: <span class="ruby-identifier">row</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value str">&quot;Resource&quot;</span> +209: <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">projectId</span><span class="ruby-operator">|</span> +210: <span class="ruby-identifier">row</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">projectId</span> +211: <span class="ruby-keyword kw">end</span> +212: +213: <span class="ruby-ivar">@resourcesTotalEffort</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resourceId</span><span class="ruby-operator">|</span> +214: <span class="ruby-comment cmt"># Add one line per resource.</span> +215: <span class="ruby-identifier">table</span> <span class="ruby-operator">&lt;&lt;</span> (<span class="ruby-identifier">row</span> = []) +216: <span class="ruby-identifier">row</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-node">&quot;#{@resources[resourceId].name} (#{resourceId})&quot;</span> +217: <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">projectId</span><span class="ruby-operator">|</span> +218: <span class="ruby-identifier">row</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">sum</span>(<span class="ruby-identifier">projectId</span>, <span class="ruby-identifier">resourceId</span>) +219: <span class="ruby-keyword kw">end</span> +220: <span class="ruby-keyword kw">end</span> +221: +222: <span class="ruby-identifier">table</span> +223: <span class="ruby-keyword kw">end</span></pre> + </div> + + </div> + + + + + </div> + + <div id="to-html-method" class="method-detail "> - <a name="M000909"></a> + <a name="method-i-to_html"></a> <div class="method-heading"> <span class="method-name">to_html</span><span class="method-args">()</span> @@ -751,11 +832,11 @@ </div> <div id="to-niku-method" class="method-detail "> - <a name="M000910"></a> + <a name="method-i-to_niku"></a> <div class="method-heading"> <span class="method-name">to_niku</span><span class="method-args">()</span> @@ -836,11 +917,11 @@ <div id="private-instance-method-details" class="method-section section"> <h3 class="section-header">Private Instance Methods</h3> <div id="collect-rojects-method" class="method-detail "> - <a name="M000917"></a> + <a name="method-i-collectProjects"></a> <div class="method-heading"> <span class="method-name">collectProjects</span><span class="method-args">()</span> @@ -858,70 +939,70 @@ <div class="method-source-code" id="collect-rojects-source"> <pre> - <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 305</span> -305: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">collectProjects</span> -306: <span class="ruby-comment cmt"># Prepare the task list.</span> -307: <span class="ruby-identifier">taskList</span> = <span class="ruby-constant">PropertyList</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@project</span>.<span class="ruby-identifier">tasks</span>) -308: <span class="ruby-identifier">taskList</span>.<span class="ruby-identifier">setSorting</span>(<span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'sortTasks'</span>)) -309: <span class="ruby-identifier">taskList</span> = <span class="ruby-identifier">filterTaskList</span>(<span class="ruby-identifier">taskList</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'hideTask'</span>), -310: <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'rollupTask'</span>)) -311: -312: -313: <span class="ruby-identifier">taskList</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">task</span><span class="ruby-operator">|</span> -314: <span class="ruby-comment cmt"># We only care about tasks that are leaf tasks and have resource</span> -315: <span class="ruby-comment cmt"># allocations.</span> -316: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">task</span>.<span class="ruby-identifier">leaf?</span> <span class="ruby-operator">||</span> -317: <span class="ruby-identifier">task</span>[<span class="ruby-value str">'assignedresources'</span>, <span class="ruby-ivar">@scenarioIdx</span>].<span class="ruby-identifier">empty?</span> -318: -319: <span class="ruby-identifier">id</span> = <span class="ruby-identifier">task</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityPID'</span>) -320: <span class="ruby-comment cmt"># Ignore tasks without a ClarityPID attribute.</span> -321: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">id</span>.<span class="ruby-identifier">nil?</span> -322: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">id</span>.<span class="ruby-identifier">empty?</span> -323: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, -324: <span class="ruby-node">&quot;ClarityPID of task #{task.fullId} may not be empty&quot;</span> -325: <span class="ruby-keyword kw">end</span> -326: -327: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">task</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityPName'</span>) -328: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">nil?</span> -329: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, -330: <span class="ruby-node">&quot;ClarityPName of task #{task.fullId} has not been set!&quot;</span> -331: <span class="ruby-keyword kw">end</span> -332: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">empty?</span> -333: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, -334: <span class="ruby-node">&quot;ClarityPName of task #{task.fullId} may not be empty!&quot;</span> -335: <span class="ruby-keyword kw">end</span> -336: -337: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">project</span> = <span class="ruby-ivar">@projects</span>[<span class="ruby-identifier">id</span>]).<span class="ruby-identifier">nil?</span> -338: <span class="ruby-comment cmt"># We don't have a record for the Clarity project yet, so we create a</span> -339: <span class="ruby-comment cmt"># new NikuProject object.</span> -340: <span class="ruby-identifier">project</span> = <span class="ruby-constant">NikuProject</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">id</span>, <span class="ruby-identifier">name</span>) -341: <span class="ruby-comment cmt"># And store it in the project list hashed by the ClarityPID.</span> -342: <span class="ruby-ivar">@projects</span>[<span class="ruby-identifier">id</span>] = <span class="ruby-identifier">project</span> -343: <span class="ruby-keyword kw">else</span> -344: <span class="ruby-comment cmt"># Due to a design flaw in the Niku file format, Clarity projects are</span> -345: <span class="ruby-comment cmt"># identified by a name and an ID. We have to check that those pairs</span> -346: <span class="ruby-comment cmt"># are always the same.</span> -347: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">fTask</span> = <span class="ruby-identifier">project</span>.<span class="ruby-identifier">tasks</span>.<span class="ruby-identifier">first</span>).<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityPName'</span>) <span class="ruby-operator">!=</span> <span class="ruby-identifier">name</span> -348: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, -349: <span class="ruby-node">&quot;Task #{task.fullId} and task #{fTask.fullId} &quot;</span> <span class="ruby-operator">+</span> -350: <span class="ruby-node">&quot;have same ClarityPID (#{id}) but different ClarityPName &quot;</span> <span class="ruby-operator">+</span> -351: <span class="ruby-node">&quot;(#{name}/#{fTask.get('ClarityPName')})&quot;</span> -352: <span class="ruby-keyword kw">end</span> -353: <span class="ruby-keyword kw">end</span> -354: <span class="ruby-comment cmt"># Append the Task to the task list of the Clarity project.</span> -355: <span class="ruby-identifier">project</span>.<span class="ruby-identifier">tasks</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">task</span> -356: <span class="ruby-keyword kw">end</span> -357: -358: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">empty?</span> -359: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, -360: <span class="ruby-value str">'No tasks with the custom attributes ClarityPID and ClarityPName '</span> <span class="ruby-operator">+</span> -361: <span class="ruby-value str">'were found!'</span> -362: <span class="ruby-keyword kw">end</span> -363: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 335</span> +335: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">collectProjects</span> +336: <span class="ruby-comment cmt"># Prepare the task list.</span> +337: <span class="ruby-identifier">taskList</span> = <span class="ruby-constant">PropertyList</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@project</span>.<span class="ruby-identifier">tasks</span>) +338: <span class="ruby-identifier">taskList</span>.<span class="ruby-identifier">setSorting</span>(<span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'sortTasks'</span>)) +339: <span class="ruby-identifier">taskList</span> = <span class="ruby-identifier">filterTaskList</span>(<span class="ruby-identifier">taskList</span>, <span class="ruby-keyword kw">nil</span>, <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'hideTask'</span>), +340: <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'rollupTask'</span>), <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'openNodes'</span>)) +341: +342: +343: <span class="ruby-identifier">taskList</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">task</span><span class="ruby-operator">|</span> +344: <span class="ruby-comment cmt"># We only care about tasks that are leaf tasks and have resource</span> +345: <span class="ruby-comment cmt"># allocations.</span> +346: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">task</span>.<span class="ruby-identifier">leaf?</span> <span class="ruby-operator">||</span> +347: <span class="ruby-identifier">task</span>[<span class="ruby-value str">'assignedresources'</span>, <span class="ruby-ivar">@scenarioIdx</span>].<span class="ruby-identifier">empty?</span> +348: +349: <span class="ruby-identifier">id</span> = <span class="ruby-identifier">task</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityPID'</span>) +350: <span class="ruby-comment cmt"># Ignore tasks without a ClarityPID attribute.</span> +351: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">id</span>.<span class="ruby-identifier">nil?</span> +352: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">id</span>.<span class="ruby-identifier">empty?</span> +353: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, +354: <span class="ruby-node">&quot;ClarityPID of task #{task.fullId} may not be empty&quot;</span> +355: <span class="ruby-keyword kw">end</span> +356: +357: <span class="ruby-identifier">name</span> = <span class="ruby-identifier">task</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityPName'</span>) +358: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">nil?</span> +359: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, +360: <span class="ruby-node">&quot;ClarityPName of task #{task.fullId} has not been set!&quot;</span> +361: <span class="ruby-keyword kw">end</span> +362: <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">name</span>.<span class="ruby-identifier">empty?</span> +363: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, +364: <span class="ruby-node">&quot;ClarityPName of task #{task.fullId} may not be empty!&quot;</span> +365: <span class="ruby-keyword kw">end</span> +366: +367: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">project</span> = <span class="ruby-ivar">@projects</span>[<span class="ruby-identifier">id</span>]).<span class="ruby-identifier">nil?</span> +368: <span class="ruby-comment cmt"># We don't have a record for the Clarity project yet, so we create a</span> +369: <span class="ruby-comment cmt"># new NikuProject object.</span> +370: <span class="ruby-identifier">project</span> = <span class="ruby-constant">NikuProject</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">id</span>, <span class="ruby-identifier">name</span>) +371: <span class="ruby-comment cmt"># And store it in the project list hashed by the ClarityPID.</span> +372: <span class="ruby-ivar">@projects</span>[<span class="ruby-identifier">id</span>] = <span class="ruby-identifier">project</span> +373: <span class="ruby-keyword kw">else</span> +374: <span class="ruby-comment cmt"># Due to a design flaw in the Niku file format, Clarity projects are</span> +375: <span class="ruby-comment cmt"># identified by a name and an ID. We have to check that those pairs</span> +376: <span class="ruby-comment cmt"># are always the same.</span> +377: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">fTask</span> = <span class="ruby-identifier">project</span>.<span class="ruby-identifier">tasks</span>.<span class="ruby-identifier">first</span>).<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityPName'</span>) <span class="ruby-operator">!=</span> <span class="ruby-identifier">name</span> +378: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, +379: <span class="ruby-node">&quot;Task #{task.fullId} and task #{fTask.fullId} &quot;</span> <span class="ruby-operator">+</span> +380: <span class="ruby-node">&quot;have same ClarityPID (#{id}) but different ClarityPName &quot;</span> <span class="ruby-operator">+</span> +381: <span class="ruby-node">&quot;(#{name}/#{fTask.get('ClarityPName')})&quot;</span> +382: <span class="ruby-keyword kw">end</span> +383: <span class="ruby-keyword kw">end</span> +384: <span class="ruby-comment cmt"># Append the Task to the task list of the Clarity project.</span> +385: <span class="ruby-identifier">project</span>.<span class="ruby-identifier">tasks</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">task</span> +386: <span class="ruby-keyword kw">end</span> +387: +388: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">empty?</span> +389: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, +390: <span class="ruby-value str">'No tasks with the custom attributes ClarityPID and ClarityPName '</span> <span class="ruby-operator">+</span> +391: <span class="ruby-value str">'were found!'</span> +392: <span class="ruby-keyword kw">end</span> +393: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -929,11 +1010,11 @@ </div> <div id="compute-roject-llocations-method" class="method-detail "> - <a name="M000918"></a> + <a name="method-i-computeProjectAllocations"></a> <div class="method-heading"> <span class="method-name">computeProjectAllocations</span><span class="method-args">()</span> @@ -952,54 +1033,54 @@ <div class="method-source-code" id="compute-roject-llocations-source"> <pre> - <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 367</span> -367: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">computeProjectAllocations</span> -368: <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">project</span><span class="ruby-operator">|</span> -369: <span class="ruby-identifier">project</span>.<span class="ruby-identifier">tasks</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">task</span><span class="ruby-operator">|</span> -370: <span class="ruby-identifier">task</span>[<span class="ruby-value str">'assignedresources'</span>, <span class="ruby-ivar">@scenarioIdx</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resource</span><span class="ruby-operator">|</span> -371: <span class="ruby-comment cmt"># Only consider resources that are in the filtered resource list.</span> -372: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@resources</span>[<span class="ruby-identifier">resource</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityRID'</span>)] -373: -374: <span class="ruby-comment cmt"># Prepare a template for the Query we will use to get all the data.</span> -375: <span class="ruby-identifier">queryAttrs</span> = { <span class="ruby-value str">'project'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@project</span>, -376: <span class="ruby-value str">'property'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">task</span>, -377: <span class="ruby-value str">'scopeProperty'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">resource</span>, -378: <span class="ruby-value str">'scenarioIdx'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@scenarioIdx</span>, -379: <span class="ruby-value str">'loadUnit'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'loadUnit'</span>), -380: <span class="ruby-value str">'numberFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'numberFormat'</span>), -381: <span class="ruby-value str">'timeFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'timeFormat'</span>), -382: <span class="ruby-value str">'currencyFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'currencyFormat'</span>), -383: <span class="ruby-value str">'start'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'start'</span>), <span class="ruby-value str">'end'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'end'</span>), -384: <span class="ruby-value str">'costAccount'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'costAccount'</span>), -385: <span class="ruby-value str">'revenueAccount'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'revenueAccount'</span>) } -386: -387: <span class="ruby-identifier">query</span> = <span class="ruby-constant">Query</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">queryAttrs</span>) -388: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">attributeId</span> = <span class="ruby-value str">'effort'</span> -389: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">process</span> -390: <span class="ruby-identifier">work</span> = <span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_num</span> -391: -392: <span class="ruby-comment cmt"># If the resource was not actually working on this task during the</span> -393: <span class="ruby-comment cmt"># report period, we don't create a record for it.</span> -394: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">work</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0.0</span> -395: -396: <span class="ruby-identifier">resourceId</span> = <span class="ruby-identifier">resource</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityRID'</span>) -397: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">resourceRecord</span> = <span class="ruby-identifier">project</span>.<span class="ruby-identifier">resources</span>[<span class="ruby-identifier">resourceId</span>]).<span class="ruby-identifier">nil?</span> -398: <span class="ruby-comment cmt"># If we don't already have a NikuResource object for the</span> -399: <span class="ruby-comment cmt"># Resource, we create a new one.</span> -400: <span class="ruby-identifier">resourceRecord</span> = <span class="ruby-constant">NikuResource</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resourceId</span>) -401: <span class="ruby-comment cmt"># Store the new NikuResource in the resource list of the</span> -402: <span class="ruby-comment cmt"># NikuProject record.</span> -403: <span class="ruby-identifier">project</span>.<span class="ruby-identifier">resources</span>[<span class="ruby-identifier">resourceId</span>] = <span class="ruby-identifier">resourceRecord</span> -404: <span class="ruby-keyword kw">end</span> -405: <span class="ruby-identifier">resourceRecord</span>.<span class="ruby-identifier">sum</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_num</span> -406: <span class="ruby-keyword kw">end</span> -407: <span class="ruby-keyword kw">end</span> -408: <span class="ruby-keyword kw">end</span> -409: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 397</span> +397: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">computeProjectAllocations</span> +398: <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">each_value</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">project</span><span class="ruby-operator">|</span> +399: <span class="ruby-identifier">project</span>.<span class="ruby-identifier">tasks</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">task</span><span class="ruby-operator">|</span> +400: <span class="ruby-identifier">task</span>[<span class="ruby-value str">'assignedresources'</span>, <span class="ruby-ivar">@scenarioIdx</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resource</span><span class="ruby-operator">|</span> +401: <span class="ruby-comment cmt"># Only consider resources that are in the filtered resource list.</span> +402: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-ivar">@resources</span>[<span class="ruby-identifier">resource</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityRID'</span>)] +403: +404: <span class="ruby-comment cmt"># Prepare a template for the Query we will use to get all the data.</span> +405: <span class="ruby-identifier">queryAttrs</span> = { <span class="ruby-value str">'project'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@project</span>, +406: <span class="ruby-value str">'property'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">task</span>, +407: <span class="ruby-value str">'scopeProperty'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">resource</span>, +408: <span class="ruby-value str">'scenarioIdx'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@scenarioIdx</span>, +409: <span class="ruby-value str">'loadUnit'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'loadUnit'</span>), +410: <span class="ruby-value str">'numberFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'numberFormat'</span>), +411: <span class="ruby-value str">'timeFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'timeFormat'</span>), +412: <span class="ruby-value str">'currencyFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'currencyFormat'</span>), +413: <span class="ruby-value str">'start'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'start'</span>), <span class="ruby-value str">'end'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'end'</span>), +414: <span class="ruby-value str">'costAccount'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'costAccount'</span>), +415: <span class="ruby-value str">'revenueAccount'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'revenueAccount'</span>) } +416: +417: <span class="ruby-identifier">query</span> = <span class="ruby-constant">Query</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">queryAttrs</span>) +418: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">attributeId</span> = <span class="ruby-value str">'effort'</span> +419: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">process</span> +420: <span class="ruby-identifier">work</span> = <span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_num</span> +421: +422: <span class="ruby-comment cmt"># If the resource was not actually working on this task during the</span> +423: <span class="ruby-comment cmt"># report period, we don't create a record for it.</span> +424: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">work</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0.0</span> +425: +426: <span class="ruby-identifier">resourceId</span> = <span class="ruby-identifier">resource</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityRID'</span>) +427: <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">resourceRecord</span> = <span class="ruby-identifier">project</span>.<span class="ruby-identifier">resources</span>[<span class="ruby-identifier">resourceId</span>]).<span class="ruby-identifier">nil?</span> +428: <span class="ruby-comment cmt"># If we don't already have a NikuResource object for the</span> +429: <span class="ruby-comment cmt"># Resource, we create a new one.</span> +430: <span class="ruby-identifier">resourceRecord</span> = <span class="ruby-constant">NikuResource</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">resourceId</span>) +431: <span class="ruby-comment cmt"># Store the new NikuResource in the resource list of the</span> +432: <span class="ruby-comment cmt"># NikuProject record.</span> +433: <span class="ruby-identifier">project</span>.<span class="ruby-identifier">resources</span>[<span class="ruby-identifier">resourceId</span>] = <span class="ruby-identifier">resourceRecord</span> +434: <span class="ruby-keyword kw">end</span> +435: <span class="ruby-identifier">resourceRecord</span>.<span class="ruby-identifier">sum</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_num</span> +436: <span class="ruby-keyword kw">end</span> +437: <span class="ruby-keyword kw">end</span> +438: <span class="ruby-keyword kw">end</span> +439: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1007,11 +1088,11 @@ </div> <div id="compute-esource-otals-method" class="method-detail "> - <a name="M000916"></a> + <a name="method-i-computeResourceTotals"></a> <div class="method-heading"> <span class="method-name">computeResourceTotals</span><span class="method-args">()</span> @@ -1031,66 +1112,67 @@ <div class="method-source-code" id="compute-esource-otals-source"> <pre> - <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 247</span> -247: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">computeResourceTotals</span> -248: <span class="ruby-comment cmt"># Prepare the resource list.</span> -249: <span class="ruby-identifier">resourceList</span> = <span class="ruby-constant">PropertyList</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@project</span>.<span class="ruby-identifier">resources</span>) -250: <span class="ruby-identifier">resourceList</span>.<span class="ruby-identifier">setSorting</span>(<span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'sortResources'</span>)) -251: <span class="ruby-identifier">resourceList</span> = <span class="ruby-identifier">filterResourceList</span>(<span class="ruby-identifier">resourceList</span>, <span class="ruby-keyword kw">nil</span>, -252: <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'hideResource'</span>), -253: <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'rollupResource'</span>)) -254: -255: <span class="ruby-identifier">resourceList</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resource</span><span class="ruby-operator">|</span> -256: <span class="ruby-comment cmt"># We only care about leaf resources that have the custom attribute</span> -257: <span class="ruby-comment cmt"># 'ClarityRID' set.</span> -258: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">resource</span>.<span class="ruby-identifier">leaf?</span> <span class="ruby-operator">||</span> -259: (<span class="ruby-identifier">resourceId</span> = <span class="ruby-identifier">resource</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityRID'</span>)).<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> -260: <span class="ruby-identifier">resourceId</span>.<span class="ruby-identifier">empty?</span> -261: -262: <span class="ruby-comment cmt"># Prepare a template for the Query we will use to get all the data.</span> -263: <span class="ruby-identifier">queryAttrs</span> = { <span class="ruby-value str">'project'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@project</span>, -264: <span class="ruby-value str">'property'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">resource</span>, -265: <span class="ruby-value str">'scopeProperty'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>, -266: <span class="ruby-value str">'scenarioIdx'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@scenarioIdx</span>, -267: <span class="ruby-value str">'loadUnit'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'loadUnit'</span>), -268: <span class="ruby-value str">'numberFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'numberFormat'</span>), -269: <span class="ruby-value str">'timeFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'timeFormat'</span>), -270: <span class="ruby-value str">'currencyFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'currencyFormat'</span>), -271: <span class="ruby-value str">'start'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'start'</span>), <span class="ruby-value str">'end'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'end'</span>), -272: <span class="ruby-value str">'costAccount'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'costAccount'</span>), -273: <span class="ruby-value str">'revenueAccount'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'revenueAccount'</span>) } -274: -275: <span class="ruby-identifier">query</span> = <span class="ruby-constant">Query</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">queryAttrs</span>) -276: -277: <span class="ruby-comment cmt"># First get the allocated effort.</span> -278: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">attributeId</span> = <span class="ruby-value str">'effort'</span> -279: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">process</span> -280: <span class="ruby-identifier">total</span> = <span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_num</span> -281: -282: <span class="ruby-comment cmt"># Then add the still available effort.</span> -283: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">attributeId</span> = <span class="ruby-value str">'freework'</span> -284: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">process</span> -285: <span class="ruby-identifier">total</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_num</span> -286: -287: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">total</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0.0</span> -288: -289: <span class="ruby-ivar">@resources</span>[<span class="ruby-identifier">resourceId</span>] = <span class="ruby-identifier">resource</span> -290: -291: <span class="ruby-comment cmt"># This is the maximum possible work of this resource in the report</span> -292: <span class="ruby-comment cmt"># period.</span> -293: <span class="ruby-ivar">@resourcesTotalEffort</span>[<span class="ruby-identifier">resourceId</span>] = <span class="ruby-identifier">total</span> -294: <span class="ruby-keyword kw">end</span> -295: -296: <span class="ruby-comment cmt"># Make sure that we have at least one Resource with a ClarityRID.</span> -297: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@resourcesTotalEffort</span>.<span class="ruby-identifier">empty?</span> -298: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, -299: <span class="ruby-value str">'No resources with the custom attribute ClarityRID were found!'</span> -300: <span class="ruby-keyword kw">end</span> -301: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 276</span> +276: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">computeResourceTotals</span> +277: <span class="ruby-comment cmt"># Prepare the resource list.</span> +278: <span class="ruby-identifier">resourceList</span> = <span class="ruby-constant">PropertyList</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@project</span>.<span class="ruby-identifier">resources</span>) +279: <span class="ruby-identifier">resourceList</span>.<span class="ruby-identifier">setSorting</span>(<span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'sortResources'</span>)) +280: <span class="ruby-identifier">resourceList</span> = <span class="ruby-identifier">filterResourceList</span>(<span class="ruby-identifier">resourceList</span>, <span class="ruby-keyword kw">nil</span>, +281: <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'hideResource'</span>), +282: <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'rollupResource'</span>), +283: <span class="ruby-ivar">@report</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'openNodes'</span>)) +284: +285: <span class="ruby-identifier">resourceList</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resource</span><span class="ruby-operator">|</span> +286: <span class="ruby-comment cmt"># We only care about leaf resources that have the custom attribute</span> +287: <span class="ruby-comment cmt"># 'ClarityRID' set.</span> +288: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">resource</span>.<span class="ruby-identifier">leaf?</span> <span class="ruby-operator">||</span> +289: (<span class="ruby-identifier">resourceId</span> = <span class="ruby-identifier">resource</span>.<span class="ruby-identifier">get</span>(<span class="ruby-value str">'ClarityRID'</span>)).<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> +290: <span class="ruby-identifier">resourceId</span>.<span class="ruby-identifier">empty?</span> +291: +292: <span class="ruby-comment cmt"># Prepare a template for the Query we will use to get all the data.</span> +293: <span class="ruby-identifier">queryAttrs</span> = { <span class="ruby-value str">'project'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@project</span>, +294: <span class="ruby-value str">'property'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">resource</span>, +295: <span class="ruby-value str">'scopeProperty'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">nil</span>, +296: <span class="ruby-value str">'scenarioIdx'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-ivar">@scenarioIdx</span>, +297: <span class="ruby-value str">'loadUnit'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'loadUnit'</span>), +298: <span class="ruby-value str">'numberFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'numberFormat'</span>), +299: <span class="ruby-value str">'timeFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'timeFormat'</span>), +300: <span class="ruby-value str">'currencyFormat'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'currencyFormat'</span>), +301: <span class="ruby-value str">'start'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'start'</span>), <span class="ruby-value str">'end'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'end'</span>), +302: <span class="ruby-value str">'costAccount'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'costAccount'</span>), +303: <span class="ruby-value str">'revenueAccount'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">a</span>(<span class="ruby-value str">'revenueAccount'</span>) } +304: +305: <span class="ruby-identifier">query</span> = <span class="ruby-constant">Query</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">queryAttrs</span>) +306: +307: <span class="ruby-comment cmt"># First get the allocated effort.</span> +308: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">attributeId</span> = <span class="ruby-value str">'effort'</span> +309: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">process</span> +310: <span class="ruby-identifier">total</span> = <span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_num</span> +311: +312: <span class="ruby-comment cmt"># Then add the still available effort.</span> +313: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">attributeId</span> = <span class="ruby-value str">'freework'</span> +314: <span class="ruby-identifier">query</span>.<span class="ruby-identifier">process</span> +315: <span class="ruby-identifier">total</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">query</span>.<span class="ruby-identifier">to_num</span> +316: +317: <span class="ruby-keyword kw">next</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">total</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-value">0.0</span> +318: +319: <span class="ruby-ivar">@resources</span>[<span class="ruby-identifier">resourceId</span>] = <span class="ruby-identifier">resource</span> +320: +321: <span class="ruby-comment cmt"># This is the maximum possible work of this resource in the report</span> +322: <span class="ruby-comment cmt"># period.</span> +323: <span class="ruby-ivar">@resourcesTotalEffort</span>[<span class="ruby-identifier">resourceId</span>] = <span class="ruby-identifier">total</span> +324: <span class="ruby-keyword kw">end</span> +325: +326: <span class="ruby-comment cmt"># Make sure that we have at least one Resource with a ClarityRID.</span> +327: <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@resourcesTotalEffort</span>.<span class="ruby-identifier">empty?</span> +328: <span class="ruby-identifier">raise</span> <span class="ruby-constant">TjException</span>.<span class="ruby-identifier">new</span>, +329: <span class="ruby-value str">'No resources with the custom attribute ClarityRID were found!'</span> +330: <span class="ruby-keyword kw">end</span> +331: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1098,11 +1180,11 @@ </div> <div id="html-ab-ell-method" class="method-detail "> - <a name="M000915"></a> + <a name="method-i-htmlTabCell"></a> <div class="method-heading"> <span class="method-name">htmlTabCell</span><span class="method-args">(text, headerCell = false, align = 'right')</span> @@ -1117,18 +1199,18 @@ <div class="method-source-code" id="html-ab-ell-source"> <pre> - <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 234</span> -234: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">htmlTabCell</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">headerCell</span> = <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">align</span> = <span class="ruby-value str">'right'</span>) -235: <span class="ruby-identifier">td</span> = <span class="ruby-constant">XMLElement</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'td'</span>, <span class="ruby-value str">'class'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">headerCell</span> <span class="ruby-operator">?</span> <span class="ruby-value str">'tabhead'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'taskcell1'</span>) -236: <span class="ruby-identifier">td</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">XMLNamedText</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">text</span>, <span class="ruby-value str">'div'</span>, -237: <span class="ruby-value str">'class'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">headerCell</span> <span class="ruby-operator">?</span> <span class="ruby-value str">'headercelldiv'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'celldiv'</span>, -238: <span class="ruby-value str">'style'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;text-align:#{align}&quot;</span>) -239: <span class="ruby-identifier">td</span> -240: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 263</span> +263: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">htmlTabCell</span>(<span class="ruby-identifier">text</span>, <span class="ruby-identifier">headerCell</span> = <span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">align</span> = <span class="ruby-value str">'right'</span>) +264: <span class="ruby-identifier">td</span> = <span class="ruby-constant">XMLElement</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value str">'td'</span>, <span class="ruby-value str">'class'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">headerCell</span> <span class="ruby-operator">?</span> <span class="ruby-value str">'tabhead'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'taskcell1'</span>) +265: <span class="ruby-identifier">td</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">XMLNamedText</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">text</span>, <span class="ruby-value str">'div'</span>, +266: <span class="ruby-value str">'class'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">headerCell</span> <span class="ruby-operator">?</span> <span class="ruby-value str">'headercelldiv'</span> <span class="ruby-operator">:</span> <span class="ruby-value str">'celldiv'</span>, +267: <span class="ruby-value str">'style'</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-node">&quot;text-align:#{align}&quot;</span>) +268: <span class="ruby-identifier">td</span> +269: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1136,11 +1218,11 @@ </div> <div id="project-otal-method" class="method-detail "> - <a name="M000913"></a> + <a name="method-i-projectTotal"></a> <div class="method-heading"> <span class="method-name">projectTotal</span><span class="method-args">(projectId)</span> @@ -1155,18 +1237,18 @@ <div class="method-source-code" id="project-otal-source"> <pre> - <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 216</span> -216: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">projectTotal</span>(<span class="ruby-identifier">projectId</span>) -217: <span class="ruby-identifier">total</span> = <span class="ruby-value">0.0</span> -218: <span class="ruby-ivar">@resources</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resourceId</span><span class="ruby-operator">|</span> -219: <span class="ruby-identifier">total</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sum</span>(<span class="ruby-identifier">projectId</span>, <span class="ruby-identifier">resourceId</span>) -220: <span class="ruby-keyword kw">end</span> -221: <span class="ruby-identifier">total</span> -222: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 245</span> +245: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">projectTotal</span>(<span class="ruby-identifier">projectId</span>) +246: <span class="ruby-identifier">total</span> = <span class="ruby-value">0.0</span> +247: <span class="ruby-ivar">@resources</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resourceId</span><span class="ruby-operator">|</span> +248: <span class="ruby-identifier">total</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sum</span>(<span class="ruby-identifier">projectId</span>, <span class="ruby-identifier">resourceId</span>) +249: <span class="ruby-keyword kw">end</span> +250: <span class="ruby-identifier">total</span> +251: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1174,11 +1256,11 @@ </div> <div id="resource-otal-method" class="method-detail "> - <a name="M000912"></a> + <a name="method-i-resourceTotal"></a> <div class="method-heading"> <span class="method-name">resourceTotal</span><span class="method-args">(resourceId)</span> @@ -1193,18 +1275,18 @@ <div class="method-source-code" id="resource-otal-source"> <pre> - <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 208</span> -208: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resourceTotal</span>(<span class="ruby-identifier">resourceId</span>) -209: <span class="ruby-identifier">total</span> = <span class="ruby-value">0.0</span> -210: <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">projectId</span><span class="ruby-operator">|</span> -211: <span class="ruby-identifier">total</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sum</span>(<span class="ruby-identifier">projectId</span>, <span class="ruby-identifier">resourceId</span>) -212: <span class="ruby-keyword kw">end</span> -213: <span class="ruby-identifier">total</span> -214: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 237</span> +237: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">resourceTotal</span>(<span class="ruby-identifier">resourceId</span>) +238: <span class="ruby-identifier">total</span> = <span class="ruby-value">0.0</span> +239: <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">projectId</span><span class="ruby-operator">|</span> +240: <span class="ruby-identifier">total</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sum</span>(<span class="ruby-identifier">projectId</span>, <span class="ruby-identifier">resourceId</span>) +241: <span class="ruby-keyword kw">end</span> +242: <span class="ruby-identifier">total</span> +243: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1212,11 +1294,11 @@ </div> <div id="sum-method" class="method-detail "> - <a name="M000911"></a> + <a name="method-i-sum"></a> <div class="method-heading"> <span class="method-name">sum</span><span class="method-args">(projectId, resourceId)</span> @@ -1231,20 +1313,20 @@ <div class="method-source-code" id="sum-source"> <pre> - <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 198</span> -198: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sum</span>(<span class="ruby-identifier">projectId</span>, <span class="ruby-identifier">resourceId</span>) -199: <span class="ruby-identifier">project</span> = <span class="ruby-ivar">@projects</span>[<span class="ruby-identifier">projectId</span>] -200: <span class="ruby-keyword kw">return</span> <span class="ruby-value">0.0</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">project</span> -201: -202: <span class="ruby-identifier">resource</span> = <span class="ruby-identifier">project</span>.<span class="ruby-identifier">resources</span>[<span class="ruby-identifier">resourceId</span>] -203: <span class="ruby-keyword kw">return</span> <span class="ruby-value">0.0</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">resource</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@resourcesTotalEffort</span>[<span class="ruby-identifier">resourceId</span>] -204: -205: <span class="ruby-identifier">resource</span>.<span class="ruby-identifier">sum</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@resourcesTotalEffort</span>[<span class="ruby-identifier">resourceId</span>] -206: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 227</span> +227: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sum</span>(<span class="ruby-identifier">projectId</span>, <span class="ruby-identifier">resourceId</span>) +228: <span class="ruby-identifier">project</span> = <span class="ruby-ivar">@projects</span>[<span class="ruby-identifier">projectId</span>] +229: <span class="ruby-keyword kw">return</span> <span class="ruby-value">0.0</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">project</span> +230: +231: <span class="ruby-identifier">resource</span> = <span class="ruby-identifier">project</span>.<span class="ruby-identifier">resources</span>[<span class="ruby-identifier">resourceId</span>] +232: <span class="ruby-keyword kw">return</span> <span class="ruby-value">0.0</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">resource</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@resourcesTotalEffort</span>[<span class="ruby-identifier">resourceId</span>] +233: +234: <span class="ruby-identifier">resource</span>.<span class="ruby-identifier">sum</span> <span class="ruby-operator">/</span> <span class="ruby-ivar">@resourcesTotalEffort</span>[<span class="ruby-identifier">resourceId</span>] +235: <span class="ruby-keyword kw">end</span></pre> </div> </div> @@ -1252,11 +1334,11 @@ </div> <div id="total-method" class="method-detail "> - <a name="M000914"></a> + <a name="method-i-total"></a> <div class="method-heading"> <span class="method-name">total</span><span class="method-args">()</span> @@ -1271,19 +1353,19 @@ <div class="method-source-code" id="total-source"> <pre> - <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 224</span> -224: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">total</span> -225: <span class="ruby-identifier">total</span> = <span class="ruby-value">0.0</span> -226: <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">projectId</span><span class="ruby-operator">|</span> -227: <span class="ruby-ivar">@resources</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resourceId</span><span class="ruby-operator">|</span> -228: <span class="ruby-identifier">total</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sum</span>(<span class="ruby-identifier">projectId</span>, <span class="ruby-identifier">resourceId</span>) -229: <span class="ruby-keyword kw">end</span> -230: <span class="ruby-keyword kw">end</span> -231: <span class="ruby-identifier">total</span> -232: <span class="ruby-keyword kw">end</span></pre> + <span class="ruby-comment cmt"># File lib/reports/NikuReport.rb, line 253</span> +253: <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">total</span> +254: <span class="ruby-identifier">total</span> = <span class="ruby-value">0.0</span> +255: <span class="ruby-ivar">@projects</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">projectId</span><span class="ruby-operator">|</span> +256: <span class="ruby-ivar">@resources</span>.<span class="ruby-identifier">each_key</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">resourceId</span><span class="ruby-operator">|</span> +257: <span class="ruby-identifier">total</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">sum</span>(<span class="ruby-identifier">projectId</span>, <span class="ruby-identifier">resourceId</span>) +258: <span class="ruby-keyword kw">end</span> +259: <span class="ruby-keyword kw">end</span> +260: <span class="ruby-identifier">total</span> +261: <span class="ruby-keyword kw">end</span></pre> </div> </div>