It's all about the answers!

Ask a question

Problem querying work item


Michele Pegoraro (1.8k14119103) | asked Sep 24 '09, 11:12 a.m.
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.

5 answers



permanent link
Patrick Streule (4.9k21) | answered Sep 24 '09, 12:42 p.m.
JAZZ DEVELOPER
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

permanent link
Michele Pegoraro (1.8k14119103) | answered Sep 25 '09, 4:59 a.m.
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.

permanent link
Michele Pegoraro (1.8k14119103) | answered Oct 06 '11, 9:28 a.m.
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.

permanent link
sam detweiler (12.5k6195201) | answered Oct 06 '11, 9:35 a.m.
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

permanent link
Michele Pegoraro (1.8k14119103) | answered Oct 06 '11, 3:28 p.m.
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.

Your answer


Register or 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.