SOLVED: [ATL] How to transform only one element of the same id [message #548910] |
Fri, 23 July 2010 13:10 |
Roger80 Messages: 79 Registered: May 2010 |
Member |
|
|
I have in a class 5 instances, these instances are:
<Participant id='30' name='Consultant'>
<Participant id='31' name='Credit clerk'>
<Participant id='30' name='Consultant'>
<Participant id='32' name='Head of credit department'>
<Participant id='30' name='Consultant'>
So, I have 3 times < Participant id='30' name ='Consultant'>, but I just want it once. How can I do that?
I tried with an iteration, but as I always just have one value after the the iterator says he cannot iterate on non-collection.
Rule looks like:
rule Role2Lane {
from
d : EPK!Participant
to
b:BPMN!Lane
(
--id <- e.flatParticpant(e.name),
id <- d.name -> iterate(e; res : Set(EPK!Participant) = Set {} |
if (res->collect(f | f.name)->includes(e.name)) then
res
else
res->including(e)
endif
)-- here we keep only one element of each name value
->collect(e | thisModule.Definition(e))
)
}
lazy rule Definition {
from
s : EPK!Participant
to
t : BPMN!Lane(
name <- s.name
)
}
Thanks for the help. Cheers Roger
[Updated on: Sun, 25 July 2010 13:56] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Re: [ATL] How to transform only one element of the same id [message #549011 is a reply to message #548998] |
Fri, 23 July 2010 16:37 |
Roger80 Messages: 79 Registered: May 2010 |
Member |
|
|
My rule now looks like:
rule Role2Lane {
from
d : EPK!Participant
to
a : BPMN!LaneSet
(
name <- 'ABC Bank',
id <- '1',
lane <- lan
),
lan : BPMN!LaneE (
id <- thisModule.collection->includes(d)
)
}
My helper:
helper def: collection() : Collection(String) =
EPK!Participant.allInstances()->collect(e | e.id)->asSet()->collect(e | EPK!Participant.allInstances()->select(f | f.id = e)->first());
I got a strange error message:
org.eclipse.m2m.atl.engine.emfvm.VMException: java.lang.String cannot be cast to org.eclipse.emf.ecore.InternalEObject
at __applyApplication#31(EPL2BPMN.atl[109:3-109:20])
local variables: self=EPL2BPMN : ASMModule, link=TransientLink {rule = Application, sourceElements = {c = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@14dec09 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@620402 (name: Application) (instanceClassName: null) (abstract: false, interface: false))}, targetElements = {g = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@808512 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1d93f39 (name: DataAssociation) (instanceClassName: null) (abstract: false, interface: false)), b = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1a07791 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@7d3b8e (name: DataObject) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}, c=IN!Loan application, b=OUT!Loan application, g=OUT!<unnamed>
at __exec__#18(EPL2BPMN.atl)
local variables: self=EPL2BPMN : ASMModule, e=TransientLink {rule = Application, sourceElements = {c = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@14dec09 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@620402 (name: Application) (instanceClassName: null) (abstract: false, interface: false))}, targetElements = {g = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@808512 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1d93f39 (name: DataAssociation) (instanceClassName: null) (abstract: false, interface: false)), b = org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1a07791 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@7d3b8e (name: DataObject) (instanceClassName: null) (abstract: false, interface: false))}, variables = {}}
at main#40(EPL2BPMN.atl)
local variables: self=EPL2BPMN : ASMModule
Do you understand that? I do not understand it...
[Updated on: Fri, 23 July 2010 16:38] Report message to a moderator
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04821 seconds