Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Texo/EMF] What is the proper way to "customize/extend" your model
[Texo/EMF] What is the proper way to "customize/extend" your model [message #1214701] Wed, 27 November 2013 20:27 Go to next message
Bertrand Quenin is currently offline Bertrand QueninFriend
Messages: 70
Registered: July 2009
Member
Hi guys,

I'm currently working on a POC for my company and I'm evaluating Texo which is really impressive so far I have to admit.

I have a topic related to model customization/extension and I have evaluated 3 approaches so far:


  • EMF Profiles
  • EMF Facets
  • Classic inheritance approach


The first 2 approaches seems interesting and clear but unfortunately, I wasn't really able to do what I wanted to with these 2 plugins.
The classic inheritance approach (which I'm sure is way less sexy than the 2 above) works like a charm but I wanted to make sure I'm not taking a wrong approach.

Basically, I have an ecore model defining lots of objects and I'd like to customize some of them (or any of them).

Let's say i have a Person object with 2 attributes firstName & lastName, but, for whatever reason, I need to make sure that one can add a custom field to the object such as "age" or "address" or whatever.

What I've done is creating a "Customizable" object including a collection of "CustomAttribute" object, itself containing a CustomAttributeType & CustomAttributeValue.
CustomAttributeType is an enum (Int, long, string, etc.)
CustomAttributeValue is an abstract class, subclassed as IntCustomAttributeValue, LongCustomAttributeValue, etc.

Finally, I made my Person object extend Customizable and it works like a charm.

However, this seems like a pretty basic approach and I'm pretty sure there's a better way of doing this.
On top of that, this approach doesn't allow to include "unknown" objects, i.e. whatever object someone created and want to use as a custom field because all possible custom attributes are predefined in the model.

Do you guys have some other approach ? I'm really curious about that!

Thanks,
BQ.

[Updated on: Thu, 28 November 2013 12:09]

Report message to a moderator

Re: [Texo/EMF] What is the proper way to "customize " your model [message #1216367 is a reply to message #1214701] Thu, 28 November 2013 12:45 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Bertrand,
There is not really a good standard solution for this, mainly because relational databases are not good at really
dynamic schema changes.

First I would define customizable as an interface, it is like a 'facet' of an object (just like auditing, logging,
versioning information are more like cross cutting concerns).
Then customizable can be used as an ESuperType next to the 'real' ESuperType of the eclass.

As you note, it is doable to create/add primitive type fields using the custom attributetype and attributevalue
approach. For reference/foreignkey/assocation values, you need to store it in 2 fields/columns: 1) to store the type of
the referenced object, 2) to store a String representation of the primary key of the referenced object. This model does
not support foreign key constraint, also deletion checking needs to be done manually/coded. Or you can make it robust
when resolving a custom object to handle the case that the referenced object has already been deleted.

You can use the concept of a volatile efeature to model accessing the referenced object, when calling the getter of this
efeature it should automatically resolve the custom reference.
When resolving the custom reference you also need an entitymanager, so your framework/infrastructure should probably
have a way to get to the current entitymanager.

Hope this helps somewhat..

gr. Martin


On 11/27/2013 09:27 PM, Bertrand Quenin wrote:
> Hi guys,
>
> I'm currently working on a POC for my company and I'm evaluating Texo which is really impressive so far I have to admit.
>
> I have a topic related to model customization/extension and I have evaluated 3 approaches so far:
>
>
> EMF Profiles
> EMF Facets
> Classic inheritance approach
>
>
> The first 2 approaches seems interesting and clear but unfortunately, I wasn't really able to do what I wanted to with
> these 2 plugins.
> The classic inheritance approach (which I'm sure is way less sexy than the 2 above) works like a charm but I wanted to
> make sure I'm not taking a wrong approach.
>
> Basically, I have an ecore model defining lots of objects and I'd like to customize some of them (or any of them).
>
> Let's say i have a Person object with 2 attributes firstName & lastName, but, for whatever reason, I need to make sure
> that one can add a custom field to the object such as "age" or "address" or whatever.
>
> What I've done is creating a "Customizable" object including a collection of "CustomAttribute" object, itself containing
> a CustomAttributeType & CustomAttributeValue.
> CustomAttributeType is an enum (Int, long, string, etc.)
> CustomAttributeValue is an abstract class, subclassed as IntCustomAttributeValue, LongCustomAttributeValue, etc.
>
> Finally, I made my Person object extend Customizable and it works like a charm.
>
> However, this seems like a pretty basic approach and I'm pretty sure there's a better way of doing this.
> On top of that, this approach doesn't allow to include "unknown" objects, i.e. whatever object someone created and want
> to use as a custom field because all possible custom attributes are part of the model.
>
> Do you guys have some other approach ? I'm really curious about that!
>
> Thanks,
> BQ.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo/EMF] What is the proper way to "customize " your model [message #1219050 is a reply to message #1216367] Sat, 30 November 2013 11:58 Go to previous messageGo to next message
Bertrand Quenin is currently offline Bertrand QueninFriend
Messages: 70
Registered: July 2009
Member
Hi Martin,

Sorry for this late reply but I've been digging into all possible solutions matching my requirements.

Basically, I found another approach to my problem. The "Customizable" approach was a first draft and even it fits most of my requirements, it doesn't cover the most essential one: being able to really customize a model (with complex objects and not only primitive types) after it has been release from RnD.

I've bumped into Dynamic EMF since then and it seems to be what I'm looking for: extending/customizing an existing model by a customer. So now, I'm trying to learn more about Dynamic EMF (that I've discovered by reading Texo converter sources) and see if I can persist these dynamic extensions into a DB. It seems that Teneo is able to persist a dynamically created model based on this article: http://wiki.eclipse.org/Teneo/Hibernate/Dynamic_EMF_Tutorial

I just wanted to double check with you if you think this can be a good approach to extend/customize a "predefined" model. The product would have a "static" Texo model and it would be extendable at runtime with dynamic EMF and persisted with Teneo. Overall, it sounds like it can work and I'm going to prototype this.

Please tell me what you think!

Thanks again for your help,
BQ.
Re: [Texo/EMF] What is the proper way to "customize " your model [message #1219052 is a reply to message #1219050] Sat, 30 November 2013 12:18 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Bertrand,
Yes for sure Teneo can work with dynamically extended models, it is being used also in production apps for this. But
(there is always a but), when you change the model, the rdb schema is also updated. Rdb schema updates often lock the
complete database. So this can only be done if the rdb schema is updated not too often or outside working hours or if
the rdb allows this flexibility ofcourse.

The nice thing is that Texo also has a EMF to json converter, so if you want to do json with dynamic eobjects that's
possible.

So to summarize, interesting approach to try out!

gr. Martin

On 11/30/2013 12:58 PM, Bertrand Quenin wrote:
> Hi Martin,
>
> Sorry for this late reply but I've been digging into all possible solutions matching my requirements.
>
> Basically, I found another approach to my problem. The "Customizable" approach was a first draft and even it fits most
> of my requirements, it doesn't cover the most essential one: being able to really customize a model (with complex
> objects and not only primitive types) after it has been release from RnD.
>
> I've bumped into Dynamic EMF since then and it seems to be what I'm looking for: extending/customizing an existing model
> by a customer. So now, I'm trying to learn more about Dynamic EMF (that I've discovered by reading Texo converter
> sources) and see if I can persist these dynamic extensions into a DB. It seems that Teneo is able to persist a
> dynamically created model based on this article: http://wiki.eclipse.org/Teneo/Hibernate/Dynamic_EMF_Tutorial
>
> I just wanted to double check with you if you think this can be a good approach to extend/customize a "predefined"
> model. The product would have a "static" Texo model and it would be extendable at runtime with dynamic EMF and persisted
> with Teneo. Overall, it sounds like it can work and I'm going to prototype this.
>
> Please tell me what you think!
>
> Thanks again for your help,
> BQ.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo/EMF] What is the proper way to "customize " your model [message #1219059 is a reply to message #1219052] Sat, 30 November 2013 14:00 Go to previous messageGo to next message
Bertrand Quenin is currently offline Bertrand QueninFriend
Messages: 70
Registered: July 2009
Member
Hi Martin,

Yeah, I've read the limitations (after posting) but I think it's an understandable compromise. I haven't tested Teneo yet but the JSON serializer is a nice feature for sure. Is it possible to expose the "dynamic" model through the Texo REST server as well ? I'm just curious about that.

Anyway thanks again for your great assistance. I'm going to prototype this next week (and I'll probably end up having new questions).

Thanks,
BQ.
Re: [Texo/EMF] What is the proper way to "customize " your model [message #1219063 is a reply to message #1219059] Sat, 30 November 2013 15:51 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Bertrand,
The texo server currently serves only texo objects, but it can be changed to also serve referenced eobjects (dynamic or
static). You can always enter a bugzilla for this, or better a contribution on this area is ofcourse also welcome!

gr. Martin

On 11/30/2013 03:00 PM, Bertrand Quenin wrote:
> Hi Martin,
>
> Yeah, I've read the limitations (after posting) but I think it's an understandable compromise. I haven't tested Teneo
> yet but the JSON serializer is a nice feature for sure. Is it possible to expose the "dynamic" model through the Texo
> REST server as well ? I'm just curious about that.
>
> Anyway thanks again for your great assistance. I'm going to prototype this next week (and I'll probably end up having
> new questions).
>
> Thanks,
> BQ.


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: [Texo/EMF] What is the proper way to "customize/extend" your model [message #1219767 is a reply to message #1214701] Thu, 05 December 2013 17:12 Go to previous message
Bertrand Quenin is currently offline Bertrand QueninFriend
Messages: 70
Registered: July 2009
Member
Hi Martin,

Quote:
The texo server currently serves only texo objects, but it can be changed to also serve referenced eobjects (dynamic or
static). You can always enter a bugzilla for this, or better a contribution on this area is ofcourse also welcome!


This actually one of my goal, I'll probably contribute some code to Texo as soon as I'm hitting this topic concretely.

The current status of my POC is:
1) I managed to create a model dynamically with "dynamic EMF".

2) I need to persist the dynamically created model. For this, I had 2 options:
- using Texo to generate code from the static model Ecore.ecore,
- persist the model to a file.

Since I don't think the "runtime designed" model needs to be queried in details, I chose file serialization (can't remember the exact output format, I think it's XSD for a model). I actually haven't done that part yet but evaluate solutions only, do you have any recommendations about this?

3) I instantiated some objects from the dynamically created model.

4) I used Teneo to:
- Create the database schema at runtime,
- persist these objects in the database.

Since it's a simple model it worked flawlessly. (On a side note, I'm totally amazed by the tools you have written: both Texo and Teneo).

So now I have 2 models (a static one & a dynamic one) but they're not connected at all. I'm conflicted about how to connect them together:
- In the example, you have the inheritance approach (dynamic model extends the static one directly by subclassing). This approach bothers me because the static model is prone to change over releases and I don't feel comfortable having customers extending the model directly...

- Another approach is to wire the 2 models together using my old Customizable approach. Basically, create an interface called Customizable having a CustomizableAttribute list, and a CustomizableAttribute having 3 attributes:
- a name (string): name of the CustomizableAttribute,
- a type (string): the dynamic model EClass canonical name of this CustomizableAttribute.
- an id (long): the database id of the persisted dynamic model instance.

So basically any object of the static model could "reference" an dynamic model instance. However, I don't think it's a good approach because it breaks the "model links".
I also thought I could use an EReference instead of an id in the CustomizableAttribute but I'm not sure it's a good approach either.

I would really love to have your insights on how to link these 2 models!

Thanks again for your great tool,
BQ.
Previous Topic:[editor] UI remove class prefix when similar to package name
Next Topic:[Texo] Modeling JoinColumns
Goto Forum:
  


Current Time: Sat Apr 20 00:42:51 GMT 2024

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

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

Back to the top