lazy rule doesn't return class [message #896645] |
Thu, 19 July 2012 09:34 |
Martin Benedict Messages: 22 Registered: June 2012 |
Junior Member |
|
|
Hello,
I'm working with lazy rules and currently I try to solve an issue on return types of lazy rules. I have defined a lazy rule that contains a do block. See code sample.
lazy rule DataTypeTransformation {
from
dt: HL7!HL7GenericDataType
using {
titled: UML!Stereotype = thisModule.getStereotype('titled');
dtpackage: UML!Package = UML!Package.allInstancesFrom('OUT') -> select(n | n.name = 'Datatypes').first();
}
to
cl: UML!Class (
name <- dt.baseType.name
)
do {
thisModule.debug('processing datatype ' + dt.baseType.name);
cl.applyStereotype(titled);
thisModule.knownDatatypes.put(dt.baseType.name, cl);
dtpackage.packagedElement.add(cl);
cl;
}
}
the calling code is the following:
type <- if (thisModule.knownDatatypes.get(p.type.baseType.name).oclIsUndefined()) then
thisModule.DataTypeTransformation(p.type.debug('create datatype ' + p.type.baseType.name ))
else
thisModule.getClass(p.type.baseType.name.debug('class exists ') + p.type.baseType.name)
endif
The problem I have is, that the lazy rule doesn't return the UML-class (cl). The type property of the attributes do not contain any class. If I remove the do block it works.
I have searched for a solution and found this: http://wiki.eclipse.org/ATL_Language_Troubleshooter#ATL_Called_Rules_Troubles.
I've added cl at the end of the do block, but this doesn't change anything. Are do blocks in lazy rules not allowed? Is the problem, that I add the class to dtpackage? How could I resolve this issue. I have to add the classes to the dtpackage, but only those that are refernced as type in a class.
It would be very nice, if there are some advices?
Thank You,
Martin
[Updated on: Thu, 19 July 2012 10:19] Report message to a moderator
|
|
|
|
Re: lazy rule doesn't return class [message #896943 is a reply to message #896857] |
Fri, 20 July 2012 13:41 |
Martin Benedict Messages: 22 Registered: June 2012 |
Junior Member |
|
|
Sylvain, thanks for your help.
I have considered your suggestions in my ATL script, but there is a new problem that has appeared.
The models my ATL scripts generate are the base for another transformation with a given tool. To that there are some rules how the models should be generated. One rule is that there should be a package which is called 'external models'.
This package should contain a reference to another model which contains base datatypes. This datatypes have applied some stereotypes. The profile I use also for my model.
The imported model has the following containment tree. (I can't modify it)
Data
|-ProfileA
| |-xmodel(Stereotype)
|-BaseDataTypes <<xmodel>>
Because normally the models are created with MagicDraw the import of the package BaseDataTypes is simple. But in my transformation there is a problem. I have to import the package BaseDataTypes. The problem is, that the stereotype xmodel isn't applied, because the 'Data'-Package is not imported. If I import it everything works fine and the stereotype is applied.
My model should look like the following hierarchy.
Data
|-ProfileA (same as in the imported model)
| |-xmodel(Stereotype)
|-external models
| |-BaseDataTypes <<xmodel>> (same package as above)
|-MyModel <<model>>
This is my current ATL snippet for importing the BaseDataTypes package. But the stereotypes are lost.
...
pi: UML!PackageImport (
importedPackage <- UML!Model.allInstancesFrom('BDT') -> select(p | p.name = 'BaseDataTypes').first()
),
...
-- if I remove this the stereotypes are applied, but the Data-package from the imported BDT is in the root of OUT, and I want to have the BaseDataTypes-model in external models
do{
externalModel.packagedElement.add(UML!Model.allInstancesFrom('BDT') ->
select(p | p.name = 'BaseDataTypes').first());
}
I already have tried with other properties of externalModel, but evertime the stereotypes of the package BaseDataTypes and all other packages are lost. The ProfileA I have applied to my root('Data')-model.
How could I preserve the stereotypes of BaseDataTypes
Could you or anybody else help me to solve this problem?
Thank You
[Updated on: Fri, 20 July 2012 13:43] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.02162 seconds