data migration of new customAttributes programmatically
![]()
hi
i need to migrate workitem customattributes via code Here is my scenario: - my process changed - i had before a customAttribute id 'text' type 'smallString' - i introduced a new customattribute id 'text2' as 'string' - the new process has been saved with success that contains the new customAttribute 'text2' - i want via code: 1. 'text2' to be updated to my workitem type ...it does not show up 2. the value of 'text' to be copied on 'text2' can somebody give me some code that i can look into to achieve what i want to do? thank you Stefania |
4 answers
![]()
hi
in particular, - I want to have access to a List <IWorkItem> coming for a query for only 1 WorkItemType. - refresh/synchronize the customAttributes of my IWorkItemType - then be able to use a IAttribute findAttribute by attribute id to find the attribute that i want to retrieve the value (IWorkItem.getValue(IAttribute) for currentValue) to be able to do IWorkItem.setValue(newAttribute, currentValue) please help thanks Stefania |
![]()
IWorkItem.addCustomAttribute(IAttribute attribute);
seems to be what i need in order to add a new custom attribute. I still have questions on how to make it work?? what is the class that i need to use in order to have my workitmetype updated? After i get all the list of my IWorkItem (possible from a query). thank you Stefania |
![]()
first: it will be a client application to do the migration.
I got to work the query part of my application. By looking at the example https://jazz.net/wiki/bin/view/Main/QueryDevGuide#ExampleTwo I can query project area /work item of a certain type and get the List of work items. &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& IQueryableAttribute projectAreaAttribute = findAttribute( projectArea, auditableClient, IWorkItem.PROJECT_AREA_PROPERTY, null ); IQueryableAttribute workItemTypeAttribute = findAttribute( projectArea, auditableClient, IWorkItem.TYPE_PROPERTY, null ); AttributeExpression projectAreaExpression = new AttributeExpression( projectAreaAttribute, AttributeOperation.EQUALS, projectArea ); AttributeExpression workItemTypeExpression = new AttributeExpression( workItemTypeAttribute, AttributeOperation.EQUALS, "myworkitemtypeid" ); Term term = new Term( Operator.AND ); term.add( projectAreaExpression ); term.add( workItemTypeExpression ); &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Now i need to see how to use the IWorkItem.addCustomAttribute and IWorkItem.removeCustomAttribute for each of my found work item where the custom attributes have already been added or simply removed in my changed process specification. thank you Stefania |
![]()
After query the work item with a specific type.
I copied what was in the old attribute to the new attribute by extending WorkItemOperation and it works &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private static class WorkItemAttributeCopy extends WorkItemOperation { private IAttribute fAttribute1; private IAttribute fAttribute2; public WorkItemAttributeCopy( IAttribute attribute1, IAttribute attribute2 ) { super( "Initializing Work Item", IWorkItem.FULL_PROFILE ); fAttribute1 = attribute1; fAttribute2 = attribute2; } protected void execute( WorkItemWorkingCopy workingCopy, IProgressMonitor monitor ) throws TeamRepositoryException { IWorkItem workItem = workingCopy.getWorkItem(); workItem.setValue( fAttribute2, workItem.getValue( fAttribute1 ) ); } &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& This is good for when i need to migrate data from an old attribute to a new attribute when i decided to change its type for whatever reason. The simple attribute add a remove in my process specification that do not require data migration should be solved by calling the same code that does the client "Synchronize Attributes". I asked the link to the code in another forum. http://jazz.net/forums/viewtopic.php?p=52809#52809. thanks Stefania |
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.