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

Getting the workitems through plain java API

hi,I want to get all of the workitems of one project area.
//My code
IAuditableClient auditableClient  = (IAuditableClient) teamRepository.getClientLibrary(IAuditableClient.class);

            IQueryClient queryClient = (IQueryClient) teamRepository.getClientLibrary(IQueryClient.class);

            IQueryableAttributeFactory factory =  QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);

            IQueryableAttribute attribute =  factory.findAttribute(projectareaname,IWorkItem.PROJECT_AREA_PROPERTY, auditableClient,null);
//
It accured an error as follows:
Exception in thread "main" com.ibm.team.repository.common.transport.ServiceMethodInvocationError: java.lang.IllegalStateException: Unable to find type for com.ibm.team.workitem.Attribute
How can I resolve it?
Thanks.

0 votes



2 answers

Permanent link
Hi,

his code has worked for me in the past. Please note, it passes the project area object and not the name.


        IWorkItemClient  workItemService = (IWorkItemClient) targetRepository
            .getClientLibrary(IWorkItemClient.class);
        IQueryClient queryClient = workItemService.getQueryClient();
        IAuditableClient auditableClient = (IAuditableClient)targetRepository.getClientLibrary(IAuditableClient.class);
        IQueryableAttribute attribute=QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(targetProjectArea, IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, monitor);
        Expression inProjectArea= new AttributeExpression(attribute,AttributeOperation.EQUALS, targetProjectArea);
        IQueryResult<IResolvedResult<IWorkItem>> results=queryClient.getResolvedExpressionResults(targetProjectArea, inProjectArea,IWorkItem.SMALL_PROFILE);
        results.setLimit(Integer.MAX_VALUE);

        while (results.hasNext(monitor)) {
            IResolvedResult<IWorkItem> resresult = (IResolvedResult<IWorkItem>) results.next(monitor);
            IWorkItem item = resresult.getItem();

2 votes

Comments

Hi, Ralph, I think you have given a very useful example. My question is if query the enum custom attribute, how to create teh expression? I know such code, but for line 2, Identifier.create(), which class should I use for custom enum attribute? Thanks!

String severity_2="severity.literal.l08"; Identifier sIdentifier2 = Identifier.create(com.ibm.team.workitem.common.model.ISeverity.class,severity_2); IQueryableAttribute customAttribute = findAttribute(projectArea, auditableClient, "test", monitor); AttributeExpression customAttrExpression= new AttributeExpression(customAttribute, AttributeOperation.EQUALS, sIdentifier2);

1 vote


Permanent link
Hi, Ralph, I think you have given a very useful example. 

My question is if query the enum custom attribute, how to create teh expression? 

I know such code, but for line 2, 
Identifier.create(), which class should I use for custom enum attribute? 
Thanks! 

String severity_2="severity.literal.l08"; 
Identifier sIdentifier2 = Identifier.create(com.ibm.team.workitem.common.model.ISeverity.class,severity_2); 
IQueryableAttribute customAttribute = findAttribute(projectArea, auditableClient, "test", monitor); 
AttributeExpression customAttrExpression= new AttributeExpression(customAttribute, AttributeOperation.EQUALS, sIdentifier2);

I post again since the comment has no format..

1 vote

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,927
× 368

Question asked: Jul 16 '12, 4:32 a.m.

Question was seen: 6,505 times

Last updated: Sep 04 '12, 1:55 p.m.

Confirmation Cancel Confirm