2013-06-26 62 views
1

我可以創建WorkItem類別,但在將它與create_type.getAssociatedTeamAreas()。add(newTAHandle)行中的teamarea.Getting錯誤關聯時出錯。我沒有得到如何返回一個ITeamAreaHandle布爾對象添加方法。獲取編譯錯誤:java.lang.UnsupportedOperationException將工作項類別與RTC中的團隊區域相關聯

請幫忙。以下是相關的代碼。

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; 
       } 

回答

0

This thread評論:

API來個類別,有團隊區域相關聯的內部

如果您仍然需要它,請將ICategory投射到內部Category界面,然後使用。 category.setDefaultTeamArea(...)

您可以通過設置相關的:

((Category) category).getTeamAreas().add(teamArea); 
+0

好在我已試過,但並不團隊區域類別相關聯。我想過使用這種語法:((Category)createcat).getAssociatedTeamAreas()。add(teamArea);但它會拋出與上面相同的錯誤。 –

+0

@KaushambiSuyal好吧,也許它與'newTAHandle'類型有關?我的意思是:如果你必須將'ICategory'轉換爲'Category',可能類似的轉換是爲了'ITeamAreaHandle'(轉換爲內部類型)? – VonC

0

試試這個:

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

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

workItemClient.saveCategory(category, getProgressMonitor());