[ATL] Model with several metamodels [message #107530] |
Tue, 30 June 2009 12:57 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Eclipse User![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=) |
|
|
|
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 #107721 is a reply to message #107688] |
Thu, 02 July 2009 13:16 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Sebastien Revol![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=sebastien.revol%40st.com) 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 message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
William Piers![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=william.piers%40obeo.fr) Messages: 303 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04694 seconds