[ATL] BPMN2BPEL-sample, helper-functions not clear [message #556212] |
Tue, 31 August 2010 07:28  |
Eclipse User |
|
|
|
Hello!
Below are helpers from BPMN2BPEL - transformation sample, form the section "XML2BPMN". Could someone please explain in short, what these 4 helpers
getAttrVal, getSon, getName and getNodeType
exactly do?
Thank you very much!
Alexey
helper context XML!Element def: getAttrVal(name : String) : String = let a : Sequence(XML!Attribute) = self.children->select(c |
c.oclIsTypeOf(XML!Attribute) and c.name = name) in
if a.isEmpty() then
''
else
a.first().value
endif;
helper context XML!Element def: getSon(name : String) : Sequence(XML!Element) =
self.children->select(c | c.name = name);
helper context XML!Element def: getName: String =
self.children->select(c | c.oclIsTypeOf(XML!Element) and c.name = 'name')->first().children
->select(d | d.oclIsTypeOf(XML!Element) and d.name = 'text')->first().children
->select(e | e.oclIsKindOf(XML!Text))->first().value;
--
--
--
helper def: getNodeType(type : String) : BPMN!NodeType =
if (type='MessageEvent')
then #MessageEvent
else if (type='StartEvent')
then #StartEvent
else if (type='TimerEvent')
then #TimerEvent
else if (type='XOR-Join')
then #XORJoin
else if (type='EBXOR-Join')
then #EBXORJoin
else if (type='AND-Join')
then #ANDJoin
else if (type='AND-Split')
then #ANDSplit
else if (type='EndEvent')
then #EndEvent
else if (type='XOR-Split')
then #XORSplit
else #EBXORSplit
endif
endif
endif
endif
endif
endif
endif
endif
endif;
|
|
|
Re: [ATL] BPMN2BPEL-sample, helper-functions not clear [message #556238 is a reply to message #556212] |
Tue, 31 August 2010 08:18  |
Eclipse User |
|
|
|
Le 31/08/2010 13:28, Alexey a écrit :
> Hello!
> Below are helpers from BPMN2BPEL - transformation sample, form the
> section "XML2BPMN". Could someone please explain in short, what these 4
> helpers
> getAttrVal, getSon, getName and getNodeType
> exactly do?
Most of them are factorized code ie centralize some operations that
could be needed in more than one place in the transformation.
ATL is a declarative language, which implies functional writing of
operations. Trying to understand what those simple helpers do could be a
good exercise if you are not comfortable with functional languages :-)
As ATL is one of them, you need to be easier with this way to code (and
think) if yout have to work with. So it may be not a help to you to
translate them in procedural equivalent....
> Thank you very much!
>
> Alexey
>
>
>
>
> helper context XML!Element def: getAttrVal(name : String) : String = let
> a : Sequence(XML!Attribute) = self.children->select(c |
> c.oclIsTypeOf(XML!Attribute) and c.name = name) in
> if a.isEmpty() then
> ''
> else
> a.first().value
> endif;
>
> helper context XML!Element def: getSon(name : String) :
> Sequence(XML!Element) =
> self.children->select(c | c.name = name);
>
> helper context XML!Element def: getName: String =
> self.children->select(c | c.oclIsTypeOf(XML!Element) and c.name =
> 'name')->first().children
> ->select(d | d.oclIsTypeOf(XML!Element) and d.name =
> 'text')->first().children
> ->select(e | e.oclIsKindOf(XML!Text))->first().value;
> --
> --
> --
> helper def: getNodeType(type : String) : BPMN!NodeType =
> if (type='MessageEvent')
> then #MessageEvent
> else if (type='StartEvent')
> then #StartEvent
> else if (type='TimerEvent')
> then #TimerEvent
> else if (type='XOR-Join')
> then #XORJoin else if (type='EBXOR-Join')
> then #EBXORJoin
> else if (type='AND-Join')
> then #ANDJoin
> else if (type='AND-Split')
> then #ANDSplit
> else if (type='EndEvent')
> then #EndEvent
> else if (type='XOR-Split')
> then #XORSplit
> else #EBXORSplit
> endif
> endif
> endif
> endif
> endif
> endif
> endif
> endif
> endif;
>
--
Cordialement
Vincent MAHÉ
Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
|
|
|
Powered by
FUDForum. Page generated in 0.06324 seconds