Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsProblem with rules with "distinct"
https://www.eclipse.org/forums/index.php/mv/msg/12726/39857/#msg_39857
Originally posted by: tristan.faure.c-s.fr
I have this code
rule Package2System {
from
p : UML!Package (p.oclIsTypeOf(UML!Package))
using {
seq : Sequence(UML!Operations) = p.getOperations() ;
}
to
s : _IF!System (
id <- p.name,
signal <- completesignal,
signal <- callsignal,
signal <- returnsignal,
process <- p.getProcesses(),
process <- thisModule.createGroupManager()
),
completesignal : _IF!Signal (
id <- 'u2i__complete'
),
callsignal : distinct _IF!Signal foreach (e in seq)(
id <- 'u2i__call_' + e.owner.name + '_' + e.name,
-- default parameters for a call signal
fparameters <- thisModule.newVariable ('waiting','pid'),
fparameters <- thisModule.newVariable ('caller','pid'),
fparameters <- thisModule.newVariable ('callerObj','pid'),
fparameters <- thisModule.newVariable ('callee','pid')
--fparameters <- e.ownedParameter
),
returnsignal : distinct _IF!Signal foreach (i in seq)(
id <- 'u2i__return_' + i.owner.name + '_' + i.name,
-- default parameters for a return signal
fparameters <- thisModule.newVariable ('callerObj','pid'),
fparameters <- thisModule.newVariable ('callee','pid')
--fparameters <- i.ownedParameter->select (a | a.name = 'return')
)
}
the code commented (fparameters <- ...) means that i want that each
parameter of the current operation (the sequence) will be inserted here
using this matched rule :
rule Parameter2Variables {
from
p : UML!Parameter (p.name.size() <> 0)
to
v : _IF!Vars (
name <- p.name,
type <- p.type.name
}
}
But this doesn't work except if i make a restriction on the parameter like
this :
fparameters <- e.ownedParameter.first()
I don't understand why when there is some parameter they can't be added :(
because of the distinct ???]]>2007-05-22T08:28:54-00:00Re: [ATL] Problem with rules with "distinct"
https://www.eclipse.org/forums/index.php/mv/msg/12726/39918/#msg_39918
Do not forget to prefix your subject with the [ATL] prefix.
Can we see the definition of the class _IF!Signal from your KM3
metamodel ? It will be easier to help you with these informations.
--
Éric Vépa
SODIUS
6, rue de Cornouaille
44319 Nantes - France
Email: evepa@sodius.com
www.mdworkbench.com
Draw more value from your models
so the signal:
<eClassifiers xsi:type="ecore:EClass" name="Signal"
eSuperTypes="#//Element">
<eStructuralFeatures xsi:type="ecore:EReference" name="fparameters"
upperBound="-1"
eType="#//Vars" containment="true"/>
</eClassifiers>
and Vars :
<eClassifiers xsi:type="ecore:EClass" name="Vars">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="mode"
eType="#//ParametersMode"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
lowerBound="1" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
</eClassifiers>]]>2007-05-22T09:28:44-00:00Re: [ATL] Problem with rules with "distinct"
https://www.eclipse.org/forums/index.php/mv/msg/12726/40043/#msg_40043
Is the issue you mention here different from the one you posted in: http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg00816.html
?
If not, please see my answer to your other post. Otherwise, could you
please first confirm that the first issue has been solved, and that this
is a different one?
Thanks,
Frédéric Jouault
Tristan FAURE wrote:
> Hi sorry for the [ATL] i forgot
>
> so the signal:
> <eClassifiers xsi:type="ecore:EClass" name="Signal"
> eSuperTypes="#//Element">
> <eStructuralFeatures xsi:type="ecore:EReference" name="fparameters"
> upperBound="-1"
> eType="#//Vars" containment="true"/>
> </eClassifiers>
>
> and Vars :
>
> <eClassifiers xsi:type="ecore:EClass" name="Vars">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="type"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="mode"
> eType="#//ParametersMode"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="value"
> lowerBound="1" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> </eClassifiers>
>]]>Frédéric Jouault2007-05-22T11:06:15-00:00Re: [ATL] Problem with rules with "distinct"
https://www.eclipse.org/forums/index.php/mv/msg/12726/40103/#msg_40103
Originally posted by: tristan.faure.c-s.fr
My probleme is that I iterate on all operations in a package
for each operation I had some predefined signals.
And i have to iterate on the parameters of the iterate operations. In the
other problem I have the impression that Pirit tried to iterate on the
same collection. Here I iterate on an element from the collection iterated.
I don't know if you understand what I mean :$
I put the necessary code with comments
-- I use all the operations of the package
using {
seq : Sequence(UML!Operations) = p.getOperations() ;
}
s : _IF!System (
id <- p.name,
-- here I had the signals in my signal collection in System
signal <- completesignal,
signal <- callsignal,
signal <- returnsignal,
),
completesignal : _IF!Signal (
id <- 'u2i__complete'
),
-- I create a signal for each operation
callsignal : distinct _IF!Signal foreach (e in seq)(
id <- 'u2i__call_' + e.owner.name + '_' + e.name,
-- default parameters for a call signal
fparameters <- thisModule.newVariable ('waiting','pid'),
fparameters <- thisModule.newVariable ('caller','pid'),
fparameters <- thisModule.newVariable ('callerObj','pid'),
fparameters <- thisModule.newVariable ('callee','pid'),
-- I want to add in my collection fparameters in the signal generated the
parameters of the operation iterated using my matched rule
Parameter2Variable
fparameters <- e.ownedParameter
),
....
And I constated that there is no problem when i use the method first() on
the collection and where there is just one parameter . . .
regards and sorry :/]]>2007-05-22T12:51:21-00:00Re: [ATL] Problem with rules with "distinct"
https://www.eclipse.org/forums/index.php/mv/msg/12726/40132/#msg_40132
Well, I am not 100% sure that your problem is the same.
However, if you did not use "distinct"-"foreach", it is possible that
you would not have such a problem. The main issue is the relatively
cryptic semantics of this construct, which is why it has been deprecated
in favor of lazy rules.
Could you please try to use lazy rules instead?
Regards,
Frédéric Jouault
Tristan FAURE wrote:
> I think I don't have the same problem of Pirit present here
> http://dev.eclipse.org/newslists/news.eclipse.modeling.m2m/m sg00815.html
>
> My probleme is that I iterate on all operations in a package
> for each operation I had some predefined signals.
> And i have to iterate on the parameters of the iterate operations. In
> the other problem I have the impression that Pirit tried to iterate on
> the same collection. Here I iterate on an element from the collection
> iterated.
>
> I don't know if you understand what I mean :$
>
> I put the necessary code with comments
>
> -- I use all the operations of the package
> using {
> seq : Sequence(UML!Operations) = p.getOperations() ;
> }
>
> s : _IF!System (
> id <- p.name,
> -- here I had the signals in my signal collection in System
> signal <- completesignal,
> signal <- callsignal,
> signal <- returnsignal,
> ),
>
> completesignal : _IF!Signal (
> id <- 'u2i__complete'
> ),
>
> -- I create a signal for each operation
> callsignal : distinct _IF!Signal foreach (e in seq)(
> id <- 'u2i__call_' + e.owner.name + '_' + e.name,
> -- default parameters for a call signal
> fparameters <- thisModule.newVariable ('waiting','pid'),
> fparameters <- thisModule.newVariable ('caller','pid'),
> fparameters <- thisModule.newVariable ('callerObj','pid'),
> fparameters <- thisModule.newVariable ('callee','pid'),
> -- I want to add in my collection fparameters in the signal generated
> the parameters of the operation iterated using my matched rule
> Parameter2Variable
> fparameters <- e.ownedParameter
> ),
> ....
>
> And I constated that there is no problem when i use the method first()
> on the collection and where there is just one parameter . . .
>
> regards and sorry :/
>]]>Frédéric Jouault2007-05-22T12:56:34-00:00Re: [ATL] Problem with rules with "distinct"
https://www.eclipse.org/forums/index.php/mv/msg/12726/40197/#msg_40197
Originally posted by: tristan.faure.c-s.fr
I love you :)
In fact I didn't understand what was the use of lazy rule and i already
have a matched rule Operation2
with this i can have Operation2... => match rule
and Operation2Signal => lazy rule
thank you so much !!!!]]>2007-05-22T13:15:40-00:00Re: [ATL] Problem with rules with "distinct"
https://www.eclipse.org/forums/index.php/mv/msg/12726/40564/#msg_40564
>
> In fact I didn't understand what was the use of lazy rule and i already
> have a matched rule Operation2
>
> with this i can have Operation2... => match rule
> and Operation2Signal => lazy rule
>
> thank you so much !!!!