Getting last modifier of process template
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?
Accepted answer
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.
Comments
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.
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?
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
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 :-)
Comments
Chris Goldthorpe
JAZZ DEVELOPER Oct 26 '12, 2:04 p.m.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.
1 vote
Morten Madsen
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
Oct 31 '12, 2:39 p.m.Please... anyone?
Chris Goldthorpe
JAZZ DEVELOPER Oct 31 '12, 4:52 p.m.I'll see if I can come up with a working code snippet that I can paste as an answer.
1 vote
Morten Madsen
Oct 31 '12, 5:41 p.m.You are awesome :-D.