Jazz Register Log in
Jazz Forum Welcome to the Jazz Community Forum

Welcome to the Jazz Community Forum

Connect and collaborate with IBM Engineering experts and users

How to modify process XML in a process configuration aspect editor

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?

0 votes



3 answers

Permanent link
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.

2 votes

Comments

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


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?

 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. 

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?

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.

showing 5 of 6 show 1 more comments

Permanent link
 https://jazz.net/library/article/1000 explains how aspect editors work.

0 votes

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. 


Permanent link
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.

-1 votes

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. 


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

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

Your answer

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

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,977

Question asked: Sep 26 '13, 12:51 p.m.

Question was seen: 5,958 times

Last updated: Oct 04 '13, 12:18 p.m.

Confirmation Cancel Confirm