Home » Modeling » UML2 » Using UML2 GenModel with a simple eCore model to handle 'subsets'
| |
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #470145 is a reply to message #470138] |
Wed, 07 February 2007 22:08 |
Tas Frangoullides Messages: 195 Registered: July 2009 |
Senior Member |
|
|
Hi Sylvain,
UML2 allows you to model subsetting through the subsettedProperty
attribute on Property.
If you define your model in UML2, and use this model as the source for
creating your genModel, you can get a genmodel that generates the code you
require. During the import process you will be presented with a dialog
that lets you choose to process property subsetting.
IF you already have your model defined in ecore you could create an
initial UML model by converting from ecore to UML (Convert to UML in the
Ecore Editor menu).
Hope that helps,
Tas.
Sylvain wrote:
> Hi again,
> To be more precise, here's a java sample of what I want to do in eCore:
> // main class Element, root for the others
> public abstract class Element
> {
> private List<Element> composites = new ArrayList<Element>();
> public List<Element> getComposites() {
> return composites;
> }
> public void setComposites(List<Element> composites) {
> this.composites = composites;
> }
> }
> // class Component, a Element
> public class Component extends Element { }
> // class configuration containing Element that are only instanceof
> Components
> public class Configuration extends Element
> {
> public List<Component> getComponents() {
> List<Component> result = new ArrayList<Component>();
> for (Element composite : this.getComposites()) {
> if (composite instanceof Component) result.add((Component)composite);
> }
> return result;
> }
> public void addComponent(Component c) {
> this.getComposites().add(c);
> }
> }
> This way the component list is clearly a subset of composites...
> Thanks for your help !
> Sylvain
> Sylvain a écrit :
>> Hi All,
>>
>> I've to create a metamodel with eCore. eCore is fine for my needs, but
>> now I get into trouble: I've a composition that is a subset of another
>> (see attached file). I've seen that there is a annotation named
>> 'subsets' in UML.ecore. I would like to take advantage of the GenModel
>> that use it, but I don't know how to use it ? I create a genmodel from
>> my ecore model but I don't see where to make reference to UML.GenModel.
>>
>> Thanks for your help !
>> Sylvain
>>
>> ------------------------------------------------------------ ------------
>>
|
|
|
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #470155 is a reply to message #470145] |
Thu, 08 February 2007 01:53 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
.... there are some draft documents that explain subsetting see the one under
"Extending UML doc"...
https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413
Hopefully they will be of some use. Please add comments or suggestions for
other topics you would like to see covered.
Cheers,
- James.
"Tas Frangoullides" <tas.frangoullides@barclaysglobal.com> wrote in message
news:2d255c2527f5a7a6f37faad04fd62254$1@www.eclipse.org...
> Hi Sylvain,
>
> UML2 allows you to model subsetting through the subsettedProperty
> attribute on Property.
>
> If you define your model in UML2, and use this model as the source for
> creating your genModel, you can get a genmodel that generates the code you
> require. During the import process you will be presented with a dialog
> that lets you choose to process property subsetting.
>
> IF you already have your model defined in ecore you could create an
> initial UML model by converting from ecore to UML (Convert to UML in the
> Ecore Editor menu).
>
> Hope that helps,
>
> Tas.
>
>
> Sylvain wrote:
>
>> Hi again,
>
>> To be more precise, here's a java sample of what I want to do in eCore:
>
>> // main class Element, root for the others
>> public abstract class Element
>> {
>> private List<Element> composites = new ArrayList<Element>();
>> public List<Element> getComposites() {
>> return composites;
>> }
>> public void setComposites(List<Element> composites) {
>> this.composites = composites;
>> } }
>
>> // class Component, a Element
>> public class Component extends Element { }
>
>> // class configuration containing Element that are only instanceof
>> Components
>> public class Configuration extends Element
>> {
>> public List<Component> getComponents() {
>> List<Component> result = new ArrayList<Component>();
>> for (Element composite : this.getComposites()) {
>> if (composite instanceof Component) result.add((Component)composite);
>> }
>> return result;
>> }
>> public void addComponent(Component c) {
>> this.getComposites().add(c);
>> }
>> }
>
>> This way the component list is clearly a subset of composites...
>> Thanks for your help !
>
>> Sylvain
>
>
>> Sylvain a
|
|
|
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #470161 is a reply to message #470138] |
Thu, 08 February 2007 13:54 |
Kenn Hussey Messages: 1620 Registered: July 2009 |
Senior Member |
|
|
Sylvain,
Take a look at the implementation of PackageImpl#getNestedPackages() or
PackageImpl#getOwnedTypes(). There you'll see how a
DerivedSubsetEObjectEList can be used to implement a list that subsbets
another list by restricting its type, much the same as you are looking to
do. Currently, however, the UML2 code generator does not generate this code,
so you'll have to add it by hand.
Kenn
"Sylvain" <sylvain.maillard@univ-nantes.fr> wrote in message
news:eqcs2e$t55$1@utils.eclipse.org...
> Hi again,
>
> To be more precise, here's a java sample of what I want to do in eCore:
>
> // main class Element, root for the others
> public abstract class Element
> {
> private List<Element> composites = new ArrayList<Element>();
> public List<Element> getComposites() {
> return composites;
> }
> public void setComposites(List<Element> composites) {
> this.composites = composites;
> } }
>
> // class Component, a Element
> public class Component extends Element { }
>
> // class configuration containing Element that are only instanceof
> Components
> public class Configuration extends Element
> {
> public List<Component> getComponents() {
> List<Component> result = new ArrayList<Component>();
> for (Element composite : this.getComposites()) {
> if (composite instanceof Component) result.add((Component)composite);
> }
> return result;
> }
> public void addComponent(Component c) {
> this.getComposites().add(c);
> }
> }
>
> This way the component list is clearly a subset of composites...
> Thanks for your help !
>
> Sylvain
>
>
> Sylvain a
|
|
|
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #470169 is a reply to message #470145] |
Thu, 08 February 2007 15:50 |
Sylvain Messages: 40 Registered: July 2009 |
Member |
|
|
Hi,
Ok I've try your solution to translate eCore to UML then create
genModel, it seems to work ;-) I have a eCore model with "subsets"
annotation, the converter generate a lots of UML elements form it and
finally I generated the java classes. I don't need all UML stuffs, just
"subsets"... Is there really no way to bypass the UML conversion step ?
BTW thanks for your useful help ;-)
Sylvain
Tas Frangoullides a écrit :
> Hi Sylvain,
>
> UML2 allows you to model subsetting through the subsettedProperty
> attribute on Property.
>
> If you define your model in UML2, and use this model as the source for
> creating your genModel, you can get a genmodel that generates the code
> you require. During the import process you will be presented with a
> dialog that lets you choose to process property subsetting.
>
> IF you already have your model defined in ecore you could create an
> initial UML model by converting from ecore to UML (Convert to UML in the
> Ecore Editor menu).
>
> Hope that helps,
>
> Tas.
>
>
> Sylvain wrote:
>
>> Hi again,
>
>> To be more precise, here's a java sample of what I want to do in eCore:
>
>> // main class Element, root for the others
>> public abstract class Element
>> {
>> private List<Element> composites = new ArrayList<Element>();
>> public List<Element> getComposites() {
>> return composites;
>> }
>> public void setComposites(List<Element> composites) {
>> this.composites = composites;
>> }
>> }
>
>> // class Component, a Element
>> public class Component extends Element { }
>
>> // class configuration containing Element that are only instanceof
>> Components
>> public class Configuration extends Element
>> {
>> public List<Component> getComponents() {
>> List<Component> result = new ArrayList<Component>();
>> for (Element composite : this.getComposites()) {
>> if (composite instanceof Component)
>> result.add((Component)composite);
>> }
>> return result;
>> }
>> public void addComponent(Component c) {
>> this.getComposites().add(c);
>> }
>> }
>
>> This way the component list is clearly a subset of composites...
>> Thanks for your help !
>
>> Sylvain
>
>
>> Sylvain a écrit :
>>> Hi All,
>>>
>>> I've to create a metamodel with eCore. eCore is fine for my needs,
>>> but now I get into trouble: I've a composition that is a subset of
>>> another (see attached file). I've seen that there is a annotation
>>> named 'subsets' in UML.ecore. I would like to take advantage of the
>>> GenModel that use it, but I don't know how to use it ? I create a
>>> genmodel from my ecore model but I don't see where to make reference
>>> to UML.GenModel.
>>>
>>> Thanks for your help !
>>> Sylvain
>>>
>>> ------------------------------------------------------------ ------------
>>>
>
>
|
|
|
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #470205 is a reply to message #470161] |
Thu, 08 February 2007 15:59 |
Sylvain Messages: 40 Registered: July 2009 |
Member |
|
|
Hi Kenn,
I will try this, in order to keep a full eCore model...
Sylvain
Kenn Hussey a écrit :
> Sylvain,
>
> Take a look at the implementation of PackageImpl#getNestedPackages() or
> PackageImpl#getOwnedTypes(). There you'll see how a
> DerivedSubsetEObjectEList can be used to implement a list that subsbets
> another list by restricting its type, much the same as you are looking to
> do. Currently, however, the UML2 code generator does not generate this code,
> so you'll have to add it by hand.
>
> Kenn
>
> "Sylvain" <sylvain.maillard@univ-nantes.fr> wrote in message
> news:eqcs2e$t55$1@utils.eclipse.org...
>> Hi again,
>>
>> To be more precise, here's a java sample of what I want to do in eCore:
>>
>> // main class Element, root for the others
>> public abstract class Element
>> {
>> private List<Element> composites = new ArrayList<Element>();
>> public List<Element> getComposites() {
>> return composites;
>> }
>> public void setComposites(List<Element> composites) {
>> this.composites = composites;
>> } }
>>
>> // class Component, a Element
>> public class Component extends Element { }
>>
>> // class configuration containing Element that are only instanceof
>> Components
>> public class Configuration extends Element
>> {
>> public List<Component> getComponents() {
>> List<Component> result = new ArrayList<Component>();
>> for (Element composite : this.getComposites()) {
>> if (composite instanceof Component) result.add((Component)composite);
>> }
>> return result;
>> }
>> public void addComponent(Component c) {
>> this.getComposites().add(c);
>> }
>> }
>>
>> This way the component list is clearly a subset of composites...
>> Thanks for your help !
>>
>> Sylvain
>>
>>
>> Sylvain a écrit :
>>> Hi All,
>>>
>>> I've to create a metamodel with eCore. eCore is fine for my needs, but
>>> now I get into trouble: I've a composition that is a subset of another
>>> (see attached file). I've seen that there is a annotation named 'subsets'
>>> in UML.ecore. I would like to take advantage of the GenModel that use it,
>>> but I don't know how to use it ? I create a genmodel from my ecore model
>>> but I don't see where to make reference to UML.GenModel.
>>>
>>> Thanks for your help !
>>> Sylvain
>>>
>>> ------------------------------------------------------------ ------------
>>>
>
>
|
|
|
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #470228 is a reply to message #470205] |
Fri, 09 February 2007 11:17 |
Sylvain Messages: 40 Registered: July 2009 |
Member |
|
|
Hi Kenn,
Your solution works well, but everything gets harder when I had a
relation one-to-one between my component and my configuration that is
another subset of the main "composite" relation: this relation give a
class attribute after code generation, but in fact i wanted that this
attribute is the only elements in my "composite" collection.
I think I will find a workaround to this problem: my composite become a
"derived" relation and I will implements the "getComposites()" by hand.
Sylvain
Sylvain a écrit :
> Hi Kenn,
>
> I will try this, in order to keep a full eCore model...
>
> Sylvain
>
> Kenn Hussey a écrit :
>> Sylvain,
>>
>> Take a look at the implementation of PackageImpl#getNestedPackages()
>> or PackageImpl#getOwnedTypes(). There you'll see how a
>> DerivedSubsetEObjectEList can be used to implement a list that
>> subsbets another list by restricting its type, much the same as you
>> are looking to do. Currently, however, the UML2 code generator does
>> not generate this code, so you'll have to add it by hand.
>>
>> Kenn
>>
>> "Sylvain" <sylvain.maillard@univ-nantes.fr> wrote in message
>> news:eqcs2e$t55$1@utils.eclipse.org...
>>> Hi again,
>>>
>>> To be more precise, here's a java sample of what I want to do in eCore:
>>>
>>> // main class Element, root for the others
>>> public abstract class Element
>>> {
>>> private List<Element> composites = new ArrayList<Element>();
>>> public List<Element> getComposites() {
>>> return composites;
>>> }
>>> public void setComposites(List<Element> composites) {
>>> this.composites = composites;
>>> } }
>>>
>>> // class Component, a Element
>>> public class Component extends Element { }
>>>
>>> // class configuration containing Element that are only instanceof
>>> Components
>>> public class Configuration extends Element
>>> {
>>> public List<Component> getComponents() {
>>> List<Component> result = new ArrayList<Component>();
>>> for (Element composite : this.getComposites()) {
>>> if (composite instanceof Component) result.add((Component)composite);
>>> }
>>> return result;
>>> }
>>> public void addComponent(Component c) {
>>> this.getComposites().add(c);
>>> }
>>> }
>>>
>>> This way the component list is clearly a subset of composites...
>>> Thanks for your help !
>>>
>>> Sylvain
>>>
>>>
>>> Sylvain a écrit :
>>>> Hi All,
>>>>
>>>> I've to create a metamodel with eCore. eCore is fine for my needs,
>>>> but now I get into trouble: I've a composition that is a subset of
>>>> another (see attached file). I've seen that there is a annotation
>>>> named 'subsets' in UML.ecore. I would like to take advantage of the
>>>> GenModel that use it, but I don't know how to use it ? I create a
>>>> genmodel from my ecore model but I don't see where to make reference
>>>> to UML.GenModel.
>>>>
>>>> Thanks for your help !
>>>> Sylvain
>>>>
>>>> ------------------------------------------------------------ ------------
>>>>
>>>>
>>
>>
|
|
| |
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #583105 is a reply to message #470138] |
Wed, 07 February 2007 22:08 |
Tas Frangoullides Messages: 195 Registered: July 2009 |
Senior Member |
|
|
Hi Sylvain,
UML2 allows you to model subsetting through the subsettedProperty
attribute on Property.
If you define your model in UML2, and use this model as the source for
creating your genModel, you can get a genmodel that generates the code you
require. During the import process you will be presented with a dialog
that lets you choose to process property subsetting.
IF you already have your model defined in ecore you could create an
initial UML model by converting from ecore to UML (Convert to UML in the
Ecore Editor menu).
Hope that helps,
Tas.
Sylvain wrote:
> Hi again,
> To be more precise, here's a java sample of what I want to do in eCore:
> // main class Element, root for the others
> public abstract class Element
> {
> private List<Element> composites = new ArrayList<Element>();
> public List<Element> getComposites() {
> return composites;
> }
> public void setComposites(List<Element> composites) {
> this.composites = composites;
> }
> }
> // class Component, a Element
> public class Component extends Element { }
> // class configuration containing Element that are only instanceof
> Components
> public class Configuration extends Element
> {
> public List<Component> getComponents() {
> List<Component> result = new ArrayList<Component>();
> for (Element composite : this.getComposites()) {
> if (composite instanceof Component) result.add((Component)composite);
> }
> return result;
> }
> public void addComponent(Component c) {
> this.getComposites().add(c);
> }
> }
> This way the component list is clearly a subset of composites...
> Thanks for your help !
> Sylvain
> Sylvain a écrit :
>> Hi All,
>>
>> I've to create a metamodel with eCore. eCore is fine for my needs, but
>> now I get into trouble: I've a composition that is a subset of another
>> (see attached file). I've seen that there is a annotation named
>> 'subsets' in UML.ecore. I would like to take advantage of the GenModel
>> that use it, but I don't know how to use it ? I create a genmodel from
>> my ecore model but I don't see where to make reference to UML.GenModel.
>>
>> Thanks for your help !
>> Sylvain
>>
>> ------------------------------------------------------------ ------------
>>
|
|
|
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #583171 is a reply to message #470145] |
Thu, 08 February 2007 01:53 |
james bruck Messages: 1724 Registered: July 2009 |
Senior Member |
|
|
.... there are some draft documents that explain subsetting see the one under
"Extending UML doc"...
https://bugs.eclipse.org/bugs/show_bug.cgi?id=77413
Hopefully they will be of some use. Please add comments or suggestions for
other topics you would like to see covered.
Cheers,
- James.
"Tas Frangoullides" <tas.frangoullides@barclaysglobal.com> wrote in message
news:2d255c2527f5a7a6f37faad04fd62254$1@www.eclipse.org...
> Hi Sylvain,
>
> UML2 allows you to model subsetting through the subsettedProperty
> attribute on Property.
>
> If you define your model in UML2, and use this model as the source for
> creating your genModel, you can get a genmodel that generates the code you
> require. During the import process you will be presented with a dialog
> that lets you choose to process property subsetting.
>
> IF you already have your model defined in ecore you could create an
> initial UML model by converting from ecore to UML (Convert to UML in the
> Ecore Editor menu).
>
> Hope that helps,
>
> Tas.
>
>
> Sylvain wrote:
>
>> Hi again,
>
>> To be more precise, here's a java sample of what I want to do in eCore:
>
>> // main class Element, root for the others
>> public abstract class Element
>> {
>> private List<Element> composites = new ArrayList<Element>();
>> public List<Element> getComposites() {
>> return composites;
>> }
>> public void setComposites(List<Element> composites) {
>> this.composites = composites;
>> } }
>
>> // class Component, a Element
>> public class Component extends Element { }
>
>> // class configuration containing Element that are only instanceof
>> Components
>> public class Configuration extends Element
>> {
>> public List<Component> getComponents() {
>> List<Component> result = new ArrayList<Component>();
>> for (Element composite : this.getComposites()) {
>> if (composite instanceof Component) result.add((Component)composite);
>> }
>> return result;
>> }
>> public void addComponent(Component c) {
>> this.getComposites().add(c);
>> }
>> }
>
>> This way the component list is clearly a subset of composites...
>> Thanks for your help !
>
>> Sylvain
>
>
>> Sylvain a
|
|
|
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #583211 is a reply to message #470138] |
Thu, 08 February 2007 13:54 |
Kenn Hussey Messages: 1620 Registered: July 2009 |
Senior Member |
|
|
Sylvain,
Take a look at the implementation of PackageImpl#getNestedPackages() or
PackageImpl#getOwnedTypes(). There you'll see how a
DerivedSubsetEObjectEList can be used to implement a list that subsbets
another list by restricting its type, much the same as you are looking to
do. Currently, however, the UML2 code generator does not generate this code,
so you'll have to add it by hand.
Kenn
"Sylvain" <sylvain.maillard@univ-nantes.fr> wrote in message
news:eqcs2e$t55$1@utils.eclipse.org...
> Hi again,
>
> To be more precise, here's a java sample of what I want to do in eCore:
>
> // main class Element, root for the others
> public abstract class Element
> {
> private List<Element> composites = new ArrayList<Element>();
> public List<Element> getComposites() {
> return composites;
> }
> public void setComposites(List<Element> composites) {
> this.composites = composites;
> } }
>
> // class Component, a Element
> public class Component extends Element { }
>
> // class configuration containing Element that are only instanceof
> Components
> public class Configuration extends Element
> {
> public List<Component> getComponents() {
> List<Component> result = new ArrayList<Component>();
> for (Element composite : this.getComposites()) {
> if (composite instanceof Component) result.add((Component)composite);
> }
> return result;
> }
> public void addComponent(Component c) {
> this.getComposites().add(c);
> }
> }
>
> This way the component list is clearly a subset of composites...
> Thanks for your help !
>
> Sylvain
>
>
> Sylvain a
|
|
|
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #583268 is a reply to message #470145] |
Thu, 08 February 2007 15:50 |
Sylvain Messages: 40 Registered: July 2009 |
Member |
|
|
Hi,
Ok I've try your solution to translate eCore to UML then create
genModel, it seems to work ;-) I have a eCore model with "subsets"
annotation, the converter generate a lots of UML elements form it and
finally I generated the java classes. I don't need all UML stuffs, just
"subsets"... Is there really no way to bypass the UML conversion step ?
BTW thanks for your useful help ;-)
Sylvain
Tas Frangoullides a écrit :
> Hi Sylvain,
>
> UML2 allows you to model subsetting through the subsettedProperty
> attribute on Property.
>
> If you define your model in UML2, and use this model as the source for
> creating your genModel, you can get a genmodel that generates the code
> you require. During the import process you will be presented with a
> dialog that lets you choose to process property subsetting.
>
> IF you already have your model defined in ecore you could create an
> initial UML model by converting from ecore to UML (Convert to UML in the
> Ecore Editor menu).
>
> Hope that helps,
>
> Tas.
>
>
> Sylvain wrote:
>
>> Hi again,
>
>> To be more precise, here's a java sample of what I want to do in eCore:
>
>> // main class Element, root for the others
>> public abstract class Element
>> {
>> private List<Element> composites = new ArrayList<Element>();
>> public List<Element> getComposites() {
>> return composites;
>> }
>> public void setComposites(List<Element> composites) {
>> this.composites = composites;
>> }
>> }
>
>> // class Component, a Element
>> public class Component extends Element { }
>
>> // class configuration containing Element that are only instanceof
>> Components
>> public class Configuration extends Element
>> {
>> public List<Component> getComponents() {
>> List<Component> result = new ArrayList<Component>();
>> for (Element composite : this.getComposites()) {
>> if (composite instanceof Component)
>> result.add((Component)composite);
>> }
>> return result;
>> }
>> public void addComponent(Component c) {
>> this.getComposites().add(c);
>> }
>> }
>
>> This way the component list is clearly a subset of composites...
>> Thanks for your help !
>
>> Sylvain
>
>
>> Sylvain a écrit :
>>> Hi All,
>>>
>>> I've to create a metamodel with eCore. eCore is fine for my needs,
>>> but now I get into trouble: I've a composition that is a subset of
>>> another (see attached file). I've seen that there is a annotation
>>> named 'subsets' in UML.ecore. I would like to take advantage of the
>>> GenModel that use it, but I don't know how to use it ? I create a
>>> genmodel from my ecore model but I don't see where to make reference
>>> to UML.GenModel.
>>>
>>> Thanks for your help !
>>> Sylvain
>>>
>>> ------------------------------------------------------------ ------------
>>>
>
>
|
|
|
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #583279 is a reply to message #470161] |
Thu, 08 February 2007 15:59 |
Sylvain Messages: 40 Registered: July 2009 |
Member |
|
|
Hi Kenn,
I will try this, in order to keep a full eCore model...
Sylvain
Kenn Hussey a écrit :
> Sylvain,
>
> Take a look at the implementation of PackageImpl#getNestedPackages() or
> PackageImpl#getOwnedTypes(). There you'll see how a
> DerivedSubsetEObjectEList can be used to implement a list that subsbets
> another list by restricting its type, much the same as you are looking to
> do. Currently, however, the UML2 code generator does not generate this code,
> so you'll have to add it by hand.
>
> Kenn
>
> "Sylvain" <sylvain.maillard@univ-nantes.fr> wrote in message
> news:eqcs2e$t55$1@utils.eclipse.org...
>> Hi again,
>>
>> To be more precise, here's a java sample of what I want to do in eCore:
>>
>> // main class Element, root for the others
>> public abstract class Element
>> {
>> private List<Element> composites = new ArrayList<Element>();
>> public List<Element> getComposites() {
>> return composites;
>> }
>> public void setComposites(List<Element> composites) {
>> this.composites = composites;
>> } }
>>
>> // class Component, a Element
>> public class Component extends Element { }
>>
>> // class configuration containing Element that are only instanceof
>> Components
>> public class Configuration extends Element
>> {
>> public List<Component> getComponents() {
>> List<Component> result = new ArrayList<Component>();
>> for (Element composite : this.getComposites()) {
>> if (composite instanceof Component) result.add((Component)composite);
>> }
>> return result;
>> }
>> public void addComponent(Component c) {
>> this.getComposites().add(c);
>> }
>> }
>>
>> This way the component list is clearly a subset of composites...
>> Thanks for your help !
>>
>> Sylvain
>>
>>
>> Sylvain a écrit :
>>> Hi All,
>>>
>>> I've to create a metamodel with eCore. eCore is fine for my needs, but
>>> now I get into trouble: I've a composition that is a subset of another
>>> (see attached file). I've seen that there is a annotation named 'subsets'
>>> in UML.ecore. I would like to take advantage of the GenModel that use it,
>>> but I don't know how to use it ? I create a genmodel from my ecore model
>>> but I don't see where to make reference to UML.GenModel.
>>>
>>> Thanks for your help !
>>> Sylvain
>>>
>>> ------------------------------------------------------------ ------------
>>>
>
>
|
|
|
Re: Using UML2 GenModel with a simple eCore model to handle 'subsets' [message #586737 is a reply to message #470205] |
Fri, 09 February 2007 11:17 |
Sylvain Messages: 40 Registered: July 2009 |
Member |
|
|
Hi Kenn,
Your solution works well, but everything gets harder when I had a
relation one-to-one between my component and my configuration that is
another subset of the main "composite" relation: this relation give a
class attribute after code generation, but in fact i wanted that this
attribute is the only elements in my "composite" collection.
I think I will find a workaround to this problem: my composite become a
"derived" relation and I will implements the "getComposites()" by hand.
Sylvain
Sylvain a écrit :
> Hi Kenn,
>
> I will try this, in order to keep a full eCore model...
>
> Sylvain
>
> Kenn Hussey a écrit :
>> Sylvain,
>>
>> Take a look at the implementation of PackageImpl#getNestedPackages()
>> or PackageImpl#getOwnedTypes(). There you'll see how a
>> DerivedSubsetEObjectEList can be used to implement a list that
>> subsbets another list by restricting its type, much the same as you
>> are looking to do. Currently, however, the UML2 code generator does
>> not generate this code, so you'll have to add it by hand.
>>
>> Kenn
>>
>> "Sylvain" <sylvain.maillard@univ-nantes.fr> wrote in message
>> news:eqcs2e$t55$1@utils.eclipse.org...
>>> Hi again,
>>>
>>> To be more precise, here's a java sample of what I want to do in eCore:
>>>
>>> // main class Element, root for the others
>>> public abstract class Element
>>> {
>>> private List<Element> composites = new ArrayList<Element>();
>>> public List<Element> getComposites() {
>>> return composites;
>>> }
>>> public void setComposites(List<Element> composites) {
>>> this.composites = composites;
>>> } }
>>>
>>> // class Component, a Element
>>> public class Component extends Element { }
>>>
>>> // class configuration containing Element that are only instanceof
>>> Components
>>> public class Configuration extends Element
>>> {
>>> public List<Component> getComponents() {
>>> List<Component> result = new ArrayList<Component>();
>>> for (Element composite : this.getComposites()) {
>>> if (composite instanceof Component) result.add((Component)composite);
>>> }
>>> return result;
>>> }
>>> public void addComponent(Component c) {
>>> this.getComposites().add(c);
>>> }
>>> }
>>>
>>> This way the component list is clearly a subset of composites...
>>> Thanks for your help !
>>>
>>> Sylvain
>>>
>>>
>>> Sylvain a écrit :
>>>> Hi All,
>>>>
>>>> I've to create a metamodel with eCore. eCore is fine for my needs,
>>>> but now I get into trouble: I've a composition that is a subset of
>>>> another (see attached file). I've seen that there is a annotation
>>>> named 'subsets' in UML.ecore. I would like to take advantage of the
>>>> GenModel that use it, but I don't know how to use it ? I create a
>>>> genmodel from my ecore model but I don't see where to make reference
>>>> to UML.GenModel.
>>>>
>>>> Thanks for your help !
>>>> Sylvain
>>>>
>>>> ------------------------------------------------------------ ------------
>>>>
>>>>
>>
>>
|
|
|
Goto Forum:
Current Time: Thu Sep 26 20:00:20 GMT 2024
Powered by FUDForum. Page generated in 0.04853 seconds
|