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

How to get the WorkItems from a Project Area based on their type ?

I am trying to get all the work items which have their type as defect from a particular project area. But I'm only able to get all the work items irrespective of their type from a particular project area. Can any one please tell me how to add the type criteria and get the work items which are of type defect. Below is the code which I am working on.

Thanks.

String repoUri = "****************";
        final String userId = "****************";
        final String password = "******************";
        List<IWorkItem> defectWorkitems=new ArrayList<IWorkItem>();
        TeamPlatform.startup();
        try {
            // Login to the repository using the provided credentials
            ITeamRepository repo = TeamPlatform.getTeamRepositoryService().getTeamRepository(repoUri); repo.registerLoginHandler(new ILoginHandler2() {
                @Override
                public ILoginInfo2 challenge(ITeamRepository arg0) {
                    return new UsernameAndPasswordLoginInfo(userId, password);
                }
            });
            repo.login(new SysoutProgressMonitor());
            IProcessItemService connect = (IProcessItemService) repo.getClientLibrary(IProcessItemService.class);
            List<IProjectArea> p = connect.findAllProjectAreas(null, new SysoutProgressMonitor());
            System.out.println("Project Areas :");
            for(IProjectArea projectArea: p){
                System.out.println(projectArea.getName());
                if(projectArea.getName().equals("********************")){
                    System.out.println("here");
                    IAuditableClient auditableClient = (IAuditableClient) repo.getClientLibrary(IAuditableClient.class);
                    IQueryClient queryClient = (IQueryClient) repo.getClientLibrary(IQueryClient.class);
                    IQueryableAttribute attribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, null);
                    Expression expression = new AttributeExpression(attribute, AttributeOperation.EQUALS, projectArea);
                    IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(projectArea, expression, IWorkItem.FULL_PROFILE);
                    while(results.hasNext(new SysoutProgressMonitor())){
                        IResolvedResult<IWorkItem> result = results.next(new SysoutProgressMonitor());
                        IWorkItem workItem = (IWorkItem) result.getItem();
                        System.out.println(workItem.getItemId());
                        if(workItem.getItemType().toString()=="Enhancement"){
                            System.out.println("here");
                            defectWorkitems.add(workItem);
                        }
                    }
                }        
}             System.out.println(defectWorkitems.size());
     } finally {
            TeamPlatform.shutdown();
        }
    }

0 votes



One answer

Permanent link
see Ralphs blog on  querys
https://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/

0 votes

Comments

I m getting an error while running the above code right after printing the Project Area list.

ERROR: com.ibm.team.workitem.common - Value set provider not found: com.ibm.sport.rtc.common.ComponentBrowseValueSetUtils

Hm.. I have not figured out how to configure a batch application using the plain java apis to support running scripted extensions.

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
× 169

Question asked: Aug 22 '14, 2:59 p.m.

Question was seen: 6,566 times

Last updated: Aug 24 '14, 6:30 a.m.

Confirmation Cancel Confirm