It's all about the answers!

Ask a question

JazzPlainJavaClient: how to use Identifier in query?


zhou yu (61) | asked Nov 19 '08, 4:27 a.m.
I am using JazzPlainJavaClient to make a query program. I has met a problem in my coding: I want to query work items with the condition of severity. This is My code:

1.String severity_normal = "severity.literal.l3";

2.Identifier sIdentifier = Identifier.create (classType, severity_normal);

3.IQueryableAttribute severityAttribute = findAttribute (projectArea, auditableClient, IWorkItem.SEVERITY_PROPERTY, null);

4.AttributeExpression severityExpression = new AttributeExpression (severityAttribute, AttributeOperation.EQUALS, sIdentifier);

Is it a correct way to create AttributeExpression of severity? And what value should be set to the param "classType" in the row #2

Accepted answer


permanent link
Patrick Streule (4.9k21) | answered Nov 20 '08, 8:18 a.m.
JAZZ DEVELOPER
I am using JazzPlainJavaClient to make a query program. I has met a
problem in my coding: I want to query work items with the condition
of severity. This is My code:

1.String severity_normal = "severity.literal.l3";

2.Identifier sIdentifier = Identifier.create (classType,
severity_normal);

3.IQueryableAttribute severityAttribute = findAttribute (projectArea,
auditableClient, IWorkItem.SEVERITY_PROPERTY, null);

4.AttributeExpression severityExpression = new AttributeExpression
(severityAttribute, AttributeOperation.EQUALS, sIdentifier);

Is it a correct way to create AttributeExpression of severity? And
what value should be set to the param "classType" in the
row #2

Yes, this looks correct. I think passing in the string instead of the
identifier is possible, too. The classType argument for the Identifier
would be ISeverity.class in your example above.

Regards,
Patrick
Jazz Work Item Team
Ralph Schoon selected this answer as the correct answer

3 other answers



permanent link
zhou yu (61) | answered Nov 21 '08, 4:54 a.m.
I am using JazzPlainJavaClient to make a query program. I has met a
problem in my coding: I want to query work items with the condition
of severity. This is My code:

1.String severity_normal = "severity.literal.l3";

2.Identifier sIdentifier = Identifier.create (classType,
severity_normal);

3.IQueryableAttribute severityAttribute = findAttribute (projectArea,
auditableClient, IWorkItem.SEVERITY_PROPERTY, null);

4.AttributeExpression severityExpression = new AttributeExpression
(severityAttribute, AttributeOperation.EQUALS, sIdentifier);

Is it a correct way to create AttributeExpression of severity? And
what value should be set to the param "classType" in the
row #2

Yes, this looks correct. I think passing in the string instead of the
identifier is possible, too. The classType argument for the Identifier
would be ISeverity.class in your example above.

Regards,
Patrick
Jazz Work Item Team


My problem has benn resolved. Thank you for your reply. Now two new puzzles appears.
(1) When a IWorkItem instance is got,how to get its "phase found" and "find in" property(IWorkItem.FOUND_IN_PROPERTY)? I can not find any method to get them.
(2) About the "phase found". I want to create AttributeExpression for it; but I can not find its
PROPERTY value defined(like PROPERTY value defined as IWorkItem.FOUND_IN_PROPERTY) in class IWorkItem .Does it have a alias or is there any other way to get it?

permanent link
Patrick Streule (4.9k21) | answered Nov 21 '08, 8:18 a.m.
JAZZ DEVELOPER
My problem has benn resolved. Thank you for your reply. Now two new
puzzles appears.
(1) When a IWorkItem instance is got,how to get its "phase
found" and "find in"
property(IWorkItem.FOUND_IN_PROPERTY)? I can not find any method to
get them.
(2) About the "phase found". I want to create
AttributeExpression for it; but I can not find its
PROPERTY value defined(like PROPERTY value defined as
IWorkItem.FOUND_IN_PROPERTY) in class IWorkItem .Does it have a alias
or is there any other way to get it?

You read all attribute values of a work item using

Object value= IWorkItem#getValue(IAttribute attribute);

where

IAttribute attribute= workItemClient.findAttribute(projectArea,
attributeId, monitor)

Patrick
Jazz Work Item Team

Comments
1
Jia Jia Li commented Sep 04 '12, 1:51 p.m.

If for enum custom attribute, how to create the identifier? In you example, you can use ISeverity.class, for custom attribute, which class should I use?

Identifier sIdentifier2 = Identifier.create(com.ibm.team.workitem.common.model.ISeverity.class,severity_2);


permanent link
Albert Yao (5411322) | answered Jan 22 '15, 4:18 a.m.
For Enumeration/Enumeration List customization attribute, you should use com.ibm.team.workitem.common.model.ILiteral

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.