It's all about the answers!

Ask a question

Attributes synchronization with Java ? Possible ?


Unknown User (2111) | asked Apr 23 '12, 11:10 a.m.
Hi,

In my company, we need to work with more than one hundred projects and regularly, we have to modify custom attributes in all projects (they have the same process template).

In article https://jazz.net/library/article/529/ is mentionned the synchronization but we need to do it manually and it takes many time ...

Could we do it with the API (Java) ?

Thanks for your answer

4 answers



permanent link
Ralph Schoon (63.1k33645) | answered Apr 23 '12, 12:20 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi,
I am pretty sure that would be possible, since the synchronize attributes is done in the Eclipse client. I am not sure how complex it would be.

Essential it would have to go through all work items (e.g. using a query) then find the custom attributes for the type and then create the attribute for the work item if it does not have it.

It is possible to create custom attributes using the API. You can do that even if they are not defined in the process template. I think they would not show up in the process template. At least I have seen that in the past.

What I haven't tried yet and thus an mot sure of is how to create then in the process description, so that they show up as custom attributes in the configuration. Since the Eclipse Client uses the API to do this, I would assume it is possible.

Have you looked into the capability of sharing a process from a project? Maybe that can reduce your effort?

permanent link
Unknown User (2111) | answered May 25 '12, 11:11 a.m.
Hi,

Maybe I have to simply look this way :

workItemClient.updateWorkItemType(workItem, type, type, monitor);

I have to test ...

permanent link
sam detweiler (12.5k6195201) | answered May 25 '12, 12:26 p.m.
that changes the workitem type from Defect to Story or whatever

permanent link
Ralph Schoon (63.1k33645) | answered May 29 '12, 3:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
The code can be found in

com.ibm.team.workitem.rcp.ui.internal.actions.SynchronizeAttributesAction

And it is in fact documented that

/**
* Change the given work item to have the given type, custom attributes
* of the type will be added and initialized to their default value iff
* the work item does not have them already.
*
* @param workItem the work item, must be a working copy
* @param newType the new type, must be of the same project area as the work item
* @param oldType the old type of the work item
* @param monitor a progress monitor or <code>null</code>
* @return whether the set of custom attributes has changed
* @throws TeamRepositoryException if anything goes wrong
* @see IItem#isWorkingCopy()
* @since 0.7
*/
boolean updateWorkItemType(IWorkItem workItem, IWorkItemType newType, IWorkItemType oldType, IProgressMonitor monitor) throws TeamRepositoryException;


Is used like this:


IWorkItem workItem= workingCopy.getWorkItem();
IWorkItemType type= workItemClient.findWorkItemType(workItem.getProjectArea(), workItem.getWorkItemType(), monitor);
if (type != null)
workItemClient.updateWorkItemType(workItem, type, type, monitor);



So the ley is to run updateWorkItemType() with the original type, which adds attributes if they are not already there.

Your answer


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