How to get the user which team area belong to?
![]()
chen fengmiao (70●3●29●32)
| asked Dec 18 '13, 7:17 a.m.
edited Apr 15 '14, 2:53 a.m. by Ralph Schoon (63.3k●3●36●46)
I want to get the user's team area in java code. Has any example?
|
2 answers
![]()
ResourcePlanningService.java has this, it might be helpful
private void getTeamAreas(final ItemCollection<IContributorHandle> contributors, final ItemAwareMap<IContributorHandle, ItemCollection<IProcessArea>> result) throws TeamRepositoryException { final IRepositoryItemService repositoryService= getService(IRepositoryItemService.class); final IQueryService queryService= getService(IQueryService.class); IItemQuery query= IItemQuery.FACTORY.newInstance(ProcessAreaQueryModel.ROOT); IPredicate contributorPredicate= ProcessAreaQueryModel.ROOT.contributors()._contains(query.newItemHandleArg()); for (int index= 0; index < contributors.size() - 1; index++) contributorPredicate= contributorPredicate._or(ProcessAreaQueryModel.ROOT.contributors()._contains(query.newItemHandleArg())); query= (IItemQuery) query.filter(contributorPredicate).distinct(); final ItemQueryIterator<IProcessArea> iterator= new ItemQueryIterator<IProcessArea>(queryService, repositoryService, query, contributors.toArray(new IContributorHandle[contributors.size()])); while (iterator.hasNext()) { final List<IProcessArea> areas= iterator.next(); for (final IProcessArea area : areas) { final IContributorHandle[] members= area.getMembers(); for (final IContributorHandle member : members) { ItemCollection<IProcessArea> collection= result.get(member); if (collection == null) { collection= new ItemHashSet<IProcessArea>(AVERAGE_TEAMS); result.put(member, collection); } collection.add(area); } } } } |
![]()
A better way
IProcessItemService processItemService = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class); List processAreasOfUser= processItemService.findProcessAreas(repo.loggedInContributor(), null, IProcessClientService.ALL_PROPERTIES , MONITOR); Iterator b = processAreasOfUser.iterator(); while (b.hasNext()) { IProcessArea processArea = (IProcessArea) b.next(); if (processArea.getItemType().getName().equals("TeamArea")) { System.out.println(processArea.getName()); } } this link is useful http://rsjazz.wordpress.com/2012/12/09/analyzing-a-aroject-areas-members-and-roles-using-the-plain-java-client-libraries/ |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.
Comments
far as I can see you have to go the other direction, given a team area, is this user in it or not.