Home » Modeling » UML2 » declaring and using a template class
|
Re: declaring and using a template class [message #471812 is a reply to message #471811] |
Tue, 27 March 2007 02:18 |
Rafael Chaves Messages: 362 Registered: July 2009 |
Senior Member |
|
|
Well, I decided to peek at the OCL models, as I knew OCL made use of EMF
generics. OCL comes with both ECore and UML versions of its models.
It seems I was doing things correctly (except for a missing
TemplateBinding in the template class itself, which puzzled me that I
had to do it), but still cannot get the results I want. So I cannot see
a reason for not being able to generate ECore models with generics from
UML models other than that not being supported at all. Please tell me I
am wrong and that I only missed one minor thing...
Rafael Chaves wrote:
> I am having a hard time building a UML model that uses template elements.
>
> For instance, how should I ago about modeling in UML a class equivalent
> to this Java code:
>
> class List<T> {
> public void add(T o) {...}
> public T get(int pos) {...}
> }
>
> and then bind that template with class Account, generating a type that
> is a list of accounts?
>
> I believe this can be done in EMF, but can it be done if modeling is
> done in UML2? How?
>
> I am still going through the specs for Templates (section 17.5), but so
> far it is not clear if I can do it in UML2. I have built the model
> attached, created a genmodel from it, but the resulting ECore model
> treats the template parameter class as a regular class. Can anyone see
> what I am doing wrong/missing?
>
> Thanks,
>
> Rafael
>
>
> ------------------------------------------------------------ ------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML" xmi:id="_SbY9YNvCEdunJ--GsIRueA" name="My">
> <packagedElement xmi:type="uml:Class" xmi:id="_bG2RoNvCEdunJ--GsIRueA" name="List">
> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature" xmi:id="_Td5xANvHEdunJ--GsIRueA" name="List Signature" parameter="_VfIB4NvHEdunJ--GsIRueA">
> <ownedParameter xmi:type="uml:ClassifierTemplateParameter" xmi:id="_VfIB4NvHEdunJ--GsIRueA" parameteredElement="_PqhDUNvlEduCr7xIhpvxLA" allowSubstitutable="false">
> <ownedParameteredElement xmi:type="uml:Class" xmi:id="_PqhDUNvlEduCr7xIhpvxLA" name="P" templateParameter="_VfIB4NvHEdunJ--GsIRueA"/>
> </ownedParameter>
> </ownedTemplateSignature>
> <ownedOperation xmi:id="_B8SSYNvdEdunJ--GsIRueA" name="op1">
> <ownedParameter xmi:id="_iO2okNviEdunJ--GsIRueA" name="p" type="_PqhDUNvlEduCr7xIhpvxLA"/>
> </ownedOperation>
> </packagedElement>
> <packagedElement xmi:type="uml:Class" xmi:id="_qayvQNviEdunJ--GsIRueA" name="ListOfAccounts">
> <templateBinding xmi:id="_uS63YNviEdunJ--GsIRueA">
> <parameterSubstitution xmi:id="_waJpoNviEdunJ--GsIRueA" formal="_VfIB4NvHEdunJ--GsIRueA" actual="_0vf5QNviEdunJ--GsIRueA"/>
> </templateBinding>
> </packagedElement>
> <packagedElement xmi:type="uml:Class" xmi:id="_0vf5QNviEdunJ--GsIRueA" name="Account"/>
> </uml:Model>
|
|
|
Re: declaring and using a template class [message #471813 is a reply to message #471811] |
Tue, 27 March 2007 02:57 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Rafael,
Attached is a sample ecore and uml representation of the example you have.
By the way, a little trick...... if you can create the ecore
representation, you can select the EPackage root, then go to the "Sample
Ecore Editor" menu item and select "convert to UML model ..." and voila...
the uml representation.
There are some new stereotypes in the ecore profile including
<<EGenericType>> and <<ETypeParameter>>.
Along with adding missing concepts from UML, the stereotypes serve as
markers to the uml to ecore converter. In the case of EGenericType, no new
EClass will be generated in the ecore representation. The idea behind this
is that in certain cases, UML requires "artificially generated classes" that
are not required in the ecore representation or in Java.
There are many subtleties concerning generics in UML and an article on this
is in the works.
A very rough draft can be found at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413
Regards,
- James
"Rafael Chaves" <chaves@inf.ufsc.nospam.br> wrote in message
news:eu9ggs$9ga$1@utils.eclipse.org...
>I am having a hard time building a UML model that uses template elements.
>
> For instance, how should I ago about modeling in UML a class equivalent
> to this Java code:
>
> class List<T> {
> public void add(T o) {...}
> public T get(int pos) {...}
> }
>
> and then bind that template with class Account, generating a type that
> is a list of accounts?
>
> I believe this can be done in EMF, but can it be done if modeling is
> done in UML2? How?
>
> I am still going through the specs for Templates (section 17.5), but so
> far it is not clear if I can do it in UML2. I have built the model
> attached, created a genmodel from it, but the resulting ECore model
> treats the template parameter class as a regular class. Can anyone see
> what I am doing wrong/missing?
>
> Thanks,
>
> Rafael
>
------------------------------------------------------------ --------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Model xmi:version="2.1"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> xmi:id="_SbY9YNvCEdunJ--GsIRueA" name="My">
> <packagedElement xmi:type="uml:Class" xmi:id="_bG2RoNvCEdunJ--GsIRueA"
> name="List">
> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
> xmi:id="_Td5xANvHEdunJ--GsIRueA" name="List Signature"
> parameter="_VfIB4NvHEdunJ--GsIRueA">
> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
> xmi:id="_VfIB4NvHEdunJ--GsIRueA"
> parameteredElement="_PqhDUNvlEduCr7xIhpvxLA" allowSubstitutable="false">
> <ownedParameteredElement xmi:type="uml:Class"
> xmi:id="_PqhDUNvlEduCr7xIhpvxLA" name="P"
> templateParameter="_VfIB4NvHEdunJ--GsIRueA"/>
> </ownedParameter>
> </ownedTemplateSignature>
> <ownedOperation xmi:id="_B8SSYNvdEdunJ--GsIRueA" name="op1">
> <ownedParameter xmi:id="_iO2okNviEdunJ--GsIRueA" name="p"
> type="_PqhDUNvlEduCr7xIhpvxLA"/>
> </ownedOperation>
> </packagedElement>
> <packagedElement xmi:type="uml:Class" xmi:id="_qayvQNviEdunJ--GsIRueA"
> name="ListOfAccounts">
> <templateBinding xmi:id="_uS63YNviEdunJ--GsIRueA">
> <parameterSubstitution xmi:id="_waJpoNviEdunJ--GsIRueA"
> formal="_VfIB4NvHEdunJ--GsIRueA" actual="_0vf5QNviEdunJ--GsIRueA"/>
> </templateBinding>
> </packagedElement>
> <packagedElement xmi:type="uml:Class" xmi:id="_0vf5QNviEdunJ--GsIRueA"
> name="Account"/>
> </uml:Model>
>
-
Attachment: My.ecore
(Size: 0.56KB, Downloaded 204 times) -
Attachment: MyPackage.uml
(Size: 2.58KB, Downloaded 226 times)
|
|
|
Re: declaring and using a template class [message #471814 is a reply to message #471812] |
Tue, 27 March 2007 03:15 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Rafael,
UML to Ecore and Ecore to UML are fully supported.
(see the other posting for further explanations)
- James.
"Rafael Chaves" <chaves@inf.ufsc.nospam.br> wrote in message
news:eu9usm$erf$1@utils.eclipse.org...
> Well, I decided to peek at the OCL models, as I knew OCL made use of EMF
> generics. OCL comes with both ECore and UML versions of its models.
>
> It seems I was doing things correctly (except for a missing
> TemplateBinding in the template class itself, which puzzled me that I had
> to do it), but still cannot get the results I want. So I cannot see a
> reason for not being able to generate ECore models with generics from UML
> models other than that not being supported at all. Please tell me I am
> wrong and that I only missed one minor thing...
>
> Rafael Chaves wrote:
>> I am having a hard time building a UML model that uses template elements.
>>
>> For instance, how should I ago about modeling in UML a class equivalent
>> to this Java code:
>>
>> class List<T> {
>> public void add(T o) {...}
>> public T get(int pos) {...}
>> }
>>
>> and then bind that template with class Account, generating a type that is
>> a list of accounts?
>>
>> I believe this can be done in EMF, but can it be done if modeling is done
>> in UML2? How?
>>
>> I am still going through the specs for Templates (section 17.5), but so
>> far it is not clear if I can do it in UML2. I have built the model
>> attached, created a genmodel from it, but the resulting ECore model
>> treats the template parameter class as a regular class. Can anyone see
>> what I am doing wrong/missing?
>>
>> Thanks,
>>
>> Rafael
>>
>>
>> ------------------------------------------------------------ ------------
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <uml:Model xmi:version="2.1"
>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>> xmi:id="_SbY9YNvCEdunJ--GsIRueA" name="My">
>> <packagedElement xmi:type="uml:Class" xmi:id="_bG2RoNvCEdunJ--GsIRueA"
>> name="List">
>> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
>> xmi:id="_Td5xANvHEdunJ--GsIRueA" name="List Signature"
>> parameter="_VfIB4NvHEdunJ--GsIRueA">
>> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
>> xmi:id="_VfIB4NvHEdunJ--GsIRueA"
>> parameteredElement="_PqhDUNvlEduCr7xIhpvxLA" allowSubstitutable="false">
>> <ownedParameteredElement xmi:type="uml:Class"
>> xmi:id="_PqhDUNvlEduCr7xIhpvxLA" name="P"
>> templateParameter="_VfIB4NvHEdunJ--GsIRueA"/>
>> </ownedParameter>
>> </ownedTemplateSignature>
>> <ownedOperation xmi:id="_B8SSYNvdEdunJ--GsIRueA" name="op1">
>> <ownedParameter xmi:id="_iO2okNviEdunJ--GsIRueA" name="p"
>> type="_PqhDUNvlEduCr7xIhpvxLA"/>
>> </ownedOperation>
>> </packagedElement>
>> <packagedElement xmi:type="uml:Class" xmi:id="_qayvQNviEdunJ--GsIRueA"
>> name="ListOfAccounts">
>> <templateBinding xmi:id="_uS63YNviEdunJ--GsIRueA">
>> <parameterSubstitution xmi:id="_waJpoNviEdunJ--GsIRueA"
>> formal="_VfIB4NvHEdunJ--GsIRueA" actual="_0vf5QNviEdunJ--GsIRueA"/>
>> </templateBinding>
>> </packagedElement>
>> <packagedElement xmi:type="uml:Class" xmi:id="_0vf5QNviEdunJ--GsIRueA"
>> name="Account"/>
>> </uml:Model>
|
|
|
Re: declaring and using a template class [message #471976 is a reply to message #471813] |
Wed, 28 March 2007 16:22 |
Rafael Chaves Messages: 362 Registered: July 2009 |
Senior Member |
|
|
Hi James,
Thanks for the reply. Please see my comments inline below
James Bruck wrote:
> Attached is a sample ecore and uml representation of the example you have.
I tried generating an EMF model (genmodel + ecore) from the UML model
you provided and the result was the same I had with my own model. Do you
have different results?
>
> By the way, a little trick...... if you can create the ecore
> representation, you can select the EPackage root, then go to the "Sample
> Ecore Editor" menu item and select "convert to UML model ..." and voila...
> the uml representation.
Thanks for the suggestion, but UML is the native metamodel the tool I am
using generates. So that is not an option, since my starting point is
always UML.
>
> There are some new stereotypes in the ecore profile including
> <<EGenericType>> and <<ETypeParameter>>.
> Along with adding missing concepts from UML, the stereotypes serve as
> markers to the uml to ecore converter. In the case of EGenericType, no new
> EClass will be generated in the ecore representation. The idea behind this
> is that in certain cases, UML requires "artificially generated classes" that
> are not required in the ecore representation or in Java.
That explains why I was not being successful.
>
> There are many subtleties concerning generics in UML and an article on this
> is in the works.
> A very rough draft can be found at
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413
It is raw indeed, but seems to be the best documentation around. Thanks
for the pointer.
Thanks a lot,
Rafael
>
> "Rafael Chaves" <chaves@inf.ufsc.nospam.br> wrote in message
> news:eu9ggs$9ga$1@utils.eclipse.org...
>> I am having a hard time building a UML model that uses template elements.
>>
>> For instance, how should I ago about modeling in UML a class equivalent
>> to this Java code:
>>
>> class List<T> {
>> public void add(T o) {...}
>> public T get(int pos) {...}
>> }
>>
>> and then bind that template with class Account, generating a type that
>> is a list of accounts?
>>
>> I believe this can be done in EMF, but can it be done if modeling is
>> done in UML2? How?
>>
>> I am still going through the specs for Templates (section 17.5), but so
>> far it is not clear if I can do it in UML2. I have built the model
>> attached, created a genmodel from it, but the resulting ECore model
>> treats the template parameter class as a regular class. Can anyone see
>> what I am doing wrong/missing?
>>
>> Thanks,
>>
>> Rafael
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <uml:Model xmi:version="2.1"
>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>> xmi:id="_SbY9YNvCEdunJ--GsIRueA" name="My">
>> <packagedElement xmi:type="uml:Class" xmi:id="_bG2RoNvCEdunJ--GsIRueA"
>> name="List">
>> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
>> xmi:id="_Td5xANvHEdunJ--GsIRueA" name="List Signature"
>> parameter="_VfIB4NvHEdunJ--GsIRueA">
>> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
>> xmi:id="_VfIB4NvHEdunJ--GsIRueA"
>> parameteredElement="_PqhDUNvlEduCr7xIhpvxLA" allowSubstitutable="false">
>> <ownedParameteredElement xmi:type="uml:Class"
>> xmi:id="_PqhDUNvlEduCr7xIhpvxLA" name="P"
>> templateParameter="_VfIB4NvHEdunJ--GsIRueA"/>
>> </ownedParameter>
>> </ownedTemplateSignature>
>> <ownedOperation xmi:id="_B8SSYNvdEdunJ--GsIRueA" name="op1">
>> <ownedParameter xmi:id="_iO2okNviEdunJ--GsIRueA" name="p"
>> type="_PqhDUNvlEduCr7xIhpvxLA"/>
>> </ownedOperation>
>> </packagedElement>
>> <packagedElement xmi:type="uml:Class" xmi:id="_qayvQNviEdunJ--GsIRueA"
>> name="ListOfAccounts">
>> <templateBinding xmi:id="_uS63YNviEdunJ--GsIRueA">
>> <parameterSubstitution xmi:id="_waJpoNviEdunJ--GsIRueA"
>> formal="_VfIB4NvHEdunJ--GsIRueA" actual="_0vf5QNviEdunJ--GsIRueA"/>
>> </templateBinding>
>> </packagedElement>
>> <packagedElement xmi:type="uml:Class" xmi:id="_0vf5QNviEdunJ--GsIRueA"
>> name="Account"/>
>> </uml:Model>
>>
>
>
|
|
|
Re: declaring and using a template class [message #471982 is a reply to message #471976] |
Wed, 28 March 2007 18:00 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Rafael,
The round trip from ecore to uml should be seemless. That is to say that if
you start with an ecore model and convert to uml then convert that uml model
back to ecore, it should be identical to what you started with.
From your comments I'm not sure if you have successfully used generics or
not? You don't seem to be happy with the solution? or am I misreading
something?
A full article would be nice but there simply is not enough time in this
release schedule ... after the M7 timeframe all the articles should be
completed.
Generics in UML is tricky... and bindings in UML can be thought of as a
"merge" rather than true generics in Java or Ecore for that matter, so you
might be seeing some artifacts of this in the mapping.
If you have definite bugs or exceptions to the mapping please let me know or
log a bugzilla.
By the way, I would suggest using the latest integration builds if you are
going to use generics.
Some comments inline below ...
Regards,
- James.
"Rafael Chaves" <chaves@inf.ufsc.nospam.br> wrote in message
news:eue4nd$t26$1@build.eclipse.org...
> Hi James,
>
> Thanks for the reply. Please see my comments inline below
>
> James Bruck wrote:
>
> > Attached is a sample ecore and uml representation of the example you
have.
>
> I tried generating an EMF model (genmodel + ecore) from the UML model
> you provided and the result was the same I had with my own model. Do you
> have different results?
The results are what I posted originally. Those should be equivalent ecore
and uml forms. Note that there are no bindings involved since in that
example we are not using the generic list as a type.
>
> >
> > By the way, a little trick...... if you can create the ecore
> > representation, you can select the EPackage root, then go to the "Sample
> > Ecore Editor" menu item and select "convert to UML model ..." and
voila...
> > the uml representation.
>
> Thanks for the suggestion, but UML is the native metamodel the tool I am
> using generates. So that is not an option, since my starting point is
> always UML.
I was suggesting that as a way of testing if your UML representation would
be correct if you knew the resulting .ecore representation.
Then you would be confident that your original UML model would be in the
correct form.
If you experiment with such conversions then you can see the required
streotypes in UML etc.
This would simply be a way of experimenting to understand the equivalent
forms.
>
> >
> > There are some new stereotypes in the ecore profile including
> > <<EGenericType>> and <<ETypeParameter>>.
> > Along with adding missing concepts from UML, the stereotypes serve as
> > markers to the uml to ecore converter. In the case of EGenericType, no
new
> > EClass will be generated in the ecore representation. The idea behind
this
> > is that in certain cases, UML requires "artificially generated classes"
that
> > are not required in the ecore representation or in Java.
>
> That explains why I was not being successful.
Hopefully you have this working now?
>
> >
> > There are many subtleties concerning generics in UML and an article on
this
> > is in the works.
> > A very rough draft can be found at
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413
>
> It is raw indeed, but seems to be the best documentation around. Thanks
> for the pointer.
Documentation should be completed after M7 when all the features and bugs
have been resolved.
>
> Thanks a lot,
>
> Rafael
>
> >
> > "Rafael Chaves" <chaves@inf.ufsc.nospam.br> wrote in message
> > news:eu9ggs$9ga$1@utils.eclipse.org...
> >> I am having a hard time building a UML model that uses template
elements.
> >>
> >> For instance, how should I ago about modeling in UML a class equivalent
> >> to this Java code:
> >>
> >> class List<T> {
> >> public void add(T o) {...}
> >> public T get(int pos) {...}
> >> }
> >>
> >> and then bind that template with class Account, generating a type that
> >> is a list of accounts?
> >>
> >> I believe this can be done in EMF, but can it be done if modeling is
> >> done in UML2? How?
> >>
> >> I am still going through the specs for Templates (section 17.5), but so
> >> far it is not clear if I can do it in UML2. I have built the model
> >> attached, created a genmodel from it, but the resulting ECore model
> >> treats the template parameter class as a regular class. Can anyone see
> >> what I am doing wrong/missing?
> >>
> >> Thanks,
> >>
> >> Rafael
> >>
> >
> >
>
> ------------------------------------------------------------ --------------
------
> >
> >
> >> <?xml version="1.0" encoding="UTF-8"?>
> >> <uml:Model xmi:version="2.1"
> >> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> >> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> >> xmi:id="_SbY9YNvCEdunJ--GsIRueA" name="My">
> >> <packagedElement xmi:type="uml:Class" xmi:id="_bG2RoNvCEdunJ--GsIRueA"
> >> name="List">
> >> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
> >> xmi:id="_Td5xANvHEdunJ--GsIRueA" name="List Signature"
> >> parameter="_VfIB4NvHEdunJ--GsIRueA">
> >> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
> >> xmi:id="_VfIB4NvHEdunJ--GsIRueA"
> >> parameteredElement="_PqhDUNvlEduCr7xIhpvxLA"
allowSubstitutable="false">
> >> <ownedParameteredElement xmi:type="uml:Class"
> >> xmi:id="_PqhDUNvlEduCr7xIhpvxLA" name="P"
> >> templateParameter="_VfIB4NvHEdunJ--GsIRueA"/>
> >> </ownedParameter>
> >> </ownedTemplateSignature>
> >> <ownedOperation xmi:id="_B8SSYNvdEdunJ--GsIRueA" name="op1">
> >> <ownedParameter xmi:id="_iO2okNviEdunJ--GsIRueA" name="p"
> >> type="_PqhDUNvlEduCr7xIhpvxLA"/>
> >> </ownedOperation>
> >> </packagedElement>
> >> <packagedElement xmi:type="uml:Class" xmi:id="_qayvQNviEdunJ--GsIRueA"
> >> name="ListOfAccounts">
> >> <templateBinding xmi:id="_uS63YNviEdunJ--GsIRueA">
> >> <parameterSubstitution xmi:id="_waJpoNviEdunJ--GsIRueA"
> >> formal="_VfIB4NvHEdunJ--GsIRueA" actual="_0vf5QNviEdunJ--GsIRueA"/>
> >> </templateBinding>
> >> </packagedElement>
> >> <packagedElement xmi:type="uml:Class" xmi:id="_0vf5QNviEdunJ--GsIRueA"
> >> name="Account"/>
> >> </uml:Model>
> >>
> >
> >
|
|
| |
Re: declaring and using a template class [message #603196 is a reply to message #471811] |
Tue, 27 March 2007 02:18 |
Rafael Chaves Messages: 362 Registered: July 2009 |
Senior Member |
|
|
Well, I decided to peek at the OCL models, as I knew OCL made use of EMF
generics. OCL comes with both ECore and UML versions of its models.
It seems I was doing things correctly (except for a missing
TemplateBinding in the template class itself, which puzzled me that I
had to do it), but still cannot get the results I want. So I cannot see
a reason for not being able to generate ECore models with generics from
UML models other than that not being supported at all. Please tell me I
am wrong and that I only missed one minor thing...
Rafael Chaves wrote:
> I am having a hard time building a UML model that uses template elements.
>
> For instance, how should I ago about modeling in UML a class equivalent
> to this Java code:
>
> class List<T> {
> public void add(T o) {...}
> public T get(int pos) {...}
> }
>
> and then bind that template with class Account, generating a type that
> is a list of accounts?
>
> I believe this can be done in EMF, but can it be done if modeling is
> done in UML2? How?
>
> I am still going through the specs for Templates (section 17.5), but so
> far it is not clear if I can do it in UML2. I have built the model
> attached, created a genmodel from it, but the resulting ECore model
> treats the template parameter class as a regular class. Can anyone see
> what I am doing wrong/missing?
>
> Thanks,
>
> Rafael
>
>
> ------------------------------------------------------------ ------------
>
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1" xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML" xmi:id="_SbY9YNvCEdunJ--GsIRueA" name="My">
> <packagedElement xmi:type="uml:Class" xmi:id="_bG2RoNvCEdunJ--GsIRueA" name="List">
> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature" xmi:id="_Td5xANvHEdunJ--GsIRueA" name="List Signature" parameter="_VfIB4NvHEdunJ--GsIRueA">
> <ownedParameter xmi:type="uml:ClassifierTemplateParameter" xmi:id="_VfIB4NvHEdunJ--GsIRueA" parameteredElement="_PqhDUNvlEduCr7xIhpvxLA" allowSubstitutable="false">
> <ownedParameteredElement xmi:type="uml:Class" xmi:id="_PqhDUNvlEduCr7xIhpvxLA" name="P" templateParameter="_VfIB4NvHEdunJ--GsIRueA"/>
> </ownedParameter>
> </ownedTemplateSignature>
> <ownedOperation xmi:id="_B8SSYNvdEdunJ--GsIRueA" name="op1">
> <ownedParameter xmi:id="_iO2okNviEdunJ--GsIRueA" name="p" type="_PqhDUNvlEduCr7xIhpvxLA"/>
> </ownedOperation>
> </packagedElement>
> <packagedElement xmi:type="uml:Class" xmi:id="_qayvQNviEdunJ--GsIRueA" name="ListOfAccounts">
> <templateBinding xmi:id="_uS63YNviEdunJ--GsIRueA">
> <parameterSubstitution xmi:id="_waJpoNviEdunJ--GsIRueA" formal="_VfIB4NvHEdunJ--GsIRueA" actual="_0vf5QNviEdunJ--GsIRueA"/>
> </templateBinding>
> </packagedElement>
> <packagedElement xmi:type="uml:Class" xmi:id="_0vf5QNviEdunJ--GsIRueA" name="Account"/>
> </uml:Model>
|
|
|
Re: declaring and using a template class [message #603201 is a reply to message #471811] |
Tue, 27 March 2007 02:57 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Hi Rafael,
Attached is a sample ecore and uml representation of the example you have.
By the way, a little trick...... if you can create the ecore
representation, you can select the EPackage root, then go to the "Sample
Ecore Editor" menu item and select "convert to UML model ..." and voila...
the uml representation.
There are some new stereotypes in the ecore profile including
<<EGenericType>> and <<ETypeParameter>>.
Along with adding missing concepts from UML, the stereotypes serve as
markers to the uml to ecore converter. In the case of EGenericType, no new
EClass will be generated in the ecore representation. The idea behind this
is that in certain cases, UML requires "artificially generated classes" that
are not required in the ecore representation or in Java.
There are many subtleties concerning generics in UML and an article on this
is in the works.
A very rough draft can be found at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413
Regards,
- James
"Rafael Chaves" <chaves@inf.ufsc.nospam.br> wrote in message
news:eu9ggs$9ga$1@utils.eclipse.org...
>I am having a hard time building a UML model that uses template elements.
>
> For instance, how should I ago about modeling in UML a class equivalent
> to this Java code:
>
> class List<T> {
> public void add(T o) {...}
> public T get(int pos) {...}
> }
>
> and then bind that template with class Account, generating a type that
> is a list of accounts?
>
> I believe this can be done in EMF, but can it be done if modeling is
> done in UML2? How?
>
> I am still going through the specs for Templates (section 17.5), but so
> far it is not clear if I can do it in UML2. I have built the model
> attached, created a genmodel from it, but the resulting ECore model
> treats the template parameter class as a regular class. Can anyone see
> what I am doing wrong/missing?
>
> Thanks,
>
> Rafael
>
------------------------------------------------------------ --------------------
> <?xml version="1.0" encoding="UTF-8"?>
> <uml:Model xmi:version="2.1"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> xmi:id="_SbY9YNvCEdunJ--GsIRueA" name="My">
> <packagedElement xmi:type="uml:Class" xmi:id="_bG2RoNvCEdunJ--GsIRueA"
> name="List">
> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
> xmi:id="_Td5xANvHEdunJ--GsIRueA" name="List Signature"
> parameter="_VfIB4NvHEdunJ--GsIRueA">
> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
> xmi:id="_VfIB4NvHEdunJ--GsIRueA"
> parameteredElement="_PqhDUNvlEduCr7xIhpvxLA" allowSubstitutable="false">
> <ownedParameteredElement xmi:type="uml:Class"
> xmi:id="_PqhDUNvlEduCr7xIhpvxLA" name="P"
> templateParameter="_VfIB4NvHEdunJ--GsIRueA"/>
> </ownedParameter>
> </ownedTemplateSignature>
> <ownedOperation xmi:id="_B8SSYNvdEdunJ--GsIRueA" name="op1">
> <ownedParameter xmi:id="_iO2okNviEdunJ--GsIRueA" name="p"
> type="_PqhDUNvlEduCr7xIhpvxLA"/>
> </ownedOperation>
> </packagedElement>
> <packagedElement xmi:type="uml:Class" xmi:id="_qayvQNviEdunJ--GsIRueA"
> name="ListOfAccounts">
> <templateBinding xmi:id="_uS63YNviEdunJ--GsIRueA">
> <parameterSubstitution xmi:id="_waJpoNviEdunJ--GsIRueA"
> formal="_VfIB4NvHEdunJ--GsIRueA" actual="_0vf5QNviEdunJ--GsIRueA"/>
> </templateBinding>
> </packagedElement>
> <packagedElement xmi:type="uml:Class" xmi:id="_0vf5QNviEdunJ--GsIRueA"
> name="Account"/>
> </uml:Model>
>
-
Attachment: My.ecore
(Size: 0.56KB, Downloaded 195 times) -
Attachment: MyPackage.uml
(Size: 2.58KB, Downloaded 182 times)
|
|
|
Re: declaring and using a template class [message #603204 is a reply to message #471812] |
Tue, 27 March 2007 03:15 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Rafael,
UML to Ecore and Ecore to UML are fully supported.
(see the other posting for further explanations)
- James.
"Rafael Chaves" <chaves@inf.ufsc.nospam.br> wrote in message
news:eu9usm$erf$1@utils.eclipse.org...
> Well, I decided to peek at the OCL models, as I knew OCL made use of EMF
> generics. OCL comes with both ECore and UML versions of its models.
>
> It seems I was doing things correctly (except for a missing
> TemplateBinding in the template class itself, which puzzled me that I had
> to do it), but still cannot get the results I want. So I cannot see a
> reason for not being able to generate ECore models with generics from UML
> models other than that not being supported at all. Please tell me I am
> wrong and that I only missed one minor thing...
>
> Rafael Chaves wrote:
>> I am having a hard time building a UML model that uses template elements.
>>
>> For instance, how should I ago about modeling in UML a class equivalent
>> to this Java code:
>>
>> class List<T> {
>> public void add(T o) {...}
>> public T get(int pos) {...}
>> }
>>
>> and then bind that template with class Account, generating a type that is
>> a list of accounts?
>>
>> I believe this can be done in EMF, but can it be done if modeling is done
>> in UML2? How?
>>
>> I am still going through the specs for Templates (section 17.5), but so
>> far it is not clear if I can do it in UML2. I have built the model
>> attached, created a genmodel from it, but the resulting ECore model
>> treats the template parameter class as a regular class. Can anyone see
>> what I am doing wrong/missing?
>>
>> Thanks,
>>
>> Rafael
>>
>>
>> ------------------------------------------------------------ ------------
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <uml:Model xmi:version="2.1"
>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>> xmi:id="_SbY9YNvCEdunJ--GsIRueA" name="My">
>> <packagedElement xmi:type="uml:Class" xmi:id="_bG2RoNvCEdunJ--GsIRueA"
>> name="List">
>> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
>> xmi:id="_Td5xANvHEdunJ--GsIRueA" name="List Signature"
>> parameter="_VfIB4NvHEdunJ--GsIRueA">
>> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
>> xmi:id="_VfIB4NvHEdunJ--GsIRueA"
>> parameteredElement="_PqhDUNvlEduCr7xIhpvxLA" allowSubstitutable="false">
>> <ownedParameteredElement xmi:type="uml:Class"
>> xmi:id="_PqhDUNvlEduCr7xIhpvxLA" name="P"
>> templateParameter="_VfIB4NvHEdunJ--GsIRueA"/>
>> </ownedParameter>
>> </ownedTemplateSignature>
>> <ownedOperation xmi:id="_B8SSYNvdEdunJ--GsIRueA" name="op1">
>> <ownedParameter xmi:id="_iO2okNviEdunJ--GsIRueA" name="p"
>> type="_PqhDUNvlEduCr7xIhpvxLA"/>
>> </ownedOperation>
>> </packagedElement>
>> <packagedElement xmi:type="uml:Class" xmi:id="_qayvQNviEdunJ--GsIRueA"
>> name="ListOfAccounts">
>> <templateBinding xmi:id="_uS63YNviEdunJ--GsIRueA">
>> <parameterSubstitution xmi:id="_waJpoNviEdunJ--GsIRueA"
>> formal="_VfIB4NvHEdunJ--GsIRueA" actual="_0vf5QNviEdunJ--GsIRueA"/>
>> </templateBinding>
>> </packagedElement>
>> <packagedElement xmi:type="uml:Class" xmi:id="_0vf5QNviEdunJ--GsIRueA"
>> name="Account"/>
>> </uml:Model>
|
|
|
Re: declaring and using a template class [message #604100 is a reply to message #471813] |
Wed, 28 March 2007 16:22 |
Rafael Chaves Messages: 362 Registered: July 2009 |
Senior Member |
|
|
Hi James,
Thanks for the reply. Please see my comments inline below
James Bruck wrote:
> Attached is a sample ecore and uml representation of the example you have.
I tried generating an EMF model (genmodel + ecore) from the UML model
you provided and the result was the same I had with my own model. Do you
have different results?
>
> By the way, a little trick...... if you can create the ecore
> representation, you can select the EPackage root, then go to the "Sample
> Ecore Editor" menu item and select "convert to UML model ..." and voila...
> the uml representation.
Thanks for the suggestion, but UML is the native metamodel the tool I am
using generates. So that is not an option, since my starting point is
always UML.
>
> There are some new stereotypes in the ecore profile including
> <<EGenericType>> and <<ETypeParameter>>.
> Along with adding missing concepts from UML, the stereotypes serve as
> markers to the uml to ecore converter. In the case of EGenericType, no new
> EClass will be generated in the ecore representation. The idea behind this
> is that in certain cases, UML requires "artificially generated classes" that
> are not required in the ecore representation or in Java.
That explains why I was not being successful.
>
> There are many subtleties concerning generics in UML and an article on this
> is in the works.
> A very rough draft can be found at
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413
It is raw indeed, but seems to be the best documentation around. Thanks
for the pointer.
Thanks a lot,
Rafael
>
> "Rafael Chaves" <chaves@inf.ufsc.nospam.br> wrote in message
> news:eu9ggs$9ga$1@utils.eclipse.org...
>> I am having a hard time building a UML model that uses template elements.
>>
>> For instance, how should I ago about modeling in UML a class equivalent
>> to this Java code:
>>
>> class List<T> {
>> public void add(T o) {...}
>> public T get(int pos) {...}
>> }
>>
>> and then bind that template with class Account, generating a type that
>> is a list of accounts?
>>
>> I believe this can be done in EMF, but can it be done if modeling is
>> done in UML2? How?
>>
>> I am still going through the specs for Templates (section 17.5), but so
>> far it is not clear if I can do it in UML2. I have built the model
>> attached, created a genmodel from it, but the resulting ECore model
>> treats the template parameter class as a regular class. Can anyone see
>> what I am doing wrong/missing?
>>
>> Thanks,
>>
>> Rafael
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <uml:Model xmi:version="2.1"
>> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
>> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
>> xmi:id="_SbY9YNvCEdunJ--GsIRueA" name="My">
>> <packagedElement xmi:type="uml:Class" xmi:id="_bG2RoNvCEdunJ--GsIRueA"
>> name="List">
>> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
>> xmi:id="_Td5xANvHEdunJ--GsIRueA" name="List Signature"
>> parameter="_VfIB4NvHEdunJ--GsIRueA">
>> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
>> xmi:id="_VfIB4NvHEdunJ--GsIRueA"
>> parameteredElement="_PqhDUNvlEduCr7xIhpvxLA" allowSubstitutable="false">
>> <ownedParameteredElement xmi:type="uml:Class"
>> xmi:id="_PqhDUNvlEduCr7xIhpvxLA" name="P"
>> templateParameter="_VfIB4NvHEdunJ--GsIRueA"/>
>> </ownedParameter>
>> </ownedTemplateSignature>
>> <ownedOperation xmi:id="_B8SSYNvdEdunJ--GsIRueA" name="op1">
>> <ownedParameter xmi:id="_iO2okNviEdunJ--GsIRueA" name="p"
>> type="_PqhDUNvlEduCr7xIhpvxLA"/>
>> </ownedOperation>
>> </packagedElement>
>> <packagedElement xmi:type="uml:Class" xmi:id="_qayvQNviEdunJ--GsIRueA"
>> name="ListOfAccounts">
>> <templateBinding xmi:id="_uS63YNviEdunJ--GsIRueA">
>> <parameterSubstitution xmi:id="_waJpoNviEdunJ--GsIRueA"
>> formal="_VfIB4NvHEdunJ--GsIRueA" actual="_0vf5QNviEdunJ--GsIRueA"/>
>> </templateBinding>
>> </packagedElement>
>> <packagedElement xmi:type="uml:Class" xmi:id="_0vf5QNviEdunJ--GsIRueA"
>> name="Account"/>
>> </uml:Model>
>>
>
>
|
|
|
Re: declaring and using a template class [message #604113 is a reply to message #471976] |
Wed, 28 March 2007 18:00 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
Rafael,
The round trip from ecore to uml should be seemless. That is to say that if
you start with an ecore model and convert to uml then convert that uml model
back to ecore, it should be identical to what you started with.
From your comments I'm not sure if you have successfully used generics or
not? You don't seem to be happy with the solution? or am I misreading
something?
A full article would be nice but there simply is not enough time in this
release schedule ... after the M7 timeframe all the articles should be
completed.
Generics in UML is tricky... and bindings in UML can be thought of as a
"merge" rather than true generics in Java or Ecore for that matter, so you
might be seeing some artifacts of this in the mapping.
If you have definite bugs or exceptions to the mapping please let me know or
log a bugzilla.
By the way, I would suggest using the latest integration builds if you are
going to use generics.
Some comments inline below ...
Regards,
- James.
"Rafael Chaves" <chaves@inf.ufsc.nospam.br> wrote in message
news:eue4nd$t26$1@build.eclipse.org...
> Hi James,
>
> Thanks for the reply. Please see my comments inline below
>
> James Bruck wrote:
>
> > Attached is a sample ecore and uml representation of the example you
have.
>
> I tried generating an EMF model (genmodel + ecore) from the UML model
> you provided and the result was the same I had with my own model. Do you
> have different results?
The results are what I posted originally. Those should be equivalent ecore
and uml forms. Note that there are no bindings involved since in that
example we are not using the generic list as a type.
>
> >
> > By the way, a little trick...... if you can create the ecore
> > representation, you can select the EPackage root, then go to the "Sample
> > Ecore Editor" menu item and select "convert to UML model ..." and
voila...
> > the uml representation.
>
> Thanks for the suggestion, but UML is the native metamodel the tool I am
> using generates. So that is not an option, since my starting point is
> always UML.
I was suggesting that as a way of testing if your UML representation would
be correct if you knew the resulting .ecore representation.
Then you would be confident that your original UML model would be in the
correct form.
If you experiment with such conversions then you can see the required
streotypes in UML etc.
This would simply be a way of experimenting to understand the equivalent
forms.
>
> >
> > There are some new stereotypes in the ecore profile including
> > <<EGenericType>> and <<ETypeParameter>>.
> > Along with adding missing concepts from UML, the stereotypes serve as
> > markers to the uml to ecore converter. In the case of EGenericType, no
new
> > EClass will be generated in the ecore representation. The idea behind
this
> > is that in certain cases, UML requires "artificially generated classes"
that
> > are not required in the ecore representation or in Java.
>
> That explains why I was not being successful.
Hopefully you have this working now?
>
> >
> > There are many subtleties concerning generics in UML and an article on
this
> > is in the works.
> > A very rough draft can be found at
> > https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413
>
> It is raw indeed, but seems to be the best documentation around. Thanks
> for the pointer.
Documentation should be completed after M7 when all the features and bugs
have been resolved.
>
> Thanks a lot,
>
> Rafael
>
> >
> > "Rafael Chaves" <chaves@inf.ufsc.nospam.br> wrote in message
> > news:eu9ggs$9ga$1@utils.eclipse.org...
> >> I am having a hard time building a UML model that uses template
elements.
> >>
> >> For instance, how should I ago about modeling in UML a class equivalent
> >> to this Java code:
> >>
> >> class List<T> {
> >> public void add(T o) {...}
> >> public T get(int pos) {...}
> >> }
> >>
> >> and then bind that template with class Account, generating a type that
> >> is a list of accounts?
> >>
> >> I believe this can be done in EMF, but can it be done if modeling is
> >> done in UML2? How?
> >>
> >> I am still going through the specs for Templates (section 17.5), but so
> >> far it is not clear if I can do it in UML2. I have built the model
> >> attached, created a genmodel from it, but the resulting ECore model
> >> treats the template parameter class as a regular class. Can anyone see
> >> what I am doing wrong/missing?
> >>
> >> Thanks,
> >>
> >> Rafael
> >>
> >
> >
>
> ------------------------------------------------------------ --------------
------
> >
> >
> >> <?xml version="1.0" encoding="UTF-8"?>
> >> <uml:Model xmi:version="2.1"
> >> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> >> xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML"
> >> xmi:id="_SbY9YNvCEdunJ--GsIRueA" name="My">
> >> <packagedElement xmi:type="uml:Class" xmi:id="_bG2RoNvCEdunJ--GsIRueA"
> >> name="List">
> >> <ownedTemplateSignature xmi:type="uml:RedefinableTemplateSignature"
> >> xmi:id="_Td5xANvHEdunJ--GsIRueA" name="List Signature"
> >> parameter="_VfIB4NvHEdunJ--GsIRueA">
> >> <ownedParameter xmi:type="uml:ClassifierTemplateParameter"
> >> xmi:id="_VfIB4NvHEdunJ--GsIRueA"
> >> parameteredElement="_PqhDUNvlEduCr7xIhpvxLA"
allowSubstitutable="false">
> >> <ownedParameteredElement xmi:type="uml:Class"
> >> xmi:id="_PqhDUNvlEduCr7xIhpvxLA" name="P"
> >> templateParameter="_VfIB4NvHEdunJ--GsIRueA"/>
> >> </ownedParameter>
> >> </ownedTemplateSignature>
> >> <ownedOperation xmi:id="_B8SSYNvdEdunJ--GsIRueA" name="op1">
> >> <ownedParameter xmi:id="_iO2okNviEdunJ--GsIRueA" name="p"
> >> type="_PqhDUNvlEduCr7xIhpvxLA"/>
> >> </ownedOperation>
> >> </packagedElement>
> >> <packagedElement xmi:type="uml:Class" xmi:id="_qayvQNviEdunJ--GsIRueA"
> >> name="ListOfAccounts">
> >> <templateBinding xmi:id="_uS63YNviEdunJ--GsIRueA">
> >> <parameterSubstitution xmi:id="_waJpoNviEdunJ--GsIRueA"
> >> formal="_VfIB4NvHEdunJ--GsIRueA" actual="_0vf5QNviEdunJ--GsIRueA"/>
> >> </templateBinding>
> >> </packagedElement>
> >> <packagedElement xmi:type="uml:Class" xmi:id="_0vf5QNviEdunJ--GsIRueA"
> >> name="Account"/>
> >> </uml:Model>
> >>
> >
> >
|
|
| |
Goto Forum:
Current Time: Fri Apr 26 08:44:36 GMT 2024
Powered by FUDForum. Page generated in 0.04950 seconds
|