Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Model with several metamodels
[ATL] Model with several metamodels [message #107530] Tue, 30 June 2009 12:57 Go to next message
Eclipse User
Originally posted by: steve.hostettler.unige.ch

Hello all,

first let me tell you, you've done a great job.

I'am trying to use ATL to transform our model of Petri Nets to the PNML
standard.

We have the following structure:

MM APN & ADT --> PNML
M Dining.Philosophers.model MyPNML.model

The Dining Philosophers petri nets uses 2 meta-models the APN (Algebraic
Petri Net) that models the structure of the net and the ADT that
represents algebraic values.


As long as I remove the elements that are from ADT in our model, it
works perfectly.


Model without references to the ADT metamodel (except in the header) :
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:algspec="http://alpina.unige.ch/algspec"
xmlns:apn="http://alpina.unige.ch/apn">

<apn:PetriNet Name="Dining Philosophers" >
<OwnedNodes xsi:type="apn:Place" Name="HasR" />
<OwnedNodes xsi:type="apn:Transition" Name="takeR" />
...
</apn:PetriNet>
</xmi:XMI>


Now if I had the following snippet:
<algspec:AlgebraicSpec>
<multiset>
...
</multiset>
</algspec:AlgebraicSpec>

I get the following error message :
>Error loading
> platform:/resource/APN2PNML/examples/dining/DiningPhilosophe rs.apn:
>org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
>'http://alpina.unige.ch/algspec' not found.
> (platform:/resource/APN2PNML/examples/dining/DiningPhilosoph ers.apn,
>20, 26)

This is clear to me since the second meta model has not been referenced
so far. To avoid that I've added the second meta model as input metamodel.

However, this does not solve my problem because the launcher ask me to
give a second model (I cannot avoid this in eclise). The problem is
that I have only one file. Actually each namespace conforms to its
metamodel.


I understand that each model should only conforms to one metamodel but
the point is that this mix between both metamodel in the same xmi come
from the emf-gmf stack I use to produce the model. There I do not get
any error that the model is not valid.


Is there any workaround for that problem?

Many thanks in advance.

Regards
Steve
Re: [ATL] Using a Referenced Metamodel [message #107643 is a reply to message #107530] Wed, 01 July 2009 09:03 Go to previous messageGo to next message
Eclipse User
Originally posted by: steve.hostettler.unige.ch

Hi all!


I'd like to write rules that use a referenced metamodel.

My config:
apn.ecore (Main metamodel)
alspec.ecore (referenced from apn.ecore)

in the transformation I would like to write something like

module Alpina2PNML;
create OUT1 : HLPNMM from IN1 : APNMM;
.....
rule Algspec2place {
from
s : APNMM!"algspec:AlgebraicSpec"

to
t : HLPNMM!Place (
id <- 'YOOOORG'
)
}

in which algspec is the namespace of the referenced metamodel.
However this seems to be ok at edit time I get the following error at
runtime:
Cannot find class algspec:AlgebraicSpec in reference model APNMM


snippet from apn.ecore
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
name="apn"
nsURI="http://alpina.unige.ch/apn" nsPrefix="apn">
.....
<eStructuralFeatures xsi:type="ecore:EReference" name="PlaceMS"
lowerBound="1"
eType="ecore:EClass algspec.ecore#//Multiset"/>



snippet from algspec.ecore
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="algspec"
nsURI="http://alpina.unige.ch/algspec" nsPrefix="algspec">



The model to transform:

<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:algspec="http://alpina.unige.ch/algspec"
xmlns:apn="http://alpina.unige.ch/apn">

<apn:PetriNet Name="Dining Philosopher" OwnedVariables="/6 /7 /9 /15"
OwnedImports="/4 /5 /32 /37">
<OwnedNodes xsi:type="apn:Place" Name="Think" PlaceMS="/36/@multiset"/>
.....
<algspec:AlgebraicSpec>
<multiset>
<ms>
<left xsi:type="algspec:UnsortedMS">
.....





I use the new eclipse galileo metamodeling tools.


Many thanks in advance for the help!

Regards
Steve
Re: [ATL] Using a Referenced Metamodel [message #107688 is a reply to message #107643] Wed, 01 July 2009 14:02 Go to previous messageGo to next message
Sebastien Revol is currently offline Sebastien Revol
Messages: 15
Registered: July 2009
Junior Member
Hi all,
I'm having the same problem.

Using a static profile as a specific ecore Metamodel, I was able with the
Regular-VM to refer to the UML metamodel by the following way:
STATIC!"uml::Element".

The transformation does not work anymore with the EMF-specific VM in ATL3.
I get the same kind of error:
ERROR: could not find model element uml::Element from STATIC

Is there a new way to access to referenced metamodel elements? Or is there
a specific option to set somewhere?

Thanks in advance,

Sébastien
Re: [ATL] Using a Referenced Metamodel [message #107721 is a reply to message #107688] Thu, 02 July 2009 13:16 Go to previous messageGo to next message
Sebastien Revol is currently offline Sebastien Revol
Messages: 15
Registered: July 2009
Junior Member
Hello,

I had a look at the ATL code to understand the problem.
I found something permitting to solve my problem, however I'm not sure it
is the correct way to do.

In the class : org.eclipse.m2m.atl.core.emf.EMFReferenceModel, the method
addAllReferencedResources uses the call to resource.getAllContents() to
get all the EClasses directly and indirectly contained in the resource,
and will add the containing resources of the indirectly contained
EClasses into the list of resources to take into account.

However, in the case of a static profile, the resource.getAllContents()
does not directly reference UML Eclasses, but EGenericTypes refering to
those EClasses.

Consequently, the addAllReferencedResources does not want to take into
account the UML.ecore resource.

I fixed the problem by changing the code:


Iterator<EObject> contents = resource.getAllContents();
while (contents.hasNext()) {
Object o = contents.next();
if (o instanceof EClass) {
addReferencedResourcesFor((EClass)o, new HashSet<EClass>());
}
}
getReferencedResources().remove(resource);


by the following:

Iterator<EObject> contents = resource.getAllContents();
while (contents.hasNext()) {
Object o = contents.next();
if (o instanceof EClass) {
addReferencedResourcesFor((EClass)o, new HashSet<EClass>());
}else if (o instanceof EGenericType &&
((EGenericType)o).getEClassifier() instanceof EClass) {

addReferencedResourcesFor((EClass)((EGenericType)o).getEClas sifier(),
new HashSet<EClass>());
}
}
getReferencedResources().remove(resource);


However I'm not sure this patch is the best solution, since I don't really
know why the getAllContents() returns instances of EGenericTypes instead
of Eclasses specifically for the UML metamodel. (I checked that the
resolveProxy was set to true for the corresponding EReferences in the
static profile).

I hope it helps,

Best regards,

Sebastien
Re: [ATL] Using a Referenced Metamodel [message #107868 is a reply to message #107721] Mon, 06 July 2009 08:51 Go to previous messageGo to next message
William Piers is currently offline William Piers
Messages: 297
Registered: July 2009
Senior Member
Hello,

What sounds strange to me is that the bug didn't appear into the Regular
VM. Could you please report a bug about that, attaching your patch and -
if possible - a sample project reproducing the bug ? Thanks in advance.

William

Sebastien Revol a écrit :
> Hello,
>
> I had a look at the ATL code to understand the problem. I found
> something permitting to solve my problem, however I'm not sure it is the
> correct way to do.
>
> In the class : org.eclipse.m2m.atl.core.emf.EMFReferenceModel, the method
> addAllReferencedResources uses the call to resource.getAllContents() to
> get all the EClasses directly and indirectly contained in the resource,
> and will add the containing resources of the indirectly contained
> EClasses into the list of resources to take into account.
> However, in the case of a static profile, the resource.getAllContents()
> does not directly reference UML Eclasses, but EGenericTypes refering to
> those EClasses.
>
> Consequently, the addAllReferencedResources does not want to take into
> account the UML.ecore resource.
>
> I fixed the problem by changing the code:
>
>
> Iterator<EObject> contents = resource.getAllContents();
> while (contents.hasNext()) {
> Object o = contents.next();
> if (o instanceof EClass) {
> addReferencedResourcesFor((EClass)o, new HashSet<EClass>());
> }
> }
> getReferencedResources().remove(resource);
>
>
> by the following:
> Iterator<EObject> contents = resource.getAllContents();
> while (contents.hasNext()) {
> Object o = contents.next();
> if (o instanceof EClass) {
> addReferencedResourcesFor((EClass)o, new HashSet<EClass>());
> }else if (o instanceof EGenericType &&
> ((EGenericType)o).getEClassifier() instanceof EClass) {
>
> addReferencedResourcesFor((EClass)((EGenericType)o).getEClas sifier(),
> new HashSet<EClass>());
> }
> }
> getReferencedResources().remove(resource);
>
>
> However I'm not sure this patch is the best solution, since I don't
> really know why the getAllContents() returns instances of EGenericTypes
> instead of Eclasses specifically for the UML metamodel. (I checked that
> the resolveProxy was set to true for the corresponding EReferences in
> the static profile).
>
> I hope it helps,
>
> Best regards,
>
> Sebastien
Re: [ATL] Using a Referenced Metamodel [message #107883 is a reply to message #107868] Mon, 06 July 2009 10:21 Go to previous messageGo to next message
Sebastien Revol is currently offline Sebastien Revol
Messages: 15
Registered: July 2009
Junior Member
Hi,
indeed I w
Re: [ATL] Using a Referenced Metamodel [message #107892 is a reply to message #107868] Mon, 06 July 2009 10:29 Go to previous message
Sebastien Revol is currently offline Sebastien Revol
Messages: 15
Registered: July 2009
Junior Member
Hi, (sorry for the preceding mail that I accidentally sent).
Indeed you're right, the bug also occured with the regular VM with ATL3.
However it did'nt with an older version (2.0.1.v200809170426, the one we
use in production at ST.)


Thus, I also wrote exactly the same fix in the EMF drivers used by the
regular vm in ATL3.

I will try to post a bug with the fix and a simple example as soon as
possible.

Best regards,

Sebastien
Previous Topic:[ATL] code example for a wrapper class for programmatic launch of ATL
Next Topic:Multiple models with a common set of references
Goto Forum:
  


Current Time: Sun Sep 21 14:21:00 GMT 2014

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

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