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
Comments
Jan
Thanks for your comments. the attribute is defined is as "Large string"
I have gone over it and recreated it multiple times and cannot find the discrepancy. I do not see where or how it expects a UUID given that the type is string
Any way to debug it ? I have also tried different attributes with a string type and they have behaved the same
Comments
Nick,
Thanks for the response. The projectarea expression has always worked ..projectArea here use the projectarea handle so that part is fine
AttributeExpression projectAreaExpression= new AttributeExpression(projectAreaAttribute, AttributeOperation.EQUALS, projectArea);
This is the one that is failing
AttributeExpression ExpressionPROD = new AttributeExpression(PROD, AttributeOperation.EQUALS, (Object) attributeproductValue);
for now String attributeproductValue = "MQSERIES";
So looks like it is expecting uuid for attributeproductValue but I am giving it a string . Question is how do I get an Item id to the specific value for the custom attribute .ie is it possible to given a uuid for the "MQSERIES" value itself
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?
NIck, thanks for the response .
1 . String (Large String ) this is what I am testing with now .... Ultimately I will be using enumeration types with other custom attribute but for now I am just using a string type
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.
PROD.getAttributeType is :: "string"
So sound like things are out of sync . I am restarting the jazz server and the whole machine .. Is there anything specifically I need to do to resync DB and config
I'm stumped. I've asked the Work Items team to help out.
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"
skipped the resolve enumeration activity to get the "UNCLASSIFIED" status and its handle is processingstatusliteral.getIdentifier2() below
String attributeprocessstatusId = "D4_PROCESSINGSTATUS";
IQueryableAttribute PS = attFactory.findAttribute(projectArea,attributeprocessstatusId , auditableClient, null);
AttributeExpression ExpressionPS = new AttributeExpression( PS, AttributeOperation.EQUALS, processingstatusliteral.getIdentifier2());
I will wait on the response from the other team about supplying the string value for string parameter
Nick,
Were you able to get anything back from the WorkItem team?
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?
Nick,
I am back to this problem again. I had to put project on hold for a few months but now I am "really" desperate to get it working .I simplified the case .Using different fields but same error. The custom attribute field is D4Activity and the value to query is "r_svt"
IQueryableAttributeFactory lattFactory = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE);
IQueryableAttribute IQACTIVITY=lattFactory.findAttribute(projectArea,"D4ACTIVITY", auditableClient, null);
Expression D4ActivityExpression = new AttributeExpression(IQACTIVITY,
AttributeOperation.EQUALS, "r_svt");
results =queryClient.getResolvedExpressionResults(projectArea,D4ActivityExpression, IWorkItem.FULL_PROFILE);
results.setLimit(Integer.MAX_VALUE-1);
com.ibm.team.repository.common.TeamRepositoryException: Incorrectly typed parameter submitted to query; Parameter 0 was class java.lang.String but com.ibm.team.repository.common.UUID was expected
Nick
I may have figured out the problem.
My custom attribute was LARGE STRING .. i changed to SMALL STRING
I am still testing but I think I can now query based on that custom attribute ....
Thanks for all your assistance
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.
Nick
I came across this doc that suggests the Large strings cannot be used in simple queries
String
String attributes, available in three sizes: Small String (250 bytes when using UTF-8 encoding), Medium String (1000 bytes) and String (32768 bytes). String can only be queried by fulltext.
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 .
Moreover I noticed that when custom att is LARGE STRING it is not available as queryable attribute in the RTC clients unless you are doing full text queries
Where to create the defect?
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:
Agreed, The error is completely misleading ..... and clearly out of place . I will open the defect asap.
Thanks
Comments
Jan Wloka
JAZZ DEVELOPER Mar 19 '13, 6:46 p.m.-- see below