Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Interface for generated EMF Interface
Interface for generated EMF Interface [message #879532] Thu, 31 May 2012 07:30 Go to next message
Mike Moor is currently offline Mike Moor
Messages: 20
Registered: November 2010
Location: Steffisburg, Switzerland
Junior Member
In our project we have an EMF Model on the client side and a POJO model on our server side. we would now like to use the same interface for both models so we can easily convert between them.

Example:

Interface
public interface IPerson {
   String getName();
   void setName(String name);
}


Server Model
public class Person implements IPerson {
   private String name;

   public String getName() { return this.name }

   public void setName(String name) { this.name = name }
}


Client EMF Model (generated Interface)
/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */

import org.eclipse.emf.ecore.EObject;


/**
 * <!-- begin-user-doc -->
 * A representation of the model object '<em><b>Person</b></em>'.
 * <!-- end-user-doc -->
 *
 * <p>
 * The following features are supported:
 * <ul>
 *   <li>{@link Person#getName <em>Name</em>}</li>
 * </ul>
 * </p>
 *
 * @see Package#getPerson()
 * @model
 * @extends SerializableEObject
 * @generated
 */
public interface Person extends EObject {
	/**
	 * Returns the value of the '<em><b>Name</b></em>' attribute.
	 * <!-- begin-user-doc -->
	 * <p>
	 * If the meaning of the '<em>Name</em>' attribute isn't clear,
	 * there really should be more of a description here...
	 * </p>
	 * <!-- end-user-doc -->
	 * @return the value of the '<em>Name</em>' attribute.
	 * @see #setName(String)
	 * @see Package#getPerson_Name()
	 * @model
	 * @generated
	 */
	String getName();

	/**
	 * Sets the value of the '{@link Person#getName <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @param value the new value of the '<em>Name</em>' attribute.
	 * @see #getName()
	 * @generated
	 */
	void setName(String value);

} // Person



As you can see, the EMF Model Interface Person does not extend IPerson. How can I do that? When I add it manually, it will be overridden the next time I generate my model.

Any hints?

Thanks!
Mike
Re: Interface for generated EMF Interface [message #879547 is a reply to message #879532] Thu, 31 May 2012 07:58 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 4462
Registered: July 2009
Senior Member
You need to map your custom interface (IPerson) into EMF (by setting the
Instance Type Name) and then put it as into the supertypes of your
Person-EClass.

Tom

Am 31.05.12 13:30, schrieb Mike Moor:
> In our project we have an EMF Model on the client side and a POJO model
> on our server side. we would now like to use the same interface for both
> models so we can easily convert between them.
>
> Example:
>
> Interface
> public interface IPerson {
> String getName();
> void setName(String name);
> }
>
>
> Server Model
> public class Person implements IPerson {
> private String name;
>
> public String getName() { return this.name }
>
> public void setName(String name) { this.name = name }
> }
>
>
> Client EMF Model (generated Interface)
>
> /**
> * <copyright>
> * </copyright>
> *
> * $Id$
> */
>
> import org.eclipse.emf.ecore.EObject;
>
>
> /**
> * <!-- begin-user-doc -->
> * A representation of the model object '<em><b>Person</b></em>'.
> * <!-- end-user-doc -->
> *
> * <p>
> * The following features are supported:
> * <ul>
> * <li>{@link Person#getName <em>Name</em>}</li>
> * </ul>
> * </p>
> *
> * @see Package#getPerson()
> * @model
> * @extends SerializableEObject
> * @generated
> */
> public interface Person extends EObject {
> /**
> * Returns the value of the '<em><b>Name</b></em>' attribute.
> * <!-- begin-user-doc -->
> * <p>
> * If the meaning of the '<em>Name</em>' attribute isn't clear,
> * there really should be more of a description here...
> * </p>
> * <!-- end-user-doc -->
> * @return the value of the '<em>Name</em>' attribute.
> * @see #setName(String)
> * @see Package#getPerson_Name()
> * @model
> * @generated
> */
> String getName();
>
> /**
> * Sets the value of the '{@link Person#getName <em>Name</em>}'
> attribute.
> * <!-- begin-user-doc -->
> * <!-- end-user-doc -->
> * @param value the new value of the '<em>Name</em>' attribute.
> * @see #getName()
> * @generated
> */
> void setName(String value);
>
> } // Person
>
>
>
> As you can see, the EMF Model Interface Person does not extend IPerson.
> How can I do that? When I add it manually, it will be overridden the
> next time I generate my model.
>
> Any hints?
>
> Thanks!
> Mike
Previous Topic:Why alwasy get root model null when load xmi file
Next Topic:[CDO(/Teneo/Hibernate)] reordering of ELists
Goto Forum:
  


Current Time: Wed May 22 02:04:46 EDT 2013

Powered by FUDForum. Page generated in 0.01991 seconds