It's all about the answers!

Ask a question

How to modify process XML in a process configuration aspect editor


Geoff Alexander (19623839) | asked Sep 26 '13, 12:51 p.m.
edited Sep 26 '13, 12:54 p.m.
We're implementing a process configuration aspect editor and need to change process configuration XML outside of the configuration element associated with the aspect.  We can call getAspect().getConfigurationRoot() to get the root of the process configuration XML and then search the process configuration XML to find the XML element(s) that we need to modify.  The problem is that getAspect().getConfigurationRoot() returns a ModelElement, which doesn't have any modification methods.  So, how do we modify and save the process configuration XML once we've found the ModelElement(s) we want to modify?

3 answers



permanent link
Chris Goldthorpe (4287) | answered Sep 27 '13, 12:24 p.m.
JAZZ DEVELOPER
As you mentioned the Model returned from getAspect().getConfigurationRoot() returns a model that is not writable. Configuration data editors update the process specification by calling getAspect().update(), passing in the source of the XML for the model. 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(). 

One consequence of this design is that it is not easy for a configuration data editor to make modifications outside of the configuration data associated with the aspect. It is possible for aspect editors to cooperate with one another, for example the aspect editors used in work items share the same underlying data so that when you add an entry in types and attributes that type becomes available in the Editor Presentations tab. We don't however encourage a configuration data editor to make changes to other sections of the process specification such as permissions or roles.

Comments
Geoff Alexander commented Sep 27 '13, 2:16 p.m. | edited Sep 27 '13, 2:22 p.m.

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



Geoff Alexander commented Sep 27 '13, 2:20 p.m. | edited Oct 04 '13, 12:17 p.m.

Chris, thanks for your answer.  I have a couple follow up questions:

  1. 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?

  2. Does RTC supply any convenience classes / methods for converting a ModelElement to XML?  Or is this something that we need to implement ourselves?


Chris Goldthorpe commented Sep 27 '13, 5:12 p.m.
JAZZ DEVELOPER

 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,


2. I'll take a look at the source of the work items configuration data editors and see what they are doing. 


Geoff Alexander commented Sep 27 '13, 5:45 p.m. | edited Oct 04 '13, 12:17 p.m.

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 changed
which 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?


Chris Goldthorpe commented Sep 27 '13, 5:55 p.m.
JAZZ DEVELOPER

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. 


Geoff Alexander commented Sep 27 '13, 6:14 p.m. | edited Oct 04 '13, 12:18 p.m.

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.

showing 5 of 6 show 1 more comments

permanent link
Ralph Schoon (60.9k33643) | answered Sep 27 '13, 6:31 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
edited Sep 27 '13, 6:31 p.m.
 https://jazz.net/library/article/1000 explains how aspect editors work.

Comments
Geoff Alexander commented Sep 27 '13, 6:54 p.m. | edited Oct 04 '13, 12:18 p.m.

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?


Ralph Schoon commented Sep 27 '13, 6:56 p.m. | edited Sep 27 '13, 6:57 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Ralph Schoon commented Sep 28 '13, 4:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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


-1
permanent link
Geoff Alexander (19623839) | answered Sep 28 '13, 3:08 a.m.
I did some more investigation and found that adding the following code to the aspect editor's saveState method allows changes to be made to the entire process configuration XML:

      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
Ralph Schoon commented Sep 28 '13, 4:09 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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. 


However, I believe also others do this to solve challenges that are otherwise unapproachable. 


1
Jared Burns commented Oct 03 '13, 8:22 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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. 

Your answer


Register or to post your answer.