Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Mapping eType of reference to eType of attribute(Mapping eTypes)
Mapping eType of reference to eType of attribute [message #1001891] Thu, 17 January 2013 14:15 Go to next message
Martin C. is currently offline Martin C.Friend
Messages: 3
Registered: January 2013
Location: Dresden
Junior Member
Hi,

I define an ecore model with Java interfaces:

import java.net.InetAddress;

/**
 * @model
 */
public interface net {
    /**
     * @model dataType="java.net.InetAddress"
     */
    InetAddress getAddress();
}


and

import java.net.InetAddress;
import java.util.List;

/**
 * @model
 */
public interface nic {
    /**
     * @model containment="true" required="false" type="java.net.InetAddress"
     */
    List<InetAddress> getAddresses();
}


Now, I would expect that ecore uses the same eType for the attribute net.address and the reference nic.addresses. However, it uses two different eTypes: InetAddress for the attribute and InetAddress_1 for the reference.

How can I enforce that the same eType is used? And why is that happening anyways?

I'm using Eclispe Juno.

Thanks,

Martin

[Updated on: Thu, 24 January 2013 11:56]

Report message to a moderator

Re: Mapping eType of reference to eType of attribute [message #1002083 is a reply to message #1001891] Thu, 17 January 2013 22:32 Go to previous messageGo to next message
Hallvard Traetteberg is currently offline Hallvard TraettebergFriend
Messages: 673
Registered: July 2009
Location: Trondheim, Norway
Senior Member
Hi,

The eType of an attribute must be a DataType, while the eType of a
Reference must be an EClass, hence it generates and uses another type
for the reference.

Hallvard

On 17.01.13 07.57, Martin C. wrote:
> Hi,
>
> I define an ecore model with Java interfaces:
>
>
> import java.net.InetAddress;
>
> /**
> * @model dataType="java.net.InetAddress"
> */
> public interface net {
> InetAddress getAddress();
> }
>
>
> and
>
>
> import java.net.InetAddress;
> import java.util.List;
>
> /**
> * @model containment="true" required="false" type="java.net.InetAddress"
> */
> public interface nic {
> List<InetAddress> getAddresses();
> }
>
>
> Now, I would expect that ecore uses the same eType for the attribute
> net.address and the reference nic.addresses. However, it uses two
> different eTypes: InetAddress for the attribute and InetAddress_1 for
> the reference.
>
> How can I enforce that the same eType is used? And why is that happening
> anyways?
>
> I'm using Eclispe Juno.
>
> Thanks,
>
> Martin
Re: Mapping eType of reference to eType of attribute [message #1002237 is a reply to message #1001891] Fri, 18 January 2013 08:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Martin,

You might want to consider using Xcore instead. The syntax is simpler
and there's much more in the way of immediate error checking and feedback:

http://wiki.eclipse.org/Xcore


On 17/01/2013 4:57 PM, Martin C. wrote:
> Hi,
>
> I define an ecore model with Java interfaces:
>
>
> import java.net.InetAddress;
>
> /**
> * @model dataType="java.net.InetAddress"
> */
> public interface net {
> InetAddress getAddress();
> }
>
>
> and
>
>
> import java.net.InetAddress;
> import java.util.List;
>
> /**
> * @model containment="true" required="false" type="java.net.InetAddress"
> */
> public interface nic {
> List<InetAddress> getAddresses();
> }
>
>
> Now, I would expect that ecore uses the same eType for the attribute
> net.address and the reference nic.addresses. However, it uses two
> different eTypes: InetAddress for the attribute and InetAddress_1 for
> the reference.
>
> How can I enforce that the same eType is used? And why is that
> happening anyways?
>
> I'm using Eclispe Juno.
>
> Thanks,
>
> Martin


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Mapping eType of reference to eType of attribute [message #1005064 is a reply to message #1002237] Thu, 24 January 2013 12:07 Go to previous messageGo to next message
Martin C. is currently offline Martin C.Friend
Messages: 3
Registered: January 2013
Location: Dresden
Junior Member
Let's use a list:

  • Thanks Hallvard, that explained what happens.
  • Also thanks Ed for the pointer to Xcore. However, I'm not quite sure if I want to use Xcore. It looks already so similar to Java that I could also model with Java classes themselves.
  • Is there a way to specify the name of the EClass/eType? So I could get rid of the annoying "_1" name.
  • BTW: I pasted the annotations to the wrong statements in my code examples, because I simplified the code to what the problem is. But it's fixed now.
Re: Mapping eType of reference to eType of attribute [message #1005084 is a reply to message #1005064] Thu, 24 January 2013 13:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Martin,

Comments below.

On 24/01/2013 1:07 PM, Martin C. wrote:
> Let's use a list:
>
> Thanks Hallvard, that explained what happens.
> Also thanks Ed for the pointer to Xcore. However, I'm not quite sure
> if I want to use Xcore. It looks already so similar to Java that I
> could also model with Java classes themselves.
Yes, but as I said, there is little in the way of feedback on what's
wrong with your @model annotations. In your example, not a single one
of the attributes you've specified was sensible in that location.
> Is there a way to specify the name of the EClass/eType? So I could get
> rid of the annoying "_1" name.
Have a look at the generated XyzPackage implementation's @model
annotations to see what data types you've ended up with. Once they're
their and they're marked @model, you have to delete them to get rid of them.
> BTW: I pasted the annotations to the wrong statements in my code
> examples, because I simplified the code to what the problem is. But
> it's fixed now.
What does it look like now?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Mapping eType of reference to eType of attribute [message #1005693 is a reply to message #1005084] Mon, 28 January 2013 10:08 Go to previous message
Martin C. is currently offline Martin C.Friend
Messages: 3
Registered: January 2013
Location: Dresden
Junior Member
Hi Ed,

the annotations were in the wrong place, because I pasted them to the wrong statement. It's now fixed in my first posting. If that should still be wrong, I really got something wrong.

Thanks,

Martin

Previous Topic:[CDO] 4.1 transaction rollback after a commit
Next Topic:[CDO] Unmonitored fail-over example
Goto Forum:
  


Current Time: Fri Mar 29 01:32:23 GMT 2024

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

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

Back to the top