Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

How to get the user which team area belong to?

I want to get the user's team area in java code. Has any example?

0 votes

Comments

far as I can see you have to go the other direction, given a team area, is this user in it or not. 


project->getteamareas()->getMembers(). I think you will have to write a special compare function 
using item1.sameitemId(item2) to compare the handles. 

thanks for asking, as I have to do something similar soon. 



2 answers

Permanent link
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);
                }
            }
        }
    }

0 votes


Permanent link
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/


0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 411

Question asked: Dec 18 '13, 7:17 a.m.

Question was seen: 5,373 times

Last updated: Apr 15 '14, 2:53 a.m.

Confirmation Cancel Confirm