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

Problem querying work item

Hi, I've a really strange error on a query into a java class developed using plain java API.
The same code, used on a server side plugin, works correctly. The only difference is the use of client side class instead of services.
The snippet I've used is:

String stateName = "OpenRU";
IProcessClientService client = (IProcessClientService)repo.getClientLibrary(IProcessClientService.class);
URI uri = URI.create("TDM");
IProjectArea prjArea = (IProjectArea)client.findProcessArea(uri, null, null);
IProjectAreaHandle prjAreaHandle = (IProjectAreaHandle)prjArea.getItemHandle();
IWorkItemClient wiCommon = (IWorkItemClient)repo.getClientLibrary(IWorkItemClient.class);
ICombinedWorkflowInfos wfInfo = wiCommon.findCombinedWorkflowInfos(prjAreaHandle, null);

Identifier<IState>[] stateIds = wfInfo.getAllStateIds();
Identifier<IState> selectedState = null;
String workflowId = WFORDId;
for(int i=0;i<stateIds.length;i++){
if(wfInfo.getStateName(stateIds[i]).equalsIgnoreCase(stateName) && stateIds[i].getStringIdentifier().contains(workflowId)){
selectedState = stateIds[i];
break;
}
}

IQueryCommon queryService = (IQueryCommon)repo.getClientLibrary(IQueryClient.class);
IAuditableClient clientAudit = (IAuditableClient)repo.getClientLibrary(IAuditableClient.class);
IQueryableAttributeFactory queryAttrFactory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);
IQueryableAttribute stateAttr = queryAttrFactory.findAttribute(prjAreaHandle,IWorkItem.STATE_PROPERTY , clientAudit, null);
AttributeExpression expressionState = new AttributeExpression(stateAttr,AttributeOperation.EQUALS,selectedState);

Term term2 = new Term(Operator.AND);
term2.add(expressionState);
IQueryResult<IResolvedResult<IWorkItem>> results = queryService.getResolvedExpressionResults(prjAreaHandle, term2, IWorkItem.FULL_PROFILE);


Other strange thing is that if I use an expression on projectArea instead of state and than cycle with the results I get that the identifier of state of the desidered workitem is equal to selectedState variable.
What I'm doing wrong on selecting this state?
Thanks on advance for any help.

0 votes



5 answers

Permanent link
Hi, I've a really strange error on a query into a java class developed
using plain java API.
The same code, used on a server side plugin, works correctly. The only
difference is the use of client side class instead of services.
The snippet I've used is:

I can only see the snippet (which basically looks ok to me), but no error
message or stack trace. Is the error you encounter the one you describe
below? Or was there an exception?

Other strange thing is that if I use an expression on projectArea
instead of state and than cycle with the results I get that the
identifier of state of the desidered workitem is equal to
selectedState variable.
What I'm doing wrong on selecting this state?
Thanks on advance for any help.

I don't quite understand; are you seeing a mismatch in state identifiers?
Like '3' vs. 's3'?
Could you describe what you expected and what you got with a little
example?

--
Regards,
Patrick
Jazz Work Item Team

0 votes


Permanent link
Thank you for the answer. I don't have any exception, simply if I put on term the constraint on the state I don't have any results as I aspect to see some results. If I take of the constraint, I see all the items and than, if I catch the ones which I know to be in correct state, I compare the IWorkItem.getState2() with my selectedState variable using equals method and it returns true. Also if I debug the code I can see that state identifiers are exactly the same.
So I was asking myself why, if they are equals, the term with "selectedState" does not run.

As I said this behaviour seems to occors only using client side class, because on server side it runs. And so I was thinking that I'm using these class incorrectly.

0 votes


Permanent link
Hi,
I'm still asking myself if I'm doing something wrong. I use this code:

Identifier<IState> eme_id_state = Identifier.create(IState.class, RU_EME_STATE);

IQueryableAttribute stateAttr = queryAttrFactory.findAttribute(projectArea,IWorkItem.STATE_PROPERTY , clientAudit, null);
AttributeExpression eme_state_exp = new AttributeExpression(stateAttr,AttributeOperation.EQUALS,eme_id_state);
IQueryResult<IResolvedResult<IWorkItem>> results = queryService.getResolvedExpressionResults(projectArea, ord_state_exp, IWorkItem.FULL_PROFILE);


and it returns zero work-item. If I use NOT_EQUALS I get the items and then if I try a comparation of getState2 method on these items I exactly have eme_id_state. So it seems quite stupid use an empty query and then cycling all results...

Any suggestions?

Thanks,
Michele.

0 votes


Permanent link
Hi,
I'm still asking myself if I'm doing something wrong. I use this code:

Identifier<IState> eme_id_state = Identifier.create(IState.class, RU_EME_STATE);

IQueryableAttribute stateAttr = queryAttrFactory.findAttribute(projectArea,IWorkItem.STATE_PROPERTY , clientAudit, null);
AttributeExpression eme_state_exp = new AttributeExpression(stateAttr,AttributeOperation.EQUALS,eme_id_state);
IQueryResult<IResolvedResult<IWorkItem>> results = queryService.getResolvedExpressionResults(projectArea, ord_state_exp, IWorkItem.FULL_PROFILE);


and it returns zero work-item. If I use NOT_EQUALS I get the items and then if I try a comparation of getState2 method on these items I exactly have eme_id_state. So it seems quite stupid use an empty query and then cycling all results...

Any suggestions?

Thanks,
Michele.


I don't know the answer, but what data types does AttributeOperation.EQUALS support comparison of?
boolean, string, integer? what is your attribute data type?

not-equals would probably work for mismatched data types..

Sam

0 votes


Permanent link
Hi Sam,
thanks for your reply. I'm using IWorkItem.STATE_PROPERTY and the Javadoc says that I obtain this property using getState2 methods.

This methods returns to me an Identifier<IState> so I've put on AttributeExpression an object of this type. The strange thing is that if I use NOT_EQUALS and then cycle the workitems returned selecting only the workitems in the state I'm searching about, if I use getState2 methods I obtain exactly what I have created on eme_id_state.

To be clear: returnedWi.getState2().equals(eme_id_state) returns true!

Michele.

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,941

Question asked: Sep 24 '09, 11:12 a.m.

Question was seen: 6,813 times

Last updated: Sep 24 '09, 11:12 a.m.

Confirmation Cancel Confirm