Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » GMT (Generative Modeling Technologies) » [AM3] Gap between AM3 and EMF?
[AM3] Gap between AM3 and EMF? [message #375940] Tue, 16 January 2007 14:15 Go to next message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
Hi Newsgroup,

I am just starting a research project with the goal to use modeling
technology as a basis for content-level linking of different documents
and artifacts in the requirements engineering area. So I am basically
going to use modeling technology not to do code generation but to do
navigation, transformation and projection.

As I started working with ATL, AM3, KM3 and so on, I wanted to set up a
chain of steps like this:

- provide a metamodel in KM3
- transform the metamodel to ecore ("Inject KM3 to Ecore metamodel")
- generate an emf editor in the future, just now I'm sticking with the
EMF dynamic reflective model editor
- create a instance of the metamodel (currently using "Create dynamic
instance...")
- edit the resulting model using the (currently dynamic) editor.

I tried this using one of the standard metamodels in the atlantic zoo:
Person.km3

However, the above does not work out of the box, because of two reasons,
as I figured out:

1. In the ecore metamodel there is an EPackage "Person" with the
Property "Ns URI" not set. This results in an exception
org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
'null' not found. (platform:/resource/km3toecore/Person.xmi, 4, 51) when
opening the dynamic instance.

Remedy: Setting "Ns URI" in Person.ecore to somethin more or less useful
before creating the dynamic instance, the Namespace URI is used and the
model is ok.

2. When the model is opened in the dynamic reflective editor, model
properties can not be edited. While it is possible to enter values for
the properties, the input is discarded as soon as return is pressed.

Remedy: As I found out, this is because the properties are typed with
data types in the PrimitiveTypes package. The data types (like String)
there do not have the "Instance Class Name" property set. When setting
this to appropriate classes, like java.lang.String, java.lang.Integer,
etc. the reflective Editor works and values can be entered -> the model
can be fully edited.


So my question is: Why is there a gap between the KM3-to-Ecore component
and the Ecore editor? What I did to get the above working is nothing
that could not be generated programmatically.

So what am I missing?
Is it because the KM3-to-Ecore converter wants to be as generic as
possible and so does not hard-code the Ns URI and data type to class
mappings?


Hoping for some answers...

Regards,

Stefan
Re: [AM3] Gap between AM3 and EMF? [message #375941 is a reply to message #375940] Wed, 17 January 2007 15:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: mikael.barbero.gmail.com

Hi Stefan,

KM3 is supposed to be a *kernel* metametamodel. That's why there is no
EMF-Specific feature like nsURI in it.

Now, concerning the KM3-to-Ecore transformation, you're right that
nsUri, nsPrefix and instanceClassName thing could have been hard-coded
in it by some kinds of default values. We don't think it is a good
solution: it is not configurable and not very beautiful (i.e. not
generic regarding other KM3-to-XXX transformation where XXX is a
metametamodel such as MDR).

The best one should be to do an ATL transformation taking the Ecore
model from KM3-to-Ecore and copying it in a new model with all data you
need. This is not a very complicated transformation. Thus, you will be
able to define your own default value for nsURI, instanceClassName etc.

Another solution is to wait for the next release of KM3 which will
provide an model annotation framework and will use it to handle those
EMF-specific metadata in a generic way.

Best regards,
Mikaël

Stefan Winkler a écrit :
> Hi Newsgroup,
>
> I am just starting a research project with the goal to use modeling
> technology as a basis for content-level linking of different documents
> and artifacts in the requirements engineering area. So I am basically
> going to use modeling technology not to do code generation but to do
> navigation, transformation and projection.
>
> As I started working with ATL, AM3, KM3 and so on, I wanted to set up a
> chain of steps like this:
>
> - provide a metamodel in KM3
> - transform the metamodel to ecore ("Inject KM3 to Ecore metamodel")
> - generate an emf editor in the future, just now I'm sticking with the
> EMF dynamic reflective model editor
> - create a instance of the metamodel (currently using "Create dynamic
> instance...")
> - edit the resulting model using the (currently dynamic) editor.
>
> I tried this using one of the standard metamodels in the atlantic zoo:
> Person.km3
>
> However, the above does not work out of the box, because of two reasons,
> as I figured out:
>
> 1. In the ecore metamodel there is an EPackage "Person" with the
> Property "Ns URI" not set. This results in an exception
> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
> 'null' not found. (platform:/resource/km3toecore/Person.xmi, 4, 51) when
> opening the dynamic instance.
>
> Remedy: Setting "Ns URI" in Person.ecore to somethin more or less useful
> before creating the dynamic instance, the Namespace URI is used and the
> model is ok.
>
> 2. When the model is opened in the dynamic reflective editor, model
> properties can not be edited. While it is possible to enter values for
> the properties, the input is discarded as soon as return is pressed.
>
> Remedy: As I found out, this is because the properties are typed with
> data types in the PrimitiveTypes package. The data types (like String)
> there do not have the "Instance Class Name" property set. When setting
> this to appropriate classes, like java.lang.String, java.lang.Integer,
> etc. the reflective Editor works and values can be entered -> the model
> can be fully edited.
>
>
> So my question is: Why is there a gap between the KM3-to-Ecore component
> and the Ecore editor? What I did to get the above working is nothing
> that could not be generated programmatically.
>
> So what am I missing?
> Is it because the KM3-to-Ecore converter wants to be as generic as
> possible and so does not hard-code the Ns URI and data type to class
> mappings?
>
>
> Hoping for some answers...
>
> Regards,
>
> Stefan



--
Mikaël Barbero - PhD Candidate
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssinière
44322 Nantes Cedex 3 - France
tel. +33 2 51 12 58 08 /\ cell.+33 6 07 63 19 00
email: Mikael.Barbero@{gmail.com, univ-nantes.fr}
http://www.sciences.univ-nantes.fr/lina/atl/
[AM3][Epsilon] (was: Gap between AM3 and EMF) - Solution and small Epsilon Example [message #375943 is a reply to message #375941] Tue, 23 January 2007 14:32 Go to previous messageGo to next message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
Hi Mikaël,

thanks for your answer - I assumed something like this but I wasn't sure
if I was doing something wrong.

Regarding the transformation: I used the 'problem' to get a bit into
Epsilon. The following eol-Script does the adjustments:

== 8< ------
'This is CorrectEcore ...'.println();

'Looking for EPackages ...'.println();
for(p in EPackage.allInstances()) {
p.autoFillNsUrl();
}

'Looking for EDataTypes ...'.println();
for(t in EDataType.allInstances()) {
t.mapInstanceClass();
}

'Done!'.println();

operation EPackage autoFillNsUrl() {
if ((not self.nsURI.isDefined()) or self.nsURI.trim() = '') {
self.nsURI := ('http://www.fernuni-hagen.de/ST/ecore/'
+ self.name + '.ecore');
(self.name + ': set new nsURI to ' + self.nsURI).println();
}
}

operation EDataType mapInstanceClass() {

if ((not self.instanceClassName.isDefined())
or self.instanceClassName.trim() = '') {

-- add more mappings here, if needed
-- is there no switch/case in eol? ;-)

if(self.name = 'String') {
self.instanceClassName := 'java.lang.String';
}
else {
if(self.name = 'Integer') {
self.instanceClassName := 'java.lang.Integer';
}
else {
if(self.name = 'Boolean') {
self.instanceClassName := 'java.lang.Boolean';
}
else {
(self.name + ': could not find instance class '
+ 'mapping!').println();
return;
}
}
}
} else {
return;
}

(self.name + ': mapped to instance class ' +
self.instanceClassName).println();

}

== 8< ------

If anyone is interested, I can also provide an Eclipse Plugin which
invokes the above script as an action for *.ecore files. Just email me,
if you want it.

Regards,
Stefan


Mikaël Barbero wrote:
> Hi Stefan,
>
> KM3 is supposed to be a *kernel* metametamodel. That's why there is no
> EMF-Specific feature like nsURI in it.
>
> Now, concerning the KM3-to-Ecore transformation, you're right that
> nsUri, nsPrefix and instanceClassName thing could have been hard-coded
> in it by some kinds of default values. We don't think it is a good
> solution: it is not configurable and not very beautiful (i.e. not
> generic regarding other KM3-to-XXX transformation where XXX is a
> metametamodel such as MDR).
>
> The best one should be to do an ATL transformation taking the Ecore
> model from KM3-to-Ecore and copying it in a new model with all data you
> need. This is not a very complicated transformation. Thus, you will be
> able to define your own default value for nsURI, instanceClassName etc.
>
> Another solution is to wait for the next release of KM3 which will
> provide an model annotation framework and will use it to handle those
> EMF-specific metadata in a generic way.
>
> Best regards,
> Mikaël
>
> Stefan Winkler a écrit :
>> Hi Newsgroup,
>>
>> I am just starting a research project with the goal to use modeling
>> technology as a basis for content-level linking of different documents
>> and artifacts in the requirements engineering area. So I am basically
>> going to use modeling technology not to do code generation but to do
>> navigation, transformation and projection.
>>
>> As I started working with ATL, AM3, KM3 and so on, I wanted to set up a
>> chain of steps like this:
>>
>> - provide a metamodel in KM3
>> - transform the metamodel to ecore ("Inject KM3 to Ecore metamodel")
>> - generate an emf editor in the future, just now I'm sticking with the
>> EMF dynamic reflective model editor
>> - create a instance of the metamodel (currently using "Create dynamic
>> instance...")
>> - edit the resulting model using the (currently dynamic) editor.
>>
>> I tried this using one of the standard metamodels in the atlantic zoo:
>> Person.km3
>>
>> However, the above does not work out of the box, because of two reasons,
>> as I figured out:
>>
>> 1. In the ecore metamodel there is an EPackage "Person" with the
>> Property "Ns URI" not set. This results in an exception
>> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
>> 'null' not found. (platform:/resource/km3toecore/Person.xmi, 4, 51) when
>> opening the dynamic instance.
>>
>> Remedy: Setting "Ns URI" in Person.ecore to somethin more or less useful
>> before creating the dynamic instance, the Namespace URI is used and the
>> model is ok.
>>
>> 2. When the model is opened in the dynamic reflective editor, model
>> properties can not be edited. While it is possible to enter values for
>> the properties, the input is discarded as soon as return is pressed.
>>
>> Remedy: As I found out, this is because the properties are typed with
>> data types in the PrimitiveTypes package. The data types (like String)
>> there do not have the "Instance Class Name" property set. When setting
>> this to appropriate classes, like java.lang.String, java.lang.Integer,
>> etc. the reflective Editor works and values can be entered -> the model
>> can be fully edited.
>>
>>
>> So my question is: Why is there a gap between the KM3-to-Ecore component
>> and the Ecore editor? What I did to get the above working is nothing
>> that could not be generated programmatically.
>>
>> So what am I missing?
>> Is it because the KM3-to-Ecore converter wants to be as generic as
>> possible and so does not hard-code the Ns URI and data type to class
>> mappings?
>>
>>
>> Hoping for some answers...
>>
>> Regards,
>>
>> Stefan
>
>
>
Re: [AM3][Epsilon] [message #375949 is a reply to message #375943] Thu, 25 January 2007 19:51 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Stefan,

With regard to your question about the switch/case in EOL
it is not yet supported but we plan to add this feature soon.
Until then, a workaround for simplifying your mapInstanceClass()
operation would be to do something like the following:

var types : Sequence;
types := Sequence{'String', 'Integer', 'Boolean'};
if (types.exists(t|t = self.name)) {
self.instanceClassName := 'java.lang.' + self.name;
}

Cheers,
Dimitrios

Stefan Winkler wrote:
> Hi Mikaël,
>
> thanks for your answer - I assumed something like this but I wasn't sure
> if I was doing something wrong.
>
> Regarding the transformation: I used the 'problem' to get a bit into
> Epsilon. The following eol-Script does the adjustments:
>
> == 8< ------
> 'This is CorrectEcore ...'.println();
>
> 'Looking for EPackages ...'.println();
> for(p in EPackage.allInstances()) {
> p.autoFillNsUrl();
> }
>
> 'Looking for EDataTypes ...'.println();
> for(t in EDataType.allInstances()) {
> t.mapInstanceClass();
> }
>
> 'Done!'.println();
>
> operation EPackage autoFillNsUrl() {
> if ((not self.nsURI.isDefined()) or self.nsURI.trim() = '') {
> self.nsURI := ('http://www.fernuni-hagen.de/ST/ecore/'
> + self.name + '.ecore');
> (self.name + ': set new nsURI to ' + self.nsURI).println();
> }
> }
>
> operation EDataType mapInstanceClass() {
>
> if ((not self.instanceClassName.isDefined())
> or self.instanceClassName.trim() = '') {
>
> -- add more mappings here, if needed
> -- is there no switch/case in eol? ;-)
>
> if(self.name = 'String') {
> self.instanceClassName := 'java.lang.String';
> }
> else {
> if(self.name = 'Integer') {
> self.instanceClassName := 'java.lang.Integer';
> }
> else {
> if(self.name = 'Boolean') {
> self.instanceClassName := 'java.lang.Boolean';
> }
> else {
> (self.name + ': could not find instance class '
> + 'mapping!').println();
> return;
> }
> }
> }
> } else {
> return;
> }
>
> (self.name + ': mapped to instance class ' +
> self.instanceClassName).println();
>
> }
>
> == 8< ------
>
> If anyone is interested, I can also provide an Eclipse Plugin which
> invokes the above script as an action for *.ecore files. Just email me,
> if you want it.
>
> Regards,
> Stefan
>
>
> Mikaël Barbero wrote:
>> Hi Stefan,
>>
>> KM3 is supposed to be a *kernel* metametamodel. That's why there is no
>> EMF-Specific feature like nsURI in it.
>>
>> Now, concerning the KM3-to-Ecore transformation, you're right that
>> nsUri, nsPrefix and instanceClassName thing could have been hard-coded
>> in it by some kinds of default values. We don't think it is a good
>> solution: it is not configurable and not very beautiful (i.e. not
>> generic regarding other KM3-to-XXX transformation where XXX is a
>> metametamodel such as MDR).
>>
>> The best one should be to do an ATL transformation taking the Ecore
>> model from KM3-to-Ecore and copying it in a new model with all data you
>> need. This is not a very complicated transformation. Thus, you will be
>> able to define your own default value for nsURI, instanceClassName etc.
>>
>> Another solution is to wait for the next release of KM3 which will
>> provide an model annotation framework and will use it to handle those
>> EMF-specific metadata in a generic way.
>>
>> Best regards,
>> Mikaël
>>
>> Stefan Winkler a écrit :
>>> Hi Newsgroup,
>>>
>>> I am just starting a research project with the goal to use modeling
>>> technology as a basis for content-level linking of different documents
>>> and artifacts in the requirements engineering area. So I am basically
>>> going to use modeling technology not to do code generation but to do
>>> navigation, transformation and projection.
>>>
>>> As I started working with ATL, AM3, KM3 and so on, I wanted to set up a
>>> chain of steps like this:
>>>
>>> - provide a metamodel in KM3
>>> - transform the metamodel to ecore ("Inject KM3 to Ecore metamodel")
>>> - generate an emf editor in the future, just now I'm sticking with the
>>> EMF dynamic reflective model editor
>>> - create a instance of the metamodel (currently using "Create dynamic
>>> instance...")
>>> - edit the resulting model using the (currently dynamic) editor.
>>>
>>> I tried this using one of the standard metamodels in the atlantic zoo:
>>> Person.km3
>>>
>>> However, the above does not work out of the box, because of two reasons,
>>> as I figured out:
>>>
>>> 1. In the ecore metamodel there is an EPackage "Person" with the
>>> Property "Ns URI" not set. This results in an exception
>>> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
>>> 'null' not found. (platform:/resource/km3toecore/Person.xmi, 4, 51) when
>>> opening the dynamic instance.
>>>
>>> Remedy: Setting "Ns URI" in Person.ecore to somethin more or less useful
>>> before creating the dynamic instance, the Namespace URI is used and the
>>> model is ok.
>>>
>>> 2. When the model is opened in the dynamic reflective editor, model
>>> properties can not be edited. While it is possible to enter values for
>>> the properties, the input is discarded as soon as return is pressed.
>>>
>>> Remedy: As I found out, this is because the properties are typed with
>>> data types in the PrimitiveTypes package. The data types (like String)
>>> there do not have the "Instance Class Name" property set. When setting
>>> this to appropriate classes, like java.lang.String, java.lang.Integer,
>>> etc. the reflective Editor works and values can be entered -> the model
>>> can be fully edited.
>>>
>>>
>>> So my question is: Why is there a gap between the KM3-to-Ecore component
>>> and the Ecore editor? What I did to get the above working is nothing
>>> that could not be generated programmatically.
>>>
>>> So what am I missing?
>>> Is it because the KM3-to-Ecore converter wants to be as generic as
>>> possible and so does not hard-code the Ns URI and data type to class
>>> mappings?
>>>
>>>
>>> Hoping for some answers...
>>>
>>> Regards,
>>>
>>> Stefan
>>
>>
Re: [AM3] Gap between AM3 and EMF? [message #562221 is a reply to message #375940] Wed, 17 January 2007 15:57 Go to previous message
Eclipse UserFriend
Originally posted by: mikael.barbero.gmail.com

Hi Stefan,

KM3 is supposed to be a *kernel* metametamodel. That's why there is no
EMF-Specific feature like nsURI in it.

Now, concerning the KM3-to-Ecore transformation, you're right that
nsUri, nsPrefix and instanceClassName thing could have been hard-coded
in it by some kinds of default values. We don't think it is a good
solution: it is not configurable and not very beautiful (i.e. not
generic regarding other KM3-to-XXX transformation where XXX is a
metametamodel such as MDR).

The best one should be to do an ATL transformation taking the Ecore
model from KM3-to-Ecore and copying it in a new model with all data you
need. This is not a very complicated transformation. Thus, you will be
able to define your own default value for nsURI, instanceClassName etc.

Another solution is to wait for the next release of KM3 which will
provide an model annotation framework and will use it to handle those
EMF-specific metadata in a generic way.

Best regards,
Mikaël

Stefan Winkler a écrit :
> Hi Newsgroup,
>
> I am just starting a research project with the goal to use modeling
> technology as a basis for content-level linking of different documents
> and artifacts in the requirements engineering area. So I am basically
> going to use modeling technology not to do code generation but to do
> navigation, transformation and projection.
>
> As I started working with ATL, AM3, KM3 and so on, I wanted to set up a
> chain of steps like this:
>
> - provide a metamodel in KM3
> - transform the metamodel to ecore ("Inject KM3 to Ecore metamodel")
> - generate an emf editor in the future, just now I'm sticking with the
> EMF dynamic reflective model editor
> - create a instance of the metamodel (currently using "Create dynamic
> instance...")
> - edit the resulting model using the (currently dynamic) editor.
>
> I tried this using one of the standard metamodels in the atlantic zoo:
> Person.km3
>
> However, the above does not work out of the box, because of two reasons,
> as I figured out:
>
> 1. In the ecore metamodel there is an EPackage "Person" with the
> Property "Ns URI" not set. This results in an exception
> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
> 'null' not found. (platform:/resource/km3toecore/Person.xmi, 4, 51) when
> opening the dynamic instance.
>
> Remedy: Setting "Ns URI" in Person.ecore to somethin more or less useful
> before creating the dynamic instance, the Namespace URI is used and the
> model is ok.
>
> 2. When the model is opened in the dynamic reflective editor, model
> properties can not be edited. While it is possible to enter values for
> the properties, the input is discarded as soon as return is pressed.
>
> Remedy: As I found out, this is because the properties are typed with
> data types in the PrimitiveTypes package. The data types (like String)
> there do not have the "Instance Class Name" property set. When setting
> this to appropriate classes, like java.lang.String, java.lang.Integer,
> etc. the reflective Editor works and values can be entered -> the model
> can be fully edited.
>
>
> So my question is: Why is there a gap between the KM3-to-Ecore component
> and the Ecore editor? What I did to get the above working is nothing
> that could not be generated programmatically.
>
> So what am I missing?
> Is it because the KM3-to-Ecore converter wants to be as generic as
> possible and so does not hard-code the Ns URI and data type to class
> mappings?
>
>
> Hoping for some answers...
>
> Regards,
>
> Stefan



--
Mikaël Barbero - PhD Candidate
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssinière
44322 Nantes Cedex 3 - France
tel. +33 2 51 12 58 08 /\ cell.+33 6 07 63 19 00
email: Mikael.Barbero@{gmail.com, univ-nantes.fr}
http://www.sciences.univ-nantes.fr/lina/atl/
[AM3][Epsilon] (was: Gap between AM3 and EMF) - Solution and small Epsilon Example [message #562273 is a reply to message #375941] Tue, 23 January 2007 14:32 Go to previous message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
Hi Mikaël,

thanks for your answer - I assumed something like this but I wasn't sure
if I was doing something wrong.

Regarding the transformation: I used the 'problem' to get a bit into
Epsilon. The following eol-Script does the adjustments:

== 8< ------
'This is CorrectEcore ...'.println();

'Looking for EPackages ...'.println();
for(p in EPackage.allInstances()) {
p.autoFillNsUrl();
}

'Looking for EDataTypes ...'.println();
for(t in EDataType.allInstances()) {
t.mapInstanceClass();
}

'Done!'.println();

operation EPackage autoFillNsUrl() {
if ((not self.nsURI.isDefined()) or self.nsURI.trim() = '') {
self.nsURI := ('http://www.fernuni-hagen.de/ST/ecore/'
+ self.name + '.ecore');
(self.name + ': set new nsURI to ' + self.nsURI).println();
}
}

operation EDataType mapInstanceClass() {

if ((not self.instanceClassName.isDefined())
or self.instanceClassName.trim() = '') {

-- add more mappings here, if needed
-- is there no switch/case in eol? ;-)

if(self.name = 'String') {
self.instanceClassName := 'java.lang.String';
}
else {
if(self.name = 'Integer') {
self.instanceClassName := 'java.lang.Integer';
}
else {
if(self.name = 'Boolean') {
self.instanceClassName := 'java.lang.Boolean';
}
else {
(self.name + ': could not find instance class '
+ 'mapping!').println();
return;
}
}
}
} else {
return;
}

(self.name + ': mapped to instance class ' +
self.instanceClassName).println();

}

== 8< ------

If anyone is interested, I can also provide an Eclipse Plugin which
invokes the above script as an action for *.ecore files. Just email me,
if you want it.

Regards,
Stefan


Mikaël Barbero wrote:
> Hi Stefan,
>
> KM3 is supposed to be a *kernel* metametamodel. That's why there is no
> EMF-Specific feature like nsURI in it.
>
> Now, concerning the KM3-to-Ecore transformation, you're right that
> nsUri, nsPrefix and instanceClassName thing could have been hard-coded
> in it by some kinds of default values. We don't think it is a good
> solution: it is not configurable and not very beautiful (i.e. not
> generic regarding other KM3-to-XXX transformation where XXX is a
> metametamodel such as MDR).
>
> The best one should be to do an ATL transformation taking the Ecore
> model from KM3-to-Ecore and copying it in a new model with all data you
> need. This is not a very complicated transformation. Thus, you will be
> able to define your own default value for nsURI, instanceClassName etc.
>
> Another solution is to wait for the next release of KM3 which will
> provide an model annotation framework and will use it to handle those
> EMF-specific metadata in a generic way.
>
> Best regards,
> Mikaël
>
> Stefan Winkler a écrit :
>> Hi Newsgroup,
>>
>> I am just starting a research project with the goal to use modeling
>> technology as a basis for content-level linking of different documents
>> and artifacts in the requirements engineering area. So I am basically
>> going to use modeling technology not to do code generation but to do
>> navigation, transformation and projection.
>>
>> As I started working with ATL, AM3, KM3 and so on, I wanted to set up a
>> chain of steps like this:
>>
>> - provide a metamodel in KM3
>> - transform the metamodel to ecore ("Inject KM3 to Ecore metamodel")
>> - generate an emf editor in the future, just now I'm sticking with the
>> EMF dynamic reflective model editor
>> - create a instance of the metamodel (currently using "Create dynamic
>> instance...")
>> - edit the resulting model using the (currently dynamic) editor.
>>
>> I tried this using one of the standard metamodels in the atlantic zoo:
>> Person.km3
>>
>> However, the above does not work out of the box, because of two reasons,
>> as I figured out:
>>
>> 1. In the ecore metamodel there is an EPackage "Person" with the
>> Property "Ns URI" not set. This results in an exception
>> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
>> 'null' not found. (platform:/resource/km3toecore/Person.xmi, 4, 51) when
>> opening the dynamic instance.
>>
>> Remedy: Setting "Ns URI" in Person.ecore to somethin more or less useful
>> before creating the dynamic instance, the Namespace URI is used and the
>> model is ok.
>>
>> 2. When the model is opened in the dynamic reflective editor, model
>> properties can not be edited. While it is possible to enter values for
>> the properties, the input is discarded as soon as return is pressed.
>>
>> Remedy: As I found out, this is because the properties are typed with
>> data types in the PrimitiveTypes package. The data types (like String)
>> there do not have the "Instance Class Name" property set. When setting
>> this to appropriate classes, like java.lang.String, java.lang.Integer,
>> etc. the reflective Editor works and values can be entered -> the model
>> can be fully edited.
>>
>>
>> So my question is: Why is there a gap between the KM3-to-Ecore component
>> and the Ecore editor? What I did to get the above working is nothing
>> that could not be generated programmatically.
>>
>> So what am I missing?
>> Is it because the KM3-to-Ecore converter wants to be as generic as
>> possible and so does not hard-code the Ns URI and data type to class
>> mappings?
>>
>>
>> Hoping for some answers...
>>
>> Regards,
>>
>> Stefan
>
>
>
Re: [AM3][Epsilon] [message #562419 is a reply to message #375943] Thu, 25 January 2007 19:51 Go to previous message
Dimitrios Kolovos is currently offline Dimitrios KolovosFriend
Messages: 1776
Registered: July 2009
Senior Member
Hi Stefan,

With regard to your question about the switch/case in EOL
it is not yet supported but we plan to add this feature soon.
Until then, a workaround for simplifying your mapInstanceClass()
operation would be to do something like the following:

var types : Sequence;
types := Sequence{'String', 'Integer', 'Boolean'};
if (types.exists(t|t = self.name)) {
self.instanceClassName := 'java.lang.' + self.name;
}

Cheers,
Dimitrios

Stefan Winkler wrote:
> Hi Mikaël,
>
> thanks for your answer - I assumed something like this but I wasn't sure
> if I was doing something wrong.
>
> Regarding the transformation: I used the 'problem' to get a bit into
> Epsilon. The following eol-Script does the adjustments:
>
> == 8< ------
> 'This is CorrectEcore ...'.println();
>
> 'Looking for EPackages ...'.println();
> for(p in EPackage.allInstances()) {
> p.autoFillNsUrl();
> }
>
> 'Looking for EDataTypes ...'.println();
> for(t in EDataType.allInstances()) {
> t.mapInstanceClass();
> }
>
> 'Done!'.println();
>
> operation EPackage autoFillNsUrl() {
> if ((not self.nsURI.isDefined()) or self.nsURI.trim() = '') {
> self.nsURI := ('http://www.fernuni-hagen.de/ST/ecore/'
> + self.name + '.ecore');
> (self.name + ': set new nsURI to ' + self.nsURI).println();
> }
> }
>
> operation EDataType mapInstanceClass() {
>
> if ((not self.instanceClassName.isDefined())
> or self.instanceClassName.trim() = '') {
>
> -- add more mappings here, if needed
> -- is there no switch/case in eol? ;-)
>
> if(self.name = 'String') {
> self.instanceClassName := 'java.lang.String';
> }
> else {
> if(self.name = 'Integer') {
> self.instanceClassName := 'java.lang.Integer';
> }
> else {
> if(self.name = 'Boolean') {
> self.instanceClassName := 'java.lang.Boolean';
> }
> else {
> (self.name + ': could not find instance class '
> + 'mapping!').println();
> return;
> }
> }
> }
> } else {
> return;
> }
>
> (self.name + ': mapped to instance class ' +
> self.instanceClassName).println();
>
> }
>
> == 8< ------
>
> If anyone is interested, I can also provide an Eclipse Plugin which
> invokes the above script as an action for *.ecore files. Just email me,
> if you want it.
>
> Regards,
> Stefan
>
>
> Mikaël Barbero wrote:
>> Hi Stefan,
>>
>> KM3 is supposed to be a *kernel* metametamodel. That's why there is no
>> EMF-Specific feature like nsURI in it.
>>
>> Now, concerning the KM3-to-Ecore transformation, you're right that
>> nsUri, nsPrefix and instanceClassName thing could have been hard-coded
>> in it by some kinds of default values. We don't think it is a good
>> solution: it is not configurable and not very beautiful (i.e. not
>> generic regarding other KM3-to-XXX transformation where XXX is a
>> metametamodel such as MDR).
>>
>> The best one should be to do an ATL transformation taking the Ecore
>> model from KM3-to-Ecore and copying it in a new model with all data you
>> need. This is not a very complicated transformation. Thus, you will be
>> able to define your own default value for nsURI, instanceClassName etc.
>>
>> Another solution is to wait for the next release of KM3 which will
>> provide an model annotation framework and will use it to handle those
>> EMF-specific metadata in a generic way.
>>
>> Best regards,
>> Mikaël
>>
>> Stefan Winkler a écrit :
>>> Hi Newsgroup,
>>>
>>> I am just starting a research project with the goal to use modeling
>>> technology as a basis for content-level linking of different documents
>>> and artifacts in the requirements engineering area. So I am basically
>>> going to use modeling technology not to do code generation but to do
>>> navigation, transformation and projection.
>>>
>>> As I started working with ATL, AM3, KM3 and so on, I wanted to set up a
>>> chain of steps like this:
>>>
>>> - provide a metamodel in KM3
>>> - transform the metamodel to ecore ("Inject KM3 to Ecore metamodel")
>>> - generate an emf editor in the future, just now I'm sticking with the
>>> EMF dynamic reflective model editor
>>> - create a instance of the metamodel (currently using "Create dynamic
>>> instance...")
>>> - edit the resulting model using the (currently dynamic) editor.
>>>
>>> I tried this using one of the standard metamodels in the atlantic zoo:
>>> Person.km3
>>>
>>> However, the above does not work out of the box, because of two reasons,
>>> as I figured out:
>>>
>>> 1. In the ecore metamodel there is an EPackage "Person" with the
>>> Property "Ns URI" not set. This results in an exception
>>> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
>>> 'null' not found. (platform:/resource/km3toecore/Person.xmi, 4, 51) when
>>> opening the dynamic instance.
>>>
>>> Remedy: Setting "Ns URI" in Person.ecore to somethin more or less useful
>>> before creating the dynamic instance, the Namespace URI is used and the
>>> model is ok.
>>>
>>> 2. When the model is opened in the dynamic reflective editor, model
>>> properties can not be edited. While it is possible to enter values for
>>> the properties, the input is discarded as soon as return is pressed.
>>>
>>> Remedy: As I found out, this is because the properties are typed with
>>> data types in the PrimitiveTypes package. The data types (like String)
>>> there do not have the "Instance Class Name" property set. When setting
>>> this to appropriate classes, like java.lang.String, java.lang.Integer,
>>> etc. the reflective Editor works and values can be entered -> the model
>>> can be fully edited.
>>>
>>>
>>> So my question is: Why is there a gap between the KM3-to-Ecore component
>>> and the Ecore editor? What I did to get the above working is nothing
>>> that could not be generated programmatically.
>>>
>>> So what am I missing?
>>> Is it because the KM3-to-Ecore converter wants to be as generic as
>>> possible and so does not hard-code the Ns URI and data type to class
>>> mappings?
>>>
>>>
>>> Hoping for some answers...
>>>
>>> Regards,
>>>
>>> Stefan
>>
>>
Previous Topic:Code generation from xTend in oAW
Next Topic:[MOFScript] The context "http://www.eclipse.org/uml2/1.0.0/UML" is not found
Goto Forum:
  


Current Time: Fri Apr 26 14:24:58 GMT 2024

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

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

Back to the top