Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Programmatically processing custom attributes

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

0 votes



2 answers

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

0 votes


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

1 vote

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,927

Question asked: Sep 02 '08, 6:08 p.m.

Question was seen: 6,767 times

Last updated: Sep 02 '08, 6:08 p.m.

Confirmation Cancel Confirm