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 09:57   |
Eclipse User |
|
|
|
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 09:57   |
Eclipse User |
|
|
|
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 09:57   |
Eclipse User |
|
|
|
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 08:10   |
Eclipse User |
|
|
|
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 08:10   |
Eclipse User |
|
|
|
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 #735407 is a reply to message #735381] |
Tue, 11 October 2011 13:18  |
Eclipse User |
|
|
|
Hi
I've been thinking about Ecore/OCL merge tooling. What you imply seems
more useful; https://bugs.eclipse.org/bugs/show_bug.cgi?id=360567
raised. I'm afraid that doesn't help you now.
If you want to extract the OCL from an OCLinEcore file, it's probably
easiest to cut and paste for now. But do you really need separate files?
Regards
Ed Willink
On 11/10/2011 17:02, pllab wrote:
> hi
> my work is going to load an ecore file and ocl file to generate test data
> before generating the test data successfully,I need a complete
> specification
> so I have to use both files to fulfill my implementation.
>
> The reason why I have to "implement" the NavigationCallExp is as follow:
> When I load the files I have mentioned before, the parser need to
> parse the file(xmi)
> And so that I can build an OCL expression tree, and also, to get the
> information that which OCL expression has shown in the OCL file.
>
> By the way, I have used oclInEcore that you suggested.
> But how can I get the ocl file when I use oclInecore editor to edit
> the ecore project?
> There is only an ecore file without ocl file.
> Do I have to erase the function to load the ocl file?
>
>
|
|
|
Re: describe mutiple classes as OCL [message #735408 is a reply to message #735381] |
Tue, 11 October 2011 13:18  |
Eclipse User |
|
|
|
Hi
I've been thinking about Ecore/OCL merge tooling. What you imply seems
more useful; https://bugs.eclipse.org/bugs/show_bug.cgi?id=360567
raised. I'm afraid that doesn't help you now.
If you want to extract the OCL from an OCLinEcore file, it's probably
easiest to cut and paste for now. But do you really need separate files?
Regards
Ed Willink
On 11/10/2011 17:02, pllab wrote:
> hi
> my work is going to load an ecore file and ocl file to generate test data
> before generating the test data successfully,I need a complete
> specification
> so I have to use both files to fulfill my implementation.
>
> The reason why I have to "implement" the NavigationCallExp is as follow:
> When I load the files I have mentioned before, the parser need to
> parse the file(xmi)
> And so that I can build an OCL expression tree, and also, to get the
> information that which OCL expression has shown in the OCL file.
>
> By the way, I have used oclInEcore that you suggested.
> But how can I get the ocl file when I use oclInecore editor to edit
> the ecore project?
> There is only an ecore file without ocl file.
> Do I have to erase the function to load the ocl file?
>
>
|
|
|
Goto Forum:
Current Time: Wed Jul 23 00:39:18 EDT 2025
Powered by FUDForum. Page generated in 0.04609 seconds
|