It's all about the answers!

Ask a question

Java client api expression .. unable to query and retrieve workitems for custom attribute value from repository "Incorrectly typed parameter submitted to query"


mark owusu-ansah (5659) | asked Feb 28 '13, 1:03 a.m.
edited Feb 28 '13, 1:04 a.m.

 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

Comments
Jan Wloka commented Mar 19 '13, 6:46 p.m. | edited Mar 19 '13, 6:46 p.m.
JAZZ DEVELOPER

-- see below

2 answers



permanent link
Jan Wloka (4161) | answered Mar 19 '13, 6:46 p.m.
JAZZ DEVELOPER
 Hi Mark,

In your project area you defined the type of the custom attribute with the ID "PRODUCT" as an item that uses a UUID, thus the attribute expression "ExpressionPROD" expects a UUID value. 

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


permanent link
Nick Edgar (6.5k711) | answered Mar 01 '13, 9:14 a.m.
JAZZ DEVELOPER
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,
 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


Nick Edgar commented Mar 01 '13, 10:26 a.m.
JAZZ DEVELOPER

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 .

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


Nick Edgar commented Mar 01 '13, 1:45 p.m.
JAZZ DEVELOPER

 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.

 

 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


Nick Edgar commented Mar 01 '13, 2:34 p.m.
JAZZ DEVELOPER

 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"

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


mark owusu-ansah commented Mar 19 '13, 11:17 a.m.

Nick,
     Were  you able to  get anything back from the  WorkItem  team?


Nick Edgar commented Mar 19 '13, 11:28 a.m.
JAZZ DEVELOPER

No, sorry, but I've pinged them again. 


Nick Edgar commented Mar 20 '13, 10:01 a.m.
JAZZ DEVELOPER

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


mark owusu-ansah commented Aug 21 '13, 11:57 a.m. | edited Aug 22 '13, 1:22 p.m.

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


Nick Edgar commented Aug 22 '13, 1:24 p.m.
JAZZ DEVELOPER

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



Nick Edgar commented Aug 22 '13, 3:23 p.m.
JAZZ DEVELOPER

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.


mark owusu-ansah commented Aug 22 '13, 3:34 p.m. | edited Aug 22 '13, 3:52 p.m.

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?


Nick Edgar commented Aug 22 '13, 3:54 p.m.
JAZZ DEVELOPER

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.
 Thanks

showing 5 of 18 show 13 more comments

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.