【问题标题】:Setting "Discussion" attribute of RTC Work Item设置 RTC 工作项的“讨论”属性
【发布时间】:2013-05-13 12:50:37
【问题描述】:

我正在尝试务实地在工作项中设置“讨论”的值。

我设法设置了“描述”属性,但是当我尝试设置讨论时,我得到了空指针异常:

  IWorkItemClient workItemClient= (IWorkItemClient)repository.getClientLibrary(IWorkItemClient.class);
 IWorkItemWorkingCopyManager manager= workItemClient.getWorkItemWorkingCopyManager();
 manager.connect(workItem, IWorkItem.SMALL_PROFILE, SysoutProgressMonitor.getMonitor());
 WorkItemWorkingCopy wc= manager.getWorkingCopy(workItem);

  IProgressMonitor monitor = SysoutProgressMonitor.getMonitor();
  IWorkItemClient service = (IWorkItemClient) repository.getClientLibrary(IWorkItemClient.class);

   IAttribute discussionAttribute = service.findAttribute(projectArea, "discussion", monitor);//Here I got  a null "discussionAttribute"?

   wc.getWorkItem().setValue(discussionAttribute, "New Value for Discussion");

任何想法!

【问题讨论】:

  • 什么是nullwc.getWorkItem()?
  • IAttribute discussionAttribute = service.findAttribute(projectArea, "discussion", monitor);//这里我得到了一个null "discussionAttribute"?

标签: java rtc jazz


【解决方案1】:

//Here I got a null "discussionAttribute"?
Attribute discussionAttribute = service.findAttribute(projectArea, "discussion", monitor);

我怀疑“discussion”不是有效的 WorkItem 属性 ID。

试题“Where can I find a list of IWorkItem attributes”查询工作项的所有属性,以获得“discussion”的正确属性名称(可能是“comments”?)

使用IItemManager.fetchCompleteItem 获取任何句柄的项目。
物品携带实际信息;句柄本质上就像指针/ URL。

例如:

IContributorHandle contributorHandle = ...

IContributor contributor = (IContributor) teamRepository.itemManager.fetchCompleteItem(contributorHandle, IItemManager.DEFAULT, null);  // should really provide a progress monitor in last arg for progress / cancelaton

String name = contributor.getName();

这是针对客户端的。对于服务器端,使用 IRepositoryItemService 获取项目。


在项目区配置的属性中,我看到了

“评论”:ID“com.ibm.team.workitem.attribute.cmets”,但没有“讨论”。

Jazz.net 上,您会找到指向this discussion 的链接,并提到一个名为“internalComments”的 ID。

然后试试:

Attribute discussionAttribute = 
  service.findAttribute(projectArea, "internalComments", monitor);

不要忘记保存修改后的工作项,例如“Modify a WorkItem

IDetailedStatus s = wc.save(null);
if (!s.isOK()) {
    throw new TeamRepositoryException("Error saving work item",
                                      s.getException());
}

【讨论】:

  • 我试图通过这种方式获取 cmets,但我收到了一个空对象:! IAttribute 属性 = service.findAttribute(projectArea, "cmets", monitor);
  • 我在我的配置中发现了这个:如何以编程方式设置它!
  • @Echo "discussion" 是 GUI 小部件 的名称,其中包含工作项上的 cmets。但是,属性(即附加到 WI 的 数据,而不是其图形表示)称为 cmets。请参阅我编辑的答案。
  • 我尝试了以下但我仍然得到 null !属性 commentAttribute= service.findAttribute(projectArea, "com.ibm.team.workitem.attribute.cmets", monitor);
  • @Echo 我已经用 id internalComments 更新了答案。
【解决方案2】:

这是最终解决方案,它有效 :) 感谢 VonC 和 Sam。

IWorkItemClient workItemClient= (IWorkItemClient)repository.getClientLibrary(IWorkItemClient.class);
         IWorkItemWorkingCopyManager manager= workItemClient.getWorkItemWorkingCopyManager();
         manager.connect(workItem, IWorkItem.SMALL_PROFILE, SysoutProgressMonitor.getMonitor());
         WorkItemWorkingCopy wc= manager.getWorkingCopy(workItem);

         IAttribute commentsAttr =  findAttribute(repository, projectArea, "internalComments");
         IComments comments= wc.getWorkItem().getComments();
         IComment comment= comments.createComment( repository.loggedInContributor(),
                 XMLString.createFromPlainText( "Aloo from Mars"));                 

            comments.append(comment); 

            wc.save(null);

【讨论】:

  • 感谢 VonC 的帮助 :)
猜你喜欢
  • 1970-01-01
  • 2023-02-10
  • 2021-12-23
  • 1970-01-01
  • 1970-01-01
  • 2022-09-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多