1

我可以创建 WorkItem 类别,但在将其关联到 teamarea 时出现错误。在 createcategory.getAssociatedTeamAreas().add(newTAHandle) 行中出现错误。我不知道如何在 add 方法中返回 ITteamareaHandle 的布尔对象。得到编译错误:java.lang.UnsupportedOperationException

请帮忙。下面是相关代码。

IWorkItemClient wservice = (IWorkItemClient) teamRepository.getClientLibrary(IWorkItemClient.class);
ICategory createcategory = wservice.createCategory(area, categoryName, null);
wservice.saveCategory(createcat, null);

 if (!teamArea.equals("NULL")){
                   List teamAreas = area.getTeamAreas();
                   List <teamareahandle> teamlist = teamAreas;
                   ITeamAreaHandle newTAHandle = findTeamAreaByName(teamlist,teamAreaName,monitor);

              createcategory.getAssociatedTeamAreas().add(newTAHandle);
     }

//Method findTeamAreaByName

private static ITeamAreaHandle findTeamAreaByName (List<teamareahandle> teamlist, String teamAreaID, IProgressMonitor monitor) throws TeamRepositoryException {
            for (ITeamAreaHandle teamAreaHandle  :  teamlist) {
            ITeamArea teamArea = (ITeamArea)teamRepository.itemManager().fetchCompleteItem(teamAreaHandle,ItemManager.DEFAULT,monitor);
            if (teamAreaID.equals(teamArea.getName())) {
                return teamAreaHandle;
                }
                }
                return null;
                }
4

2 回答 2

0

该线程评论:

将类别与团队区域相关联的 API 是 internal

如果您仍然需要它,请将其ICategory转换为内部Category接口并使用例如category.setDefaultTeamArea(...).

您可以使用以下方法设置关联的:

((Category) category).getTeamAreas().add(teamArea);
于 2013-06-26T08:30:41.050 回答
0

尝试这个:

ICategory category = workItemClient.createCategory(projectArea, categoryName, getProgressMonitor());

((Category) category).doSetDefaultTeamArea(teamArea);
((Category) category).setArchived(false); //if it is archived

workItemClient.saveCategory(category, getProgressMonitor());
于 2016-02-19T11:56:36.893 回答