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
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
Accepted answer
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);
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);
7 other answers
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
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
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;
}
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;
}
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.
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.