It's all about the answers!

Ask a question

Getting last modifier of process template


0
1
Morten Madsen (3053150) | asked Oct 25 '12, 8:08 a.m.
edited Oct 26 '12, 2:17 a.m. by David Olsen (5237)
Hi, I'm creating a tool to manage the currently deployed process templates using the RTC Java API.

I've gotten almost everything to work, but I can't figure out how to retrieve the "modified()" and "modifiedBy()" of the *current* process template of a project.

I'm using the same alorithm as in this message: https://jazz.net/forum/questions/81391/how-do-i-find-out-who-has-created-andor-modified-an-iteration-in-the-project-configuration

But if you do:


project.getProcessDefinition();

you get a pointer to the *original* process template and not the active one.
You can get the current process xml by using:
project.getProcessData().get("com.ibm.team.internal.process.compiled.xml")

But this will only get you the IContent. Any ideas?

Comments
1
Chris Goldthorpe commented Oct 26 '12, 2:04 p.m.
JAZZ DEVELOPER

When you say the current process template are you looking to find the most recent state of the process template that was used to create a project area, even if that is newer than the version which was used to create the project area? You are correct in that getting the process xml is not going to help you  discover anything about the process template. 


Did you try calling IItemManager.fetchAllStateHandles(...). parring in the process definition to get all of its states?


Morten Madsen commented Oct 28 '12, 12:35 p.m.

Hi, thanks for your answer.

I'm trying to access the information about who last edited the process for the project. This history is normally accessible by going to "Process source" -> right click -> history.

Do you know how to access this information using the API?

Yes, I tried what you are suggesting, and then I actually get the information I'm looking for, but for the Process Template of which the project was originally initialized.

Do you know how to fetch the same information, but from the "active" process xml in the project?


Morten Madsen commented Oct 31 '12, 2:39 p.m.

Please... anyone?


1
Chris Goldthorpe commented Oct 31 '12, 4:52 p.m.
JAZZ DEVELOPER

 I'll see if I can come up with a working code snippet that I can paste as an answer.


Morten Madsen commented Oct 31 '12, 5:41 p.m.

You are awesome :-D.

Accepted answer


permanent link
Jared Burns (4.5k29) | answered Oct 31 '12, 5:13 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
What you're asking to do is basically the same thing that RTC currently does to compute the history of the process specification for the Eclipse client. It works like this:

1. We walk the predecessor states of the project area backward, starting from the current.
2. As we go, we note the content ID of the IContent for the process specification (it sounds like you already know how to get to this).
3. Whenever we detect a change in the content ID between two states, we know the specification was changed.

So something like this:
PA stateID  -  spec contentID
_aaaaaaa    -  abc
_bbbbbbb    -  abc           <--- the spec changed in state _bbbbbbb
_cccccccc    -  def
_ddddddd    -  def
_eeeeeee    -  def           <--- the spec changed in state _eeeeeee
_fffffffffffffff   -  ghi
_ggggggg    -  ghi

Hope that helps.
Morten Madsen selected this answer as the correct answer

Comments
Chris Goldthorpe commented Oct 31 '12, 5:41 p.m.
JAZZ DEVELOPER

 I agree with what Jared said and will add that to get the process specification of a project area you need to make a call like this.


IContent content =(IContent)projectArea.getProcessData().get(ProcessContentKeys.PROCESS_SPECIFICATION_KEY);


Morten Madsen commented Oct 31 '12, 5:45 p.m.

Ah, sounds great!! :-). Will try that tomorrow and write feedback here!!

I don't remember precisely, but I still can't get the "modifiedBy()" can I? That's only from a ProcessDefinition, as far as I remember?


Morten Madsen commented Nov 01 '12, 4:25 a.m.

Ah, I think I found what I'm looking for.

an IProjectArea has a "getModifiedBy()" (inherited from IItem). This is the one telling who changed the project area.

This will unfortunately also tell me who changed the project name, wiki, members etc. So I have to do as you recommend. Get all states and scan through them, find the most recent one, and compare the IContent id.

Thanks for your help, but please tell me, if you find an easier way :-).

One other answer



permanent link
Morten Madsen (3053150) | answered Nov 01 '12, 4:45 a.m.
edited Nov 01 '12, 6:54 a.m.
Hi, I ended up doing like this:
public IProjectArea fetchLatestProcessModifiedState(IProjectAreaHandle handle) throws TeamRepositoryException
{
	List<IProjectArea> states = repo.itemManager().fetchAllStateHandles((IAuditableHandle) handle, monitor);
	states = repo.itemManager().fetchCompleteStates(states, monitor);
	
	IProjectArea latest = null;
	UUID latestContentId = null;
	for (IProjectArea p : states)
	{
		IContent content = (IContent) p.getProcessData().get(ProcessContentKeys.PROCESS_SPECIFICATION_KEY);
		if (latest == null)
		{
			latest = p;
			latestContentId = content.getContentId();
		}
		else if (latest.modified().before(p.modified()) && !content.getContentId().equals(latestContentId))
		{
			latest = p;		
			latestContentId = content.getContentId();
		}
		else if (latest.modified().after(p.modified()) && content.getContentId().equals(latestContentId))
		{
			latest = p;
			latestContentId = content.getContentId();
		}	
	}
	return latest;
}
/Cheers :-)

Your answer


Register or 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.