Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to define my own "ecore" metamodel
How to define my own "ecore" metamodel [message #1125331] Fri, 04 October 2013 11:57 Go to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hello,

First of all, i apologize for maybe not using the proper terms regarding ecore, models, metamodels.

When using ecore, we can model concepts by defining classes and their attributes/relationships.

Let's consider the following model, (defined using ecore):
Class: "Book"
Attributes: Name (String), Price (double), NoPages (int)
Refs: author (Author)

Class: "Author"
Attributes: Name (String), NativeLang (String)
Refs: books (Book)

Now let's consider that i need to provide my users a way for defining custom attributes on books given the hypothesis that my users cannot modify the Book and Author model, they can only extend it. I would like them to be able to define things like a ISBN attribute having a String type.

How can i use ecore (or something else) to address this kind of need?

Many thanks for your help,

Best Regards,
Re: How to define my own "ecore" metamodel [message #1125343 is a reply to message #1125331] Fri, 04 October 2013 12:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Jean-Baptise,

Comments below.

On 04/10/2013 1:57 PM, Jean-Baptiste Guillois wrote:
> Hello,
>
> First of all, i apologize for maybe not using the proper terms
> regarding ecore, models, metamodels.
>
> When using ecore, we can model concepts by defining classes and their
> attributes/relationships.
>
> Let's consider the following model, (defined using ecore):
> Class: "Book"
> Attributes: Name (String), Price (double), NoPages (int)
> Refs: author (Author)
>
> Class: "Author"
> Attributes: Name (String), NativeLang (String)
> Refs: books (Book)
>
> Now let's consider that i need to provide my users a way for defining
> custom attributes on books given the hypothesis that my users cannot
> modify the Book and Author model, they can only extend it.
That's not necessarily the only conclusion. Often models make
themselves "extensible" via some type of annotation mechanism.
> I would like them to be able to define things like a ISBN attribute
> having a String type.
So is the user capable of using Ecore so that they can define BookWithISBN?
>
> How can i use ecore (or something else) to address this kind of need?
It really depends a lot on the sophistication of your users. Do they
understand type systems? Will they want user defined types or should
you just enumerate the types? Will they be capable of defining
something type-system like, e.g., all Books should also have an ISBN
attribute of type string that I want to call isbn. Will two different
users want different things and still share the same Book instance?
>
> Many thanks for your help,
>
> Best Regards,


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to define my own "ecore" metamodel [message #1125347 is a reply to message #1125331] Fri, 04 October 2013 12:16 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You can extend an ecore metamodel by using inheritance on EClasses for example.
Then you have another metamodel that you can generate in Java using EMF as usual.
You just need to reference your genmodel in the genmodel of the new metamodel (this is a simple as clicking a checkbox in a wizard).
Re: How to define my own "ecore" metamodel [message #1125364 is a reply to message #1125343] Fri, 04 October 2013 12:41 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Thx for your quick reply

Quote:
That's not necessarily the only conclusion. Often models make
themselves "extensible" via some type of annotation mechanism.

==> Right, but i consider that i have to provide my users a mechanism for 1) defining these extensions (new types) and 2) using these new types for creating their instances (both of these without requiring java code to be written)

Quote:
So is the user capable of using Ecore so that they can define BookWithISBN?

==> Let's assume yes, I want to provide my users with a mechanism for doing so and force them to create "themselves" this ecore file (i may generate (automatically) it for them given a description/specification they can provide)

Quote:
It really depends a lot on the sophistication of your users. Do they
understand type systems? Will they want user defined types or should
you just enumerate the types? Will they be capable of defining
something type-system like, e.g., all Books should also have an ISBN
attribute of type string that I want to call isbn. Will two different
users want different things and still share the same Book instance?

==> The will want user defined types

Quote:
Will they be capable of defining something type-system like, e.g., all Books should also have an ISBN attribute of type string that I want to call isbn.

==> Yes

Quote:
Will two different users want different things and still share the same Book instance?

==> No

Thx



Ed Merks wrote on Fri, 04 October 2013 08:13
Jean-Baptise,

Comments below.

On 04/10/2013 1:57 PM, Jean-Baptiste Guillois wrote:
> Hello,
>
> First of all, i apologize for maybe not using the proper terms
> regarding ecore, models, metamodels.
>
> When using ecore, we can model concepts by defining classes and their
> attributes/relationships.
>
> Let's consider the following model, (defined using ecore):
> Class: "Book"
> Attributes: Name (String), Price (double), NoPages (int)
> Refs: author (Author)
>
> Class: "Author"
> Attributes: Name (String), NativeLang (String)
> Refs: books (Book)
>
> Now let's consider that i need to provide my users a way for defining
> custom attributes on books given the hypothesis that my users cannot
> modify the Book and Author model, they can only extend it.
That's not necessarily the only conclusion. Often models make
themselves "extensible" via some type of annotation mechanism.
> I would like them to be able to define things like a ISBN attribute
> having a String type.
So is the user capable of using Ecore so that they can define BookWithISBN?
>
> How can i use ecore (or something else) to address this kind of need?
It really depends a lot on the sophistication of your users. Do they
understand type systems? Will they want user defined types or should
you just enumerate the types? Will they be capable of defining
something type-system like, e.g., all Books should also have an ISBN
attribute of type string that I want to call isbn. Will two different
users want different things and still share the same Book instance?
>
> Many thanks for your help,
>
> Best Regards,

Re: How to define my own "ecore" metamodel [message #1125440 is a reply to message #1125364] Fri, 04 October 2013 14:05 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Jean-Baptiste,

Comments below.

On 04/10/2013 2:41 PM, Jean-Baptiste Guillois wrote:
> Thx for your quick reply
>
> Quote:
>> That's not necessarily the only conclusion. Often models make
>> themselves "extensible" via some type of annotation mechanism.
>
> ==> Right, but i consider that i have to provide my users a mechanism
> for 1) defining these extensions (new types) and 2) using these new
> types for creating their instances (both of these without requiring
> java code to be written)
That's what Ecore already does...
>
> Quote:
>> So is the user capable of using Ecore so that they can define
>> BookWithISBN?
>
> ==> Let's assume yes, I want to provide my users with a mechanism for
> doing so and force them to create "themselves" this ecore file (i may
> generate (automatically) it for them given a description/specification
> they can provide)
Okay.
>
> Quote:
>> It really depends a lot on the sophistication of your users. Do they
>> understand type systems? Will they want user defined types or should
>> you just enumerate the types? Will they be capable of defining
>> something type-system like, e.g., all Books should also have an ISBN
>> attribute of type string that I want to call isbn. Will two different
>> users want different things and still share the same Book instance?
>
> ==> The will want user defined types
>
> Quote:
>> Will they be capable of defining something type-system like, e.g.,
>> all Books should also have an ISBN attribute of type string that I
>> want to call isbn.
>
> ==> Yes
>
> Quote:
>> Will two different users want different things and still share the
>> same Book instance?
>
> ==> No
So just use Ecore. As Sylvain suggest, this is is all possible
already. Even things like
http://ed-merks.blogspot.de/2008/01/creating-children-you-didnt-know.html are
supported.
>
> Thx
>
>
>
> Ed Merks wrote on Fri, 04 October 2013 08:13
>> Jean-Baptise,
>>
>> Comments below.
>>
>> On 04/10/2013 1:57 PM, Jean-Baptiste Guillois wrote:
>> > Hello,
>> >
>> > First of all, i apologize for maybe not using the proper terms >
>> regarding ecore, models, metamodels.
>> >
>> > When using ecore, we can model concepts by defining classes and
>> their > attributes/relationships.
>> >
>> > Let's consider the following model, (defined using ecore):
>> > Class: "Book"
>> > Attributes: Name (String), Price (double), NoPages (int)
>> > Refs: author (Author)
>> >
>> > Class: "Author"
>> > Attributes: Name (String), NativeLang (String)
>> > Refs: books (Book)
>> >
>> > Now let's consider that i need to provide my users a way for
>> defining > custom attributes on books given the hypothesis that my
>> users cannot > modify the Book and Author model, they can only extend
>> it.
>> That's not necessarily the only conclusion. Often models make
>> themselves "extensible" via some type of annotation mechanism.
>> > I would like them to be able to define things like a ISBN attribute
>> > having a String type.
>> So is the user capable of using Ecore so that they can define
>> BookWithISBN?
>> >
>> > How can i use ecore (or something else) to address this kind of need?
>> It really depends a lot on the sophistication of your users. Do they
>> understand type systems? Will they want user defined types or should
>> you just enumerate the types? Will they be capable of defining
>> something type-system like, e.g., all Books should also have an ISBN
>> attribute of type string that I want to call isbn. Will two different
>> users want different things and still share the same Book instance?
>> >
>> > Many thanks for your help,
>> >
>> > Best Regards,
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:EAnnotation Validation
Next Topic:Problem loading an XML model instance into GUI editor: Package with uri '..' not found
Goto Forum:
  


Current Time: Thu Mar 28 23:47:49 GMT 2024

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

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

Back to the top