It's all about the answers!

Ask a question

Accessing childern of a workitem through Java API program


Ramya Gopalan (3141) | asked May 21 '10, 12:57 a.m.
Hi,

I am trying to find the children of a workitem in RTC and access the links for the children using plain java programs. Suppose I have a workitem A with a children workitems B and C, then from workitem A, I want to get the link/page for workitems B and C. I have the following questions:

1. What interface and methods can I use to get details of the children of a work item in RTC?
2. How to access the links and page for each child?
3. Is there a generic way to access all the links? If so, is there a way that I can find it?

I appreciate any ideas or code snippets or pointers that would help.

Thanks!
Ramya.

6 answers



permanent link
sundarrajan rangarajan (3124) | answered Mar 19 '12, 6:00 a.m.
Hi,
below is the piece of code for getting the changesets for an wotkitem.


public static void getChangeSets(IWorkItem workItem) throws TeamRepositoryException {
workSpaceManager = SCMPlatform.getWorkspaceManager(teamRepository);
IProgressMonitor monitor = new SysoutProgressMonitor();
ILinkManager fLinkManager = (ILinkManager) teamRepository.getClientLibrary(ILinkManager.class);
IReferenceFactory fReferenceFactory = fLinkManager.referenceFactory();
IReference reference = fReferenceFactory.createReferenceToItem(workItem.getItemHandle());
ILinkQueryPage page;
page = fLinkManager.findLinksByTarget("com.ibm.team.filesystem.workitems.change_set", reference, monitor);
System.out.println("page size "+page.getSize()); ---> this is getting the count of changesets correctly
//ILinkCollection linkCollection = page.getLinks();

//Collection<ILink> links = linkCollection.getLinksById("com.ibm.team.filesystem.workitems.change_set");
Collection<ILink> links = page.getLinks().getLinksById("com.ibm.team.filesystem.workitems.change_set");
if (links.isEmpty()) --->this is becoming true always
System.out.println("link is empty "+ links.size());-- this is always empty
else
System.out.println("link is not empty");
Iterator<ILink> iter = links.iterator();

while (iter.hasNext())
{
ILink link = iter.next();
System.out.println("inside changeset function");
}
}


I am not able to get the links for changeset from the page . can somebody let me know where I am going wrong

permanent link
Ralph Schoon (63.1k33645) | answered May 24 '10, 4:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi again,

there is a dedicated forum for these types of questions. See and search http://jazz.net/forums/viewforum.php?f=2 maybe this has already been dicussed there.

Ralph

Hi,

I am trying to find the children of a workitem in RTC and access the links for the children using plain java programs. Suppose I have a workitem A with a children workitems B and C, then from workitem A, I want to get the link/page for workitems B and C. I have the following questions:

1. What interface and methods can I use to get details of the children of a work item in RTC?
2. How to access the links and page for each child?
3. Is there a generic way to access all the links? If so, is there a way that I can find it?

I appreciate any ideas or code snippets or pointers that would help.

Thanks!
Ramya.

permanent link
Ramya Gopalan (3141) | answered May 24 '10, 5:29 a.m.
Hi Ralph,

I think I have my post in the same forum as you have pointed out "Extending Team Concert" (and your link directs me to the same). Please let me know if you mean something else, when you say "dedicated forum".

I tried searching in the jazz extend forum but was not able to find answers for my questions specific to children links. I was able to find something for changeset links at http://jazz.net/forums/viewtopic.php?t=2404&highlight=ilinkquerypage. Any help/pointers for something similar with the methods to be used for accessing relationships will be really helpful.

Thanks!
Ramya.

permanent link
Ralph Schoon (63.1k33645) | answered May 25 '10, 1:52 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Ramya,

my fault, for whatever reason I ended up browsing the wrong forum 8-)

Sometimes the search is problematic.

I have no code you need. Here is a similar situation with a dependency instead. Maybe this gives you some idea.


List<IWorkItemHandle> dependencies= new ArrayList<IWorkItemHandle>();
List<IReference> references= saveParameter.getNewReferences().getReferences(WorkItemEndPoints.DEPENDS_ON_WORK_ITEM);
for (IReference reference: references)
if (reference.isItemReference() && ((IItemReference) reference).getReferencedItem() instanceof IWorkItemHandle)
dependencies.add((IWorkItemHandle) ((IItemReference) reference).getReferencedItem());
[code]

Ralph

Hi Ralph,

I think I have my post in the same forum as you have pointed out "Extending Team Concert" (and your link directs me to the same). Please let me know if you mean something else, when you say "dedicated forum".

I tried searching in the jazz extend forum but was not able to find answers for my questions specific to children links. I was able to find something for changeset links at http://jazz.net/forums/viewtopic.php?t=2404&highlight=ilinkquerypage. Any help/pointers for something similar with the methods to be used for accessing relationships will be really helpful.

Thanks!
Ramya.[/code]

permanent link
Ramya Gopalan (3141) | answered May 25 '10, 4:48 a.m.
Hi Ralph,

That is exactly what I was looking for. Thank you very much :D.

Ramya.

permanent link
sundarrajan rangarajan (3124) | answered May 11 '12, 5:57 a.m.
Hi,
There is a need for us to automate the code delivery process in java.
we have 13 development streams and one integration stream.
on monthly basis we would deliver changes from these 13 streams in to the integration stream. so far, we have been doing this manually. we do this by creating 13 repository workspaces for 13 streams and after accepting the changes, we will change the flow target to integration stream and start deliver the change sets one by one provided the change sets met required approvals. this takes lot of time as we do this manually.

I have a logic for doing this . but i don't know how to approach this in java.
my logic is ,..
1. At the end of the month , i will accept all the changes in my 13 repository work spaces .

2. After accepting ,I will find the total number of change sets delivered in the month by comparing the 13 development streams and integration stream and the output will be in change lo file

3. now comes the java program. i will loop through the list of change sets by reading the work item number in the change log file.
(up to this ,I know how to do in java)


4. for every change set i read , I have to change the flow target to integration stream programatically and i will deliver the change set to integration stream ( from this point onwards, i have no idea which class to use)

5. Change sets can be delivered only if it meet the required approvals


please help me and let me know how to proceed

Thanks,
Sundar

Your answer


Register or to post your answer.