Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Constraint XOR
Constraint XOR [message #871494] Mon, 14 May 2012 08:45 Go to next message
Augusto Ribeiro is currently offline Augusto RibeiroFriend
Messages: 5
Registered: April 2010
Junior Member
Hi all,

Sorry for asking such a basic question, I am new to both Papyrus and UML but I need to know if it is possible to model this in Papyrus and if yes, how to do it. I attached a picture with the part of the model I need to model.


I have to leave the link like this because I cannot post hyperlinks:
imageshack.us/photo/my-images/151/constraint.png

Thanks in advance,
Augusto


Augusto Ribeiro
Aarhus School of Engineering

[Updated on: Mon, 14 May 2012 08:46]

Report message to a moderator

Re: Constraint XOR [message #872007 is a reply to message #871494] Tue, 15 May 2012 09:39 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
You should probably use an Enumeration in this case.

Class Person{age:Integer, name:String, gender:Gender}
Enumeration Gender{Male, Female}


Camille Letavernier
Re: Constraint XOR [message #872028 is a reply to message #872007] Tue, 15 May 2012 10:39 Go to previous messageGo to next message
Augusto Ribeiro is currently offline Augusto RibeiroFriend
Messages: 5
Registered: April 2010
Junior Member
Hi Camille,

Thanks for your answer but from what I gather Enumerations can only contain literals. What I want to represent is that "gender" attribute can be of type Male or Female (which are classes), or bool (a primitive type). This is somehow similar to union types in C "en.wikipedia.org/wiki/Union_(computer_science)". Therefore the XOR constraint, constraining the "gender" attribute to be only one of those types (Male, Female or bool).

The example I gave is valid UML and done in Enterprise Architect, I would like to know if it possible to do the same with Papyrus and how.

Best regards,
Augusto


Augusto Ribeiro
Aarhus School of Engineering

[Updated on: Tue, 15 May 2012 10:40]

Report message to a moderator

Re: Constraint XOR [message #872114 is a reply to message #872028] Tue, 15 May 2012 13:43 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hello Augusto,

I have to admit I'm not familiar with this kind of pattern. I guess you can do the same with Papyrus, with the "Constraint" and "Link" elements:

- Create your classes and primitive types
- Draw your "gender" associations
- Add a Constraint to your diagram
- Add a Link between the constraint and each association

Although I'm not sure what the exact semantic of this pattern is (It depends on the exact constraint specification, I guess).


Hope this helps,
Camille


Camille Letavernier
Re: Constraint XOR [message #874650 is a reply to message #872114] Mon, 21 May 2012 10:13 Go to previous messageGo to next message
Augusto Ribeiro is currently offline Augusto RibeiroFriend
Messages: 5
Registered: April 2010
Junior Member
Hi Camille,

Thanks for the help, that was exactly what I needed.

Regards,
Augusto


Augusto Ribeiro
Aarhus School of Engineering
Re: Constraint XOR [message #902060 is a reply to message #872114] Wed, 15 August 2012 17:12 Go to previous message
Andrea is currently offline AndreaFriend
Messages: 27
Registered: July 2009
Junior Member
On 05/15/2012 03:43 PM, Camille Letavernier wrote:
>
> - Create your classes and primitive types
> - Draw your "gender" associations
> - Add a Constraint to your diagram
> - Add a Link between the constraint and each association
>

I'm not sure what I'm doing wrong, but I can't quite follow the steps
described here. The constraint editor doesn't allow me to just specify
the word xor, like it is done in the picture. I would assume that it
doesn't consider it valid OCL.
I'm not sure if the keyword "xor" alone is valid OCL, but for what I
know a constraint can also contain plain text, so anything should be fine.
Is there anything I can do to change this behavior?

Thanks
Previous Topic:Papyrus Cookbook
Next Topic:Stereotype generalisation producing exceptions
Goto Forum:
  


Current Time: Thu Mar 28 12:17:15 GMT 2024

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

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

Back to the top