how to call 'Synchronize Attributes' via client code
hi
I want to be able to call the 'Synchronize Attributes' via code or doing the same thing via code. how can i do so? After the process specification changes, the 'Synchronize Attributes' of the work item query result in the RTC Eclipse IDE will get the changes . thanks in advantage Stefania |
9 answers
i think this is the code
com.ibm.team.workitem.common.model.ItemProfile.SynchronizeAttributesAction i will try to use a similar logic stefy |
seems to work fine with the
1. WorkItemOperation extension 2. workItemClient.updateWorkItemType(workItem, type, type, null); where old type and new type are the same. |
We are trying to use the code below to synchronize attributes on a work-item:
ITeamRepository repo = …
But then no attributes have been synched... Any advice?
By the way, the same snippet code was suggested by a Jazz developer: https://jazz.net/forum/questions/75734/attributes-synchronization-with-java-possible/75738
Thanks in advance.
|
to change the single work item
I created a query and synchronize each work item result of the query. while (result.hasNext( null )) { IResolvedResult<IWorkItem> resolved = result.next( null ); IWorkItem workItem = resolved.getItem(); WorkItemSynchronizeAttributes synchronizeOperation = new WorkItemSynchronizeAttributes(); synchronizeOperation.run( workItem, null ); } WorkItemSynchronizeAttributes extendis WorkItemOperation its method execute will do the rest. protected void execute( WorkItemWorkingCopy workingCopy, IProgressMonitor monitor ) throws TeamRepositoryException { IWorkItem workItem = workingCopy.getWorkItem(); ITeamRepository teamRepository = workingCopy.getTeamRepository(); IWorkItemClient workItemClient = (IWorkItemClient)teamRepository .getClientLibrary( IWorkItemClient.class ); IWorkItemType type = workItemClient.findWorkItemType( workItem .getProjectArea(), workItem.getWorkItemType(), null ); if (type != null) { workItemClient.updateWorkItemType( workItem, type, type, null ); } } |
Ok, even our code seems to work like a charm.
We got problems when we try to update the project area's process with the new attributes using the code below:
IProcessDefinition processTemplate = ...This is a very strange behaviour because the process configuration source in the project area it really contains all the attributes...! |
are you trying to change the process configuration based on a new updated template? this is what i do -------------------------------------------------------------------------------------------
IProcessItemService processService = (IProcessItemService)repository.getClientLibrary( IProcessItemService.class );
IWorkingCopyManager workingCopyManager = processService.getWorkingCopyManager();
workingCopyManager.connect( projectArea ); IProcessItemWorkingCopy itemWorkingCopy = workingCopyManager.getWorkingCopy( projectArea ); ...... document.set(xml); itemWorkingCopy.save( null );
|
Yep, given a template we update all the existing project area with that template. So, instead of: IProjectAreaWorkingCopy prjAreaFreshCopy = (IProjectAreaWorkingCopy) workingCopyManager.createPrivateWorkingCopy(prjArea); as suggest here: https://jazz.net/forum/questions/49535/how-to-get-process-template-source/49536, we have to use: workingCopyManager.connect(prjArea); P.S. Thanks a bunch for you answers, Stefania! |
Hello,
I try to synch my workitem to another workitem via server-side code. When I press Save Button, my plugin will synchronize Task WorkItem to Release Workitem. And there are some other controls which happens when a Release Workitem created. IWorkItemType oldType = wiServer.findWorkItemType(operation.getProcessArea().getProjectArea(),"task", monitor); IWorkItemType newType = wiServer.findWorkItemType(operation.getProcessArea().getProjectArea(),"com.avea.workItemType.release", monitor); workItemCommon.updateWorkItemType(newWorkItem, newType, oldType, monitor); Synchronization worked for the attributes but workflow didnt get synchronized. It says "Uninitialized" And also link type with the other workitems is lost. I can see the my childworkitems but there's no releation information. Do you have any idea how to solve this problem? Comments
Ralph Schoon
commented Nov 27 '12, 6:15 a.m.
| edited Nov 27 '12, 6:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I am pretty sure that synchronizing work items is not supposed to solve your scenario. Synchronize attributes is only supposed to add any missing attributes from the type to the work item. If you change the type there is a certain mapping that would need to be done. If the work item has a state literal that is not available in the new type's workflow, I would assume issues. Synchronize won't fix that. You might have to: Change the type, map some attributes such as the state (see http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/) and then sync to get new attributes added.
On a second thought, if you change the type of the work item and there is no matching state in the new type, the work item gets the new state.
Canberk Akduygu
commented Nov 27 '12, 10:54 a.m.
As you said there's no matching state in both workitems but state turns into Uninitilized state or may be I understood your assumption.
Ralph Schoon
commented Nov 27 '12, 10:59 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
You could create an Advisor that prevents from changing the type. For API hints look at http://rsjazz.wordpress.com/2012/11/26/manipulating-work-item-states/, the development Wiki and other posts and links.
|
Ralph Schoon (63.5k●3●36●46)
| answered Nov 27 '12, 6:10 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Here is an APP that does it for you: http://rsjazz.wordpress.com/2012/11/19/using-an-expression-to-synchronize-attributes-for-work-items-of-a-specific-type/
Comments Instead of an expression you can also use a query as described in http://rsjazz.wordpress.com/2012/10/29/using-work-item-queris-for-automation/
|
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.