1

我正在通过 Ruby使用 Rally API ( http://developer.help.rallydev.com/ruby-toolkit-rally-rest-api-json )。我想查询投资组合项目的属性(字段?)。我有工作代码,例如这可以正常工作(虽然它似乎显示名称,而不是 ID ——我期待像“T30”这样的东西,但这显示“这是我的倡议的名称”):

pi_query.order = "FormattedID Asc"

通过反复试验,我也看到

pi_query.order = "Name Asc"

也可以。我的问题:我可以在这里使用什么值?我已经找了好几个小时了。Name、FormattedID 和 Description 工作;父母没有。我找不到参考文档。

(我正在尝试编写一个显示投资组合项目的自定义报告,这是一种更具可读性的方式——主题、倡议和功能以某种我可以打印的嵌套方式显示。Rally 中的投资组合层次应用程序没有提供可打印的视图,所以我希望为它编写一个快速脚本。我不需要太多,主要是名称,以及事物是主题、倡议还是功能。像这样:)

T30 My first theme
    I65 The first initiative
        F44 The first feature under that
        F45 Another feature
    I66 Another initiative
T31 My second theme
    I67 Yet another initiative
4

2 回答 2

2

我找到了。这是文档的正确链接:

https://rally1.rallydev.com/slm/doc/webservice/

如果单击左侧的“ AllowedAttributeValue ”,您将获得属性列表。按 Ctrl-F 并搜索“投资组合”。当您进入标题为“组合项目(不可创建类型)”的主标题时,有一个用于“获取完整对象”和“美化 JSON 输出”的复选框。检查两者,然后点击下方的“查询”按钮。您将在新窗口中获得一个对象模型。

在这个新窗口中,您可以看到所有有效属性。例如,搜索“父”,您可以看到父哈希的有效值。其中一个键是 _refObjectName,它为您提供父节点的名称。

这是一个工作示例,它查询倡议并显示他们的名字和他们父母的名字。

require 'rally_api'

config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "REPLACE"
config[:password] = "REPLACE"
config[:workspace] = "REPLACE"
config[:project] = "REPLACE"
@rally = RallyAPI::RallyRestJson.new(config)

pi_query = RallyAPI::RallyQuery.new()
pi_query.type = "portfolioitem/initiative"
pi_query.fetch = "Name,FormattedID,Description,PortfolioItemTypeName,Parent"
pi_query.project_scope_up = true
pi_query.project_scope_down = true
pi_query.order = "FormattedID Asc"
pi_results = @rally.find(pi_query)

pi_results.each do |result|
   parent_name = (result.Parent == nil)? "" : "has parent \"" + result.Parent["_refObjectName"] + "\""
   puts result.FormattedID + " " + result.Name + " "  + parent_name
end
于 2013-06-02T04:43:59.703 回答
1

这是一个更完整的版本,将主题、它们的倡议和它们的功能显示为缩进输出。可能有一种更有效的方法来进行输出,但这种方法确实会针对我的项目生成正确的输出。

require 'rally_api'

config = {:base_url => "https://rally1.rallydev.com/slm"}
config[:username] = "REPLACE"
config[:password] = "REPLACE"
config[:workspace] = "REPLACE"
config[:project] = "REPLACE"
@rally = RallyAPI::RallyRestJson.new(config)

pi_query = RallyAPI::RallyQuery.new()
pi_query.project_scope_up = false
pi_query.project_scope_down = true
pi_query.order = "FormattedID Asc"

# Themes

pi_query.type = "portfolioitem/theme"
pi_query.fetch = "Name,FormattedID"
pi_results = @rally.find(pi_query)

themes = []
pi_results.each { |theme| themes << [ theme.FormattedID, theme.Name ] }

# Initiatives

pi_query.type = "portfolioitem/initiative"
pi_query.fetch = "Name,FormattedID,Parent"
pi_results = @rally.find(pi_query)

initiatives = []
pi_results.each do |initiative|
  parent_name = (initiative.Parent == nil)? "" : initiative.Parent["_refObjectName"]
  initiatives << [ initiative.FormattedID, initiative.Name, parent_name]
end

# Features

pi_query.type = "portfolioitem/feature"
pi_query.fetch = "Name,FormattedID,Parent"
pi_results = @rally.find(pi_query)

features = []
pi_results.each do |feature|
   parent_name = (feature.Parent == nil)? "" : feature.Parent["_refObjectName"]
   features << [ feature.FormattedID, feature.Name, parent_name]
end

# Output

themes.each do |theme|
  puts theme[0] + " " + theme[1]
  initiatives.each do |initiative|
    if (initiative[2] == theme[1])
      puts "    " + initiative[0] + " " + initiative[1]
      features.each do |feature|
        if (feature[2] == initiative[1])
           puts "        " + feature[0] + " " + feature[1]
        end
      end
    end
  end
end
于 2013-06-05T06:54:31.790 回答