Home » Modeling » OCL » describe mutiple classes as OCL
|
Re: describe mutiple classes as OCL [message #727534 is a reply to message #727503] |
Wed, 21 September 2011 13:57 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
I'm not clear what you mean by an OCL file, and it is not clear why you
are using OCL at all for a navigation relationship between two classes.
It might help if you provided an example.
It is also not clear what you mean by drawing diagrams in EMF. EMF
provides XSD, XMI, tree and model representations; no graphics. Do you
mean the Ecore Tools Diagram Editor?
2) Just about any Class Diagram notation can support a directional
navigation, however the graphical presentation options may not always
fully reflect the flexibility of an underlying Ecore or UML model.
1) Yes OCL works fine for multiple classes in one or more files.
Regards
Ed Willink
On 21/09/2011 14:23, pllab wrote:
> Hi,I'm a new user with OCL. And I have met several problems...
>
> The question is when I want to describe a class diagram with two classes,
>
> I would like to implement the relation which is "navigation" between
> these two classes
> but it looks like that it doesn't work when I write the OCL which
> describes both classes in an OCL file.
>
> I have no idea whether it does make sense that the OCL can allow both
> classes in a same file. --- Problem 1
>
> Besides, in EMF, I want to draw the diagrams which have a 'navigation'
> relation between classes without arrow. However,the EMF doesn't allow
> me to do that, i.e. there is still an arrow between two classes. ---
> Problem 2
>
> Please answer my questions, thanks you a lot :d
>
|
|
|
Re: describe mutiple classes as OCL [message #727537 is a reply to message #727503] |
Wed, 21 September 2011 13:57 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
I'm not clear what you mean by an OCL file, and it is not clear why you
are using OCL at all for a navigation relationship between two classes.
It might help if you provided an example.
It is also not clear what you mean by drawing diagrams in EMF. EMF
provides XSD, XMI, tree and model representations; no graphics. Do you
mean the Ecore Tools Diagram Editor?
2) Just about any Class Diagram notation can support a directional
navigation, however the graphical presentation options may not always
fully reflect the flexibility of an underlying Ecore or UML model.
1) Yes OCL works fine for multiple classes in one or more files.
Regards
Ed Willink
On 21/09/2011 14:23, pllab wrote:
> Hi,I'm a new user with OCL. And I have met several problems...
>
> The question is when I want to describe a class diagram with two classes,
>
> I would like to implement the relation which is "navigation" between
> these two classes
> but it looks like that it doesn't work when I write the OCL which
> describes both classes in an OCL file.
>
> I have no idea whether it does make sense that the OCL can allow both
> classes in a same file. --- Problem 1
>
> Besides, in EMF, I want to draw the diagrams which have a 'navigation'
> relation between classes without arrow. However,the EMF doesn't allow
> me to do that, i.e. there is still an arrow between two classes. ---
> Problem 2
>
> Please answer my questions, thanks you a lot :d
>
|
|
|
Re: describe mutiple classes as OCL [message #727554 is a reply to message #727503] |
Wed, 21 September 2011 13:57 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
I'm not clear what you mean by an OCL file, and it is not clear why you
are using OCL at all for a navigation relationship between two classes.
It might help if you provided an example.
It is also not clear what you mean by drawing diagrams in EMF. EMF
provides XSD, XMI, tree and model representations; no graphics. Do you
mean the Ecore Tools Diagram Editor?
2) Just about any Class Diagram notation can support a directional
navigation, however the graphical presentation options may not always
fully reflect the flexibility of an underlying Ecore or UML model.
1) Yes OCL works fine for multiple classes in one or more files.
Regards
Ed Willink
On 21/09/2011 14:23, pllab wrote:
> Hi,I'm a new user with OCL. And I have met several problems...
>
> The question is when I want to describe a class diagram with two classes,
>
> I would like to implement the relation which is "navigation" between
> these two classes
> but it looks like that it doesn't work when I write the OCL which
> describes both classes in an OCL file.
>
> I have no idea whether it does make sense that the OCL can allow both
> classes in a same file. --- Problem 1
>
> Besides, in EMF, I want to draw the diagrams which have a 'navigation'
> relation between classes without arrow. However,the EMF doesn't allow
> me to do that, i.e. there is still an arrow between two classes. ---
> Problem 2
>
> Please answer my questions, thanks you a lot :d
>
|
|
| |
Re: describe mutiple classes as OCL [message #728028 is a reply to message #727810] |
Thu, 22 September 2011 12:10 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
Ok, you are using 'Complete' OCL, which is really intended for
complementing an existing model rather than defining a model; as you
have noticed the syntax is insufficient for definition. Just enough for
reference.
I would recommend using Ecore directly, or OCLinEcore to define the
model. If you use OCLinEcore then you can embed the OCL and have it
incorporated in generated Java (for interpreted execution in Indigo,
direct Java in Juno).
The OCLinEcore could look like
package motordriver
{
class Person
{
property age : Integer;
property motor#man : Motor[*];
invariant: age > 0;
operation Person(a:Integer)
{
precondition: a > 0;
postcondition: age = a;
}
operation isAdult() : Boolean
{
body:
if age >= 18 then
true
else
false
endif;
}
}
class Motor
{
property displacement : Integer;
property man#motor : Person;
invariant: displacement >= 50;
invariant: self.man.age = 18;
operation Motor(d:Integer)
{
precondition: d > 0;
postcondition: displacement = d;
}
operation heavyWeight() : String
{
body:
if displacement >= 100 then
'HeavyWeight'
else
if displacement = 50 then
'LightWeight'
else
'Nothing'
endif
endif;
}
}
}
On 22/09/2011 03:10, pllab wrote:
> Thanks to your reply, and I'm sorry for my unclear questions.
> I have uploaded the class diagram.
> About the first question,I write the OCL which I refer to "OCL file" is as follows:
>
> package motordriver
>
> context Person
> inv: age> 0
>
> context Person::Person(a:Integer):
> pre: a> 0
> post: age = a
>
> context Person::isAdult(): Boolean
> post:
> if age>= 18 then
> result = true
> else
> result = false
> endif
>
> context Motor
> inv: displacement>= 50
>
> --context Motor
> --inv:self.man.age = 18
> context Motor::Motor(d:Integer):
> pre: d> 0
> post: displacement = d
>
> context Motor::heavyWeight():String
> post:
> if displacement>= 100 then
> result = 'HeavyWeight'
> else
> if displacement = 50 then
> result = 'LightWeight'
> else
> result = 'Nothing'
> endif
> endif
> endpackage
>
> There are two classes in the diagram, and I describe this diagram via OCL specification. When I want to parse it, it looks like the parser can parse only one class diagram. BTW, the tool I use is ecore modeling framework for eclipse.
>
|
|
|
Re: describe mutiple classes as OCL [message #728029 is a reply to message #727810] |
Thu, 22 September 2011 12:10 |
Ed Willink Messages: 7670 Registered: July 2009 |
Senior Member |
|
|
Hi
Ok, you are using 'Complete' OCL, which is really intended for
complementing an existing model rather than defining a model; as you
have noticed the syntax is insufficient for definition. Just enough for
reference.
I would recommend using Ecore directly, or OCLinEcore to define the
model. If you use OCLinEcore then you can embed the OCL and have it
incorporated in generated Java (for interpreted execution in Indigo,
direct Java in Juno).
The OCLinEcore could look like
package motordriver
{
class Person
{
property age : Integer;
property motor#man : Motor[*];
invariant: age > 0;
operation Person(a:Integer)
{
precondition: a > 0;
postcondition: age = a;
}
operation isAdult() : Boolean
{
body:
if age >= 18 then
true
else
false
endif;
}
}
class Motor
{
property displacement : Integer;
property man#motor : Person;
invariant: displacement >= 50;
invariant: self.man.age = 18;
operation Motor(d:Integer)
{
precondition: d > 0;
postcondition: displacement = d;
}
operation heavyWeight() : String
{
body:
if displacement >= 100 then
'HeavyWeight'
else
if displacement = 50 then
'LightWeight'
else
'Nothing'
endif
endif;
}
}
}
On 22/09/2011 03:10, pllab wrote:
> Thanks to your reply, and I'm sorry for my unclear questions.
> I have uploaded the class diagram.
> About the first question,I write the OCL which I refer to "OCL file" is as follows:
>
> package motordriver
>
> context Person
> inv: age> 0
>
> context Person::Person(a:Integer):
> pre: a> 0
> post: age = a
>
> context Person::isAdult(): Boolean
> post:
> if age>= 18 then
> result = true
> else
> result = false
> endif
>
> context Motor
> inv: displacement>= 50
>
> --context Motor
> --inv:self.man.age = 18
> context Motor::Motor(d:Integer):
> pre: d> 0
> post: displacement = d
>
> context Motor::heavyWeight():String
> post:
> if displacement>= 100 then
> result = 'HeavyWeight'
> else
> if displacement = 50 then
> result = 'LightWeight'
> else
> result = 'Nothing'
> endif
> endif
> endpackage
>
> There are two classes in the diagram, and I describe this diagram via OCL specification. When I want to parse it, it looks like the parser can parse only one class diagram. BTW, the tool I use is ecore modeling framework for eclipse.
>
|
|
| | | | | |
Goto Forum:
Current Time: Wed Sep 25 05:23:11 GMT 2024
Powered by FUDForum. Page generated in 0.04316 seconds
|