Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] NullPointerException--ERROR
[ATL] NullPointerException--ERROR [message #79829] Wed, 23 April 2008 10:40 Go to next message
Rasha is currently offline RashaFriend
Messages: 61
Registered: July 2009
Member
Hi all,

I try to copy some classes from a profiled source model to the target
model. But I get this error
SEVERE: ****** BEGIN Stack Trace
SEVERE: exception: SEVERE: null
java.lang.NullPointerException
at
org.eclipse.m2m.atl.drivers.uml24atl.ASMUMLModelElement.real Invoke(ASMUMLModelElement.java:624)
at
org.eclipse.m2m.atl.drivers.uml24atl.ASMUMLModelElement.invo ke(ASMUMLModelElement.java:581)
at
org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
at
org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
at
org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)

I think the problem is in these helpers as the rest of the code works fine
without them.

helper context UML!"uml::Element" def: getTaggedValue(stereo :
String ,tag : String) : UML!"uml::Element" =
self.getValue(self.getAppliedStereotype(stereo),tag);

helper context UML!"uml::Element" def : checkMyPropertyValue() : Boolean =
if (self.hasStereotype('MyStereotype')) then
if (self.getTaggedValue('MyStereotype','myProperty')-> exists (s| s.name
<> 'value1')) then ...


Any hint will be great,

Rasha
Re: [ATL] NullPointerException--ERROR [message #79844 is a reply to message #79829] Wed, 23 April 2008 11:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Hugo.Bruneliere.univ-nantes.fr

Hi Rasha,

Rasha a écrit :
> Hi all,
>
> I try to copy some classes from a profiled source model to the target
> model. But I get this error SEVERE: ****** BEGIN Stack Trace
> SEVERE: exception: SEVERE: null
> java.lang.NullPointerException
> at
> org.eclipse.m2m.atl.drivers.uml24atl.ASMUMLModelElement.real Invoke(ASMUMLModelElement.java:624)
>
> at
> org.eclipse.m2m.atl.drivers.uml24atl.ASMUMLModelElement.invo ke(ASMUMLModelElement.java:581)
>
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
> at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
> at
> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
>
> at
> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)
>
>
> I think the problem is in these helpers as the rest of the code works
> fine without them.
>
> helper context UML!"uml::Element" def: getTaggedValue(stereo :
> String ,tag : String) : UML!"uml::Element" =
> self.getValue(self.getAppliedStereotype(stereo),tag);
>
> helper context UML!"uml::Element" def : checkMyPropertyValue() : Boolean =
> if (self.hasStereotype('MyStereotype')) then
> if (self.getTaggedValue('MyStereotype','myProperty')-> exists (s| s.name
> <> 'value1')) then ...
>

The getTaggedValue helper you defined returns a single element (of type
UML!uml::Element) and not a collection of elements. Thus you cannot do
"self.getTaggedValue('MyStereotype','myProperty')-> exists" in another
helper because "exists" is an operator on collections and not on single
elements.

>
> Any hint will be great,
>
> Rasha
>
>

Best regards,

Hugo

--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
Re: [ATL] NullPointerException--ERROR [message #79905 is a reply to message #79844] Wed, 23 April 2008 19:25 Go to previous messageGo to next message
Rasha is currently offline RashaFriend
Messages: 61
Registered: July 2009
Member
Thanks Hugo. I fixed it by comparing directly the name of the return
element from the getTaggedValue('MyStereotype','myProperty') method with
‘value1’

helper context UML!"uml::Element" def : checkMyPropertyValue() : Boolean =
if (self.hasStereotype('MyStereotype')) then
if (self.getTaggedValue('MyStereotype','myProperty').name <>'value1')
then...

However, I still have the same error NullPointerException.

Any hint what else could make this error.

Rasha
Re: [ATL] NullPointerException--ERROR [message #80037 is a reply to message #79905] Fri, 25 April 2008 15:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Hugo.Bruneliere.univ-nantes.fr

Hi Rasha,

Rasha a écrit :
> Thanks Hugo. I fixed it by comparing directly the name of the return
> element from the getTaggedValue('MyStereotype','myProperty') method with
> �value1�
>
> helper context UML!"uml::Element" def : checkMyPropertyValue() : Boolean =
> if (self.hasStereotype('MyStereotype')) then
> if (self.getTaggedValue('MyStereotype','myProperty').name
> <>'value1') then...
>
> However, I still have the same error NullPointerException.
> Any hint what else could make this error.

Are you sure that the NullPointerException comes from this helper?
Do you have already tested separately all the other helpers you are
calling from this one?

> Rasha
>
>

Best regards,

Hugo

--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
Re: [ATL] NullPointerException--ERROR [message #80051 is a reply to message #80037] Fri, 25 April 2008 16:51 Go to previous messageGo to next message
Rasha is currently offline RashaFriend
Messages: 61
Registered: July 2009
Member
I have only another helper “hasStereotype” which I tested separately and
works fine. I attached the whole transformation file.


---This helper define the method "hasStereotype"
helper context UML!"uml::Element" def: hasStereotype(stereotype :
String) : Boolean =
self.getAppliedStereotypes()-> exists (c | c.name = stereotype);

---This helper define the method "getTaggedValue"
helper context UML!"uml::Element" def: getTaggedValue(stereo :
String ,tag : String) : UML!"uml::Element" =
self.getValue(self.getAppliedStereotype(stereo),tag);

---This helper verifies if the value of the proterty 'myProperty' is
different of 'value1'
helper context UML!"uml::Element" def : checkMyPropertyValue() : Boolean =
if (self.hasStereotype('MyStereotype')) then
if (self.getTaggedValue('MyStereotype','myProperty')<>'value1') then
true
else
false
endif
else
true
endif;

rule Copyclass{
from
s : UML!Class (s.checkMyPropertyValue())
to
t : UML!Class(
name <- s.name
)
}


Best Regards,

Rasha
Re: [ATL] NullPointerException--ERROR [message #80065 is a reply to message #80051] Mon, 28 April 2008 08:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: Hugo.Bruneliere.univ-nantes.fr

Hi Rasha,

First, do you pass the definition of the profile (which is a UML model)
as an input of your transformation?

Rasha a écrit :
> I have only another helper �hasStereotype� which I tested separately and
> works fine. I attached the whole transformation file.
>
>
> ---This helper define the method "hasStereotype"
> helper context UML!"uml::Element" def: hasStereotype(stereotype :
> String) : Boolean =
> self.getAppliedStereotypes()-> exists (c | c.name = stereotype);
>
> ---This helper define the method "getTaggedValue"
> helper context UML!"uml::Element" def: getTaggedValue(stereo :
> String ,tag : String) : UML!"uml::Element" =
> self.getValue(self.getAppliedStereotype(stereo),tag);
>

Are you sure the getValue method is actually returning a uml::Element?
What happens if the property of the given stereotype is of type String
or Integer?

> ---This helper verifies if the value of the proterty 'myProperty' is
> different of 'value1'
> helper context UML!"uml::Element" def : checkMyPropertyValue() : Boolean =
> if (self.hasStereotype('MyStereotype')) then
> if (self.getTaggedValue('MyStereotype','myProperty')<>'value1') then
> true
> else false
> endif
> else
> true
> endif;
>
> rule Copyclass{
> from
> s : UML!Class (s.checkMyPropertyValue())
> to t : UML!Class( name <- s.name
> )
> }
>
>
> Best Regards,
>
> Rasha
>
>

Best regards,

Hugo


--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
Re: [ATL] NullPointerException--ERROR [message #80129 is a reply to message #80065] Mon, 28 April 2008 13:10 Go to previous messageGo to next message
Rasha is currently offline RashaFriend
Messages: 61
Registered: July 2009
Member
Hi Hugo,

Yes, I pass the definition of the profile as follow

module CopyClass_3; -- Module Template
create OUT : UML from IN : UML, IN_profile : UML;

I’ve just applied the use case “Verifying UML profiled models” using the
same source files “sample.uml” and “sample.profile.uml”. I tried to
complete the ATL transformation file which shown on its web site by
defining the two helpers “hasStereotype” and “getTaggedValue”.

I got this helper which works well for this transformation from Frederic
Thomas
helper context UML2!Element def : getTagValue(stereo :
UML2!Stereotype,tag : UML2!Property ) : UML2!Element =
self.getValue(self.getAppliedStereotype(stereo.name),tag.nam e);

In this use case, the value of the property of the given stereotype is a
string. However, when I tried the getValue method with String as follow, I
still get the same error.

helper context UML!"uml::Element" def: getTaggedValue(stereo :
String ,tag : String) : String =
self.getValue(self.getAppliedStereotype(stereo),tag);

Your help is greatly appreciated,
Rasha
Re: [ATL] NullPointerException--ERROR [message #84026 is a reply to message #80065] Mon, 09 June 2008 13:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kachd.web.de

Dear Hugo!

I have the same problem using the MARTE profile... When I try to define
an input profile, eclipse wants me to pick a file from my workspace or
my File System... What kind of file is needed here?

Greetings,

Bragenheim


Hugo Bruneliere schrieb:
> Hi Rasha,
>
> First, do you pass the definition of the profile (which is a UML model)
> as an input of your transformation?
>
> Rasha a écrit :
>> I have only another helper �hasStereotype� which I tested separately
>> and works fine. I attached the whole transformation file.
>>
>>
>> ---This helper define the method "hasStereotype"
>> helper context UML!"uml::Element" def: hasStereotype(stereotype :
>> String) : Boolean =
>> self.getAppliedStereotypes()-> exists (c | c.name = stereotype);
>>
>> ---This helper define the method "getTaggedValue"
>> helper context UML!"uml::Element" def: getTaggedValue(stereo :
>> String ,tag : String) : UML!"uml::Element" =
>> self.getValue(self.getAppliedStereotype(stereo),tag);
>>
>
> Are you sure the getValue method is actually returning a uml::Element?
> What happens if the property of the given stereotype is of type String
> or Integer?
>
>> ---This helper verifies if the value of the proterty 'myProperty' is
>> different of 'value1'
>> helper context UML!"uml::Element" def : checkMyPropertyValue() :
>> Boolean =
>> if (self.hasStereotype('MyStereotype')) then
>> if (self.getTaggedValue('MyStereotype','myProperty')<>'value1')
>> then
>> true
>> else false
>> endif
>> else
>> true
>> endif;
>>
>> rule Copyclass{
>> from
>> s : UML!Class (s.checkMyPropertyValue())
>> to t : UML!Class( name <- s.name
>> )
>> }
>>
>>
>> Best Regards,
>>
>> Rasha
>>
>>
>
> Best regards,
>
> Hugo
>
>
Re: [ATL] NullPointerException--ERROR [message #87211 is a reply to message #84026] Thu, 31 July 2008 14:49 Go to previous messageGo to next message
Guillaume Doux is currently offline Guillaume DouxFriend
Messages: 56
Registered: July 2009
Member
Hi Arnd,

I have looked at your transformation and I can not reproduce your
exceptions, because the elements in the source model does not seem to
have any stereotypes

applied.

(cf: - In papyrus, the Profile item on the "Properties" view is empty
for the "Class_0"
- In ATL the result of getAppliedStereotypes() on each elements where
hasStereotypes is called return an empty sequence.)

So your problem may happen during the creation of the source model.


I will try to answer to your question without testing it, but by giving
you the more generals infomations needed to correct it by yourself.


I have look more precisely at the way you use to retrieve the tagged
value in the model, and it is not done correctly.
- First, you did not have to use the MARTE profile has an entry model
or metamodel in order to read tagged value. So the header of your ATL

transformation must be :

module UML_2_SymTAS; -- Module Template
create OUT : symtas from IN : uml;

And so you don't have to specify the MARTE profile in the launch
configuration because it will already be referenced in your source model
(maybe you will have to modify manually the source model to point to the
good location for the MARTE profile file)

Note that the "getAppliedStereotype(stereotypeName : String)" method
takes the fully qualified name of the stereotype as parameter, so
something like "profileName::StereotypeName". Without the fully
qualified name, the stereotypes can not be found.

This is now summarised in the ATL Howtos at
http://wiki.eclipse.org/ATL_Howtos#How_can_I_retrieve_tagged _values_from_stereotyped_UML_model_elements.3F
(Do not worry if you have not seen it before, it is newly added)
On this howto you have also another version of the hasStereotype helper
which uses the fully qualified name.


Thirdly, by looking at your ATL code, it seems that you sometimes try to
reimplement predefined methods. As example, we can see:
- eqStr(String, String) : Boolean, the "=" between two String may be
sufficent,
- isOfType(String) : Boolean, a oclIsTypeOf(t : oclType) and
oclIsKindOf(t : oclType) returning a Boolean are already defined. (See
page 16 on the ATL

manual) The argument for this method is an oclType, so you can just put
something like UML!Class if you want to know if your element is an UML
class, or

symtas!ArchitectureType if you want to now if your element is an
architecureType from symtas.

In your code you use also mostly imperative satements in a do block with
calls to called rules. This type of programming is not recommended, the
declarative

way is simpler and cleaner. The imperative style is only here for very
specific operations, and it seems that you did not have to use it.
Moreover, when you write something like in the do section of the main rule:

for (c in uml!Class.allInstances()) {
if (c.isBus()) {
ar.bus <- thisModule.generateArchBus(c.getInstance());
}
if (c.isCPU()) {
ar.cpu <- thisModule.generateArchCPU(c.getInstance());
}
}

the for loop you use made the same things that the ATL engine does when
it calls declarative rule, so this type of code is useless and takes you
far away from

the ATL language.

for example,
for (c in uml!Class.allInstances()) {
if (c.isBus()) {
ar.bus <- thisModule.generateArchBus(c.getInstance());
}
if (c.isCPU()) {
ar.cpu <- thisModule.generateArchCPU(c.getInstance());
}
}

and

rule generateArchBus(name : String) {
to
b : symtas!ArchitectureBus
do {
b.name <- name;
b.xPosition <- 0;
b.yPosition <- 0;
b.width <- 0;
b.height <- 0;
b.busspeed <- thisModule.generateBusspeed(1);
b.speedup <- thisModule.generateSpeedup();
b.ports <- thisModule.generateResourcePort();
b;
}
}

and

rule generateArchCPU(name : String) {
to
b : symtas!ArchitectureCPU
do {
b.name <- name;
b.xPosition <- 0;
b.yPosition <- 0;
b.width <- 0;
b.height <- 0;
b.speedup <- thisModule.generateSpeedup();
b.ports <- thisModule.generateResourcePort();
b;
}
}

is equivalent to a declarative the 2 following rules:

rule Class2ABUS {
from
s : UML!Class (s.isBus())
to
archBus : symtas!ArchitectureBus(
name <- s.name,
xPosition <- 0,
yPosition <- 0,
width <- 0,
height <- 0,
busspeed <- thisModule.generateBusspeed(1),
speedup <- thisModule.generateSpeedup(),
ports <- thisModule.generateResourcePort(),
)
}

rule Class2ACPU {
from
s : UML!Class (s.isBus())
to
archBus : symtas!ArchitectureCPU(
name <- s.name,
xPosition <- 0,
yPosition <- 0,
width <- 0,
height <- 0,
b.speedup <- thisModule.generateSpeedup(),
b.ports <- thisModule.generateResourcePort()
)
}

with somlething like that in your main rule:
-- Haupttransformationsregel für einmalige Wurzeltransformation
rule Model2System {
from
-- Eingabemodell
m : uml!Model
to
... (the other element you want to create in the same way as the
following)
ar : symtas!ArchitectureType(
bus <- uml!Class.allInstancesFrom('IN')->select(c | c.isBus()),
cpu <- uml!Class.allInstancesFrom('IN')->select(c | c.isCPU()),
...
),
...
}

With this, you can also use the same way to replace the call to
thisModule.generateSpeedup() and others in the matching rules.

This type of programming allows you to do all your rules without any
"do" sections and imperatives blocks.

Your transformation will be much simpler.


You should use the various ATL constructs in this preference order:
- standard matched rules,
- unique lazy rules,
- lazy rules,
- called rules

As you can infer from this list, the prefered style is declarative. If
you cannot do something with it (i.e., standard, unique lazy, and lazy
rules are not

enough) then you may use imperative blocks.


You can also remove all the () in your helpers which have no parameters
because your transformation will be faster (cf. the ATL manual about
attribute helper

caching).
Note that you must also remove the () at the calling sites.

You can look at the ATL manual for other predefined ATL functions:
http://www.eclipse.org/m2m/atl/doc/ATL_User_Manual%5Bv0.7%5D .pdf



I hope all of this can help you to do your work, if you have any other
questions feel free to ask again in the newsgroup.


Best regards.

Guillaume.



Arnd a écrit :
> Dear Hugo!
>
> I have the same problem using the MARTE profile... When I try to define
> an input profile, eclipse wants me to pick a file from my workspace or
> my File System... What kind of file is needed here?
>
> Greetings,
>
> Bragenheim
>
>
> Hugo Bruneliere schrieb:
>> Hi Rasha,
>>
>> First, do you pass the definition of the profile (which is a UML
>> model) as an input of your transformation?
>>
>> Rasha a écrit :
>>> I have only another helper �hasStereotype� which I tested separately
>>> and works fine. I attached the whole transformation file.
>>>
>>>
>>> ---This helper define the method "hasStereotype"
>>> helper context UML!"uml::Element" def: hasStereotype(stereotype :
>>> String) : Boolean =
>>> self.getAppliedStereotypes()-> exists (c | c.name = stereotype);
>>>
>>> ---This helper define the method "getTaggedValue"
>>> helper context UML!"uml::Element" def: getTaggedValue(stereo :
>>> String ,tag : String) : UML!"uml::Element" =
>>> self.getValue(self.getAppliedStereotype(stereo),tag);
>>>
>>
>> Are you sure the getValue method is actually returning a uml::Element?
>> What happens if the property of the given stereotype is of type String
>> or Integer?
>>
>>> ---This helper verifies if the value of the proterty 'myProperty' is
>>> different of 'value1'
>>> helper context UML!"uml::Element" def : checkMyPropertyValue() :
>>> Boolean =
>>> if (self.hasStereotype('MyStereotype')) then
>>> if
>>> (self.getTaggedValue('MyStereotype','myProperty')<>'value1') then
>>> true
>>> else false
>>> endif
>>> else
>>> true
>>> endif;
>>>
>>> rule Copyclass{
>>> from
>>> s : UML!Class (s.checkMyPropertyValue())
>>> to t : UML!Class( name <- s.name
>>> )
>>> }
>>>
>>>
>>> Best Regards,
>>>
>>> Rasha
>>>
>>>
>>
>> Best regards,
>>
>> Hugo
>>
>>
Re: [ATL] NullPointerException--ERROR [message #87381 is a reply to message #87211] Tue, 05 August 2008 07:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kachd.web.de

This is a multi-part message in MIME format.
--------------020806070409020600080006
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Hello Guillaume!

You made a good point about not seeing Stereotypes on my model in your
papyrus. It seems that models I create cannot be easily transferred to
other computers, seems to be some papyrus-bug on my system. My assisting
tudor confirmed that his papyrus can't see stereotypes on the models I
sent him, and his ATL didn't do so either.

So we recreated the model on his system, and the same
NullPointerException happened, when we tried to transform it with ATL.
The faulty ATL-code can only be executed if the helper
"CallOperationAction.isChannel()" returns true, and that only happens
when the correct stereotypes are applied, so his ATL sees the
stereotypes too. My papyrus can show his model with stereotypes, so we
assume this is a valid uml-model, and my ATL transformation throws a
NullPointerException as well.

I tested this, so I know that on my system and on the system of my
assisting tudor it works like this.

Thank you for correcting my programming style in public, but I did
not ask for it. I would rather like it a bit more private. Though, I
have looked at your proposals, and have two questions:

1. Matched rules are called automatically and produce their output
element right under the root node of the output model. I don't want this
to happen, but I can't stop it. So I chose called rules. Because of this
behavior, if I insert one of the matched rules you proposed, the output
is not equivalent. I tested this, so... Is there a way to stop them from
being called automatically?

2. For the main rule, you propose a code like this:
"ar:symtas!ArchitectureType(bus<-uml!Class.allInstancesFrom('IN')- >select(c|c.isBus())),"
but if I insert it and test the transformation, there's another exception:
"SCHWERWIEGEND: cannot set feature symtas!ArchitectureType.bus to value
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1c36942 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@48bddf (name: ArchitectureCPU)
(instanceClassName: null) (abstract: false, interface: false))
java.lang.RuntimeException: cannot set feature
symtas!ArchitectureType.bus to value
org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1c36942 (eClass:
org.eclipse.emf.ecore.impl.EClassImpl@48bddf (name: ArchitectureCPU)
(instanceClassName: null) (abstract: false, interface: false))"
Again, the output is not equivalent(*g*), so what am I doing wrong here?


Please don't put too much effort into answering these questions, I asked
for help at a point where I need it, and I would appreciate if you had a
closer look at what's wrong with my tagged value problem. I will send
you the model I and my assisting tudor created, perhaps it might be
helpful, if you recreated a similar uml model on your system and try to
transform that. If you cannot reproduce the Exception this way either,
it seems our problem is rather a papyrus problem than an ATL problem.

Regards,

Arnd



Guillaume Doux schrieb:
> Hi Arnd,
>
> I have looked at your transformation and I can not reproduce your
> exceptions, because the elements in the source model does not seem to
> have any stereotypes
>
> applied.
>
> (cf: - In papyrus, the Profile item on the "Properties" view is
> empty for the "Class_0"
> - In ATL the result of getAppliedStereotypes() on each elements
> where hasStereotypes is called return an empty sequence.)
>
> So your problem may happen during the creation of the source model.
>
>
> I will try to answer to your question without testing it, but by giving
> you the more generals infomations needed to correct it by yourself.
>
>
> I have look more precisely at the way you use to retrieve the tagged
> value in the model, and it is not done correctly.
> - First, you did not have to use the MARTE profile has an entry
> model or metamodel in order to read tagged value. So the header of your ATL
>
> transformation must be :
>
> module UML_2_SymTAS; -- Module Template
> create OUT : symtas from IN : uml;
>
> And so you don't have to specify the MARTE profile in the launch
> configuration because it will already be referenced in your source model
> (maybe you will have to modify manually the source model to point to the
> good location for the MARTE profile file)
>
> Note that the "getAppliedStereotype(stereotypeName : String)" method
> takes the fully qualified name of the stereotype as parameter, so
> something like "profileName::StereotypeName". Without the fully
> qualified name, the stereotypes can not be found.
>
> This is now summarised in the ATL Howtos at
> http://wiki.eclipse.org/ATL_Howtos#How_can_I_retrieve_tagged _values_from_stereotyped_UML_model_elements.3F
>
> (Do not worry if you have not seen it before, it is newly added)
> On this howto you have also another version of the hasStereotype helper
> which uses the fully qualified name.
>
>
> Thirdly, by looking at your ATL code, it seems that you sometimes try to
> reimplement predefined methods. As example, we can see:
> - eqStr(String, String) : Boolean, the "=" between two String may be
> sufficent,
> - isOfType(String) : Boolean, a oclIsTypeOf(t : oclType) and
> oclIsKindOf(t : oclType) returning a Boolean are already defined. (See
> page 16 on the ATL
>
> manual) The argument for this method is an oclType, so you can just put
> something like UML!Class if you want to know if your element is an UML
> class, or
>
> symtas!ArchitectureType if you want to now if your element is an
> architecureType from symtas.
>
> In your code you use also mostly imperative satements in a do block with
> calls to called rules. This type of programming is not recommended, the
> declarative
>
> way is simpler and cleaner. The imperative style is only here for very
> specific operations, and it seems that you did not have to use it.
> Moreover, when you write something like in the do section of the main rule:
>
> for (c in uml!Class.allInstances()) {
> if (c.isBus()) {
> ar.bus <- thisModule.generateArchBus(c.getInstance());
> }
> if (c.isCPU()) {
> ar.cpu <- thisModule.generateArchCPU(c.getInstance());
> }
> }
>
> the for loop you use made the same things that the ATL engine does when
> it calls declarative rule, so this type of code is useless and takes you
> far away from
>
> the ATL language.
>
> for example,
> for (c in uml!Class.allInstances()) {
> if (c.isBus()) {
> ar.bus <- thisModule.generateArchBus(c.getInstance());
> }
> if (c.isCPU()) {
> ar.cpu <- thisModule.generateArchCPU(c.getInstance());
> }
> }
>
> and
>
> rule generateArchBus(name : String) {
> to
> b : symtas!ArchitectureBus
> do {
> b.name <- name;
> b.xPosition <- 0;
> b.yPosition <- 0;
> b.width <- 0;
> b.height <- 0;
> b.busspeed <- thisModule.generateBusspeed(1);
> b.speedup <- thisModule.generateSpeedup();
> b.ports <- thisModule.generateResourcePort();
> b;
> }
> }
>
> and
>
> rule generateArchCPU(name : String) {
> to
> b : symtas!ArchitectureCPU
> do {
> b.name <- name;
> b.xPosition <- 0;
> b.yPosition <- 0;
> b.width <- 0;
> b.height <- 0;
> b.speedup <- thisModule.generateSpeedup();
> b.ports <- thisModule.generateResourcePort();
> b;
> }
> }
>
> is equivalent to a declarative the 2 following rules:
>
> rule Class2ABUS {
> from
> s : UML!Class (s.isBus())
> to
> archBus : symtas!ArchitectureBus(
> name <- s.name,
> xPosition <- 0,
> yPosition <- 0,
> width <- 0,
> height <- 0,
> busspeed <- thisModule.generateBusspeed(1),
> speedup <- thisModule.generateSpeedup(),
> ports <- thisModule.generateResourcePort(),
> )
> }
>
> rule Class2ACPU {
> from
> s : UML!Class (s.isBus())
> to
> archBus : symtas!ArchitectureCPU(
> name <- s.name,
> xPosition <- 0,
> yPosition <- 0,
> width <- 0,
> height <- 0,
> b.speedup <- thisModule.generateSpeedup(),
> b.ports <- thisModule.generateResourcePort()
> )
> }
>
> with somlething like that in your main rule:
> -- Haupttransformationsregel für einmalige Wurzeltransformation
> rule Model2System {
> from
> -- Eingabemodell
> m : uml!Model
> to
> ... (the other element you want to create in the same way as the
> following)
> ar : symtas!ArchitectureType(
> bus <- uml!Class.allInstancesFrom('IN')->select(c | c.isBus()),
> cpu <- uml!Class.allInstancesFrom('IN')->select(c | c.isCPU()),
> ...
> ),
> ...
> }
>
> With this, you can also use the same way to replace the call to
> thisModule.generateSpeedup() and others in the matching rules.
>
> This type of programming allows you to do all your rules without any
> "do" sections and imperatives blocks.
>
> Your transformation will be much simpler.
>
>
> You should use the various ATL constructs in this preference order:
> - standard matched rules,
> - unique lazy rules,
> - lazy rules,
> - called rules
>
> As you can infer from this list, the prefered style is declarative. If
> you cannot do something with it (i.e., standard, unique lazy, and lazy
> rules are not
>
> enough) then you may use imperative blocks.
>
>
> You can also remove all the () in your helpers which have no parameters
> because your transformation will be faster (cf. the ATL manual about
> attribute helper
>
> caching).
> Note that you must also remove the () at the calling sites.
>
> You can look at the ATL manual for other predefined ATL functions:
> http://www.eclipse.org/m2m/atl/doc/ATL_User_Manual%5Bv0.7%5D .pdf
>
>
>
> I hope all of this can help you to do your work, if you have any other
> questions feel free to ask again in the newsgroup.
>
>
> Best regards.
>
> Guillaume.
>
>
>
> Arnd a écrit :
>> Dear Hugo!
>>
>> I have the same problem using the MARTE profile... When I try to
>> define an input profile, eclipse wants me to pick a file from my
>> workspace or my File System... What kind of file is needed here?
>>
>> Greetings,
>>
>> Bragenheim
>>
>>
>> Hugo Bruneliere schrieb:
>>> Hi Rasha,
>>>
>>> First, do you pass the definition of the profile (which is a UML
>>> model) as an input of your transformation?
>>>
>>> Rasha a écrit :
>>>> I have only another helper �hasStereotype� which I tested separately
>>>> and works fine. I attached the whole transformation file.
>>>>
>>>>
>>>> ---This helper define the method "hasStereotype"
>>>> helper context UML!"uml::Element" def: hasStereotype(stereotype :
>>>> String) : Boolean =
>>>> self.getAppliedStereotypes()-> exists (c | c.name = stereotype);
>>>>
>>>> ---This helper define the method "getTaggedValue"
>>>> helper context UML!"uml::Element" def: getTaggedValue(stereo :
>>>> String ,tag : String) : UML!"uml::Element" =
>>>> self.getValue(self.getAppliedStereotype(stereo),tag);
>>>>
>>>
>>> Are you sure the getValue method is actually returning a uml::Element?
>>> What happens if the property of the given stereotype is of type
>>> String or Integer?
>>>
>>>> ---This helper verifies if the value of the proterty 'myProperty' is
>>>> different of 'value1'
>>>> helper context UML!"uml::Element" def : checkMyPropertyValue() :
>>>> Boolean =
>>>> if (self.hasStereotype('MyStereotype')) then
>>>> if
>>>> (self.getTaggedValue('MyStereotype','myProperty')<>'value1') then
>>>> true
>>>> else false
>>>> endif
>>>> else
>>>> true
>>>> endif;
>>>>
>>>> rule Copyclass{
>>>> from
>>>> s : UML!Class (s.checkMyPropertyValue())
>>>> to t : UML!Class( name <- s.name
>>>> )
>>>> }
>>>>
>>>>
>>>> Best Regards,
>>>>
>>>> Rasha
>>>>
>>>>
>>>
>>> Best regards,
>>>
>>> Hugo
>>>
>>>



--------------020806070409020600080006
Content-Type: application/octet-stream;
name="new model.rar"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="new model.rar"

UmFyIRoHAM+QcwAADQAAAAAAAAATHXQggDkAzQMAANUSAAAC6Bij8ChEBTkd MxkAIAAAAG5l
dyBtb2RlbFx1bWxFeGFtcGxlMS5kaTIMGUzMzRPNQVve/imJvtsfROiysXbm zodggyzJBHej
czxgeRqSPK+kNuW2b/60Ru5K3E2U64651bcy5gGCZ4QNtEpk84uEpOfmCUUe HtH3CECBwhIh
Ac9eX3eCypXcJptRhf+pxs8ycUJfAwmovif1VGvatTvdzcXLoKof/lu0UTrK +HO0GeXbPDHf
+Nxxk8svvzk9hbFn2sRYZSV/Nu476EbmcYYaDjoRwYxLJfyPdtxKEAWnKwkH POykzlayN5IM
JnNLqHk84sCqjLYo4EDM4cs8AyX1DmnRGFFcoe1PsKJYmklilG+vPKfNUQwX BshF8MTbnPBC
iuUCDa0FVgIZq4kXMpHRth+J+b/rvocAEClSPk/Ex2hDWYyLp7Vr80sHa7rA KYmtqxZYhhcj
PQw91LwuhJFgWFLIq5IBowuAZwBK6QTamUB5Hw5suogts6Bs4/gwOCd7cZmH xyDZFVGo6UeT
MbRd7ajV5jaXGebBR9Hjmik7kgE2mbAUAf6EgNMMB/mSCYBQyNyJxqGMrtEE 7XQ8YcH+JixE
4yqll0X7oiInYJt1b3SgefH0v85JSSJAm4Cs3rfkETunk0QAjrwoq8jQJ7Ll h/ggzXg4zUMv
P/s4n0ibgAUNhcmHQpgr44Tk8xZhf9yh9PN+wIjeUiE7eslHre+pMqrwJlG8 3bAtVfERqkpO
ShzWWD0GX2N6EfPeJ6Jm30V9hCtaB6Skje9bWbqWVNRmt60MSeINb8K0VwgM fzLvpF4OfXhM
zqFgIFoqMEHqZ7kNmY+4ARHnRmY82GPEQ8ElolRGzw7/4v+/FYrfGz76KCZ1 nGzetG9mSzUq
60+F6k+6jINxrGwOOG7UuT0w1mqPGIiwxswZroV1PA3NNjI+JWHraLiQx78J hIxqI5PvKO5M
fYow9c2jKTD8yt9eRoMZTjfhReu8TGm9pHk4Uuiajj6gWVaVe5bt3PhfR6UL yFzp+N1C/dvX
PJvfUv2LSN3oq+WhYsof+aKbXC/Mry3C666qTbe6XPX6BfS07rtl39gMcDXq 7qQ3PE+wUPNv
jDh2OIRx+ifvwyepmje2swCRTqGZ6LZ1jY73216xWfNxb5Scby97rVvl1sZu UuOR+biJ3TPg
e4H+C6rggLuDeLKTkBDGErqbFXSz98H/5mB6+FvhVJgmmVNNJVN1UDPGbb8J pCGQ4P3PCb38
Jc2c2pQgWgdLaRSdKXoZH57jC7naQkqrLxhquDfcYzs6L6CGbbbUP0bePaar N0IkeRGni9vv
C/iL0klnPdTne7PlctfcXpX9J/VI+v+QJTZ0IIA5ANMGAAA/RQAAAoWb7kwo RAU5HTMZACAA
AABuZXcgbW9kZWxcdW1sRXhhbXBsZTEudW1sDB1NDI1VvJQV/fn8UK/exSHR aQqvOcUAhCWy
HXAoeIoSYQgTpJkhKX/6+W3Ib3aBYdFoW7Lzl+3u/IR5AKQem9NvOh5JMn8o 3jeNvT6lHEqr
EYsgT9Hp6Wkuv++9daJkE2NVlj+eaPzkc0QTCTKarCnjkLFCKTzf3/X8decq vV3HmxNX76pk
jnjhxCOYH1Q8/x+BxxrqjRhpYBLo87K6n321PHNCSjQio2+mjDo99znek60m QQRHCjq+tRxd
IY3EdJgvQfMrHh/nlVrBfPr+7tBl1hNFyEqD2tv8cKVGutoSo5JmN0tPLRsn nySkbnfkKjE+
iyrlBsKYRWy6YhnspiW9V+rlBzkm0jw7fOvzIF7Ha8hWVaGLW8Wge/qeWRGL 1I3oEd/D8QOH
+5GqGOciMgedBT/HVsKRzKWt9Po4PojWduDOXUp6n4crbo7tStToGnF19q4a bZvqraVYSn/z
QNakYiA1ifRxK/9SU9oYeza839fxEidcKF1a2jXawqn/PNdmzbllkztlZ3SD MDVY2PadMJ+0
TTOvDLiEEX3+Ja0OR9ajhUmk1LEioI3yRltz3Ke0GuwLCGV1pwk6mwbrEOZW tjE2FXRpgbFf
+257oZyXTjZtbzlNLr6uGo3oHVcVyCsQiR86yt5tFvLsfgjmjbTejewyf5nc xa8sSYHgg04c
n2nXaUewxpz+/CWUKlDJlxEdYiKWlLE9+odr9VAMWTP7O0oqVqspjsDKQqMN dEuq+VXpGGL3
Sexw/6WNnj7cGKpIx1tDcuU/R50pei9hpT2wM9aLDFW6VxhbkMKBi98xaYML bpo5sbRDUplw
W11dkMXyjTQVNU8IKonTI681hk6l8vBAmWsJcTDnuyOJyyIx825zJxwsJvxZ ZutMukbnbZeY
0M09Bjeugb3KbtUnzbYb/UFwMnT0M/yj4gMU7SiLeP1a1cph2bU78nDmiwI5 NJ7fuXpSUOZS
r4/eX1eZX6VA3+gLeYULPMQ5zfvjsist6wPlJavveYto66WWG/gCoWdEZ9OV 8cfdxUhL9xFt
QW9bHt2cNv46MhLbPETY4nw2J428+0bU+/rGeN7I0f6T12UxxTTSyuyqf+6k nXDsz1Y0buaw
o4PmR+btjZdbSF/rWWkB/P9Yb4ovvw6Ewe9NGuus6i9t+HDpjfW/NXh0RaaL aftqfMvgh0E2
1WA4xuZLzF+bIzy6Ht0V+uNvvF681HVCmHBk2Kn9Fsb94H5R9+RJczDhtMmB 5s9cpRpj775W
gWsECJtBr+5Jj5LR4IzuhIqpRChUr96nbdnzGlP3ZWrl3zQAua9iCEQnmpGA yQumFMlVD36d
QciysdF2zkqv+/sijANOSeELlNqgztV3MQIatBAAoTCAhOF0a5/C7rNoxAEF nFKAIqLwQncn
NeBnbUKV/+F1y/ZfEvP5Eyurc6Sy+zRbJpjBAvjZAOSkoEIjPa4niF5aVe4a +gevAKV3JBCX
hLmgztGXJUqb2PBSlXoon0q7Stx4PfKiqABigdBCpnVOJ1CET8FwcF+xDYFf DTJCFEvlzNLy
50tB9BUwkAG1K5EoaVG6h77NMyQkQCC248AcNDkTS76PFuJ5XSlE2KVmQYrB IB8/yX4TEhcL
BngG4RAhyWC3wzLPIleQs66g+zwok1iwQRcL4WaLkEKiYYXIgZVCSC0gv2TZ YwDVk8i3XMhK
T7NuLNoWwQVhYgCkmMIRjuMKgZulX+lR9Am3mCysUEK0U3xPpQuRu9lQgQLM ZhZLbPI+IXxL
vJlaWM4nMgy3iQCSQVyPQ0vs5Cbg1IL9mLO/Q7/20ai/CtXyOJ5XUWPfShxC 0/tJsJzEMDp1
Cp+74NU12M5gtWLiAQmOVL4n0N+VdyOQ1CBfWStQYSAKffbCEbRv4gZzr5Mu UCAVsBNdz8K4
ezxPsoRZt9gqBBjWGAZTJoQjU7AVAzk2a5D311DS10SKsAMc64EK6RdJfZyr 1mQQ/f457ACq
3uRMQvhbfbgwei5OpmggsoFgEQuRNLvlqKcT68n0pSL2KBBfHAHG0nyJiF5b tHifeTJ5pvYy
VUpZr3G3ALwpvwvhjS4l4NVMoJ43iosHJ2CWu6ZenYz3oPeQkAibZYQrc8do GaCnhbBATdfC
3QV5FyurrtWBnOoqmhR32pYSe/ww4os9koPt5P6egSNfEZWP6ofRmE3Vkb2d tYWyN7dInt7T
r/BuYvQ7lj1bogromE3/nuCvrrlQsdGcyuvXcE1uXp3hUo4g3UkV/TcGvx7p t86fNz7zmXOK
PtEbdxBIrUBefXmgL4xm+XS2PK4flBZl7cY0GlMQw/Xh7o3hYnXG2elDPFf9 QKptdOCAKQAA
AAAAAAAAAAIAAAAABUUFORQwCQAQAAAAbmV3IG1vZGVsxD17AEAHAA==
--------------020806070409020600080006--
Re: [ATL] NullPointerException--ERROR [message #87622 is a reply to message #87381] Wed, 06 August 2008 17:55 Go to previous messageGo to next message
Guillaume Doux is currently offline Guillaume DouxFriend
Messages: 56
Registered: July 2009
Member
Hello Arnd,

With the new test model, I have reproduced the error.

If we look at the obtained stack trace, we see that there is a
nullPointerException, so we probably try to access something which did
not exist.

And in the following stack trace, we see that the problem is at the line
116. (the rest of the explanations are in and after the stack trace)

GRAVE: ****** BEGIN Stack Trace
GRAVE: exception:
GRAVE: null
java.lang.NullPointerException
at
org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.invok e(ASMEMFModelElement.java:699)
at
org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
at
org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
at
org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.invok e(ASMEMFModelElement.java:691)
at
org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
at
org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
at
org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)
at
org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
at
org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:335)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
at
org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
at
org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)
at
org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
at
org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:335)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
at
org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
at
org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)
at
org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
at
org.eclipse.m2m.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:299)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:179)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:121)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:97)
at
org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLaunche r(AtlRegularVM.java:361)
at
org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLaunche r(AtlRegularVM.java:463)
at
org.eclipse.m2m.atl.adt.launching.AtlRegularVM.launch(AtlReg ularVM.java:435)
at
org.eclipse.m2m.atl.adt.launching.AtlLaunchConfigurationDele gate.launch(AtlLaunchConfigurationDelegate.java:42)
at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:764)
at
org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:614)
at
org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:880)
at
org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1083)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
GRAVE: A.main() : ??#24 null
GRAVE: local variables = {self=UML_2_SymTAS : ASMModule}
GRAVE: local stack = []
GRAVE: A.__exec__() : ??#8 null
GRAVE: local variables = {e=TransientLink {rule = 'Model2System',
sourceElements = {m = IN!umlExample1}, targetElements = {an_ob =
OUT!<unnamed>, oc = OUT!<unnamed>, gl = OUT!<unnamed>, op =
OUT!<unnamed>, ap = OUT!<unnamed>, root = OUT!<unnamed>, ma =
OUT!<unnamed>, an = OUT!<notnamedyet>, an_ap = OUT!<unnamed>, ar =
OUT!<unnamed>, an_ar = OUT!<unnamed>}, variables = {j = 0, i = 0}},
self=UML_2_SymTAS : ASMModule}
GRAVE: local stack = []
GRAVE: A.__applyModel2System(1 : NTransientLink;) : ??#185 198:20-198:54
GRAVE: local variables = {an=OUT!<notnamedyet>,
coa=IN!CallOperationAction_0, an_ap=OUT!<unnamed>, an_ob=OUT!<unnamed>,
oc=OUT!<unnamed>, an_ar=OUT!<unnamed>, i=0, m=IN!umlExample1,
link=TransientLink {rule = 'Model2System', sourceElements = {m =
IN!umlExample1}, targetElements = {an_ob = OUT!<unnamed>, oc =
OUT!<unnamed>, gl = OUT!<unnamed>, op = OUT!<unnamed>, ap =
OUT!<unnamed>, root = OUT!<unnamed>, ma = OUT!<unnamed>, an =
OUT!<notnamedyet>, an_ap = OUT!<unnamed>, ar = OUT!<unnamed>, an_ar =
OUT!<unnamed>}, variables = {j = 0, i = 0}}, gl=OUT!<unnamed>,
self=UML_2_SymTAS : ASMModule, ar=OUT!<unnamed>, ap=OUT!<unnamed>,
root=OUT!<unnamed>, j=0, op=OUT!<unnamed>, ma=OUT!<unnamed>}
GRAVE: local stack = [OUT!<unnamed>]
GRAVE: A.generateAppChannel(1 : Muml!CallOperationAction;) : ??#26
413:9-413:36
GRAVE: local variables = {b=OUT!Operation_0, i=0,
coa=IN!CallOperationAction_0, self=UML_2_SymTAS : ASMModule}
GRAVE: local stack = []

GRAVE: Muml!Element;.getPriority() : ??#7 116:2-116:82
//Here is the problem

GRAVE: local variables = {self=IN!Operation_0}
GRAVE: local stack = []
GRAVE: ****** END Stack Trace

So if we look at this line in your transformation we see:

114 --Sollte die SchedPolicy zurückgeben, tut's aber nicht
115 helper context uml!Element def: getPriority() : Integer =
116 self.getValue(self.getAppliedStereotype('SaCommStep'), 'priority');

if we put a debug instruction on self.getAppliedStereotype('SaCommStep')
we obtain ... self.getAppliedStereotype('SaCommStep').debug('maybe it is
undefined') ...

At the execution of the transformation, just before the exception we have:
INFO: maybe it is undefined: OclUndefined

So we see that self.getAppliedStereotype('SaCommStep') return a null
value, so you can not get the value of the 'priority' attribute from
null and it throws the NullPointerException.

As I have said in the previous mail:

> Note that the "getAppliedStereotype(stereotypeName : String)" method takes the fully qualified name of the stereotype as parameter, so something like "profileName::StereotypeName". Without the fully qualified name, the stereotypes can not be found.

You must use with getAppliedStereotype(stereotypeName : String) the
fully qualified name of the stereotype.

Here it is : 'MARTE::MARTE_AnalysisModel::SAM::SaCommStep'

So if you change:

So if we look at this line in your transformation we see:

114 --Sollte die SchedPolicy zurückgeben, tut's aber nicht
115 helper context uml!Element def: getPriority() : Integer =
116 self.getValue(self.getAppliedStereotype('SaCommStep'), 'priority');

by:

114 --Sollte die SchedPolicy zurückgeben, tut's aber nicht
115 helper context uml!Element def: getPriority() : Integer =
116 self.getValue(
117self.getAppliedStereotype('MARTE::MARTE_AnalysisModel::SA M::SaCommStep')
118 .debug('maybe it is undefined'), 'priority');

your transformation will be executed without error, and you will see in
the ATL console:

INFO: maybe it is undefined: marte!SaCommStep

So you see it is not undefined yet. And your output model is created.

Next are answers to your new questions:

Arnd a écrit :
> Hello Guillaume!
>
> You made a good point about not seeing Stereotypes on my model in your
> papyrus. It seems that models I create cannot be easily transferred to
> other computers, seems to be some papyrus-bug on my system. My assisting
> tudor confirmed that his papyrus can't see stereotypes on the models I
> sent him, and his ATL didn't do so either.
>
> So we recreated the model on his system, and the same
> NullPointerException happened, when we tried to transform it with ATL.
> The faulty ATL-code can only be executed if the helper
> "CallOperationAction.isChannel()" returns true, and that only happens
> when the correct stereotypes are applied, so his ATL sees the
> stereotypes too. My papyrus can show his model with stereotypes, so we
> assume this is a valid uml-model, and my ATL transformation throws a
> NullPointerException as well.
>
> I tested this, so I know that on my system and on the system of my
> assisting tudor it works like this.
>
> Thank you for correcting my programming style in public, but I did
> not ask for it. I would rather like it a bit more private. Though, I
> have looked at your proposals, and have two questions:
>
> 1. Matched rules are called automatically and produce their output
> element right under the root node of the output model. I don't want this
> to happen, but I can't stop it. So I chose called rules. Because of this
> behavior, if I insert one of the matched rules you proposed, the output
> is not equivalent. I tested this, so... Is there a way to stop them from
> being called automatically?
>

Matched rules are called automatically and produce their output element
tight under the root node only if you did not link it with a container
structural feature.

The type of matched rule I proposed must be used with links like the
links I proposed in your following question to obtained a correct tree.

You can look at
http://www.eclipse.org/m2m/atl/atlTransformations/Class2Rela tional/ExampleClass2Relational%5Bv00.01%5D.pdf
to have an example of how to obtain a good tree with declarated rules.



> 2. For the main rule, you propose a code like this:
> "ar:symtas!ArchitectureType(bus<-uml!Class.allInstancesFrom('IN')- >select(c|c.isBus())),"
>
> but if I insert it and test the transformation, there's another exception:
> "SCHWERWIEGEND: cannot set feature symtas!ArchitectureType.bus to value
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1c36942 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@48bddf (name: ArchitectureCPU)
> (instanceClassName: null) (abstract: false, interface: false))
> java.lang.RuntimeException: cannot set feature
> symtas!ArchitectureType.bus to value
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1c36942 (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@48bddf (name: ArchitectureCPU)
> (instanceClassName: null) (abstract: false, interface: false))"

I have just done a proposition of declarative code, I did not know your
output metamodel , so this code was only guide lines and not a code to
copy/paste.
Sorry if I have not been clear on it.

Here, I may have make a mistake on the attribute type I wanted to reference.

> Again, the output is not equivalent(*g*), so what am I doing wrong here?
>

The output can not be equivalent because if an error occurs during the
transformation the output model will be corrupted.


>
> Please don't put too much effort into answering these questions, I asked
> for help at a point where I need it, and I would appreciate if you had a
> closer look at what's wrong with my tagged value problem. I will send
> you the model I and my assisting tudor created, perhaps it might be
> helpful, if you recreated a similar uml model on your system and try to
> transform that. If you cannot reproduce the Exception this way either,
> it seems our problem is rather a papyrus problem than an ATL problem.
>
> Regards,
>
> Arnd
>

Best regards,

Guillaume.

>
> Guillaume Doux schrieb:
>> Hi Arnd,
>>
>> I have looked at your transformation and I can not reproduce your
>> exceptions, because the elements in the source model does not seem to
>> have any stereotypes
>>
>> applied.
>>
>> (cf: - In papyrus, the Profile item on the "Properties" view is
>> empty for the "Class_0"
>> - In ATL the result of getAppliedStereotypes() on each elements
>> where hasStereotypes is called return an empty sequence.)
>>
>> So your problem may happen during the creation of the source model.
>>
>>
>> I will try to answer to your question without testing it, but by
>> giving you the more generals infomations needed to correct it by
>> yourself.
>>
>>
>> I have look more precisely at the way you use to retrieve the tagged
>> value in the model, and it is not done correctly.
>> - First, you did not have to use the MARTE profile has an entry
>> model or metamodel in order to read tagged value. So the header of
>> your ATL
>>
>> transformation must be :
>>
>> module UML_2_SymTAS; -- Module Template
>> create OUT : symtas from IN : uml;
>>
>> And so you don't have to specify the MARTE profile in the launch
>> configuration because it will already be referenced in your source model
>> (maybe you will have to modify manually the source model to point to
>> the good location for the MARTE profile file)
>>
>> Note that the "getAppliedStereotype(stereotypeName : String)" method
>> takes the fully qualified name of the stereotype as parameter, so
>> something like "profileName::StereotypeName". Without the fully
>> qualified name, the stereotypes can not be found.
>>
>> This is now summarised in the ATL Howtos at
>> http://wiki.eclipse.org/ATL_Howtos#How_can_I_retrieve_tagged _values_from_stereotyped_UML_model_elements.3F
>>
>> (Do not worry if you have not seen it before, it is newly added)
>> On this howto you have also another version of the hasStereotype
>> helper which uses the fully qualified name.
>>
>>
>> Thirdly, by looking at your ATL code, it seems that you sometimes try
>> to reimplement predefined methods. As example, we can see:
>> - eqStr(String, String) : Boolean, the "=" between two String may
>> be sufficent,
>> - isOfType(String) : Boolean, a oclIsTypeOf(t : oclType) and
>> oclIsKindOf(t : oclType) returning a Boolean are already defined. (See
>> page 16 on the ATL
>>
>> manual) The argument for this method is an oclType, so you can just
>> put something like UML!Class if you want to know if your element is an
>> UML class, or
>>
>> symtas!ArchitectureType if you want to now if your element is an
>> architecureType from symtas.
>>
>> In your code you use also mostly imperative satements in a do block
>> with calls to called rules. This type of programming is not
>> recommended, the declarative
>>
>> way is simpler and cleaner. The imperative style is only here for
>> very specific operations, and it seems that you did not have to use it.
>> Moreover, when you write something like in the do section of the main
>> rule:
>>
>> for (c in uml!Class.allInstances()) {
>> if (c.isBus()) {
>> ar.bus <- thisModule.generateArchBus(c.getInstance());
>> }
>> if (c.isCPU()) {
>> ar.cpu <- thisModule.generateArchCPU(c.getInstance());
>> }
>> }
>>
>> the for loop you use made the same things that the ATL engine does
>> when it calls declarative rule, so this type of code is useless and
>> takes you far away from
>>
>> the ATL language.
>> for example,
>> for (c in uml!Class.allInstances()) {
>> if (c.isBus()) {
>> ar.bus <- thisModule.generateArchBus(c.getInstance());
>> }
>> if (c.isCPU()) {
>> ar.cpu <- thisModule.generateArchCPU(c.getInstance());
>> }
>> }
>>
>> and
>>
>> rule generateArchBus(name : String) {
>> to
>> b : symtas!ArchitectureBus
>> do {
>> b.name <- name;
>> b.xPosition <- 0;
>> b.yPosition <- 0;
>> b.width <- 0;
>> b.height <- 0;
>> b.busspeed <- thisModule.generateBusspeed(1);
>> b.speedup <- thisModule.generateSpeedup();
>> b.ports <- thisModule.generateResourcePort();
>> b; }
>> }
>>
>> and
>>
>> rule generateArchCPU(name : String) {
>> to
>> b : symtas!ArchitectureCPU
>> do {
>> b.name <- name;
>> b.xPosition <- 0;
>> b.yPosition <- 0;
>> b.width <- 0;
>> b.height <- 0;
>> b.speedup <- thisModule.generateSpeedup();
>> b.ports <- thisModule.generateResourcePort();
>> b; }
>> }
>>
>> is equivalent to a declarative the 2 following rules:
>>
>> rule Class2ABUS {
>> from
>> s : UML!Class (s.isBus())
>> to
>> archBus : symtas!ArchitectureBus(
>> name <- s.name,
>> xPosition <- 0,
>> yPosition <- 0,
>> width <- 0,
>> height <- 0,
>> busspeed <- thisModule.generateBusspeed(1),
>> speedup <- thisModule.generateSpeedup(),
>> ports <- thisModule.generateResourcePort(),
>> )
>> }
>>
>> rule Class2ACPU {
>> from
>> s : UML!Class (s.isBus())
>> to
>> archBus : symtas!ArchitectureCPU(
>> name <- s.name,
>> xPosition <- 0,
>> yPosition <- 0,
>> width <- 0,
>> height <- 0,
>> b.speedup <- thisModule.generateSpeedup(),
>> b.ports <- thisModule.generateResourcePort()
>> )
>> }
>>
>> with somlething like that in your main rule:
>> -- Haupttransformationsregel für einmalige Wurzeltransformation
>> rule Model2System {
>> from
>> -- Eingabemodell
>> m : uml!Model
>> to
>> ... (the other element you want to create in the same way as
>> the following)
>> ar : symtas!ArchitectureType(
>> bus <- uml!Class.allInstancesFrom('IN')->select(c |
>> c.isBus()),
>> cpu <- uml!Class.allInstancesFrom('IN')->select(c |
>> c.isCPU()),
>> ...
>> ),
>> ...
>> }
>>
>> With this, you can also use the same way to replace the call to
>> thisModule.generateSpeedup() and others in the matching rules.
>>
>> This type of programming allows you to do all your rules without any
>> "do" sections and imperatives blocks.
>>
>> Your transformation will be much simpler.
>>
>>
>> You should use the various ATL constructs in this preference order:
>> - standard matched rules,
>> - unique lazy rules,
>> - lazy rules,
>> - called rules
>>
>> As you can infer from this list, the prefered style is declarative. If
>> you cannot do something with it (i.e., standard, unique lazy, and lazy
>> rules are not
>>
>> enough) then you may use imperative blocks.
>>
>> You can also remove all the () in your helpers which have no
>> parameters because your transformation will be faster (cf. the ATL
>> manual about attribute helper
>>
>> caching).
>> Note that you must also remove the () at the calling sites.
>>
>> You can look at the ATL manual for other predefined ATL functions:
>> http://www.eclipse.org/m2m/atl/doc/ATL_User_Manual%5Bv0.7%5D .pdf
>>
>>
>>
>> I hope all of this can help you to do your work, if you have any other
>> questions feel free to ask again in the newsgroup.
>>
>>
>> Best regards.
>>
>> Guillaume.
>>
>>
>>
>> Arnd a écrit :
>>> Dear Hugo!
>>>
>>> I have the same problem using the MARTE profile... When I try to
>>> define an input profile, eclipse wants me to pick a file from my
>>> workspace or my File System... What kind of file is needed here?
>>>
>>> Greetings,
>>>
>>> Bragenheim
>>>
>>>
>>> Hugo Bruneliere schrieb:
>>>> Hi Rasha,
>>>>
>>>> First, do you pass the definition of the profile (which is a UML
>>>> model) as an input of your transformation?
>>>>
>>>> Rasha a écrit :
>>>>> I have only another helper �hasStereotype� which I tested
>>>>> separately and works fine. I attached the whole transformation file.
>>>>>
>>>>>
>>>>> ---This helper define the method "hasStereotype"
>>>>> helper context UML!"uml::Element" def: hasStereotype(stereotype :
>>>>> String) : Boolean =
>>>>> self.getAppliedStereotypes()-> exists (c | c.name = stereotype);
>>>>>
>>>>> ---This helper define the method "getTaggedValue"
>>>>> helper context UML!"uml::Element" def: getTaggedValue(stereo :
>>>>> String ,tag : String) : UML!"uml::Element" =
>>>>> self.getValue(self.getAppliedStereotype(stereo),tag);
>>>>>
>>>>
>>>> Are you sure the getValue method is actually returning a uml::Element?
>>>> What happens if the property of the given stereotype is of type
>>>> String or Integer?
>>>>
>>>>> ---This helper verifies if the value of the proterty 'myProperty'
>>>>> is different of 'value1'
>>>>> helper context UML!"uml::Element" def : checkMyPropertyValue() :
>>>>> Boolean =
>>>>> if (self.hasStereotype('MyStereotype')) then
>>>>> if
>>>>> (self.getTaggedValue('MyStereotype','myProperty')<>'value1') then
>>>>> true
>>>>> else false
>>>>> endif
>>>>> else
>>>>> true
>>>>> endif;
>>>>>
>>>>> rule Copyclass{
>>>>> from
>>>>> s : UML!Class (s.checkMyPropertyValue())
>>>>> to t : UML!Class( name <- s.name
>>>>> )
>>>>> }
>>>>>
>>>>>
>>>>> Best Regards,
>>>>>
>>>>> Rasha
>>>>>
>>>>>
>>>>
>>>> Best regards,
>>>>
>>>> Hugo
>>>>
>>>>
>
>
Re: [ATL] NullPointerException--ERROR [message #87728 is a reply to message #87622] Thu, 07 August 2008 11:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: kachd.web.de

Hi Guillaume,

Thanks for the fast and qualitative help, You did indeed see the problem
before you could test it. Your solution works, I somehow think I should
have been able to work it out myself, but I'm quite inexperienced with
ATL and stereotyped UML-models, so thank you for letting me bother you.

There is just one thing that struck me:

The Method "getAppliedStereotype(s : String)" needs a fully qualified
name like 'MARTE::MARTE_AnalysisModel::SAM::SaCommStep' to work
properly, whereas the construct
"getAppliedStereotypes()->collect(st|st.name)->includes(s : String)"
only (sic!) works with an unqualified name like 'SaCommStep'.

I guess you don't have much influence on these UML-Methods, but I think
this is kind of irritating. I don't want to talk myself out of a tight
spot, I just want to let you know about what I think is inconsistent.
But I think OMG would be a better adressee...

Thanks again for good and quick help,

With best regards,

Bragenheim


Guillaume Doux schrieb:
> Hello Arnd,
>
> With the new test model, I have reproduced the error.
>
> If we look at the obtained stack trace, we see that there is a
> nullPointerException, so we probably try to access something which did
> not exist.
>
> And in the following stack trace, we see that the problem is at the line
> 116. (the rest of the explanations are in and after the stack trace)
>
> GRAVE: ****** BEGIN Stack Trace
> GRAVE: exception:
> GRAVE: null
> java.lang.NullPointerException
> at
> org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.invok e(ASMEMFModelElement.java:699)
>
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
> at
> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
>
> at
> org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.invok e(ASMEMFModelElement.java:691)
>
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
> at
> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
>
> at
> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)
>
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:335)
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
> at
> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
>
> at
> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)
>
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:335)
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
> at
> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
>
> at
> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)
>
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
> at
> org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
> at
> org.eclipse.m2m.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:299)
>
> at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:179)
> at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:121)
> at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:97)
> at
> org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLaunche r(AtlRegularVM.java:361)
>
> at
> org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLaunche r(AtlRegularVM.java:463)
>
> at
> org.eclipse.m2m.atl.adt.launching.AtlRegularVM.launch(AtlReg ularVM.java:435)
>
> at
> org.eclipse.m2m.atl.adt.launching.AtlLaunchConfigurationDele gate.launch(AtlLaunchConfigurationDelegate.java:42)
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:764)
>
> at
> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:614)
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:880)
>
> at
> org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1083)
> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
> GRAVE: A.main() : ??#24 null
> GRAVE: local variables = {self=UML_2_SymTAS : ASMModule}
> GRAVE: local stack = []
> GRAVE: A.__exec__() : ??#8 null
> GRAVE: local variables = {e=TransientLink {rule = 'Model2System',
> sourceElements = {m = IN!umlExample1}, targetElements = {an_ob =
> OUT!<unnamed>, oc = OUT!<unnamed>, gl = OUT!<unnamed>, op =
> OUT!<unnamed>, ap = OUT!<unnamed>, root = OUT!<unnamed>, ma =
> OUT!<unnamed>, an = OUT!<notnamedyet>, an_ap = OUT!<unnamed>, ar =
> OUT!<unnamed>, an_ar = OUT!<unnamed>}, variables = {j = 0, i = 0}},
> self=UML_2_SymTAS : ASMModule}
> GRAVE: local stack = []
> GRAVE: A.__applyModel2System(1 : NTransientLink;) : ??#185 198:20-198:54
> GRAVE: local variables = {an=OUT!<notnamedyet>,
> coa=IN!CallOperationAction_0, an_ap=OUT!<unnamed>, an_ob=OUT!<unnamed>,
> oc=OUT!<unnamed>, an_ar=OUT!<unnamed>, i=0, m=IN!umlExample1,
> link=TransientLink {rule = 'Model2System', sourceElements = {m =
> IN!umlExample1}, targetElements = {an_ob = OUT!<unnamed>, oc =
> OUT!<unnamed>, gl = OUT!<unnamed>, op = OUT!<unnamed>, ap =
> OUT!<unnamed>, root = OUT!<unnamed>, ma = OUT!<unnamed>, an =
> OUT!<notnamedyet>, an_ap = OUT!<unnamed>, ar = OUT!<unnamed>, an_ar =
> OUT!<unnamed>}, variables = {j = 0, i = 0}}, gl=OUT!<unnamed>,
> self=UML_2_SymTAS : ASMModule, ar=OUT!<unnamed>, ap=OUT!<unnamed>,
> root=OUT!<unnamed>, j=0, op=OUT!<unnamed>, ma=OUT!<unnamed>}
> GRAVE: local stack = [OUT!<unnamed>]
> GRAVE: A.generateAppChannel(1 : Muml!CallOperationAction;) : ??#26
> 413:9-413:36
> GRAVE: local variables = {b=OUT!Operation_0, i=0,
> coa=IN!CallOperationAction_0, self=UML_2_SymTAS : ASMModule}
> GRAVE: local stack = []
>
> GRAVE: Muml!Element;.getPriority() : ??#7 116:2-116:82
> //Here is the problem
>
> GRAVE: local variables = {self=IN!Operation_0}
> GRAVE: local stack = []
> GRAVE: ****** END Stack Trace
>
> So if we look at this line in your transformation we see:
>
> 114 --Sollte die SchedPolicy zurückgeben, tut's aber nicht
> 115 helper context uml!Element def: getPriority() : Integer =
> 116 self.getValue(self.getAppliedStereotype('SaCommStep'), 'priority');
>
> if we put a debug instruction on self.getAppliedStereotype('SaCommStep')
> we obtain ... self.getAppliedStereotype('SaCommStep').debug('maybe it is
> undefined') ...
>
> At the execution of the transformation, just before the exception we have:
> INFO: maybe it is undefined: OclUndefined
>
> So we see that self.getAppliedStereotype('SaCommStep') return a null
> value, so you can not get the value of the 'priority' attribute from
> null and it throws the NullPointerException.
>
> As I have said in the previous mail:
>
>> Note that the "getAppliedStereotype(stereotypeName : String)" method
>> takes the fully qualified name of the stereotype as parameter, so
>> something like "profileName::StereotypeName". Without the fully
>> qualified name, the stereotypes can not be found.
>
> You must use with getAppliedStereotype(stereotypeName : String) the
> fully qualified name of the stereotype.
>
> Here it is : 'MARTE::MARTE_AnalysisModel::SAM::SaCommStep'
>
> So if you change:
>
> So if we look at this line in your transformation we see:
>
> 114 --Sollte die SchedPolicy zurückgeben, tut's aber nicht
> 115 helper context uml!Element def: getPriority() : Integer =
> 116 self.getValue(self.getAppliedStereotype('SaCommStep'), 'priority');
>
> by:
>
> 114 --Sollte die SchedPolicy zurückgeben, tut's aber nicht
> 115 helper context uml!Element def: getPriority() : Integer =
> 116 self.getValue(
> 117self.getAppliedStereotype('MARTE::MARTE_AnalysisModel::SA M::SaCommStep')
> 118 .debug('maybe it is undefined'), 'priority');
>
> your transformation will be executed without error, and you will see in
> the ATL console:
>
> INFO: maybe it is undefined: marte!SaCommStep
>
> So you see it is not undefined yet. And your output model is created.
>
> Next are answers to your new questions:
>
> Arnd a écrit :
>> Hello Guillaume!
>>
>> You made a good point about not seeing Stereotypes on my model in your
>> papyrus. It seems that models I create cannot be easily transferred to
>> other computers, seems to be some papyrus-bug on my system. My
>> assisting tudor confirmed that his papyrus can't see stereotypes on
>> the models I sent him, and his ATL didn't do so either.
>>
>> So we recreated the model on his system, and the same
>> NullPointerException happened, when we tried to transform it with ATL.
>> The faulty ATL-code can only be executed if the helper
>> "CallOperationAction.isChannel()" returns true, and that only happens
>> when the correct stereotypes are applied, so his ATL sees the
>> stereotypes too. My papyrus can show his model with stereotypes, so we
>> assume this is a valid uml-model, and my ATL transformation throws a
>> NullPointerException as well.
>>
>> I tested this, so I know that on my system and on the system of my
>> assisting tudor it works like this.
>>
>> Thank you for correcting my programming style in public, but I did
>> not ask for it. I would rather like it a bit more private. Though, I
>> have looked at your proposals, and have two questions:
>>
>> 1. Matched rules are called automatically and produce their output
>> element right under the root node of the output model. I don't want this
>> to happen, but I can't stop it. So I chose called rules. Because of this
>> behavior, if I insert one of the matched rules you proposed, the output
>> is not equivalent. I tested this, so... Is there a way to stop them from
>> being called automatically?
>>
>
> Matched rules are called automatically and produce their output element
> tight under the root node only if you did not link it with a container
> structural feature.
>
> The type of matched rule I proposed must be used with links like the
> links I proposed in your following question to obtained a correct tree.
>
> You can look at
> http://www.eclipse.org/m2m/atl/atlTransformations/Class2Rela tional/ExampleClass2Relational%5Bv00.01%5D.pdf
>
> to have an example of how to obtain a good tree with declarated rules.
>
>
>
>> 2. For the main rule, you propose a code like this:
>> "ar:symtas!ArchitectureType(bus<-uml!Class.allInstancesFrom('IN')- >select(c|c.isBus())),"
>>
>> but if I insert it and test the transformation, there's another
>> exception:
>> "SCHWERWIEGEND: cannot set feature symtas!ArchitectureType.bus to value
>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1c36942 (eClass:
>> org.eclipse.emf.ecore.impl.EClassImpl@48bddf (name: ArchitectureCPU)
>> (instanceClassName: null) (abstract: false, interface: false))
>> java.lang.RuntimeException: cannot set feature
>> symtas!ArchitectureType.bus to value
>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1c36942 (eClass:
>> org.eclipse.emf.ecore.impl.EClassImpl@48bddf (name: ArchitectureCPU)
>> (instanceClassName: null) (abstract: false, interface: false))"
>
> I have just done a proposition of declarative code, I did not know your
> output metamodel , so this code was only guide lines and not a code to
> copy/paste.
> Sorry if I have not been clear on it.
>
> Here, I may have make a mistake on the attribute type I wanted to
> reference.
>
>> Again, the output is not equivalent(*g*), so what am I doing wrong here?
>>
>
> The output can not be equivalent because if an error occurs during the
> transformation the output model will be corrupted.
>
>
>>
>> Please don't put too much effort into answering these questions, I asked
>> for help at a point where I need it, and I would appreciate if you had a
>> closer look at what's wrong with my tagged value problem. I will send
>> you the model I and my assisting tudor created, perhaps it might be
>> helpful, if you recreated a similar uml model on your system and try
>> to transform that. If you cannot reproduce the Exception this way
>> either, it seems our problem is rather a papyrus problem than an ATL
>> problem.
>>
>> Regards,
>>
>> Arnd
>>
>
> Best regards,
>
> Guillaume.
>
>>
>> Guillaume Doux schrieb:
>>> Hi Arnd,
>>>
>>> I have looked at your transformation and I can not reproduce your
>>> exceptions, because the elements in the source model does not seem to
>>> have any stereotypes
>>>
>>> applied.
>>>
>>> (cf: - In papyrus, the Profile item on the "Properties" view is
>>> empty for the "Class_0"
>>> - In ATL the result of getAppliedStereotypes() on each elements
>>> where hasStereotypes is called return an empty sequence.)
>>>
>>> So your problem may happen during the creation of the source model.
>>>
>>>
>>> I will try to answer to your question without testing it, but by
>>> giving you the more generals infomations needed to correct it by
>>> yourself.
>>>
>>>
>>> I have look more precisely at the way you use to retrieve the tagged
>>> value in the model, and it is not done correctly.
>>> - First, you did not have to use the MARTE profile has an entry
>>> model or metamodel in order to read tagged value. So the header of
>>> your ATL
>>>
>>> transformation must be :
>>>
>>> module UML_2_SymTAS; -- Module Template
>>> create OUT : symtas from IN : uml;
>>>
>>> And so you don't have to specify the MARTE profile in the launch
>>> configuration because it will already be referenced in your source model
>>> (maybe you will have to modify manually the source model to point to
>>> the good location for the MARTE profile file)
>>>
>>> Note that the "getAppliedStereotype(stereotypeName : String)" method
>>> takes the fully qualified name of the stereotype as parameter, so
>>> something like "profileName::StereotypeName". Without the fully
>>> qualified name, the stereotypes can not be found.
>>>
>>> This is now summarised in the ATL Howtos at
>>> http://wiki.eclipse.org/ATL_Howtos#How_can_I_retrieve_tagged _values_from_stereotyped_UML_model_elements.3F
>>>
>>> (Do not worry if you have not seen it before, it is newly added)
>>> On this howto you have also another version of the hasStereotype
>>> helper which uses the fully qualified name.
>>>
>>>
>>> Thirdly, by looking at your ATL code, it seems that you sometimes try
>>> to reimplement predefined methods. As example, we can see:
>>> - eqStr(String, String) : Boolean, the "=" between two String may
>>> be sufficent,
>>> - isOfType(String) : Boolean, a oclIsTypeOf(t : oclType) and
>>> oclIsKindOf(t : oclType) returning a Boolean are already defined.
>>> (See page 16 on the ATL
>>>
>>> manual) The argument for this method is an oclType, so you can just
>>> put something like UML!Class if you want to know if your element is
>>> an UML class, or
>>>
>>> symtas!ArchitectureType if you want to now if your element is an
>>> architecureType from symtas.
>>>
>>> In your code you use also mostly imperative satements in a do block
>>> with calls to called rules. This type of programming is not
>>> recommended, the declarative
>>>
>>> way is simpler and cleaner. The imperative style is only here for
>>> very specific operations, and it seems that you did not have to use it.
>>> Moreover, when you write something like in the do section of the main
>>> rule:
>>>
>>> for (c in uml!Class.allInstances()) {
>>> if (c.isBus()) {
>>> ar.bus <- thisModule.generateArchBus(c.getInstance());
>>> }
>>> if (c.isCPU()) {
>>> ar.cpu <- thisModule.generateArchCPU(c.getInstance());
>>> }
>>> }
>>>
>>> the for loop you use made the same things that the ATL engine does
>>> when it calls declarative rule, so this type of code is useless and
>>> takes you far away from
>>>
>>> the ATL language.
>>> for example,
>>> for (c in uml!Class.allInstances()) {
>>> if (c.isBus()) {
>>> ar.bus <- thisModule.generateArchBus(c.getInstance());
>>> }
>>> if (c.isCPU()) {
>>> ar.cpu <- thisModule.generateArchCPU(c.getInstance());
>>> }
>>> }
>>>
>>> and
>>>
>>> rule generateArchBus(name : String) {
>>> to
>>> b : symtas!ArchitectureBus
>>> do {
>>> b.name <- name;
>>> b.xPosition <- 0;
>>> b.yPosition <- 0;
>>> b.width <- 0;
>>> b.height <- 0;
>>> b.busspeed <- thisModule.generateBusspeed(1);
>>> b.speedup <- thisModule.generateSpeedup();
>>> b.ports <- thisModule.generateResourcePort();
>>> b; }
>>> }
>>>
>>> and
>>>
>>> rule generateArchCPU(name : String) {
>>> to
>>> b : symtas!ArchitectureCPU
>>> do {
>>> b.name <- name;
>>> b.xPosition <- 0;
>>> b.yPosition <- 0;
>>> b.width <- 0;
>>> b.height <- 0;
>>> b.speedup <- thisModule.generateSpeedup();
>>> b.ports <- thisModule.generateResourcePort();
>>> b; }
>>> }
>>>
>>> is equivalent to a declarative the 2 following rules:
>>>
>>> rule Class2ABUS {
>>> from
>>> s : UML!Class (s.isBus())
>>> to
>>> archBus : symtas!ArchitectureBus(
>>> name <- s.name,
>>> xPosition <- 0,
>>> yPosition <- 0,
>>> width <- 0,
>>> height <- 0,
>>> busspeed <- thisModule.generateBusspeed(1),
>>> speedup <- thisModule.generateSpeedup(),
>>> ports <- thisModule.generateResourcePort(),
>>> )
>>> }
>>>
>>> rule Class2ACPU {
>>> from
>>> s : UML!Class (s.isBus())
>>> to
>>> archBus : symtas!ArchitectureCPU(
>>> name <- s.name,
>>> xPosition <- 0,
>>> yPosition <- 0,
>>> width <- 0,
>>> height <- 0,
>>> b.speedup <- thisModule.generateSpeedup(),
>>> b.ports <- thisModule.generateResourcePort()
>>> )
>>> }
>>>
>>> with somlething like that in your main rule:
>>> -- Haupttransformationsregel für einmalige Wurzeltransformation
>>> rule Model2System {
>>> from
>>> -- Eingabemodell
>>> m : uml!Model
>>> to
>>> ... (the other element you want to create in the same way as
>>> the following)
>>> ar : symtas!ArchitectureType(
>>> bus <- uml!Class.allInstancesFrom('IN')->select(c |
>>> c.isBus()),
>>> cpu <- uml!Class.allInstancesFrom('IN')->select(c |
>>> c.isCPU()),
>>> ...
>>> ),
>>> ...
>>> }
>>>
>>> With this, you can also use the same way to replace the call to
>>> thisModule.generateSpeedup() and others in the matching rules.
>>>
>>> This type of programming allows you to do all your rules without any
>>> "do" sections and imperatives blocks.
>>>
>>> Your transformation will be much simpler.
>>>
>>>
>>> You should use the various ATL constructs in this preference order:
>>> - standard matched rules,
>>> - unique lazy rules,
>>> - lazy rules,
>>> - called rules
>>>
>>> As you can infer from this list, the prefered style is declarative.
>>> If you cannot do something with it (i.e., standard, unique lazy, and
>>> lazy rules are not
>>>
>>> enough) then you may use imperative blocks.
>>> You can also remove all the () in your helpers which
>>> have no parameters because your transformation will be faster (cf.
>>> the ATL manual about attribute helper
>>>
>>> caching).
>>> Note that you must also remove the () at the calling sites.
>>>
>>> You can look at the ATL manual for other predefined ATL functions:
>>> http://www.eclipse.org/m2m/atl/doc/ATL_User_Manual%5Bv0.7%5D .pdf
>>>
>>>
>>>
>>> I hope all of this can help you to do your work, if you have any
>>> other questions feel free to ask again in the newsgroup.
>>>
>>>
>>> Best regards.
>>>
>>> Guillaume.
>>>
>>>
>>>
>>> Arnd a écrit :
>>>> Dear Hugo!
>>>>
>>>> I have the same problem using the MARTE profile... When I try to
>>>> define an input profile, eclipse wants me to pick a file from my
>>>> workspace or my File System... What kind of file is needed here?
>>>>
>>>> Greetings,
>>>>
>>>> Bragenheim
>>>>
>>>>
>>>> Hugo Bruneliere schrieb:
>>>>> Hi Rasha,
>>>>>
>>>>> First, do you pass the definition of the profile (which is a UML
>>>>> model) as an input of your transformation?
>>>>>
>>>>> Rasha a écrit :
>>>>>> I have only another helper �hasStereotype� which I tested
>>>>>> separately and works fine. I attached the whole transformation file.
>>>>>>
>>>>>>
>>>>>> ---This helper define the method "hasStereotype"
>>>>>> helper context UML!"uml::Element" def: hasStereotype(stereotype :
>>>>>> String) : Boolean =
>>>>>> self.getAppliedStereotypes()-> exists (c | c.name = stereotype);
>>>>>>
>>>>>> ---This helper define the method "getTaggedValue"
>>>>>> helper context UML!"uml::Element" def: getTaggedValue(stereo :
>>>>>> String ,tag : String) : UML!"uml::Element" =
>>>>>> self.getValue(self.getAppliedStereotype(stereo),tag);
>>>>>>
>>>>>
>>>>> Are you sure the getValue method is actually returning a uml::Element?
>>>>> What happens if the property of the given stereotype is of type
>>>>> String or Integer?
>>>>>
>>>>>> ---This helper verifies if the value of the proterty 'myProperty'
>>>>>> is different of 'value1'
>>>>>> helper context UML!"uml::Element" def : checkMyPropertyValue() :
>>>>>> Boolean =
>>>>>> if (self.hasStereotype('MyStereotype')) then
>>>>>> if
>>>>>> (self.getTaggedValue('MyStereotype','myProperty')<>'value1') then
>>>>>> true
>>>>>> else false
>>>>>> endif
>>>>>> else
>>>>>> true
>>>>>> endif;
>>>>>>
>>>>>> rule Copyclass{
>>>>>> from
>>>>>> s : UML!Class (s.checkMyPropertyValue())
>>>>>> to t : UML!Class( name <- s.name
>>>>>> )
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Best Regards,
>>>>>>
>>>>>> Rasha
>>>>>>
>>>>>>
>>>>>
>>>>> Best regards,
>>>>>
>>>>> Hugo
>>>>>
>>>>>
>>
>>
>
Re: [ATL] NullPointerException--ERROR [message #87780 is a reply to message #87728] Thu, 07 August 2008 16:07 Go to previous message
Guillaume Doux is currently offline Guillaume DouxFriend
Messages: 56
Registered: July 2009
Member
Hi Arnd,

I do not know why some UML methods accept qualified or unqualified name,
but in my transformations I use:

"not self.getAppliedStereotype(name : string).oclIsUndefined()"

instead of:

"getAppliedStereotypes()->collect(st|st.name)->includes(s : String)"

and with this one name must be also fully qualified. With it's look more
consistent in your transformation.

The two ways are giving the same result, but the use of "not
self.getAppliedStereotype(name : string).oclIsUndefined()" would
probably be fastest (it has not being tested) because
getAppliedStereotype(name : string) is a built-in function and it must
be easier to call it instead of doing a collect on the set and a test on
the name.

Best regards,

Guillaume


Arnd a écrit :
> Hi Guillaume,
>
> Thanks for the fast and qualitative help, You did indeed see the problem
> before you could test it. Your solution works, I somehow think I should
> have been able to work it out myself, but I'm quite inexperienced with
> ATL and stereotyped UML-models, so thank you for letting me bother you.
>
> There is just one thing that struck me:
>
> The Method "getAppliedStereotype(s : String)" needs a fully qualified
> name like 'MARTE::MARTE_AnalysisModel::SAM::SaCommStep' to work
> properly, whereas the construct
> "getAppliedStereotypes()->collect(st|st.name)->includes(s : String)"
> only (sic!) works with an unqualified name like 'SaCommStep'.
>
> I guess you don't have much influence on these UML-Methods, but I think
> this is kind of irritating. I don't want to talk myself out of a tight
> spot, I just want to let you know about what I think is inconsistent.
> But I think OMG would be a better adressee...
>
> Thanks again for good and quick help,
>
> With best regards,
>
> Bragenheim
>
>
> Guillaume Doux schrieb:
>> Hello Arnd,
>>
>> With the new test model, I have reproduced the error.
>>
>> If we look at the obtained stack trace, we see that there is a
>> nullPointerException, so we probably try to access something which did
>> not exist.
>>
>> And in the following stack trace, we see that the problem is at the line
>> 116. (the rest of the explanations are in and after the stack trace)
>>
>> GRAVE: ****** BEGIN Stack Trace
>> GRAVE: exception:
>> GRAVE: null
>> java.lang.NullPointerException
>> at
>> org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.invok e(ASMEMFModelElement.java:699)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
>> at
>> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
>>
>> at
>> org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModelElement.invok e(ASMEMFModelElement.java:691)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
>> at
>> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:335)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
>> at
>> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:335)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
>> at
>> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:143)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASM OclAny.java:101)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOpera tion.java:240)
>>
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation .java:171)
>> at
>> org.eclipse.m2m.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:299)
>>
>> at
>> org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:179)
>> at
>> org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:121)
>> at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.ja va:97)
>> at
>> org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLaunche r(AtlRegularVM.java:361)
>>
>> at
>> org.eclipse.m2m.atl.adt.launching.AtlRegularVM.runAtlLaunche r(AtlRegularVM.java:463)
>>
>> at
>> org.eclipse.m2m.atl.adt.launching.AtlRegularVM.launch(AtlReg ularVM.java:435)
>>
>> at
>> org.eclipse.m2m.atl.adt.launching.AtlLaunchConfigurationDele gate.launch(AtlLaunchConfigurationDelegate.java:42)
>>
>> at
>> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:764)
>>
>> at
>> org.eclipse.debug.internal.core.LaunchConfiguration.launch(L aunchConfiguration.java:614)
>>
>> at
>> org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(D ebugUIPlugin.java:880)
>>
>> at
>> org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlu gin.java:1083)
>>
>> at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
>> GRAVE: A.main() : ??#24 null
>> GRAVE: local variables = {self=UML_2_SymTAS : ASMModule}
>> GRAVE: local stack = []
>> GRAVE: A.__exec__() : ??#8 null
>> GRAVE: local variables = {e=TransientLink {rule = 'Model2System',
>> sourceElements = {m = IN!umlExample1}, targetElements = {an_ob =
>> OUT!<unnamed>, oc = OUT!<unnamed>, gl = OUT!<unnamed>, op =
>> OUT!<unnamed>, ap = OUT!<unnamed>, root = OUT!<unnamed>, ma =
>> OUT!<unnamed>, an = OUT!<notnamedyet>, an_ap = OUT!<unnamed>, ar =
>> OUT!<unnamed>, an_ar = OUT!<unnamed>}, variables = {j = 0, i = 0}},
>> self=UML_2_SymTAS : ASMModule}
>> GRAVE: local stack = []
>> GRAVE: A.__applyModel2System(1 : NTransientLink;) : ??#185 198:20-198:54
>> GRAVE: local variables = {an=OUT!<notnamedyet>,
>> coa=IN!CallOperationAction_0, an_ap=OUT!<unnamed>, an_ob=OUT!<unnamed>,
>> oc=OUT!<unnamed>, an_ar=OUT!<unnamed>, i=0, m=IN!umlExample1,
>> link=TransientLink {rule = 'Model2System', sourceElements = {m =
>> IN!umlExample1}, targetElements = {an_ob = OUT!<unnamed>, oc =
>> OUT!<unnamed>, gl = OUT!<unnamed>, op = OUT!<unnamed>, ap =
>> OUT!<unnamed>, root = OUT!<unnamed>, ma = OUT!<unnamed>, an =
>> OUT!<notnamedyet>, an_ap = OUT!<unnamed>, ar = OUT!<unnamed>, an_ar =
>> OUT!<unnamed>}, variables = {j = 0, i = 0}}, gl=OUT!<unnamed>,
>> self=UML_2_SymTAS : ASMModule, ar=OUT!<unnamed>, ap=OUT!<unnamed>,
>> root=OUT!<unnamed>, j=0, op=OUT!<unnamed>, ma=OUT!<unnamed>}
>> GRAVE: local stack = [OUT!<unnamed>]
>> GRAVE: A.generateAppChannel(1 : Muml!CallOperationAction;) : ??#26
>> 413:9-413:36
>> GRAVE: local variables = {b=OUT!Operation_0, i=0,
>> coa=IN!CallOperationAction_0, self=UML_2_SymTAS : ASMModule}
>> GRAVE: local stack = []
>>
>> GRAVE: Muml!Element;.getPriority() : ??#7 116:2-116:82
>> //Here is the problem
>>
>> GRAVE: local variables = {self=IN!Operation_0}
>> GRAVE: local stack = []
>> GRAVE: ****** END Stack Trace
>>
>> So if we look at this line in your transformation we see:
>>
>> 114 --Sollte die SchedPolicy zurückgeben, tut's aber nicht
>> 115 helper context uml!Element def: getPriority() : Integer =
>> 116 self.getValue(self.getAppliedStereotype('SaCommStep'), 'priority');
>>
>> if we put a debug instruction on self.getAppliedStereotype('SaCommStep')
>> we obtain ... self.getAppliedStereotype('SaCommStep').debug('maybe it is
>> undefined') ...
>>
>> At the execution of the transformation, just before the exception we
>> have:
>> INFO: maybe it is undefined: OclUndefined
>>
>> So we see that self.getAppliedStereotype('SaCommStep') return a null
>> value, so you can not get the value of the 'priority' attribute from
>> null and it throws the NullPointerException.
>>
>> As I have said in the previous mail:
>>
>>> Note that the "getAppliedStereotype(stereotypeName : String)" method
>>> takes the fully qualified name of the stereotype as parameter, so
>>> something like "profileName::StereotypeName". Without the fully
>>> qualified name, the stereotypes can not be found.
>>
>> You must use with getAppliedStereotype(stereotypeName : String) the
>> fully qualified name of the stereotype.
>>
>> Here it is : 'MARTE::MARTE_AnalysisModel::SAM::SaCommStep'
>>
>> So if you change:
>>
>> So if we look at this line in your transformation we see:
>>
>> 114 --Sollte die SchedPolicy zurückgeben, tut's aber nicht
>> 115 helper context uml!Element def: getPriority() : Integer =
>> 116 self.getValue(self.getAppliedStereotype('SaCommStep'), 'priority');
>>
>> by:
>>
>> 114 --Sollte die SchedPolicy zurückgeben, tut's aber nicht
>> 115 helper context uml!Element def: getPriority() : Integer = 116
>> self.getValue(
>> 117self.getAppliedStereotype('MARTE::MARTE_AnalysisModel::SA M::SaCommStep')
>>
>> 118 .debug('maybe it is undefined'), 'priority');
>>
>> your transformation will be executed without error, and you will see in
>> the ATL console:
>>
>> INFO: maybe it is undefined: marte!SaCommStep
>>
>> So you see it is not undefined yet. And your output model is created.
>>
>> Next are answers to your new questions:
>>
>> Arnd a écrit :
>>> Hello Guillaume!
>>>
>>> You made a good point about not seeing Stereotypes on my model in
>>> your papyrus. It seems that models I create cannot be easily
>>> transferred to other computers, seems to be some papyrus-bug on my
>>> system. My assisting tudor confirmed that his papyrus can't see
>>> stereotypes on the models I sent him, and his ATL didn't do so either.
>>>
>>> So we recreated the model on his system, and the same
>>> NullPointerException happened, when we tried to transform it with
>>> ATL. The faulty ATL-code can only be executed if the helper
>>> "CallOperationAction.isChannel()" returns true, and that only happens
>>> when the correct stereotypes are applied, so his ATL sees the
>>> stereotypes too. My papyrus can show his model with stereotypes, so
>>> we assume this is a valid uml-model, and my ATL transformation throws
>>> a NullPointerException as well.
>>>
>>> I tested this, so I know that on my system and on the system of my
>>> assisting tudor it works like this.
>>>
>>> Thank you for correcting my programming style in public, but I did
>>> not ask for it. I would rather like it a bit more private. Though, I
>>> have looked at your proposals, and have two questions:
>>>
>>> 1. Matched rules are called automatically and produce their output
>>> element right under the root node of the output model. I don't want this
>>> to happen, but I can't stop it. So I chose called rules. Because of this
>>> behavior, if I insert one of the matched rules you proposed, the output
>>> is not equivalent. I tested this, so... Is there a way to stop them from
>>> being called automatically?
>>>
>>
>> Matched rules are called automatically and produce their output element
>> tight under the root node only if you did not link it with a container
>> structural feature.
>>
>> The type of matched rule I proposed must be used with links like the
>> links I proposed in your following question to obtained a correct tree.
>>
>> You can look at
>> http://www.eclipse.org/m2m/atl/atlTransformations/Class2Rela tional/ExampleClass2Relational%5Bv00.01%5D.pdf
>>
>> to have an example of how to obtain a good tree with declarated rules.
>>
>>
>>
>>> 2. For the main rule, you propose a code like this:
>>> "ar:symtas!ArchitectureType(bus<-uml!Class.allInstancesFrom('IN')- >select(c|c.isBus())),"
>>>
>>> but if I insert it and test the transformation, there's another
>>> exception:
>>> "SCHWERWIEGEND: cannot set feature symtas!ArchitectureType.bus to value
>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1c36942 (eClass:
>>> org.eclipse.emf.ecore.impl.EClassImpl@48bddf (name: ArchitectureCPU)
>>> (instanceClassName: null) (abstract: false, interface: false))
>>> java.lang.RuntimeException: cannot set feature
>>> symtas!ArchitectureType.bus to value
>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1c36942 (eClass:
>>> org.eclipse.emf.ecore.impl.EClassImpl@48bddf (name: ArchitectureCPU)
>>> (instanceClassName: null) (abstract: false, interface: false))"
>>
>> I have just done a proposition of declarative code, I did not know your
>> output metamodel , so this code was only guide lines and not a code to
>> copy/paste.
>> Sorry if I have not been clear on it.
>>
>> Here, I may have make a mistake on the attribute type I wanted to
>> reference.
>>
>>> Again, the output is not equivalent(*g*), so what am I doing wrong here?
>>>
>>
>> The output can not be equivalent because if an error occurs during the
>> transformation the output model will be corrupted.
>>
>>
>>>
>>> Please don't put too much effort into answering these questions, I asked
>>> for help at a point where I need it, and I would appreciate if you had a
>>> closer look at what's wrong with my tagged value problem. I will send
>>> you the model I and my assisting tudor created, perhaps it might be
>>> helpful, if you recreated a similar uml model on your system and try
>>> to transform that. If you cannot reproduce the Exception this way
>>> either, it seems our problem is rather a papyrus problem than an ATL
>>> problem.
>>>
>>> Regards,
>>>
>>> Arnd
>>>
>>
>> Best regards,
>>
>> Guillaume.
>>
>>>
>>> Guillaume Doux schrieb:
>>>> Hi Arnd,
>>>>
>>>> I have looked at your transformation and I can not reproduce your
>>>> exceptions, because the elements in the source model does not seem
>>>> to have any stereotypes
>>>>
>>>> applied.
>>>>
>>>> (cf: - In papyrus, the Profile item on the "Properties" view is
>>>> empty for the "Class_0"
>>>> - In ATL the result of getAppliedStereotypes() on each elements
>>>> where hasStereotypes is called return an empty sequence.)
>>>>
>>>> So your problem may happen during the creation of the source model.
>>>>
>>>>
>>>> I will try to answer to your question without testing it, but by
>>>> giving you the more generals infomations needed to correct it by
>>>> yourself.
>>>>
>>>>
>>>> I have look more precisely at the way you use to retrieve the tagged
>>>> value in the model, and it is not done correctly.
>>>> - First, you did not have to use the MARTE profile has an entry
>>>> model or metamodel in order to read tagged value. So the header of
>>>> your ATL
>>>>
>>>> transformation must be :
>>>>
>>>> module UML_2_SymTAS; -- Module Template
>>>> create OUT : symtas from IN : uml;
>>>>
>>>> And so you don't have to specify the MARTE profile in the launch
>>>> configuration because it will already be referenced in your source
>>>> model
>>>> (maybe you will have to modify manually the source model to point to
>>>> the good location for the MARTE profile file)
>>>>
>>>> Note that the "getAppliedStereotype(stereotypeName : String)" method
>>>> takes the fully qualified name of the stereotype as parameter, so
>>>> something like "profileName::StereotypeName". Without the fully
>>>> qualified name, the stereotypes can not be found.
>>>>
>>>> This is now summarised in the ATL Howtos at
>>>> http://wiki.eclipse.org/ATL_Howtos#How_can_I_retrieve_tagged _values_from_stereotyped_UML_model_elements.3F
>>>>
>>>> (Do not worry if you have not seen it before, it is newly added)
>>>> On this howto you have also another version of the hasStereotype
>>>> helper which uses the fully qualified name.
>>>>
>>>>
>>>> Thirdly, by looking at your ATL code, it seems that you sometimes
>>>> try to reimplement predefined methods. As example, we can see:
>>>> - eqStr(String, String) : Boolean, the "=" between two String
>>>> may be sufficent,
>>>> - isOfType(String) : Boolean, a oclIsTypeOf(t : oclType) and
>>>> oclIsKindOf(t : oclType) returning a Boolean are already defined.
>>>> (See page 16 on the ATL
>>>>
>>>> manual) The argument for this method is an oclType, so you can just
>>>> put something like UML!Class if you want to know if your element is
>>>> an UML class, or
>>>>
>>>> symtas!ArchitectureType if you want to now if your element is an
>>>> architecureType from symtas.
>>>>
>>>> In your code you use also mostly imperative satements in a do block
>>>> with calls to called rules. This type of programming is not
>>>> recommended, the declarative
>>>>
>>>> way is simpler and cleaner. The imperative style is only here for
>>>> very specific operations, and it seems that you did not have to use it.
>>>> Moreover, when you write something like in the do section of the
>>>> main rule:
>>>>
>>>> for (c in uml!Class.allInstances()) {
>>>> if (c.isBus()) {
>>>> ar.bus <- thisModule.generateArchBus(c.getInstance());
>>>> }
>>>> if (c.isCPU()) {
>>>> ar.cpu <- thisModule.generateArchCPU(c.getInstance());
>>>> }
>>>> }
>>>>
>>>> the for loop you use made the same things that the ATL engine does
>>>> when it calls declarative rule, so this type of code is useless and
>>>> takes you far away from
>>>>
>>>> the ATL language.
>>>> for example,
>>>> for (c in uml!Class.allInstances()) {
>>>> if (c.isBus()) {
>>>> ar.bus <- thisModule.generateArchBus(c.getInstance());
>>>> }
>>>> if (c.isCPU()) {
>>>> ar.cpu <- thisModule.generateArchCPU(c.getInstance());
>>>> }
>>>> }
>>>>
>>>> and
>>>>
>>>> rule generateArchBus(name : String) {
>>>> to
>>>> b : symtas!ArchitectureBus
>>>> do {
>>>> b.name <- name;
>>>> b.xPosition <- 0;
>>>> b.yPosition <- 0;
>>>> b.width <- 0;
>>>> b.height <- 0;
>>>> b.busspeed <- thisModule.generateBusspeed(1);
>>>> b.speedup <- thisModule.generateSpeedup();
>>>> b.ports <- thisModule.generateResourcePort();
>>>> b; }
>>>> }
>>>>
>>>> and
>>>>
>>>> rule generateArchCPU(name : String) {
>>>> to
>>>> b : symtas!ArchitectureCPU
>>>> do {
>>>> b.name <- name;
>>>> b.xPosition <- 0;
>>>> b.yPosition <- 0;
>>>> b.width <- 0;
>>>> b.height <- 0;
>>>> b.speedup <- thisModule.generateSpeedup();
>>>> b.ports <- thisModule.generateResourcePort();
>>>> b; }
>>>> }
>>>>
>>>> is equivalent to a declarative the 2 following rules:
>>>>
>>>> rule Class2ABUS {
>>>> from
>>>> s : UML!Class (s.isBus())
>>>> to
>>>> archBus : symtas!ArchitectureBus(
>>>> name <- s.name,
>>>> xPosition <- 0,
>>>> yPosition <- 0,
>>>> width <- 0,
>>>> height <- 0,
>>>> busspeed <- thisModule.generateBusspeed(1),
>>>> speedup <- thisModule.generateSpeedup(),
>>>> ports <- thisModule.generateResourcePort(),
>>>> )
>>>> }
>>>>
>>>> rule Class2ACPU {
>>>> from
>>>> s : UML!Class (s.isBus())
>>>> to
>>>> archBus : symtas!ArchitectureCPU(
>>>> name <- s.name,
>>>> xPosition <- 0,
>>>> yPosition <- 0,
>>>> width <- 0,
>>>> height <- 0,
>>>> b.speedup <- thisModule.generateSpeedup(),
>>>> b.ports <- thisModule.generateResourcePort()
>>>> )
>>>> }
>>>>
>>>> with somlething like that in your main rule:
>>>> -- Haupttransformationsregel für einmalige Wurzeltransformation
>>>> rule Model2System {
>>>> from
>>>> -- Eingabemodell
>>>> m : uml!Model
>>>> to
>>>> ... (the other element you want to create in the same way as
>>>> the following)
>>>> ar : symtas!ArchitectureType(
>>>> bus <- uml!Class.allInstancesFrom('IN')->select(c |
>>>> c.isBus()),
>>>> cpu <- uml!Class.allInstancesFrom('IN')->select(c |
>>>> c.isCPU()),
>>>> ...
>>>> ),
>>>> ...
>>>> }
>>>>
>>>> With this, you can also use the same way to replace the call to
>>>> thisModule.generateSpeedup() and others in the matching rules.
>>>>
>>>> This type of programming allows you to do all your rules without any
>>>> "do" sections and imperatives blocks.
>>>>
>>>> Your transformation will be much simpler.
>>>>
>>>>
>>>> You should use the various ATL constructs in this preference order:
>>>> - standard matched rules,
>>>> - unique lazy rules,
>>>> - lazy rules,
>>>> - called rules
>>>>
>>>> As you can infer from this list, the prefered style is declarative.
>>>> If you cannot do something with it (i.e., standard, unique lazy, and
>>>> lazy rules are not
>>>>
>>>> enough) then you may use imperative blocks.
>>>> You can also remove all the () in your helpers which
>>>> have no parameters because your transformation will be faster (cf.
>>>> the ATL manual about attribute helper
>>>>
>>>> caching).
>>>> Note that you must also remove the () at the calling sites.
>>>>
>>>> You can look at the ATL manual for other predefined ATL functions:
>>>> http://www.eclipse.org/m2m/atl/doc/ATL_User_Manual%5Bv0.7%5D .pdf
>>>>
>>>>
>>>>
>>>> I hope all of this can help you to do your work, if you have any
>>>> other questions feel free to ask again in the newsgroup.
>>>>
>>>>
>>>> Best regards.
>>>>
>>>> Guillaume.
>>>>
>>>>
>>>>
>>>> Arnd a écrit :
>>>>> Dear Hugo!
>>>>>
>>>>> I have the same problem using the MARTE profile... When I try to
>>>>> define an input profile, eclipse wants me to pick a file from my
>>>>> workspace or my File System... What kind of file is needed here?
>>>>>
>>>>> Greetings,
>>>>>
>>>>> Bragenheim
>>>>>
>>>>>
>>>>> Hugo Bruneliere schrieb:
>>>>>> Hi Rasha,
>>>>>>
>>>>>> First, do you pass the definition of the profile (which is a UML
>>>>>> model) as an input of your transformation?
>>>>>>
>>>>>> Rasha a écrit :
>>>>>>> I have only another helper �hasStereotype� which I tested
>>>>>>> separately and works fine. I attached the whole transformation file.
>>>>>>>
>>>>>>>
>>>>>>> ---This helper define the method "hasStereotype"
>>>>>>> helper context UML!"uml::Element" def: hasStereotype(stereotype :
>>>>>>> String) : Boolean =
>>>>>>> self.getAppliedStereotypes()-> exists (c | c.name = stereotype);
>>>>>>>
>>>>>>> ---This helper define the method "getTaggedValue"
>>>>>>> helper context UML!"uml::Element" def: getTaggedValue(stereo :
>>>>>>> String ,tag : String) : UML!"uml::Element" =
>>>>>>> self.getValue(self.getAppliedStereotype(stereo),tag);
>>>>>>>
>>>>>>
>>>>>> Are you sure the getValue method is actually returning a
>>>>>> uml::Element?
>>>>>> What happens if the property of the given stereotype is of type
>>>>>> String or Integer?
>>>>>>
>>>>>>> ---This helper verifies if the value of the proterty 'myProperty'
>>>>>>> is different of 'value1'
>>>>>>> helper context UML!"uml::Element" def : checkMyPropertyValue() :
>>>>>>> Boolean =
>>>>>>> if (self.hasStereotype('MyStereotype')) then
>>>>>>> if
>>>>>>> (self.getTaggedValue('MyStereotype','myProperty')<>'value1') then
>>>>>>> true
>>>>>>> else false
>>>>>>> endif
>>>>>>> else
>>>>>>> true
>>>>>>> endif;
>>>>>>>
>>>>>>> rule Copyclass{
>>>>>>> from
>>>>>>> s : UML!Class (s.checkMyPropertyValue())
>>>>>>> to t : UML!Class( name <- s.name
>>>>>>> )
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> Best Regards,
>>>>>>>
>>>>>>> Rasha
>>>>>>>
>>>>>>>
>>>>>>
>>>>>> Best regards,
>>>>>>
>>>>>> Hugo
>>>>>>
>>>>>>
>>>
>>>
>>
Previous Topic:[ATL] Filtering target elements based on global variable
Next Topic:[ATL]
Goto Forum:
  


Current Time: Fri Apr 26 08:11:57 GMT 2024

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

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

Back to the top