Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » describe mutiple classes as OCL
describe mutiple classes as OCL [message #727503] Wed, 21 September 2011 13:23 Go to next message
pllab Missing name is currently offline pllab Missing nameFriend
Messages: 6
Registered: September 2011
Junior Member
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 Very Happy
Re: describe mutiple classes as OCL [message #727534 is a reply to message #727503] Wed, 21 September 2011 13:57 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 #727810 is a reply to message #727554] Thu, 22 September 2011 02:10 Go to previous messageGo to next message
pllab Missing name is currently offline pllab Missing nameFriend
Messages: 6
Registered: September 2011
Junior Member
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.
  • Attachment: cd.jpg
    (Size: 17.05KB, Downloaded 942 times)
Re: describe mutiple classes as OCL [message #728028 is a reply to message #727810] Thu, 22 September 2011 12:10 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
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 #728846 is a reply to message #728029] Sat, 24 September 2011 03:34 Go to previous messageGo to next message
pllab Missing name is currently offline pllab Missing nameFriend
Messages: 6
Registered: September 2011
Junior Member
Hello! Very appreciate for your advice.

I do not understand what did you mean in the first paragraph.
I'm now using ecore model to describe the example what I want to implement.
And after that, I have to write OCL manually to support that ecore model.

But the methods what I use is required by my teacher.
I try to figure out the question that I have mentioned before.
Is it possible to implement navigationCallExp in OCL by the methods what I use now?
My work is going to do software testing by using both ecore model and OCL.
And using ECLiPSe to verify the correctness with that model.

The information what I reference is as follow:
download.eclipse.org/modeling/mdt/ocl/javadoc/3.0.0/org/eclipse/ocl/ecore/package-summary.html

If there is anything you don't know what I say, I'll explain it clearly again.
Thanks for your help!!
Re: describe mutiple classes as OCL [message #728862 is a reply to message #728846] Sat, 24 September 2011 05:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Very little of what you write makes any sense to me at all.

navigationCallExp is a mechanism in OCL why would you want to implement
what the tool implements?

Either you have misunderstood your teacher or your teacher is very
misguided.

You do not understand my first paragraph, which you do not quote, I
presume it is the sentence about Complete OCL. I suggest you read the
OCL specification or Google some of my papers to find out about Complete
OCL wrt Essential OCL. The Javadocs should be completely irrelevant to
your use of OCL. Do you read the class documentation in order to use an
email tool?

You will eventually find evidence that a bidirectional relationship
cannot be defined in Complete OCL, which may form part of your class
answer and justify your use of a solution that actually works.

Regards

Ed Willink

On 24/09/2011 04:34, pllab wrote:
> Hello! Very appreciate for your advice.
>
> I do not understand what did you mean in the first paragraph.
> I'm now using ecore model to describe the example what I want to
> implement.
> And after that, I have to write OCL manually to support that ecore model.
>
> But the methods what I use is required by my teacher.
> I try to figure out the question that I have mentioned before.
> Is it possible to implement navigationCallExp in OCL by the methods
> what I use now?
> My work is going to do software testing by using both ecore model and
> OCL.
> And using ECLiPSe to verify the correctness with that model.
> The information what I reference is as follow:
> download.eclipse.org/modeling/mdt/ocl/javadoc/3.0.0/org/eclipse/ocl/ecore/package-summary.html
>
>
> If there is anything you don't know what I say, I'll explain it
> clearly again.
> Thanks for your help!!
>
Re: describe mutiple classes as OCL [message #735381 is a reply to message #728862] Tue, 11 October 2011 16:02 Go to previous messageGo to next message
pllab Missing name is currently offline pllab Missing nameFriend
Messages: 6
Registered: September 2011
Junior Member
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 #735407 is a reply to message #735381] Tue, 11 October 2011 17:18 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 17:18 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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?
>
>
Previous Topic:Evaluate operations defined via OCLinEcore in the interactive console yields OCLinvalid
Next Topic:[OCLinEcore] Resolving attributes in OCL Constraints
Goto Forum:
  


Current Time: Thu Apr 25 05:41:27 GMT 2024

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

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

Back to the top