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.
Sungyeun Hwang
commented Oct 08 '12, 12:45 a.m.
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/
Sungyeun Hwang
commented Oct 08 '12, 4:09 a.m.
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.
Sungyeun Hwang
commented Oct 08 '12, 8:50 p.m.
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.1k●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
Sungyeun Hwang
commented Oct 08 '12, 4:09 a.m.
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); } } } } Comments
Sungyeun Hwang
commented Oct 08 '12, 8:49 p.m.
Thanks!!!! Finally, I got it due to your help !! :)
Thanks ,Pugazh !!! |
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.
|
Ralph,
the following is the code I have as part of my implementation
public void run(AdvisableOperation operation,
IProcessConfigurationElement participantConfig,
IParticipantInfoCollector collector, IProgressMonitor monitor)
throws TeamRepositoryException {
if (workItemServer == null)
{
workItemServer = getService(IWorkItemServer.class);
}
Object data = operation.getOperationData();
if(data instanceof ISaveParameter) {
IAuditable auditable = ((ISaveParameter)data).getNewState();
if (auditable instanceof IWorkItem)
{
IWorkItem workItem = (IWorkItem)auditable;
{
IAuditableCommon iac = ((ISaveParameter)data).getSaveOperationParameter().getAuditableCommon();
WorkflowManager wfm = new WorkflowManager(iac);
IWorkflowInfo workflowInfo = wfm.getWorkflowInfo(workItem, monitor);
IDevelopmentLineHandle developmentHandle = ((IProjectArea) workItem.getProjectArea()).getProjectDevelopmentLine();
/* if (developmentHandles != null) {
try {
developmentLines = teamRepository.itemManager()
.fetchCompleteItems(Arrays.asList(developmentHandles),
IItemManager.DEFAULT, null);
} catch (TeamRepositoryException e1) {
e1.printStackTrace();
}
}*/
}
}
}
}
}
This code gets called when the user tries to save a work item and I need to find the current iteration and set it to one for the attribute.
how can i get the teamRepository Instance here.
Comments
Surender Biyyala
commented Mar 10 '14, 5:02 a.m.
I can also get the current iteration using the following code
IAuditableCommon iac = ((ISaveParameter)data).getSaveOperationParameter().getAuditableCommon();
IDevelopmentLine dev = iac.getDevelopmentLine(teamArea, monitor);
dev.getCurrentIteration();
But I dont know how to get the teamArea here i mean which API method is used to get the Team Area.
Please suggest me If Im going in awrong path.
Thanks
Surender
http://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ shows an example for how to access that data from work items. e.g.
IProcessAreaHandle processAreaHandle = workItemCommon.findProcessArea(workItem, monitor); IProcessArea processArea = (IProcessArea) workItemCommon.getAuditableCommon().resolveAuditable(processAreaHandle, ItemProfile.PROCESS_AREA_DEFAULT,monitor); |
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.