regenerating code from genmodel

Started by Hervé, December 09, 2017, 15:26:22 PM

Previous topic - Next topic

Hervé

Hi,

I regenerated the code from the genmodel files and a lot of errors pointed out, mainly because of missing variables. Some of them are protected so impact their defining class only, but some others are also used in extending classes.

For instance, in original com.archimatetool.model.impl.Bounds.java:
protected int x = X_EDEFAULT;

public int getX() {
     return x;
}

public void setX(int newX) {
     int oldX = x;
     x = newX;
     if (eNotificationRequired())
          eNotify(new ENotificationImpl(this, Notification.SET, IArchimatePackage.BOUNDS__X, oldX, x));
}


And in generated code:
public int getX() {
     return (Integer)eDynamicGet(IArchimatePackage.BOUNDS__X, IArchimatePackage.Literals.BOUNDS__X, true, true);
}

public void setX(int newX) {
     eDynamicSet(IArchimatePackage.BOUNDS__X, IArchimatePackage.Literals.BOUNDS__X, newX);
}


My questions:

  • Did I do something wrong ?
  • If not, did you do these updates manually or did you use an automatic procedure ?
  • What should I do to keep these updates when I regenerate the code from the genmodel files on my Eclipse platform (Oxygen / Windows 64bit) ?

Thanks and regards
Hervé

Phil Beauvoir

Hi Hervé,

This is how I generate the model code:

1. Open the archimate.genmodel file
2. Select "Generate Model Code" from the "Generator" main menu

It depends what you have changed in the archimate.ecore and archimate.genmodel files

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Hervé

Hi Phil,

Thanks for your quick answer.

What I did:

  • Install the CDO and Net4J Eclipse plugins
  • Right click on the genmodel files and select CDO -> Migrate EMF Generator model
  • Open the genmodel files then right click on the top archimate line and select Generate all

Best regards
Hervé

Phil Beauvoir

Hervé,

I haven't done this before, so I can't advise on what it's doing.

Normally any code that's been manually added to the generated files is ignored when re-generating.

But you probably only need to generate the model files if you're not generating tests and UI edit files.

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Hervé

I've got the same behavior when I choose the "Generate Model code" option ...

I will try to understand what the CDO converter does and may be try to convert it manually ...

I'll let you know.

Thanks and regards
Hervé

Phil Beauvoir

Sounds like the CDO converter is doing something funky. Be aware that if you manually change it you might not be able to regenerate ever again. I'd take a look to see if there are any options in the CDO converter and read up on it.

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Hervé

I can easilly revert to a clean situation using git. I can even re-download and restart from scratch.

I can hardly find up to date information on CDO on the net. A lot of howto are dated 2008 or 2009 and the official documentation suppose one has got a minimum of knowledge (that I unfortunately doesn't have). I do not even know the EMF modeling framework :( So I'm going very little step by very little step ...

But I would be very happy if you can give me a hand to start. ;D

If I understood correctly, CDO would allow to have a centralised repository and a real time collaboration between several people working on the same elements and relationships. So, everything that I would like to acheive  ;D

Phil Beauvoir

Ah yes, the world of Eclipse development where every example (if you can find one) comes from the year 2003. Where every Eclipse developer forum is more empty than a tumble-weed town in an old western. Where the concept of documentation does not exist...

I have never used CDO so I can't really help that much, other than maybe to take a look at what you might achieve. I believe that it supports collaboration.

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Hervé

Ok, one step after another, I begin to put some puzzle pieces together ...

I succeed to compile when I do "generate model" only, but when I select "generate editor", it complains because of missing "com.archimatetool.model.edit" classes. then when I select "generate edit", these classes are generated but I have thousands of errors, a lot of them being "The hierarchy of xxxxx is inconsistent".

Very weird ...

How do you generate your Java code ? Do you use "generate model" only, or do your use the other generators ?

Thanks
Hervé

Phil Beauvoir

See my replies earlier. I only generate the model code. The "edit" code stuff is if you want to generate a tabular GUI.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Hervé