Activity node get executed in a template that accepts only Class type

StackOverflow https://stackoverflow.com/questions/13438388

  •  30-11-2021
  •  | 
  •  

Pergunta

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

Foi útil?

Solução

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))]
...
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top