lib/taskjuggler/Query.rb in taskjuggler-3.4.0 vs lib/taskjuggler/Query.rb in taskjuggler-3.5.0

- old
+ new

@@ -1,11 +1,11 @@ #!/usr/bin/env ruby -w # encoding: UTF-8 # # = Query.rb -- The TaskJuggler III Project Management Software # -# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012 +# Copyright (c) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 # by Chris Schlaeger <chris@linux.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of version 2 of the GNU General Public License as # published by the Free Software Foundation. @@ -121,11 +121,11 @@ # to_sort() and result(). def process reset begin # Resolve property reference from property ID. - if @property.nil? && !@propertyId.nil? + if @propertyId && (@property.nil? || @propertyId[0] == '!') @property = resolvePropertyId(@propertyType, @propertyId) unless @property @errorMessage = "Unknown property #{@propertyId} queried" return @ok = false end @@ -295,18 +295,31 @@ def resolvePropertyId(pType, pId) unless @project raise "Need Project reference to process the query" end - case pType - when :Account - @project.account(pId) - when :Task - @project.task(pId) - when:Resource - @project.resource(pId) + if pId[0] == '!' + # This is the case where the property ID is just a sequence of + # exclamation marks. Each one moves the scope 1 level up from the + # current level. + pId.each_utf8_char do |c| + if c == '!' + @property = @property.parent + end + break unless @property + end + @property else - raise "Unknown property type #{pType}" + case pType + when :Account + @project.account(pId) + when :Task + @project.task(pId) + when:Resource + @project.resource(pId) + else + raise "Unknown property type #{pType}" + end end end # This function converts number to strings that may include a unit. The # unit is determined by @loadUnit. In the automatic modes, the shortest