Welcome to the Jazz Community Forum
How to modify process XML in a process configuration aspect editor

3 answers

Comments

Moved to an separate answer due 1200 character limitation in comments.

Chris, thanks for your answer. I have a couple follow up questions:
-
Can getAspect().update() update a portion of the process configuration XML, that is can we simply call getAspect().update() with an updated XML element (and its children if any)? Or do we need to call getAspect().update() with the entire process configuration XML containing our changes? If it's the former, can we make multiple getAspect().update() calls to update different XML elements?
- Does RTC supply any convenience classes / methods for converting a ModelElement to XML? Or is this something that we need to implement ourselves?

1. I'm pretty sure that getAspect().update() requires you to supply xml for the complete configuration-data section, not just the part you changed,

Chris, I'm confused by your answer to question 1. In your original answer, you said
The typical aspect editor for configuration data will call getAspect().getConfigurationRoot() to get the configuration data and convert that data into a data structure which is easier for the editor to work. When it comes time to save the modified data the data is written out in XML format and passed to getAspect().update().I read that to mean that getAspect().update() could update the entire process model since you said the typical use is to pass getAspect().update() updated XML derived from the full process model, that is from getAspect().getConfigurationRoot().
But in your answer to question 1, you say
getAspect().update() requires you to supply xml for the complete configuration-data section, not just the part you changedwhich implies that getAspect().update() can only update the configuration data associated with the aspect.
So, can getAspect().update() parts of the process model outside of the configuration data associated with the aspect? Or is it limited to just the configuration data associated with the aspect?

What I meant to say was that when you call update you would pass all of the xml for that specific aspect, not the entire process specification. The configuration data is divided into different <configuration-data> sections and the internal class ConfigurationDataAspect corresponds to one configuration data section.

Chris, thanks for your latest response. This means that your original answer doesn't really answer my original question. My original question asks how from within process aspect editor (extension of the abstract ProcessAspectEditor class) does one update a process model element that occurs outside of the process model element associated with the aspect.

Comments

Ralph, thanks for the pointer to the Rational Team Concert 4.0 Extensions Workshop. I've been thru the workshop (though some time ago), and I along with others on my team have written a few process aspect editors. We're trying to get an answer to a specific question, which I don't remember being answered (at least directly) in the Extensions Workshop. Did I happen to miss the answer somewhere? If so, could you point me to where I should look?

As far as I can tell, the aspect editor can only modify the schema it is responsible for and not anything outside of this context.

No, the workshop does only modify in the configuration for the participant. You are correct.

Log log = LogFactory.getLog( this.getClass() );
IProcessContainerWorkingCopy processContainerWorkingCopy = getAspect()
.getProcessContainerWorkingCopy();
IDocument spec = processContainerWorkingCopy.getProcessSpecification();
String s = spec.get();
String s1 = s.replace( "<project-configuration>",
"<project-configuration Geoff=\"it works\">" );
log.warn( "specification:\n" + s1 );
spec.set( s1 );
try
{
processContainerWorkingCopy.save( null );
}
catch (TeamRepositoryException e)
{
log.error( "TeamRepostioryException encountered saving "
+ "process specification changes", e );
}
I'm not sure that this is entirely kosher, but it does seem to do what we need.
Comments

I would be extremely careful when doing this. In discussions I came across in the past it was always suggested not to modify the process XML directly, what I believe you are doing here.

You absolutely shouldn't do this. You're saving the project area out from under the editor, which might be dirty with other changes. This can result in corruption or loss of data.
1 vote