It's all about the answers!

Ask a question

Programmatically processing custom attributes


William Yates (122) | asked Sep 02 '08, 6:08 p.m.
I am writing code to allow a user to create en masse a set of new work items, Specifically a new work item type that contains custom attributes.

I understand how I can add and remove custom Attributes from the IWorkItem. However I am unable to understand how to process the List of IAttributeHandle objects I receive from IWorkItem.getCustomAttributes.


What I would like to know is how to iterate over the list viewing the custom name of the attribute and if required changing the contents.

If anyone has links to appropriate areas of the doc or code snippets that they would be happy to share I would be very grateful
Thank you

2 answers



permanent link
Patrick Streule (4.9k21) | answered Sep 03 '08, 12:32 p.m.
JAZZ DEVELOPER
I understand how I can add and remove custom Attributes from the
IWorkItem. However I am unable to understand how to process the List
of IAttributeHandle objects I receive from
IWorkItem.getCustomAttributes.


What I would like to know is how to iterate over the list viewing the
custom name of the attribute and if required changing the contents.

You can resolve the IAttributeHandles to IAttributes that contain the
desired information:

IAuditableClient client= ...
List<IAttribute> attributes=
client.resolveAuditables(workItem.getCustomAttributes(),
IAttribute.FULL_PROFILE, monitor);

You can then iterate over this list and access the attribute name using
IAttribute#getDisplayName()

HTH,
Patrick
Jazz Work Item Team

permanent link
Susan Hanson (1.6k2201194) | answered Sep 14 '11, 1:17 a.m.
I understand how I can add and remove custom Attributes from the
IWorkItem. However I am unable to understand how to process the List
of IAttributeHandle objects I receive from
IWorkItem.getCustomAttributes.


What I would like to know is how to iterate over the list viewing the
custom name of the attribute and if required changing the contents.

You can resolve the IAttributeHandles to IAttributes that contain the
desired information:

IAuditableClient client= ...
List<IAttribute> attributes=
client.resolveAuditables(workItem.getCustomAttributes(),
IAttribute.FULL_PROFILE, monitor);

You can then iterate over this list and access the attribute name using
IAttribute#getDisplayName()

HTH,
Patrick
Jazz Work Item Team



Hi ... this has been very helpful but I have one final issue that I struggle with. I am able to get down to the IAttribute and do the resolve and can show the display name, but within my Eclipse environment, I can't figure out how to get the actual value that is entered into the field. For example, the attribute DisplayName is something like "Target Release" but I need to get what value was entered and stored.

ITeamRepository rep = session.getRepository();
IAuditableClient client= session.getAuditableClient();
List<IAttribute> customAttribs = client.resolveAuditables(workItem.getCustomAttributes(), IAttribute.FULL_PROFILE, null);
for (IAttribute ia : customAttribs) {
System.out.println( this.id + ":" + ia.getDisplayName());
}

And that prints out the ID of the work item and the Display Name of the attribute, but I can't get the actual entered value. I see a getValue method call, but I was a little confused since it seems to want a workItem argument, but the custom attributes came from a single work item, so I wouldn't expect to need to send the same work item back in.

Thanks in advance,
Susan

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.