Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » out of date model(how to sync models)
out of date model [message #1773622] Sun, 01 October 2017 07:41 Go to next message
Emil Peric is currently offline Emil PericFriend
Messages: 7
Registered: February 2015
Junior Member
Hi, i have an model which is out of date. The generated classes are in our main software development project.

Is there a way/tool to compare a list of classes bettwen the EMF model project and the classes in other project.

Re: out of date model [message #1774302 is a reply to message #1773622] Thu, 12 October 2017 14:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Eclipse let's you compare entire folders with each other...

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: out of date model [message #1774958 is a reply to message #1774302] Sun, 22 October 2017 17:21 Go to previous messageGo to next message
Emil Peric is currently offline Emil PericFriend
Messages: 7
Registered: February 2015
Junior Member
Thanks for suggestion but the problem is little bit different.

we use TEXO to generate java classes from ecore model. But during time the generated java clases (which) we use in another project got out of sync with the original model.

It would be perfect if we could generate new ecore model from these java classes.

regards.
Re: out of date model [message #1774960 is a reply to message #1774958] Sun, 22 October 2017 18:13 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you read the EMF book you will find out how you can annotate your Java so that Ecore is derivable.

But I strongly suspect that you will find it easier to manually update the Ecore so that you generate the new Java.

Realistically you will find that you have rather too much manual code; move it out of the Ecore model classes into some utility/helper/manager classes. The real model stuff should be easy to update.

Regards

Ed Willink
Re: out of date model [message #1774962 is a reply to message #1774960] Sun, 22 October 2017 19:43 Go to previous messageGo to next message
Emil Peric is currently offline Emil PericFriend
Messages: 7
Registered: February 2015
Junior Member
Hi, i have over 500 classes, and only few of them where manually changed. I tried to reverse engineer the java classes into UML and mostly succeeded (with yatta tool) but converting to ecore is failing since it doesn't interpret inheritance very good. As you suggested i wondered if there is any tool that can compare the ecore model with generated java classes.

This is for example one of the classes in my model (the language is not English) generated with TEXO (it generates jpa anotated java code from ecore model). My intention was to scan these classes and find the attributes/relations that where manually changed. We dint generate java code from EMF since it has to much unnecessary code.
package core._1;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToMany;

/**
* A representation of the model object '<em><b>Lokacija</b></em>'. <!--
* begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Entity(name = "Lokacija")
public class Lokacija {

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Id @GeneratedValue
public long idLokacija = 0;

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Basic()
private String gIS_Latitude = null;

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Basic()
private String gIS_Longitude = null;

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Basic()
private String gIS_Height = null;

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@ManyToMany(cascade = {
CascadeType.REFRESH })
private List<CL_VrstaLokacije> vrstaLokacije = new ArrayList<CL_VrstaLokacije>();

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Basic()
public String naziv = null;

/**
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Basic()
private String opis = null;

/**
* Returns the value of '<em><b>IdLokacija</b></em>' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @return the value of '<em><b>IdLokacija</b></em>' feature
* @generated
*/
public long getIdLokacija() {
return idLokacija;
}

/**
* Sets the '{@link Lokacija#getIdLokacija() <em>IdLokacija</em>}' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @param newIdLokacija
* the new value of the '{@link Lokacija#getIdLokacija()
* IdLokacija}' feature.
* @generated
*/
public void setIdLokacija(long newIdLokacija) {
idLokacija = newIdLokacija;
}

/**
* Returns the value of '<em><b>GIS_Latitude</b></em>' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @return the value of '<em><b>GIS_Latitude</b></em>' feature
* @generated
*/
public String getGIS_Latitude() {
return gIS_Latitude;
}

/**
* Sets the '{@link Lokacija#getGIS_Latitude() <em>GIS_Latitude</em>}'
* feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @param newGIS_Latitude
* the new value of the '{@link Lokacija#getGIS_Latitude()
* GIS_Latitude}' feature.
* @generated
*/
public void setGIS_Latitude(String newGIS_Latitude) {
gIS_Latitude = newGIS_Latitude;
}

/**
* Returns the value of '<em><b>GIS_Longitude</b></em>' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @return the value of '<em><b>GIS_Longitude</b></em>' feature
* @generated
*/
public String getGIS_Longitude() {
return gIS_Longitude;
}

/**
* Sets the '{@link Lokacija#getGIS_Longitude() <em>GIS_Longitude</em>}'
* feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @param newGIS_Longitude
* the new value of the '{@link Lokacija#getGIS_Longitude()
* GIS_Longitude}' feature.
* @generated
*/
public void setGIS_Longitude(String newGIS_Longitude) {
gIS_Longitude = newGIS_Longitude;
}

/**
* Returns the value of '<em><b>GIS_Height</b></em>' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @return the value of '<em><b>GIS_Height</b></em>' feature
* @generated
*/
public String getGIS_Height() {
return gIS_Height;
}

/**
* Sets the '{@link Lokacija#getGIS_Height() <em>GIS_Height</em>}' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @param newGIS_Height
* the new value of the '{@link Lokacija#getGIS_Height()
* GIS_Height}' feature.
* @generated
*/
public void setGIS_Height(String newGIS_Height) {
gIS_Height = newGIS_Height;
}

/**
* Returns the value of '<em><b>VrstaLokacije</b></em>' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @return the value of '<em><b>VrstaLokacije</b></em>' feature
* @generated
*/
public List<CL_VrstaLokacije> getVrstaLokacije() {
return vrstaLokacije;
}

/**
* Adds to the <em>VrstaLokacije</em> feature.
*
* @param vrstaLokacijeValue
* the value to add
* @return true if the value is added to the collection (it was not yet
* present in the collection), false otherwise
* @generated
*/
public boolean addToVrstaLokacije(CL_VrstaLokacije vrstaLokacijeValue) {
if (!vrstaLokacije.contains(vrstaLokacijeValue)) {
boolean result = vrstaLokacije.add(vrstaLokacijeValue);
return result;
}
return false;
}

/**
* Removes from the <em>VrstaLokacije</em> feature.
*
* @param vrstaLokacijeValue
* the value to remove
* @return true if the value is removed from the collection (it existed in
* the collection before removing), false otherwise
*
* @generated
*/
public boolean removeFromVrstaLokacije(CL_VrstaLokacije vrstaLokacijeValue) {
if (vrstaLokacije.contains(vrstaLokacijeValue)) {
boolean result = vrstaLokacije.remove(vrstaLokacijeValue);
return result;
}
return false;
}

/**
* Clears the <em>VrstaLokacije</em> feature.
*
* @generated
*/
public void clearVrstaLokacije() {
while (!vrstaLokacije.isEmpty()) {
removeFromVrstaLokacije(vrstaLokacije.iterator().next());
}
}

/**
* Sets the '{@link Lokacija#getVrstaLokacije() <em>VrstaLokacije</em>}'
* feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @param newVrstaLokacije
* the new value of the '{@link Lokacija#getVrstaLokacije()
* VrstaLokacije}' feature.
* @generated
*/
public void setVrstaLokacije(List<CL_VrstaLokacije> newVrstaLokacije) {
vrstaLokacije = newVrstaLokacije;
}

/**
* Returns the value of '<em><b>Naziv</b></em>' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @return the value of '<em><b>Naziv</b></em>' feature
* @generated
*/
public String getNaziv() {
return naziv;
}

/**
* Sets the '{@link Lokacija#getNaziv() <em>Naziv</em>}' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @param newNaziv
* the new value of the '{@link Lokacija#getNaziv() Naziv}'
* feature.
* @generated
*/
public void setNaziv(String newNaziv) {
naziv = newNaziv;
}

/**
* Returns the value of '<em><b>Opis</b></em>' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @return the value of '<em><b>Opis</b></em>' feature
* @generated
*/
public String getOpis() {
return opis;
}

/**
* Sets the '{@link Lokacija#getOpis() <em>Opis</em>}' feature.
*
* <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @param newOpis
* the new value of the '{@link Lokacija#getOpis() Opis}'
* feature.
* @generated
*/
public void setOpis(String newOpis) {
opis = newOpis;
}

/**
* A toString method which prints the values of all EAttributes of this
* instance. <!-- begin-user-doc --> <!-- end-user-doc -->
*
* @generated
*/
@Override
public String toString() {
return "Lokacija " + " [idLokacija: " + getIdLokacija() + "]"
+ " [gIS_Latitude: " + getGIS_Latitude() + "]"
+ " [gIS_Longitude: " + getGIS_Longitude() + "]"
+ " [gIS_Height: " + getGIS_Height() + "]" + " [naziv: "
+ getNaziv() + "]" + " [opis: " + getOpis() + "]";
}
}
Re: out of date model [message #1774973 is a reply to message #1774962] Mon, 23 October 2017 05:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

I am not aware of any tooling focused on your use case. Ecore should be the master. If Ecore generates too much code, you should investigate the many genmodel options. You could consider customizing the JET templates. But if you only want structural EMF without any of the reflection I would use a custom more modern M2T; simple structure is rather easy. This seems to be exactly what you have done with TEXO. The problem seems to be your converter was inadequate and you neglected to support all the facilities you needed.

wrt your current code, converting Java to Ecore seems really hard.

Probably easiest is to compare your 500 classes as originally generated from Ecore with those few manual evolutions. A GIT diff should make this all obvious. Reverse engineer the few changes in conjunction with fixed TYEXO.

When comparing generated Java, make sure your converter preserves cosmetic characteristics such as method ordering; best to do an alphabetic sort.

Regards

Ed Willink
Re: out of date model [message #1774975 is a reply to message #1774973] Mon, 23 October 2017 06:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
EMF's usual templates include @model annotations so that you can derived the Ecore model from the generated Java interfaces. If those aren't present when using the templates you used to generate this stuff, then you're out of luck and would need to add them, which is likely more work than updating the existing out-of-date *.ecore.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: out of date model [message #1775037 is a reply to message #1774975] Mon, 23 October 2017 22:21 Go to previous message
Emil Peric is currently offline Emil PericFriend
Messages: 7
Registered: February 2015
Junior Member
thanks for your suggestions, GIT diff could do the trick.
Previous Topic:Documentation/specification/standard for the BInaryResource format?
Next Topic:Type EAttribute
Goto Forum:
  


Current Time: Thu Apr 25 16:02:28 GMT 2024

Powered by FUDForum. Page generated in 0.03576 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top