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

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);
    }
  }
}

1

0 votes

Comments

I have some more details on the root cause.

The root cause is the synchronization done by the method

this.fWorkItemClient.updateWorkItemType(workItem, type, type, mon);
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.
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.


Accepted answer

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

0 votes

Comments

 Thanks for sharing, Marko!


One other answer

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

0 votes

Comments

That is what I was trying. But still the new attribute did not appear when calling IWorkItem.hasAttribute().
Actually the problem is happening in relation to the WCL tool.
We have integrated WCL into a framework that in this scenario:
1. Switches the master project area
2. Runs the synchronization
3. Wants to set some dedicated values to the new attributes.

But in step 3 WCL complains (correctly) that the attribute to be set is not existing in the work item.

 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

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,937

Question asked: Nov 24 '16, 5:52 p.m.

Question was seen: 3,548 times

Last updated: Nov 30 '16, 7:25 a.m.

Confirmation Cancel Confirm