Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » uml2 genmodel, abstract classes and operations
uml2 genmodel, abstract classes and operations [message #476357] Wed, 10 October 2007 14:28 Go to next message
Javi is currently offline JaviFriend
Messages: 23
Registered: July 2009
Junior Member
Hello,

When a class implements an interface and the operations package
is turned on, I found that the operations class is created for the
interface instead of for the concrete class.

Thank you.

This is the situation in depth:

I have a model in UML like this:
- Interface A
- op()
- Class B implements A

When I create a genmodel from it, I get an ecore like this:
- Class A (abstract)
- op()
- Class B extends A

When I generate model code with an (operations package) I get:
ImplPackage
- Class BImpl
- op() {OperationsPackage.AOperations.op(this)}

OperationsPackage
- Class AOperations
- op() {throw new UnsupportedOperationException();}

I expected:
ImplPackage
- Class BImpl
- op() {OperationsPackage.BOperations.op(this)}

OperationsPackage
- Class BOperations
- op() {throw new UnsupportedOperationException();}
Re: uml2 genmodel, abstract classes and operations [message #476361 is a reply to message #476357] Thu, 11 October 2007 03:27 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Javi,

When you say "Class B implements A" are you creating an interface
realization or a generalization to from ClassB to Interface A?
If I create a class B, interface A, and an interface realization, I get the
expected results.

Please post your model so I can have a more careful look at the issue.

- James.

"Javi" <jfbriones_tech@yahoo.es> wrote in message
news:c6bf52b356920058f94cc80aaef7985a$1@www.eclipse.org...
> Hello,
>
> When a class implements an interface and the operations package
> is turned on, I found that the operations class is created for the
> interface instead of for the concrete class.
>
> Thank you.
>
> This is the situation in depth:
>
> I have a model in UML like this:
> - Interface A
> - op()
> - Class B implements A
>
> When I create a genmodel from it, I get an ecore like this:
> - Class A (abstract)
> - op()
> - Class B extends A
>
> When I generate model code with an (operations package) I get:
> ImplPackage
> - Class BImpl
> - op() {OperationsPackage.AOperations.op(this)}
>
> OperationsPackage
> - Class AOperations
> - op() {throw new UnsupportedOperationException();}
>
> I expected:
> ImplPackage
> - Class BImpl
> - op() {OperationsPackage.BOperations.op(this)}
>
> OperationsPackage
> - Class BOperations
> - op() {throw new UnsupportedOperationException();}
>
>
Re: uml2 genmodel, abstract classes and operations [message #476382 is a reply to message #476361] Thu, 11 October 2007 08:56 Go to previous messageGo to next message
Javi is currently offline JaviFriend
Messages: 23
Registered: July 2009
Junior Member
Hi James,

I meant Interface Realization, but I do not get the expected results.
I reproduce here a basic uml model for testing.
Create the genmodel and set Pkg."Operations Package" = Pkg.operations
Generate the code.

Thank you.

<?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.1.0/UML"
xmi:id="_0WJsIHfVEdyEboBJ9-54sA" name="Pkg">
<packagedElement xmi:type="uml:Class" xmi:id="_3WFA8HfVEdyEboBJ9-54sA"
name="B" clientDependency="_9EWLUHfVEdyEboBJ9-54sA">
<interfaceRealization xmi:id="_9EWLUHfVEdyEboBJ9-54sA" name="ir"
supplier="_4tZZMHfVEdyEboBJ9-54sA" client="_3WFA8HfVEdyEboBJ9-54sA"
contract="_4tZZMHfVEdyEboBJ9-54sA"/>
</packagedElement>
<packagedElement xmi:type="uml:Interface"
xmi:id="_4tZZMHfVEdyEboBJ9-54sA" name="A">
<ownedOperation xmi:id="_7fK9QHfVEdyEboBJ9-54sA" name="op"/>
</packagedElement>
</uml:Model>
Re: uml2 genmodel, abstract classes and operations [message #476386 is a reply to message #476357] Thu, 11 October 2007 12:53 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Javi,

This by design. The names of the operations classes are generated based on
the names of the classes/interfaces in which the operations are defined. One
of the reasons for introducing the concept of an operations class was to
reduce the number of redundant implementations of the same operation in
cases where the class/interface containing the operation is mixed into
(multiply inherited/realized) by more than one class...

Kenn

"Javi" <jfbriones_tech@yahoo.es> wrote in message
news:c6bf52b356920058f94cc80aaef7985a$1@www.eclipse.org...
> Hello,
>
> When a class implements an interface and the operations package
> is turned on, I found that the operations class is created for the
> interface instead of for the concrete class.
>
> Thank you.
>
> This is the situation in depth:
>
> I have a model in UML like this:
> - Interface A
> - op()
> - Class B implements A
>
> When I create a genmodel from it, I get an ecore like this:
> - Class A (abstract)
> - op()
> - Class B extends A
>
> When I generate model code with an (operations package) I get:
> ImplPackage
> - Class BImpl
> - op() {OperationsPackage.AOperations.op(this)}
>
> OperationsPackage
> - Class AOperations
> - op() {throw new UnsupportedOperationException();}
>
> I expected:
> ImplPackage
> - Class BImpl
> - op() {OperationsPackage.BOperations.op(this)}
>
> OperationsPackage
> - Class BOperations
> - op() {throw new UnsupportedOperationException();}
>
>
Re: uml2 genmodel, abstract classes and operations [message #476387 is a reply to message #476386] Thu, 11 October 2007 13:47 Go to previous messageGo to next message
Javi is currently offline JaviFriend
Messages: 23
Registered: July 2009
Junior Member
Thank you Kenn,

Now I understand it, and it is a good reason to avoid the redundancy of
method implementations.

I suppose there is no variable in the genmodel file to change this
behavior.
It would be really nice to have it in order the uml2.codegen could be
reused by more people.

At first sight I cannot make it by changing only the templates. I seems
that the names are created in the genmodel.

Could you please confirm me this point.

Javi
Re: uml2 genmodel, abstract classes and operations [message #476396 is a reply to message #476387] Wed, 17 October 2007 13:33 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Javi,

Yes, the names are calculated in the generator model based on the class
(interface) names. I'm not sure that I understand how/why you need the
behavior to be different, but if you can justify this as something that
would be generally useful, feel free to open an enhancement request in
Bugzilla.

Kenn

"Javi" <jfbriones_tech@yahoo.es> wrote in message
news:c02364e7f23320f9ccb40fffade84c8a$1@www.eclipse.org...
> Thank you Kenn,
>
> Now I understand it, and it is a good reason to avoid the redundancy of
> method implementations.
>
> I suppose there is no variable in the genmodel file to change this
> behavior.
> It would be really nice to have it in order the uml2.codegen could be
> reused by more people.
>
> At first sight I cannot make it by changing only the templates. I seems
> that the names are created in the genmodel.
>
> Could you please confirm me this point.
>
> Javi
>
>
Re: uml2 genmodel, abstract classes and operations [message #625173 is a reply to message #476357] Thu, 11 October 2007 03:27 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi Javi,

When you say "Class B implements A" are you creating an interface
realization or a generalization to from ClassB to Interface A?
If I create a class B, interface A, and an interface realization, I get the
expected results.

Please post your model so I can have a more careful look at the issue.

- James.

"Javi" <jfbriones_tech@yahoo.es> wrote in message
news:c6bf52b356920058f94cc80aaef7985a$1@www.eclipse.org...
> Hello,
>
> When a class implements an interface and the operations package
> is turned on, I found that the operations class is created for the
> interface instead of for the concrete class.
>
> Thank you.
>
> This is the situation in depth:
>
> I have a model in UML like this:
> - Interface A
> - op()
> - Class B implements A
>
> When I create a genmodel from it, I get an ecore like this:
> - Class A (abstract)
> - op()
> - Class B extends A
>
> When I generate model code with an (operations package) I get:
> ImplPackage
> - Class BImpl
> - op() {OperationsPackage.AOperations.op(this)}
>
> OperationsPackage
> - Class AOperations
> - op() {throw new UnsupportedOperationException();}
>
> I expected:
> ImplPackage
> - Class BImpl
> - op() {OperationsPackage.BOperations.op(this)}
>
> OperationsPackage
> - Class BOperations
> - op() {throw new UnsupportedOperationException();}
>
>
Re: uml2 genmodel, abstract classes and operations [message #625174 is a reply to message #476361] Thu, 11 October 2007 08:56 Go to previous message
Javi is currently offline JaviFriend
Messages: 23
Registered: July 2009
Junior Member
Hi James,

I meant Interface Realization, but I do not get the expected results.
I reproduce here a basic uml model for testing.
Create the genmodel and set Pkg."Operations Package" = Pkg.operations
Generate the code.

Thank you.

<?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.1.0/UML"
xmi:id="_0WJsIHfVEdyEboBJ9-54sA" name="Pkg">
<packagedElement xmi:type="uml:Class" xmi:id="_3WFA8HfVEdyEboBJ9-54sA"
name="B" clientDependency="_9EWLUHfVEdyEboBJ9-54sA">
<interfaceRealization xmi:id="_9EWLUHfVEdyEboBJ9-54sA" name="ir"
supplier="_4tZZMHfVEdyEboBJ9-54sA" client="_3WFA8HfVEdyEboBJ9-54sA"
contract="_4tZZMHfVEdyEboBJ9-54sA"/>
</packagedElement>
<packagedElement xmi:type="uml:Interface"
xmi:id="_4tZZMHfVEdyEboBJ9-54sA" name="A">
<ownedOperation xmi:id="_7fK9QHfVEdyEboBJ9-54sA" name="op"/>
</packagedElement>
</uml:Model>
Re: uml2 genmodel, abstract classes and operations [message #625178 is a reply to message #476357] Thu, 11 October 2007 12:53 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Javi,

This by design. The names of the operations classes are generated based on
the names of the classes/interfaces in which the operations are defined. One
of the reasons for introducing the concept of an operations class was to
reduce the number of redundant implementations of the same operation in
cases where the class/interface containing the operation is mixed into
(multiply inherited/realized) by more than one class...

Kenn

"Javi" <jfbriones_tech@yahoo.es> wrote in message
news:c6bf52b356920058f94cc80aaef7985a$1@www.eclipse.org...
> Hello,
>
> When a class implements an interface and the operations package
> is turned on, I found that the operations class is created for the
> interface instead of for the concrete class.
>
> Thank you.
>
> This is the situation in depth:
>
> I have a model in UML like this:
> - Interface A
> - op()
> - Class B implements A
>
> When I create a genmodel from it, I get an ecore like this:
> - Class A (abstract)
> - op()
> - Class B extends A
>
> When I generate model code with an (operations package) I get:
> ImplPackage
> - Class BImpl
> - op() {OperationsPackage.AOperations.op(this)}
>
> OperationsPackage
> - Class AOperations
> - op() {throw new UnsupportedOperationException();}
>
> I expected:
> ImplPackage
> - Class BImpl
> - op() {OperationsPackage.BOperations.op(this)}
>
> OperationsPackage
> - Class BOperations
> - op() {throw new UnsupportedOperationException();}
>
>
Re: uml2 genmodel, abstract classes and operations [message #625179 is a reply to message #476386] Thu, 11 October 2007 13:47 Go to previous message
Javi is currently offline JaviFriend
Messages: 23
Registered: July 2009
Junior Member
Thank you Kenn,

Now I understand it, and it is a good reason to avoid the redundancy of
method implementations.

I suppose there is no variable in the genmodel file to change this
behavior.
It would be really nice to have it in order the uml2.codegen could be
reused by more people.

At first sight I cannot make it by changing only the templates. I seems
that the names are created in the genmodel.

Could you please confirm me this point.

Javi
Re: uml2 genmodel, abstract classes and operations [message #625229 is a reply to message #476387] Wed, 17 October 2007 13:33 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Javi,

Yes, the names are calculated in the generator model based on the class
(interface) names. I'm not sure that I understand how/why you need the
behavior to be different, but if you can justify this as something that
would be generally useful, feel free to open an enhancement request in
Bugzilla.

Kenn

"Javi" <jfbriones_tech@yahoo.es> wrote in message
news:c02364e7f23320f9ccb40fffade84c8a$1@www.eclipse.org...
> Thank you Kenn,
>
> Now I understand it, and it is a good reason to avoid the redundancy of
> method implementations.
>
> I suppose there is no variable in the genmodel file to change this
> behavior.
> It would be really nice to have it in order the uml2.codegen could be
> reused by more people.
>
> At first sight I cannot make it by changing only the templates. I seems
> that the names are created in the genmodel.
>
> Could you please confirm me this point.
>
> Javi
>
>
Previous Topic:using PacakageMerge to transform a model.
Next Topic:Re: metamodel conflict while reading xmi file
Goto Forum:
  


Current Time: Wed Apr 24 20:54:43 GMT 2024

Powered by FUDForum. Page generated in 0.04225 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top