Java client api expression .. unable to query and retrieve workitems for custom attribute value from repository "Incorrectly typed parameter submitted to query"
I am unable to programmatically query for custom attribute == XXXXXX . The error is below com.ibm.team.repository.common.TeamRepositoryException: Incorrectly typed parameter submitted to query; Parameter 1 was class java.lang.String but com.ibm.team.repository.common.UUID was expected at com.ibm.team.repository.service.internal.AbstractQueryService.validateParameterTypes(AbstractQueryService.java:130) at com.ibm.team.repository.service.internal.AbstractQueryService.performQuery(AbstractQueryService.java:66) at com.ibm.team.repository.service.internal.QueryService.doExecuteItemQuery(QueryService.java:336) at com.ibm.team.repository.service.internal.QueryService.access$0(QueryService.java:331) at com.ibm.team.repository.service.internal.QueryService$1.run(QueryService.java:178) at com.ibm.team.repository.service.internal.QueryService$1.run(QueryService.java:1) at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$Transaction.run(RepositoryDatabase.java:500) at com.ibm.team.repository.service.internal.rdb.RepositoryDatabase$1.run(RepositoryDatabase.java:324) at com.ibm.team.repository.service.internal.rdb.ConnectionPoolService.withCurrentConnection(ConnectionPoolService.java:381) at sun.reflect.GeneratedMethodAccessor49.invoke(null) Here is the relevant piece of code .. I understand the error because I am supplying the exact specific value of the custom attribute but how can I get uuid for a specific custom attribute value .One expression for projectarea works ok but dont know how to represent the custom attribute value in a uuid format or get a handle to string value projectArea = (IProjectArea) processClient.findProcessArea(uri, null, monitor); IQueryableAttributeFactory attFactory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE); IQueryableAttribute projectAreaAttribute= attFactory.findAttribute(projectArea,IWorkItem.PROJECT_AREA_PROPERTY, auditableClient, null); AttributeExpression projectAreaExpression= new AttributeExpression(projectAreaAttribute, AttributeOperation.EQUALS, projectArea); String attributeproductId = "PRODUCT"; String attributeproductValue = "MQSERIES"; IQueryableAttribute PROD = attFactory.findAttribute(projectArea,attributeproductId, auditableClient, null); AttributeExpression ExpressionPROD = new AttributeExpression(PROD, AttributeOperation.EQUALS, (Object) attributeproductValue); Term term= new Term(Term.Operator.AND); term.add(projectAreaExpression); term.add(ExpressionPROD); So the projectAreaExpression is working fine but ExpressionPROD is failing com.ibm.team.repository.common.TeamRepositoryException: Incorrectly typed parameter submitted to query; Parameter 1 was class java.lang.String but com.ibm.team.repository.common.UUID was expected Please advise |
2 answers
Hi Mark,
You're either using the wrong attribute ID in your query or have given the custom attribute a wrong type. Either way, in "new AttributeExpression(attribute, AttributeOperation.EQUALS, value)" the type of "attribute" must fit to the "value" you pass in.
You have two options to make your code work:
(i) Change the type of the attribute with ID "PRODUCT" to a String type
(ii) Pass into your attribute expression a UUID value, see com.ibm.team.repository.common.UUID
HTH, Jan.
Comments
mark owusu-ansah
commented Mar 19 '13, 7:52 p.m.
Jan
|
Hi Mark,
The UUID it expects is the item id for the project area. You're currently passing what appears to be a project area name. At the top of the snippet, you looked up the project area item. Try using projectArea.getItemId() as the value in the attribute expression.
Comments
mark owusu-ansah
commented Mar 01 '13, 9:41 a.m.
Nick,
That depends on what kind of item it is. What is the type of the custom attribute? Is it an item type? If so, is there API for looking up an item, given its name?
mark owusu-ansah
commented Mar 01 '13, 1:01 p.m.
NIck, thanks for the response .
That's strange. If it's a string typed custom attribute, then giving it a string should work. What does PROD.getAttributeType() show? Is it possible the type used to be an item type, but got changed to a string? Attributes are persisted in the DB, not just the project config, so there's the possibility of things getting out of sync.
mark owusu-ansah
commented Mar 01 '13, 2:15 p.m.
I'm stumped. I've asked the Work Items team to help out.
mark owusu-ansah
commented Mar 01 '13, 5:09 p.m.
Thanks . Here is an interesting find . I am able to query for Enumerated custom attributes. This code work for retrieving a custom attribute called D4_PROCESSINGSTATUS where the attribute is "UNCLASSIFIED"
mark owusu-ansah
commented Mar 19 '13, 11:17 a.m.
Nick,
No, sorry, but I've pinged them again. For the enum query, is that the only attribute you're querying on? Maybe in the other query it's getting confused by having two terms (though the way you're constructing it looks OK to me). Can you simplify the problematic case to have just the string term?
mark owusu-ansah
commented Aug 19 '13, 8:48 p.m.
Nick,
Nick
Hi Mark, good to hear that you've found something that appears to work. I'm still puzzled, though, since I'd expect large string and small string to work similarly, i.e. the expected value in a query would be a String in both cases, not a UUID.
mark owusu-ansah
commented Aug 22 '13, 1:36 p.m.
Nick
If that is indeed the problem, I'd expect it to fail with a clearer error message to that effect, not complain about a type mismatch with UUID. If you think that's the problem, please open a work item against Work Items. I have done enough testing since yesterday to confidently say it is the problem . I have created 2 same environments except the same attribute has SMALL STRING in the case that works and LARGE STRING where it fails .
If it's working now for small strings, but failing for large string, then that does suggest the problem is due to large strings not being indexed like regular attributes, just for full text search. If the failure mode is that it complains that it's not a UUID, then that's a bug. You can open a work item against RTC at:
mark owusu-ansah
commented Aug 22 '13, 4:01 p.m.
Agreed, The error is completely misleading ..... and clearly out of place . I will open the defect asap.
showing 5 of 18
show 13 more comments
|
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.
Comments
-- see below