|
Re: Acceleo [message #1829349 is a reply to message #1829344] |
Wed, 01 July 2020 17:54 |
Ed Willink Messages: 7681 Registered: July 2009 |
Senior Member |
|
|
Hi
I would expect aEClass tobe an EClass so that the operations are present.
But since you seem to be attempting to rewrite the EMF JET templates that have been rewritten in Acceleo already, I suggest that you make very sure that you do not want to use the JET templates that are supported and well tested, else learn from the stale Acceleo variants.
Regards
Ed Willink
[Updated on: Wed, 01 July 2020 19:10] Report message to a moderator
|
|
|
|
|
Re: Acceleo [message #1829538 is a reply to message #1829382] |
Mon, 06 July 2020 12:27 |
Sel ma Messages: 16 Registered: June 2020 |
Junior Member |
|
|
Hi Ed Willink, Thank you for your replay! I have been doing some research and I figured out that I should add .eCLass() just before .eAllAttributes (myinteractionspatiale.eClass().eAllAttributes ) . Now following that I have a related concern :
I am trying to generate the java code of MyModels.pfe using Accelo -the class root is InterationSpatiale.
I want to generate a *.java for each of my classes in the diagram here is my generate.mtl file
[comment encoding = UTF-8 /]
[module generate('http://www.example.org/pfe')/]
[template public generateElement(myinteractionspatiale :
InteractionSpatiale)]
[comment @main/]
[file (myinteractionspatiale.name.concat('.java'), false, 'UTF-8')]
public class [myinteractionspatiale.name/] {
[for (aEAttribute : ecore :: EAttribute |
myinteractionspatiale.eClass().eAllAttributes)]
[aEAttribute.eType.instanceClassName/] [aEAttribute.name/];
[/for]
[for (aEReference : EReference
|myinteractionspatiale.eClass().eAllReferences)]
[aEReference.eReferenceType.name/] [aEReference.name/];
[/for]
[for (aEAttribute : EAttribute |
myinteractionspatiale.eClass().eAllAttributes)]
public [aEAttribute.eType.instanceClassName/]
get[aEAttribute.name.toUpperFirst()/] () {
return this.[aEAttribute.name/];
}
[/for]
[for (aEAttribute : EAttribute |
myinteractionspatiale.eClass().eAllAttributes)]
public void set[aEAttribute.name.toUpperFirst()/]
([aEAttribute.eType.instanceClassName/] [aEAttribute.name/]) {
this.[aEAttribute.name/] = [aEAttribute.name/];
}
[/for]
[for (aEReference : EReference |
myinteractionspatiale.eClass().eAllReferences)]
public [aEReference.eReferenceType.name/]
get[aEReference.name.toUpperFirst()/] () {
return this.[aEReference.name/];
}
[/for]
[for (aEReference : EReference |
myinteractionspatiale.eClass().eAllReferences)]
public void set[aEReference.name.toUpperFirst()/]
([aEReference.eReferenceType.name/] [aEReference.name/]) {
this.[aEReference.name/] = [aEReference.name/];}
[/for]
[for (aEOperation : EOperation |
myinteractionspatiale.eClass().eAllOperations)]
public [aEOperation.eType.instanceClassName/] [aEOperation.name/] () {
}
[/for]
}
[/file]
[/template]
the generated file I got is App.java is
public class App {
java.lang.String name;
Entite entite;
Evenement evenement;
SystemeCoordonnees systemecoordonnees;
TacheSysteme tachesysteme;
RelationSpatiale relationspatiale;
InteractionSpatiale interactionspatiale;
public java.lang.String getName () {
return this.name;
}
public void setName (java.lang.String name) {
this.name = name;
}
public Entite getEntite () {
return this.entite;
}
public Evenement getEvenement () {
return this.evenement;
}
public SystemeCoordonnees getSystemecoordonnees () {
return this.systemecoordonnees;
}
public TacheSysteme getTachesysteme () {
return this.tachesysteme;
}
public RelationSpatiale getRelationspatiale () {
return this.relationspatiale;
}
public InteractionSpatiale getInteractionspatiale () {
return this.interactionspatiale;
}
public void setEntite (Entite entite) {
this.entite = entite;
}
public void setEvenement (Evenement evenement) {
this.evenement = evenement;
}
public void setSystemecoordonnees (SystemeCoordonnees systemecoordonnees)
{
this.systemecoordonnees = systemecoordonnees;
}
public void setTachesysteme (TacheSysteme tachesysteme) {
this.tachesysteme = tachesysteme;
}
public void setRelationspatiale (RelationSpatiale relationspatiale) {
this.relationspatiale = relationspatiale;
}
public void setInteractionspatiale (InteractionSpatiale
interactionspatiale) {
this.interactionspatiale = interactionspatiale;
}
}
But what I really wanted is to have a file for each class of the model MyModels.pfe not just the java file of the root class.
My concern is :
1. how to iterate and have a file for each class with its attributes and their values[EFixe.java, EMobile.java ...]
2. I cannot access the values of the attributes: I tried
[aEAttribute->any(true).value /]
but it doesn't work
I really appreciate any sort of help.
[Updated on: Mon, 06 July 2020 17:43] Report message to a moderator
|
|
|
|
|
|
Re: Acceleo [message #1829614 is a reply to message #1829595] |
Tue, 07 July 2020 16:08 |
Sel ma Messages: 16 Registered: June 2020 |
Junior Member |
|
|
Hi Ed Willink,
Thank you so much for your response! As you have mentioned earlier, about the use of eGet(). I realized that I badly used it!
So, I used it like this EObject#eGet(EStructuralFeature) and it works perfectly
= [myInteractionSpatiale.eGet(aEAttribute)/]
I got
public class EFixe{
int Position_Absolue = 20;
int Orientation_Absolue = 12; }
Sir, the part you talked about XML :
1. Do you think that there is a better way than transforming at the XML level?
2. About the process of the plugin, I will give it a try immediately.
Thank you!
Regards.
[Updated on: Tue, 07 July 2020 16:09] Report message to a moderator
|
|
|
|
|
Re: Acceleo [message #1829644 is a reply to message #1829621] |
Wed, 08 July 2020 08:35 |
Sel ma Messages: 16 Registered: June 2020 |
Junior Member |
|
|
Hi,
I have created a template for each class in different module files and I tried to call them in the main *.mtl module after importing all the modules.
In the main template that takes an InteractionSpatiale (root) as input and a java file as output: I called template [generateEntiteFixe (p )/] but the problem is the parameter p to pass as input to the template. I tried to extract it from the root (myInteractionSpatiale )
[ myInteractionSpatiale.eContents().eClass().name ]
I got this in the java file :
EFixeEMobileEvenEMobileEFixeTacheSystemeRelationSpatiale
which is the name of all my classes concatinated . As I need the name of each class to pass it as a parameter to different templates , I tried to extract class by class :
[myInteractionSpatiale.eContents().eClass().name->any(str | str = 'EFixe')/]
I got
So to call the template :
[generateEntiteFixe (myInteractionSpatiale.eContents().eClass().name->any(str | str = 'EFixe')/]
but it doesn't execute or generate the code of the template ' generateEntiteFixe ' ;
I wan to extract each class of my tree model where the root is [myInteractionSpatiale : InteractionSpatiale ] in order to call my templates in the main module.
any help in what's the problem or how to do it correctly is much appreciated.
Regards.
[Updated on: Wed, 08 July 2020 08:45] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04764 seconds