Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » EMF metmodel(problems when creating a metamodel using emf language)
EMF metmodel [message #1754727] Tue, 21 February 2017 19:37 Go to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 145
Registered: October 2014
Senior Member
Hi,
This my first time using EMF language can you please help me .
@namespace(uri="mapping", prefix="mapping")
package mapping;

class mapping {
val sourceType[+]#hasSource contents;

}
class sourceType{
attr String Sname;
ref targetType[+] hasTargets;
ref mapping[1]#contents hasSource;


}
class targetType{
attr String Tname;

i have started creating the metamodel step by step not all at once but i am facing problem between the class sourceType and class targetType when i tried to create an instance from that metamodel ,what i mean by the relation between them that source has many targets .
Can you please help me.

Taghreed.
Re: EMF metmodel [message #1754736 is a reply to message #1754727] Tue, 21 February 2017 20:38 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1487
Registered: July 2009
Location: York, UK
Senior Member

Hi Taghreed,

I'm not sure I fully understand the problem you're reporting. Could you please elaborate a bit more?

Cheers,
Dimitris

Re: EMF metmodel [message #1754738 is a reply to message #1754736] Tue, 21 February 2017 21:08 Go to previous messageGo to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 145
Registered: October 2014
Senior Member
Hi Dimitris,
i created the metamodel then i tried to create an instance from that metamodel i have chosen mapping as a root element then added sourceType as child ,i think i have something wrong with the relations .I attached screenshot for what i have.

Thanks
Taghreed,
  • Attachment: mapping.png
    (Size: 118.69KB, Downloaded 38 times)

[Updated on: Tue, 21 February 2017 21:08]

Report message to a moderator

Re: EMF metmodel [message #1754745 is a reply to message #1754738] Tue, 21 February 2017 22:02 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1487
Registered: July 2009
Location: York, UK
Senior Member

What does the Problems view say?

Cheers,
Dimitris
Re: EMF metmodel [message #1754746 is a reply to message #1754745] Tue, 21 February 2017 22:26 Go to previous messageGo to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 145
Registered: October 2014
Senior Member
I changed the code to be like this
@namespace(uri="mapping", prefix="")
package mapping;

class mapping {
val sourceType[+] #sources sourceType;
val targetType[+] #targets targetType ;
}
class sourceType{
attr String Sname;
val targetType[+] #hasSource targetType;
ref mapping[1]#sourceType sources;
}
class targetType{
attr String Tname;
ref sourceType[1]#targetType hasSource;
ref mapping[1]#targetType targets;


i got warning on the bold lines says that:
A containment reference of a type with a container feature org.eclipse.emf.ecore.impl.EReferenceImpl@23199524{platform:/resource/evolving%20Source%20Model/mapping.emf#//targetType/targets} that requires instances to be contained elsewhere cannot be populated
Re: EMF metmodel [message #1754748 is a reply to message #1754746] Tue, 21 February 2017 22:31 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1487
Registered: July 2009
Location: York, UK
Senior Member

Hi Taghreed,

val targetType[+] #hasSource targetType;


should be

ref targetType[+] #hasSource targetType;


instead.

Cheers,
Dimitris
Re: EMF metmodel [message #1754750 is a reply to message #1754748] Tue, 21 February 2017 23:14 Go to previous messageGo to next message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 145
Registered: October 2014
Senior Member
Hi Dimitris,
That correction removed the warning but when i created the instance model i had to add sourceType as a child and then add targetType as a child then set the feature target type manually by choosing the target type that i want to match it with sourceType .
How can i make sourceType a container for targetType and each sourceType has a relation targetType with targetType

Thanks,
Taghreed
Re: EMF metmodel [message #1754751 is a reply to message #1754750] Tue, 21 February 2017 23:40 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1487
Registered: July 2009
Location: York, UK
Senior Member

Hi Taghreed,

If you turn SourceType.targetType to a containment reference (val) then each target type can only be connected to one SourceType. Does this sound like what you're after?

On a related note, it's common for class names to start with an upper case letter (i.e. SourceType instead of sourceType) to avoid naming conflicts with references/attributes.

Cheers,
Dimitris
Re: EMF metmodel [message #1754820 is a reply to message #1754751] Wed, 22 February 2017 18:30 Go to previous message
taghreed altamimi is currently offline taghreed altamimiFriend
Messages: 145
Registered: October 2014
Senior Member
Hi Dimitris,

Thanks.
Taghreed
Previous Topic:Can not instantiate EmfModel
Next Topic:Add EPackage of the EMF Registry as a reference in a my metamodelo's instance - Agregar un EPackage
Goto Forum:
  


Current Time: Thu Nov 23 16:31:51 GMT 2017

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

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