Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » [ATL] transform generic EList type in generic EMF class
[ATL] transform generic EList type in generic EMF class [message #1715164] Thu, 19 November 2015 17:22 Go to next message
Joachim Engelhardt is currently offline Joachim EngelhardtFriend
Messages: 53
Registered: September 2013
Member

Hello,

I try to transform an EMF model to another one. The source model has an
EMF generic class MyCollection<T>. This class contains a feature
contents : T with multiplicity=-1 and as type the generic type of
MyCollection.
Other defined classes in the model have features with the type
MyCollection and defining an explicit template type.
E.g. I have a EClass MyPackage with the containing feature classes :
MyCollection<MyClass>.

Now, when defining the ATL rules, I do not see the specific template
type for the feature which uses the generic type. In this example, the
feature classes of MyPackage instances is shown simply as MyCollection
without the template type. Furthermore, its containing feature classes
is of type EObject[0..*] and not EMyClass[0..*].

When executung the rules, theses collections are not considered.

I tried to cast the feature, but .asOclType() is not supported by ATL.

Are such generic types not supported by ATL?

How can I get these typed list features work?

Thank you for any hints and comments.

Best regards,
Joachim Engelhardt
Re: [ATL] transform generic EList type in generic EMF class [message #1715173 is a reply to message #1715164] Thu, 19 November 2015 19:53 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 350
Registered: September 2012
Location: Belgium
Senior Member

ATL is a dynamic language when it comes to execution semantics: you do not need to perform any typecasts. ATL is also not aware of EMF generics support, and was developed before generics were introduced to EMF.

That said, you should be able to work with any features in ATL, regardless of their type. Can you show the specific ATL rule and indicate what exactly you mean by "these collections are not considered"?


Cheers,
Dennis
Re: [ATL] transform generic EList type in generic EMF class [message #1715205 is a reply to message #1715173] Fri, 20 November 2015 09:07 Go to previous messageGo to next message
Joachim Engelhardt is currently offline Joachim EngelhardtFriend
Messages: 53
Registered: September 2013
Member

This is an simple example of a rule with the problem I mentioned. It should transform only the package hierarchy.
rule Package2Package {
  from
    myPackage: MyModel!MyPackage
  to
    umlPackage: UML!Package (
      name <- myPackage.name,
      packagedElement <- myPackage.packages.contents
    )
}

I get the root package, but none of its containing subpackages.
With a look at the console output I see the following error:
Cannot set feature packagedElement to value [...a List of the objects in myPackage.packages.contents...], containment references cannot span across models.

I'm currently researching about this issue, but still could not found a
suitable solution. What does this error mean?

[Updated on: Fri, 20 November 2015 16:01]

Report message to a moderator

Re: [ATL] transform generic EList type in generic EMF class [message #1715239 is a reply to message #1715205] Fri, 20 November 2015 13:25 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 350
Registered: September 2012
Location: Belgium
Senior Member

It means the subpackages did not trigger any of your transformation rules, and therefore "packagedElement <- myPackage.packages.contents" just tries to assign the exact value of "myPackage.packages.contents" instead of the corresponding target elements.

Cheers,
Dennis
Re: [ATL] transform generic EList type in generic EMF class [message #1715246 is a reply to message #1715239] Fri, 20 November 2015 14:01 Go to previous messageGo to next message
Joachim Engelhardt is currently offline Joachim EngelhardtFriend
Messages: 53
Registered: September 2013
Member

Thank you for this answer. I now understand the error, but what could be the reason in this case to not trigger the rule Package2Package? I think, the type of the contents is not determined correctly. This is why I assume, that the generics of EMF do not work properly at this point.

I have another rule for the root model, which works for Packages, if I use it as follows:

rule MyProject2Model {
  from
    myProject: MyModel!MyProject
  using {
    projectPackages: Sequence(MyModel!MyPackage) = myProject.packages.contents;
  }
  to
    umlElement: UML!Model (
      name <- myProject.name,
      packagedElement <- projectPackages
    )
}


This works correctly. But adopting this to the Package2Package rule does not success. I don't know, why, but it seems, that this only works, because the feature assignment is outside the rule for the transformation; for instance: MyProject2Model uses Package2Package. It doesn't work, if Package2Package must use itself to transform the sequence.

Any ideas?
Re: [ATL] transform generic EList type in generic EMF class [message #1715257 is a reply to message #1715246] Fri, 20 November 2015 15:38 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 350
Registered: September 2012
Location: Belgium
Senior Member

You mentioned both "MyModel!MyPackage" and "MyModel!RPPackage" in your example code. Do you have multiple kinds of packages in your model?

Also, why do you need a double property navigation to get to the subpackages (i.e. ".packages.contents")?


Cheers,
Dennis
Re: [ATL] transform generic EList type in generic EMF class [message #1715262 is a reply to message #1715257] Fri, 20 November 2015 15:58 Go to previous messageGo to next message
Joachim Engelhardt is currently offline Joachim EngelhardtFriend
Messages: 53
Registered: September 2013
Member

I have only MyModel!MyPackage elements. The other type was a type mistake when making the simple example.

You are right with the question about the double property navigation. Sure, you can discuss this, but let us assume, that it is necessary due to other properties circumstances which I didn't mentioned, because they are not relevant for the actual problem.
The problem still is, that I have an EClass like this (represented as generated interface java code):
public interface MyCollection<T> {
  EList<T> getContents();
}

And use it in another EClass like this:
public interface MyPackage {
  MyCollection<MyPackage> getPackages();
}

Is this sufficient to understand the problem for the ATL rule? I actually do not want to discuss the structure in particular, because the problem itself may still exist for other use cases.
Re: [ATL] transform generic EList type in generic EMF class [message #1715362 is a reply to message #1715262] Sun, 22 November 2015 20:58 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 350
Registered: September 2012
Location: Belgium
Senior Member

Well, EMF generics work for ATL (at least for EMFTVM). I've attached a test project...

Cheers,
Dennis
Re: [ATL] transform generic EList type in generic EMF class [message #1715805 is a reply to message #1715362] Thu, 26 November 2015 11:15 Go to previous message
Joachim Engelhardt is currently offline Joachim EngelhardtFriend
Messages: 53
Registered: September 2013
Member

Thank you very much for your example. That ATL handles generics correctly let us search at the right place for the source of the problem.
We changed the compiler to EMFTVM. We also call the templates by Java code and adapted also these calls to use the Emft execution environment.

After all, it still doesn't work.
But then we found out, that some modifications in the generated EClass files broke the correct work of eIsSet(). This is why ATL didn't iterate through the whole model. In this case, the feature property was only set, if the appropriate getter was called first. But eIsSet() checks only the property itself.

However, thank you very much for your help.
Previous Topic:Saving modification of a Map in a function
Next Topic:Call Operation, model and code in the same workspace
Goto Forum:
  


Current Time: Mon Sep 25 13:25:41 GMT 2017

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

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