How to get and set the 'Iteration - target(ID)' using java API ?
![]() Hi. I'm trying to set an Iteration as current target but it did not work.. The focus are that
How to:
I'd like you to give the sample code to me. I just couldn't do that by myself. :( Please any ask.. Thanks for help,
Sungyeun
|
Accepted answer
![]()
Hi Hwang,
The following functions will help you to read all the Iteration's from the project area. it will return iteration names as String of Array. public String[] getPlannedForList() { ArrayList<String> list = new ArrayList<String>(); ArrayList<ArrayList<String>> listall = new ArrayList<ArrayList<String>>(); IDevelopmentLineHandle[] developmentHandles = ((IProjectArea) projectArea) .getDevelopmentLines(); IDevelopmentLine line = null; if (developmentHandles != null) { List developmentLines = null; try { developmentLines = teamRepository.itemManager() .fetchCompleteItems(Arrays.asList(developmentHandles), IItemManager.DEFAULT, null); } catch (TeamRepositoryException e1) { e1.printStackTrace(); } for (Iterator e = developmentLines.iterator(); e.hasNext();) { line = (IDevelopmentLine) e.next(); IIterationHandle[] iterationHandles = line.getIterations(); list = PlannedForRecursive(iterationHandles); if (list != null) listall.add(list); } } int size = listall.size(); int i = 1; for (ArrayList<String> lis : listall) { if (lis != null) { for (String s : lis) { if (s != null) { i++; } } } } String[] data = new String[i]; data[0] = "Unassigned"; i = 1; for (ArrayList<String> lis : listall) { if (lis != null) { for (String s : lis) { if (s != null) { data[i] = s; i++; } } } } return data; } public static ArrayList<String> PlannedForRecursive( IIterationHandle[] iterationHandles) { ArrayList<String> interation_name = new ArrayList<String>(); int i = 0; if (iterationHandles != null) { List iterationlines = null; try { iterationlines = teamRepository.itemManager() .fetchCompleteItems(Arrays.asList(iterationHandles), IItemManager.DEFAULT, null); } catch (TeamRepositoryException e) { e.printStackTrace(); } IIteration iteration = null; for (Iterator e1 = iterationlines.iterator(); e1.hasNext();) { iteration = (IIteration) e1.next(); if (iteration.getName() != null&&!iteration.isArchived()) interation_name.add(iteration.getName()); i++; ArrayList<String> templist = null; if (iteration.getChildren() != null) { templist = PlannedForRecursive(iteration.getChildren()); } if (templist != null) for (String s : templist) { if (s != null) { interation_name.add(s); // System.out.println("planned for recursive :"+s); } // i++; } } } return interation_name; } code for set Target : workItem.setTarget(getPlannedForLiteral("targetstring")); Modify the above functions to get Literal value for a given target string. Please ignore if its not relevant to your question. Regards, Pugazh S Sungyeun Hwang selected this answer as the correct answer
Comments Hi Pugazh, nice code, thanks for contributing.
Thanks!! But, I can't apply to my code. :( That's difficult. There are some typos and minor errors in the code above. Try http://rsjazz.wordpress.com/2012/10/05/handling-iterations-automation-for-the-planned-for-attribute/ Hi. Ralph. Thanks for your comment!! But, I couldn't try to use that code(http://rsjazz.wordpress.com/2012/10/05/handling-iterations-automation-for-the-planned-for-attribute/). That's difficult. I mean, I'd like use a code as like other attribute(Category, date etc..) For example > for setCategory :
List<ICategory> findCategories= workItemClient.findCategories(projectArea, ICategory.FULL_PROFILE, monitor);
Like this.. :( But, 'setTarget ' that to setting 'IIterationHandle' is so difficult to me.. Please any help. :) Thanks, That is the only way I know of. I have mentioned the difference to the category in the blog post. I think you should really read it.
Thanks!! All of your Answer ! I got it for your help :) I really thank you !!!
showing 5 of 6
show 1 more comments
|
4 other answers
![]()
Ralph Schoon (63.3k●3●36●46)
| answered Oct 05 '12, 3:28 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Here is another helper I developed: http://rsjazz.wordpress.com/2012/10/05/handling-iterations-automation-for-the-planned-for-attribute/
Comments Hi. Ralph. Thanks for your comment!! But, I couldn't try to use that code(http://rsjazz.wordpress.com/2012/10/05/handling-iterations-automation-for-the-planned-for-attribute/) That's difficult. I mean, I'd like use a code as like other attribute(Category, date etc..) For example > for setCategory :
List<ICategory> findCategories= workItemClient.findCategories(projectArea, ICategory.FULL_PROFILE, monitor);
Like this.. :( But, 'setTarget ' that to setting 'IIterationHandle' is so difficult to me.. Please any help. :) Thanks, |
![]()
Hi Hwang,
check the below code to set Target: workItem.setTarget(getIterationLiteral("Iteration String")); Declare the below Variable as common to both function: private IIterationHandle listitehandle; Functions to get Literal value for a given Value: public IIterationHandle getIterationLiteral(String val) throws TeamRepositoryException { IDevelopmentLineHandle[] developmentHandles = ((IProjectArea) projectArea) .getDevelopmentLines(); IDevelopmentLine line = null; if (developmentHandles != null) { List developmentLines = teamRepository.itemManager() .fetchCompleteItems(Arrays.asList(developmentHandles), IItemManager.DEFAULT, null); for (Iterator e = developmentLines.iterator(); e.hasNext();) { line = (IDevelopmentLine) e.next(); IIterationHandle[] iterationHandles = line.getIterations(); IterationRecursiveLiteral(iterationHandles, val); } } return listitehandle; } public void IterationRecursiveLiteral( IIterationHandle[] iterationHandles, String val) { String interation_name = null; IIteration iteration = null; IIteration iteration_r = null; int i = 0; if (iterationHandles != null) { List iterationlines = null; try { iterationlines = teamRepository.itemManager() .fetchCompleteItems(Arrays.asList(iterationHandles), IItemManager.DEFAULT, null); } catch (TeamRepositoryException e) { e.printStackTrace(); } for (Iterator e1 = iterationlines.iterator(); e1.hasNext();) { iteration = (IIteration) e1.next(); if (iteration.getName().equalsIgnoreCase(val)) { listitehandle = iteration; return; } if (iteration.getChildren() != null) { IterationRecursiveLiteral(iteration.getChildren(), val); } } } } |
![]()
HI,
The code here talks about get the iteration on the client side .
could you please help me in getting the all the iterations of a projectarea on the server side.
Thanks
Surender
Comments Most of the code e.g. also published here: https://rsjazz.wordpress.com/2012/10/05/handling-iterations-automation-for-the-planned-for-attribute/ uses common API that is available on client as well as server.
|
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.