Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Modifying a static ecore model via the EMF dynamic API
Modifying a static ecore model via the EMF dynamic API [message #418651] Tue, 22 April 2008 22:38 Go to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
Hi,

Is it possible to dynamically modify the structure of static ecore model
(e.g. add new features in runtime) via the EMF dynamic API?

Thanks in advance!
Re: Modifying a static ecore model via the EMF dynamic API [message #418652 is a reply to message #418651] Tue, 22 April 2008 23:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
AJ,

No, but it's possible to create a derived dynamic EClass that extends a
static EClass to include more features that way.


AJ wrote:
> Hi,
>
> Is it possible to dynamically modify the structure of static ecore
> model (e.g. add new features in runtime) via the EMF dynamic API?
>
> Thanks in advance!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Modifying a static ecore model via the EMF dynamic API [message #418656 is a reply to message #418652] Wed, 23 April 2008 08:36 Go to previous messageGo to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
Hi, Ed,

It is clear that the dynamic EClass must be contained by an EPackage which
has an EFactory which is what will be used to create an instance of that
EClass. However, since the static ecore model already generates a
xyzPackage and xyzFactory class, then is a possible to use them to contain
the dynamic EClasses that extend the static model and create an instance
as shown below?

EClass dynaClass = EcoreFactory.eINSTANCE.createEClass();
dynaClass.setName("dynaClass");
dynaAttribute = EcoreFactory.eINSTANCE.createEAttribute();
dynaAttribute.setEType(EcorePackage.eINSTANCE.getEJavaObject ());
dynaClass.getEStructuralFeatures().add(dynaAttribute);
dynaAttribute.setTransient(true);
dynaClass.getESuperTypes().add(PlanningPackage.Literals.EPLA N);
xyzPackage.eINSTANCE.getEClassifiers().add(dynaClass);
EObject eDynaObject = xyzFactory.eINSTANCE.create(dynaClass);


Thanks!
Re: Modifying a static ecore model via the EMF dynamic API [message #418659 is a reply to message #418656] Wed, 23 April 2008 10:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
AJ,

No, the generated package should be considered immutable. Maybe what
you really want is EMF's equivalent of XML Schema wildcards that allow
you to associate additional properties directly an existing base
instance? Such data could come from another static model or from a
dynamic model...


AJ wrote:
> Hi, Ed,
>
> It is clear that the dynamic EClass must be contained by an EPackage
> which has an EFactory which is what will be used to create an instance
> of that EClass. However, since the static ecore model already
> generates a xyzPackage and xyzFactory class, then is a possible to use
> them to contain the dynamic EClasses that extend the static model and
> create an instance as shown below?
>
> EClass dynaClass = EcoreFactory.eINSTANCE.createEClass();
> dynaClass.setName("dynaClass");
> dynaAttribute = EcoreFactory.eINSTANCE.createEAttribute();
> dynaAttribute.setEType(EcorePackage.eINSTANCE.getEJavaObject ());
> dynaClass.getEStructuralFeatures().add(dynaAttribute);
> dynaAttribute.setTransient(true);
> dynaClass.getESuperTypes().add(PlanningPackage.Literals.EPLA N);
> xyzPackage.eINSTANCE.getEClassifiers().add(dynaClass);
> EObject eDynaObject = xyzFactory.eINSTANCE.create(dynaClass);
>
>
> Thanks!
>
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Modifying a static ecore model via the EMF dynamic API [message #418669 is a reply to message #418659] Wed, 23 April 2008 14:38 Go to previous messageGo to next message
Al B is currently offline Al BFriend
Messages: 130
Registered: July 2009
Senior Member
Ed,

Please see comments below.

>No, the generated package should be considered immutable.

So, does it mean the dynamic model will have to create/use its own edit
providers as well?


>Maybe what you really want is EMF's equivalent of XML Schema wildcards that
>allow you to associate additional properties directly an existing base
instance? >Such data could come from another static model or from a dynamic
model...

Yes, the latter sounds right. Can you please point me to where I can find
more information or some examples?

Thanks Ed!
Re: Modifying a static ecore model via the EMF dynamic API [message #418670 is a reply to message #418669] Wed, 23 April 2008 14:46 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040207020404070908080907
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

AJ,

Comments below.


AJ wrote:
> Ed,
>
> Please see comments below.
>
>> No, the generated package should be considered immutable.
>
> So, does it mean the dynamic model will have to create/use its own
> edit providers as well?
Yes, the reflective ones.
>
>
>> Maybe what you really want is EMF's equivalent of XML Schema
>> wildcards that allow you to associate additional properties directly
>> an existing base
> instance? >Such data could come from another static model or from a
> dynamic model...
>
> Yes, the latter sounds right. Can you please point me to where I can
> find more information or some examples?
You'll want to create an XML Schema with wildcards and generate a model
from that.

Binding XML to Java
< http://www.theserverside.com/tt/articles/article.tss?l=Bindi ngXMLJava>

Be forewarned though, all this XML Schema wildcard stuff is kind of gross.

Perhaps I should be asking what problem you are trying to solve. I.e.,
why is it that you'd not know about the properties that you need until
later while you are running?
>
> Thanks Ed!
>
>


--------------040207020404070908080907
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
AJ,<br>
<br>
Comments below.<br>
<br>
<br>
AJ wrote:
<blockquote
cite="mid:c1e06835c91d23b0a141592403636596$1@www.eclipse.org"
type="cite">Ed,
<br>
<br>
Please see comments below.
<br>
<br>
<blockquote type="cite">No, the generated package should be
considered immutable.
<br>
</blockquote>
<br>
So, does it mean the dynamic model will have to create/use its own edit
providers as well?
<br>
</blockquote>
Yes, the reflective ones.<br>
<blockquote
cite="mid:c1e06835c91d23b0a141592403636596$1@www.eclipse.org"
type="cite"><br>
<br>
<blockquote type="cite">Maybe what you really want is EMF's
equivalent of XML Schema wildcards that allow you to associate
additional properties directly an existing base </blockquote>
instance?


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Package with uri not found
Next Topic:What is the workflow to update a model generated from xsd schema
Goto Forum:
  


Current Time: Sat Apr 27 00:35:20 GMT 2024

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

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

Back to the top