1.At 12:39 PM
on Jul 25, 2008,
Christian W. Damus
wrote:
Re: HowTo specify that an EReference must be "mapped" on another?
Hi, Olivier,
EMF doesn't provide, out-o-the-box, any support for such constraints.
However, the MDT UML2 project's extension to EMF's code generation do
implement at least the superset/subset property constraints from
MOF/UML. It appears, though, that your requirement is more general than
simply subsetting.
If you want to generate this, I think you will have to customize EMF's
code generation templates (this isn't difficult). Perhaps this article
can give you some ideas of where to start:
Olivier PATRY wrote:
> Hi,
>
> I had an EReference from A to B named "bs", I want synchronize contents
> of this EReference (A::EList
) to another one.
>
> a.add(b) -> must add b to a.bs AND add b to somethingelse.somereference
>
> (the types are compatibles)
>
> I can do that in Java generated code
>
> class A {
>
> ...
>
> public void add(B b) {
> bs.add(b);
> magicalWayToGetSomethingElse.add(b);
> }
> }
>
> How can I do this generation automaticaly with my ECore files?
> (I'm able to add EAnnotation to rely a.bs to somethingelse.somereference
> if necessary)
>
> Thanks,
>
> Olivier PATRY
2.At 8:53 AM
on Jul 30, 2008,
Olivier PATRY
wrote:
Re: HowTo specify that an EReference must be "mapped" on another?
Christian W. Damus a écrit :
> Hi, Olivier,
>
> EMF doesn't provide, out-o-the-box, any support for such constraints.
> However, the MDT UML2 project's extension to EMF's code generation do
> implement at least the superset/subset property constraints from
> MOF/UML. It appears, though, that your requirement is more general than
> simply subsetting.
>
> If you want to generate this, I think you will have to customize EMF's
> code generation templates (this isn't difficult). Perhaps this article
> can give you some ideas of where to start:
>
> http://www.eclipse.org/articles/article.php?file=Article-EMF-Codegen-with-OCL/index.html >
>
> HTH,
>
> Christian
>
>
> Olivier PATRY wrote:
>> Hi,
>>
>> I had an EReference from A to B named "bs", I want synchronize
>> contents of this EReference (A::EList
) to another one.
>>
>> a.add(b) -> must add b to a.bs AND add b to somethingelse.somereference
>>
>> (the types are compatibles)
>>
>> I can do that in Java generated code
>>
>> class A {
>>
>> ...
>>
>> public void add(B b) {
>> bs.add(b);
>> magicalWayToGetSomethingElse.add(b);
>> }
>> }
>>
>> How can I do this generation automaticaly with my ECore files?
>> (I'm able to add EAnnotation to rely a.bs to
>> somethingelse.somereference if necessary)
>>
>> Thanks,
>>
>> Olivier PATRY
Hi, thanks for answering.
So, you suggest I put code synchronization in JET templates, typically:
>> public void add(B b) {
>> bs.add(b);
>> magicalWayToGetSomethingElse.add(b);
>> }
That's what I've thinking but I'm not very cool with JET...
HowTo specify that an EReference must be "mapped" on another?
At 12:19 PM on Jul 25, 2008, Olivier PATRY wrote:
I had an EReference from A to B named "bs", I want synchronize contents
of this EReference (A::EList ) to another one.
a.add(b) -> must add b to a.bs AND add b to somethingelse.somereference
(the types are compatibles)
I can do that in Java generated code
class A {
...
public void add(B b) {
bs.add(b);
magicalWayToGetSomethingElse.add(b);
}
}
How can I do this generation automaticaly with my ECore files?
(I'm able to add EAnnotation to rely a.bs to somethingelse.somereference
if necessary)
Thanks,
Olivier PATRY
2 replies so far (
Post your own)
Re: HowTo specify that an EReference must be "mapped" on another?
Hi, Olivier,EMF doesn't provide, out-o-the-box, any support for such constraints.
However, the MDT UML2 project's extension to EMF's code generation do
implement at least the superset/subset property constraints from
MOF/UML. It appears, though, that your requirement is more general than
simply subsetting.
If you want to generate this, I think you will have to customize EMF's
code generation templates (this isn't difficult). Perhaps this article
can give you some ideas of where to start:
http://www.eclipse.org/articles/article.php?file=Article-EMF-Codegen-with-OCL/index.html
HTH,
Christian
Olivier PATRY wrote:
> Hi,
>
> I had an EReference from A to B named "bs", I want synchronize contents
> of this EReference (A::EList ) to another one.
>
> a.add(b) -> must add b to a.bs AND add b to somethingelse.somereference
>
> (the types are compatibles)
>
> I can do that in Java generated code
>
> class A {
>
> ...
>
> public void add(B b) {
> bs.add(b);
> magicalWayToGetSomethingElse.add(b);
> }
> }
>
> How can I do this generation automaticaly with my ECore files?
> (I'm able to add EAnnotation to rely a.bs to somethingelse.somereference
> if necessary)
>
> Thanks,
>
> Olivier PATRY
Re: HowTo specify that an EReference must be "mapped" on another?
Christian W. Damus a écrit :> Hi, Olivier,
>
> EMF doesn't provide, out-o-the-box, any support for such constraints.
> However, the MDT UML2 project's extension to EMF's code generation do
> implement at least the superset/subset property constraints from
> MOF/UML. It appears, though, that your requirement is more general than
> simply subsetting.
>
> If you want to generate this, I think you will have to customize EMF's
> code generation templates (this isn't difficult). Perhaps this article
> can give you some ideas of where to start:
>
> http://www.eclipse.org/articles/article.php?file=Article-EMF-Codegen-with-OCL/index.html
>
>
> HTH,
>
> Christian
>
>
> Olivier PATRY wrote:
>> Hi,
>>
>> I had an EReference from A to B named "bs", I want synchronize
>> contents of this EReference (A::EList ) to another one.
>>
>> a.add(b) -> must add b to a.bs AND add b to somethingelse.somereference
>>
>> (the types are compatibles)
>>
>> I can do that in Java generated code
>>
>> class A {
>>
>> ...
>>
>> public void add(B b) {
>> bs.add(b);
>> magicalWayToGetSomethingElse.add(b);
>> }
>> }
>>
>> How can I do this generation automaticaly with my ECore files?
>> (I'm able to add EAnnotation to rely a.bs to
>> somethingelse.somereference if necessary)
>>
>> Thanks,
>>
>> Olivier PATRY
Hi, thanks for answering.
So, you suggest I put code synchronization in JET templates, typically:
>> public void add(B b) {
>> bs.add(b);
>> magicalWayToGetSomethingElse.add(b);
>> }
That's what I've thinking but I'm not very cool with JET...
Thanks,
Olivier PATRY