Skip to main content



      Home
Home » Archived » M2M (model-to-model transformation) » [ATL] PackageImpl cannot be cast to Classifi
[ATL] PackageImpl cannot be cast to Classifi [message #557302] Mon, 06 September 2010 10:45 Go to next message
Eclipse UserFriend
Hi all,

Sorry to disturb you again but I'm facing a new problem when I try to transform a UML model :s

The context is the following:
Input conforms to modelA is transformed to be conform to modelB.
During this transformation classes are copied and some of them moved into different packages than source items. For example:
classB is a generalization of classA, both contained in packA
becomes
classB contained in packB is a generalization of classA contained in packA

When I try to use the rule:
rule copyGeneralization{
   from s : TB_Profile!Generalization
   to t : UML!Generalization(
      generalizationSet <- s.generalizationSet,
      general<-s.general,
      isSubstitutable <- s.isSubstitutable	
      )
}


I have got a exception:
org.eclipse.m2m.atl.engine.emfvm.VMException: org.eclipse.uml2.uml.internal.impl.PackageImpl cannot be cast to org.eclipse.uml2.uml.Classifier

It seems to be due to the package moving, because if I let classes in the same package, the rule works ...
I have got the same kind of problem with association, values are not correctly set.

I hope someone will have an idea.
Re: [ATL] PackageImpl cannot be cast to Classifi [message #557307 is a reply to message #557302] Mon, 06 September 2010 11:15 Go to previous messageGo to next message
Eclipse UserFriend
We'll need the rest of the transformation and especially the Class rule to answer to that but I'm guessing you're transforming a Class into a package and the class :
from s : UML2!Class
to
t : UML2!Package(
packagedElement <- class
),
class : UML2!Class()

If you code it like that, then the resolve mechanism of ATL will link the input class to the first transformed element which is here the package.
When the resolve occurs for the generalization, it will take the resulting transformed element which is the package. But a generalization can't target a package.

Solution :
from s : UML2!Class
to
class : UML2!Class(),
t : UML2!Package(
packagedElement <- class
)

This way the input class is linked to the resulting class and this will be taken into account for the generalization.
Note that if you want to refer the package you can still use resolveTemp on an input class.
Re: [ATL] PackageImpl cannot be cast to Classifi [message #557390 is a reply to message #557302] Tue, 07 September 2010 05:24 Go to previous message
Eclipse UserFriend
My rule was:
from f: UML!Class
to t: UML!Package(
        name <- f.name
    ),
    c: UML!Class(
        package <- t
    )


So the resolve mechanism linked to the package.
Thanks to your code, I modified my rule and now that works.

Thanks for your time and consideration

Previous Topic:GUI for ATL?
Next Topic:[QVTo] Failed to load model extent
Goto Forum:
  


Current Time: Sun Jul 06 21:42:19 EDT 2025

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

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

Back to the top