Skip to content

Commit

Permalink
Support all attributes in tracereport title queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
scrapper committed Mar 9, 2012
1 parent 41e177f commit 354f5cd
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
8 changes: 8 additions & 0 deletions lib/taskjuggler/SimpleQueryExpander.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ def initialize(inputStr, query, sourceFileInfo)
def expand
# Create a copy of the input string since we will modify it.
str = @inputStr.dup

# The scenario name is not an attribute that can be queried. We need to
# handle this separately
if @query.scenarioIdx
str.gsub!(/<-scenario->/,
@query.project.scenario(@query.scenarioIdx).id)
end

# Replace all occurences of <-name->.
str.gsub!(/<-[a-zA-Z][_a-zA-Z]*->/) do |match|
attribute = match[2..-3]
Expand Down
16 changes: 11 additions & 5 deletions lib/taskjuggler/reports/TraceReport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ def generateIntermediateFormat

# Generate the table header.
headers = [ 'Date' ] +
generatePropertyListHeader(accountList) +
generatePropertyListHeader(resourceList) +
generatePropertyListHeader(taskList)
generatePropertyListHeader(accountList, query) +
generatePropertyListHeader(resourceList, query) +
generatePropertyListHeader(taskList, query)

discontinuedColumns = 0
if File.exists?(@fileName)
Expand Down Expand Up @@ -137,13 +137,19 @@ def to_csv

private

def generatePropertyListHeader(propertyList)
def generatePropertyListHeader(propertyList, query)
headers = []
query = query.dup
a('columns').each do |columnDescr|
query.attributeId = columnDescr.id
a('scenarios').each do |scenarioIdx|
query.scenarioIdx = scenarioIdx
propertyList.each do |property|
query.property = property

#adjustColumnPeriod(columnDescr, propertyList, a.get('scenarios'))
header = columnTitle(property, scenarioIdx, columnDescr)
header = SimpleQueryExpander.new(columnDescr.title, query,
@report.sourceFileInfo).expand

if headers.include?(header)
error('trace_columns_not_uniq',
Expand Down
28 changes: 28 additions & 0 deletions test/test_SimpleQueryExpander.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@

class TestSimpleQueryExpander < Test::Unit::TestCase

class Scenario

def id
'scId'
end

end

class Project

def initialize
end

def scenario(foo)
Scenario.new
end

end

class Query

def initialize
Expand All @@ -28,6 +47,14 @@ def initialize
def process
end

def project
Project.new
end

def scenarioIdx
0
end

def attributeId=(value)
end

Expand All @@ -38,6 +65,7 @@ def ok
def to_s
'XXX'
end

end

def setup
Expand Down

0 comments on commit 354f5cd

Please sign in to comment.