After work item type update/attribute sync the new attributes are not visible on work item object
Hi
I have developed a tool for synchronizing the work item attributes. For that I am using the class listed at the end of this post. If I run my (plain java) application that synchronizes work items in order to show up some new attributes it works fine if I run the tool and then open the browser for looking at the work items. That means the new work item attributes are appearing then in the browser. But this is not what I want/need. I am running the below listed operation on a bunch of work items. In the same application session I want to access the newly appearing attributes. But these attributes are not available via API. When I ask the project area for the new attributes they are found. But when I then fetch the synchronized work items and call IWorkItem.hasAttribute(xyz) the new attributes are not found. I could imagine that the work item objet ct (before the sync) is somehow cached and then returned instead of work item with the new custom attributes. Code for running the work item attribute synch: import org.apache.logging.log4j.LogManager; import org.eclipse.core.runtime.IProgressMonitor; import com.ibm.team.repository.common.TeamRepositoryException; import com.ibm.team.workitem.client.IWorkItemClient; import com.ibm.team.workitem.client.WorkItemOperation; import com.ibm.team.workitem.client.WorkItemWorkingCopy; import com.ibm.team.workitem.common.model.IWorkItem; import com.ibm.team.workitem.common.model.IWorkItemType; public class SynchronizeWorkItemOperation extends WorkItemOperation { private IWorkItemClient fWorkItemClient = null; /** * Parameterised constructor. * * @param workItemClient , {@link IWorkItemClient} instance , must not be null */ public SynchronizeWorkItemOperation(final IWorkItemClient workItemClient) { super("Synchronize Attribute Schema of Work Items", IWorkItem.FULL_PROFILE); this.fWorkItemClient = workItemClient; } @Override public void execute(final WorkItemWorkingCopy workingCopy, final IProgressMonitor mon) throws TeamRepositoryException { IWorkItem workItem = workingCopy.getWorkItem(); IWorkItemType type = this.fWorkItemClient.findWorkItemType(workItem.getProjectArea(), workItem.getWorkItemType(), mon); if (type != null) { this.fWorkItemClient.updateWorkItemType(workItem, type, type, mon); } } } |
Accepted answer
I partially found a solution for it.
In the end the reason for this is that the call ProcessClientService.refreshProcessCache() is not happening in my application when the project area working copy object is saved. In the save() method implementation of ProcessAreaWorkingCopy the above mentioned call is executed not in all scenarios though. If I manually invoke the refresh... call in my code then it works fine. I will be investigating why this call is not done automatically. Ralph Schoon selected this answer as the correct answer
|
One other answer
Ralph Schoon (63.4k●3●36●46)
| answered Nov 25 '16, 2:43 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Nov 25 '16, 2:45 a.m.
Marco,
I am unsure what your requirement really is. The code above seems to be identical to https://rsjazz.wordpress.com/2012/11/19/using-an-expression-to-synchronize-attributes-for-work-items-of-a-specific-type/ and has worked for me.
If you want to access the new Attributes after the synchronize, I would suggest to exit the operation, use the work item handle to resolve the updated work item again with a refresh.
IWorkItem itemm = (IWorkItem) teamRepository.itemManager() .fetchCompleteItem(handle, IItemManager.REFRESH, monitor); Comments
Marko Tomljenovic
commented Nov 25 '16, 3:20 a.m.
That is what I was trying. But still the new attribute did not appear when calling IWorkItem.hasAttribute().
I don't know the answer, unfortunately. I looked at com.ibm.team.workitem.rcp.ui.internal.actions.SynchronizeAttributesAction and the code is really identical. |
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.
Comments
I have some more details on the root cause.
When debugging the method I can see that this method actually does nothing since the new custom attributes (introduced by new master pa) are not available in the "type" instance. Therefore actually nothing is done.The root cause is the synchronization done by the method
So it must have something to do with how the type instance is retrieved.
I am really out of ideas now.
When debugging the same code in Eclipse client the method gets the updated work item type with the new attributes whereas in my plain java world it is not working.