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

Programmatically updating the "Acceptance Test" field of a S

I'm trying to copy over some user stories from a lotus notes database into RTC using the plain java client and have run into a snag. I have been successful in updating all standard work item fields (creator, owner, summary, description, etc) but when it comes to the custom attribute of the "Acceptance Test" field, it continues to fail and I'm not able to update that field at all.

Here are some code snippets (simplified) around how I'm trying to update the custom attribute. I've found a lot of examples around the core work item updates but haven't been able to find a clear example/explanation around the custom attributes, so any examples/help would be appreciated.

// Create a work item to set fields on
WorkItem workItem = (WorkItem) IWorkItem.ITEM_TYPE.createItem();
workItem.setSummary("My Summary");
workItem.setDescription("This is a new description");

IAttribute attr = workItemClient.findAttribute(getDefaultProjectArea(), "com.ibm.team.apt.attribute.acceptance", monitor);
if (attr != null) {
workItem.setValue(attr, "My Acceptance Test Text");
}

...... More field setting code

// Then generate a working copy, setting all of the fields
WorkItemWorkingCopy wc = workItemClient.getWorkItemWorkingCopyManager().getWorkingCopy(handle);
IDetailedStatus s = wc.save(monitor);

--------------------------------------------------------------------
After all of that, I then get the following error even though the "attr != null" check passes as not null.

java.lang.NullPointerException
at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.hasBuiltInAttribute(WorkItemImpl.java:2925)
at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.hasAttribute(WorkItemImpl.java:2918)
at com.ibm.team.workitem.common.internal.model.impl.WorkItemImpl.setValue(WorkItemImpl.java:2836)
at com.ibm.ddraeger.sync.icsw.SyncBTTDesignDB.createNewWorkItemFromBTT(SyncBTTDesignDB.java:157)
at com.ibm.ddraeger.sync.icsw.SyncBTTDesignDB.addBTTItemsToJazz(SyncBTTDesignDB.java:95)
at com.ibm.ddraeger.sync.icsw.SyncBTTDesignDB.syncBTTToJazz(SyncBTTDesignDB.java:80)
at com.ibm.ddraeger.sync.icsw.SyncBTTDesignDB.main(SyncBTTDesignDB.java:63)

----------------------------------------------------------------------
Any assistance on this would be greatly appreciated. Ideally a link/code snippet of an example on getting/setting custom attributes (especially the "Acceptance Test") would be helpful.

Thanks!

--
Dave Draeger

0 votes



3 answers

Permanent link
Hi,

i want to save custom attribute of type workitem.

Like Parent Development for Development workitem.

could any suggest any idea.


Thanks ,

Pugazh

0 votes


Permanent link
Thank you for the feedback, I am now able to update the Acceptance Test field. I did have one minor problem with the
workItem.setValue not liking the XMLString.createFromPlainText("My Acceptance Test Text")) parameter, but after setting
it to a standard java String it worked fine.

Thanks again.
--
Dave Draeger
IBM WebSphere Serviceability Development
"Patrick Streule" <patrick_streule> wrote in message news:hjks1p$rot$1@localhost.localdomain...
WorkItem workItem = (WorkItem) IWorkItem.ITEM_TYPE.createItem();

This is the problematic line of code. It will not correctly initialize the work item.

You could use a WorkItemOperation as described in
https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation

Or alternatively, you would use the working copy manager to create a work item for you:

IWorkItemHandle handle= manager.connectNew(IWorkItemType workItemType, IProgressMonitor monitor);
WorkItemWorkingCopy workingCopy= manager.getWorkingCopy(handle);
workingCopy.getWorkItem().setHTMLSummary(XMLString.createFromPlainText("original summary"));

IAttribute attr = workItemClient.findAttribute(workingCopy.getWorkItem().getProjectArea(),
"com.ibm.team.apt.attribute.acceptance", monitor);
if (attr != null) {
workItem.setValue(attr, XMLString.createFromPlainText("My Acceptance Test Text"));
}

--
Regards,
Patrick
Jazz Work Item Team

0 votes


Permanent link
WorkItem workItem = (WorkItem) IWorkItem.ITEM_TYPE.createItem();

This is the problematic line of code. It will not correctly initialize
the work item.

You could use a WorkItemOperation as described in
https://jazz.net/wiki/bin/view/Main/ProgrammaticWorkItemCreation

Or alternatively, you would use the working copy manager to create a
work item for you:

IWorkItemHandle handle= manager.connectNew(IWorkItemType workItemType,
IProgressMonitor monitor);
WorkItemWorkingCopy workingCopy= manager.getWorkingCopy(handle);
workingCopy.getWorkItem().setHTMLSummary(XMLString.createFromPlainText("original
summary"));

IAttribute attr =
workItemClient.findAttribute(workingCopy.getWorkItem().getProjectArea(),
"com.ibm.team.apt.attribute.acceptance", monitor);
if (attr != null) {
workItem.setValue(attr, XMLString.createFromPlainText("My
Acceptance Test Text"));
}

--
Regards,
Patrick
Jazz Work Item Team

0 votes

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
× 411
× 14

Question asked: Jan 25 '10, 2:38 p.m.

Question was seen: 9,340 times

Last updated: Nov 14 '12, 8:20 a.m.

Confirmation Cancel Confirm