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

How to Set the Category (Filed Against) based on the Category of another Work item from Different Project area?

Hi,

I am having two work items each from different project area.
If am just assigning the Category from one WI to another

WorkItem1.setCategory(WorkItem2.getCategory());

I am getting "The category is not from the same project area as the work item." exception.

I have created the same Category in both the project areas. I want to get the Category from One project area and assign to work item of another project area with corresponding project area name.

Thanks

0 votes


Accepted answer

Permanent link
Hi,

since the category only exists in a project area you can't use the same object in another area. You have to get the string representation of the original category and find the matching category in the other project area. Then you can set the attribute with the result. Here some code from https://jazz.net/wiki/bin/view/Main/WorkItemExampleSource
 that is used in the examples to find a category based on a string representation.

        List<String> path = Arrays.asList(categoryName.split("/"));
        ICategoryHandle category = workItemClient.findCategoryByNamePath(
                projectArea, path, null);

Muthukumar C selected this answer as the correct answer

1 vote


7 other answers

Permanent link
Ralph,

Its working fine. Thanks

Same way, I want to associate the PLANNED FOR field between work items of two project areas.
That is, i have created development iterations with same labels in both project areas. I want to select the same label from other project area.

Is it possible ? How?

Thanks

0 votes


Permanent link
Hi,

you basically have to follow the same strategy. You get the target from the original work item, then you use the string representation to find the iteration in the other project area and use workItem.setTarget(iteration) to set it. I have no example code for that, unfortunately.

0 votes


Permanent link
Thanks ralph.

I am already working on it
Will give you the sample code shortly if its working fine.

0 votes


Permanent link
Hi,

Using the code below, I am trying to map the Planned for field of two work items in diff project area. But, planned for filed is unassigned which means, condition is not met some where. Pls highlight any mistakes in the code,

        IDevelopmentLineHandle[] iDevelopmentLineHandle = projectArea.getDevelopmentLines();
        boolean breakfor;
        System.out.println("iDevelopmentLineHandle.length : " + iDevelopmentLineHandle.length);
        for (int i=0;i<iDevelopmentLineHandle.length; i++){
            IDevelopmentLineHandle iDevelopmentLinehndl = iDevelopmentLineHandle[i];
            IDevelopmentLine iDevelopmentline = (IDevelopmentLine) repositoryItemService.fetchItem(iDevelopmentLinehndl, null);
            IIterationHandle[] iterationHndls = iDevelopmentline.getIterations();
            breakfor = false;
            System.out.println("iterationHndls.length : " + iterationHndls.length);
            for (int j=0;j<iterationHndls.length; j++){
                IIterationHandle iterationHandle = iterationHndls[j];
                IIteration Destinationiteration = (IIteration) repositoryItemService.fetchItem(iterationHandle,null);
                System.out.println("Destinationiteration.getLabel() : " + Destinationiteration.getLabel());
                if(Destinationiteration.getLabel().equalsIgnoreCase(SourceIterationLabel)){
                    workItem.setTarget(Destinationiteration);
                    breakfor = true;
                    break;
                }
            }
            if (breakfor) break;
        }

0 votes


Permanent link
The way this code works, you only catch the top level iterations. Iterations have children (getChildren()).

If you look for /Release1/Iteration 2/Endgame you have to split the string and search for Release 1 at the 1st level, Iteration 2 on the 2nd and Endgame below that.

0 votes


Permanent link
Hi,

It seems that the Children again can have iterations and so on...
So, How many levels I need to dig to search the string???

process is becoming Tedious :(

Is there any function to get the IterationHandle using the given string irrespective of the LEVEL of Children??

0 votes


Permanent link
Hi,

there is no limitation in levels. It is a tree and hence recursive. The same applies for the iteration from your source work item.

What you have to do is:
At the source work item get the target. Resolve the iteration. Get the name or ID, get the parent iteration, get the name or ID. Continue until there is no parent. Regardless how you want to stare the information for mapping, you will end up with information like

Release 1; Iteration 2; Endgame

given the iteration names/ID's from the example.

You need to pass this to the matching operation. I would probably put the results into an ArrayList, that would help you to easily fetch the name/ID you search for passing it as parameter into the recursive descend.

I would search for ID and name. I would not use getLabel().

You are done if you found it or if you have not found it and you don't have input anymore.


0 votes

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

Question asked: Jun 11 '12, 7:26 a.m.

Question was seen: 5,658 times

Last updated: Jun 12 '12, 6:24 a.m.

Confirmation Cancel Confirm