Login | Register
My pages Projects Community openCollabNet

Discussions > modules-dev > Re: [argouml-modules-dev] New Figures and Save/Load process

Discussion topic

Back to topic list

Re: [argouml-modules-dev] New Figures and Save/Load process

Author bobtarling
Full name Bob Tarling
Date 2005-06-28 10:27:40 PDT
Message The save is done by means of OCLExpander and OCLEvaluator interpreting
tee files to generate XML. The tee file in question for diagrams is
PGML.tee. You'll find this in the org.argouml.persistence package.

This is all fairly complex, I just had to work it out for myself. I'd
like to see it replaced by some more industry standard templating
system, but what we have works for now and there are other priorites.

Basically the evaluation start with the templating system being given
an object to evaluate. In this case the object is of type Diagram.

If you look in pgml.tee you will find it contains a template for this
(I reformat slightly and ignore the CDATA tags) -

<template class="org.tigris.ge​f.base.Diagram">

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE pgml SYSTEM "pgml.dtd">
    <pgml description="<ocl​>self.classAndMod​elID</ocl>"
        <private>ItemUID="<ocl ignoreNull>self.I​temUID</ocl>"​</private>


You see within template the core structure of the PGML XML document,
first the xml version tag, then the doctype followed by the root pgml
tag. There is also the end pgml tag here.

Now look at the attributes inside <pgml>. For example -


The OCL evaluator converts "self" to the actual Diagram object that
was passed to the evaluator. It then determines a way to use
reflection to get the value of "classAndModelID" from that object. It
does that by trying various means till it succeeds. If there is a
public instance variable of that name then it will simply access it by
reflection. If not then it will look for a method called
getClassAndModelID and try to call that by reflection.

Having got that value it replaces the <ocl>..</ocl> tags with the
actual value returned.

Now see the OCS expression within <private>...​</private>
I recently made the OCL templates stricter so that they will throw an
exception if an expression returns null. The ignoreNull tag
specifically states that null is acceptable in which case the entire
line is ignored.

The next OCL expression demonstrate the recursive nature of this
template mechanism.


Each time an expression is evaluated the type of object returned by
the expression is checked.

If the object type is another class that exists in the same template
file then the result of the expression is passed as the input to that
template. If not then the value is simply output to the final

If the expression results in a collection or an array then each object
in that collection is passed through that same process so taking the
1st recursive example -


"self" is a Diagram object. The evaluator calls the getLayer() method
of that Diagram and then calls the getContentsNoEdges() method of that
Layer. This returns a List of Figs.

The tee files is scanned for each one, you will see template entries
in the tee file for many Fig types. I'll take FigNodeModelElement as
an example as this handles all ArgoUML FigNodes. Here it is reproduced
(reformatted and with CDATA stripped out).

<template class="org.argouml.u​ml.diagram.ui.FigNod​eModelElement">

    <group name="<ocl>sel​f.id</ocl>"
        href="<ocl ignoreNull>self.o​wner.UUID</ocl​>"

        ItemUID="<ocl ignoreNull>self.I​temUID</ocl>"
        enclosingFig="<ocl ignoreNull>self.e​nclosingFig.id</o​cl>"




Hopefully this is now fairly self explanatory. "self" is now a
FigNodeModelElement class and all the evaluation is now against that.

The main thing to notice here though is that this template will keep
calling Fig templates repeatedly for all child Figs it contains.


This will call getFigs() to get the children of the input Fig. A
template will be called for each one and that template may well
contain <ocl>self.figs​</ocl> again. This is how the template
recursively builds up the PGML structure for children within children
within children.

I hope this all makes sense. It's hard to explain.

So if you think the format of the PGML is incorrect then it is the tee
file that needs to be looked at.

If you think the PGML has been saved correctly then we need lessons in
PGMLStackParser (I hope Michael M can oblige).



On 6/28/05, Laetitia Duby <laetitia at ee dot usyd dot edu dot au> wrote:
> Hi !
> I created new figures in a module that are very similar to the FigActor,
> except that it contains an image icon. I have a problem when I load a
> project that contains such figures : the icon is separated from the fig
> group that only contains the name box.
> I think there is a mistake in the save process because the positions of
> the enclosed figures of the group are not really correct. Actually, I
> don't understand how the diagrams are saved : I know that the
> UmlFilePersister provide a DiagramMemberFile from which the OCLExpander of
> GEF is called but I don't know how the fig and its position are translated
> into xml element. Can someone help me ?
> Many thanks,
> Laetitia
> --------------------​--------------------​--------------------​---------
> To unsubscribe, e-mail: modules-dev-unsubscr​ibe at argouml dot tigris.o​rg
> For additional commands, e-mail: modules-dev-help@arg​ouml.tigris.org

« Previous message in topic | 2 of 2 | Next message in topic »


Show all messages in topic

New Figures and Save/Load process Laetitia Duby <laetitia at ee dot usyd dot edu dot au> Laetitia Duby <laetitia at ee dot usyd dot edu dot au> 2005-06-27 18:54:24 PDT
     Re: [argouml-modules-dev] New Figures and Save/Load process bobtarling Bob Tarling 2005-06-28 10:27:40 PDT
Messages per page: