Question

I have an uml diagram made with Topcased 5.2. The uml contains Class diagram and Activity Diagram. I wrote a template that accepts as parameter Class type in order to generate java classes.

The java classes were generated but in addition my method get executed for Activity node. How can I prevent execution of Activity node?

Following my template:

[template public generateEntity(c : Class)]
[comment @main /]
[file (c.getEntityFullPathFile().trim(), false)]
[c.generateEntity()/]
[/file]
[/template]

Thanks for your help

Was it helpful?

Solution

Please have a look at the UML metamodel (File > import > select "plugins and fragments", click 'next' then search for 'org.eclipse.uml2.uml', select it and 'Finish' the wizard). In there, you will see that an Activity is a Class (Activity inherits from Behavior which inherits from Class). That's all Acceleo 'sees'.

If you wish to generate your code for all Classes save for Activities, you can use a guard :

[template public generateEntity(c : Class) ? (not c.oclIsKindOf(Activity))]
...
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top