Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Setting a property's initial value on Papyrus OCL
Setting a property's initial value on Papyrus OCL [message #1738359] Tue, 19 July 2016 09:29 Go to next message
Philippe de Rochambeau is currently offline Philippe de RochambeauFriend
Messages: 40
Registered: February 2013
Member
Hello,

in OCL books , you often see code such as

context LoyaltyAccount::points
init: 0

How do you set a property's initial value in Papyrus OCL?

Is the Papyrus "DefaultValue" the same as the OCL "init:"?

Many thanks.

phiroc

[Updated on: Tue, 19 July 2016 09:38]

Report message to a moderator

Re: Setting a property's initial value on Papyrus OCL [message #1738364 is a reply to message #1738359] Tue, 19 July 2016 09:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6569
Registered: July 2009
Senior Member
Hi

There is a terminology mismatch between OCL and UML.

OCL's inital property value is an expression that corresponds to a UML
default value.

OCL's derived property value is a constraint that corresponds to a UML
class constraint whose constrained element is the property.

So in Papyrus (a UML tool) set the default value of the property. If the
value is not a simple literal, you must indeed use an OpaqueExpression.

Regards

Ed Willink


On 19/07/2016 10:29, Philippe de Rochambeau wrote:
> Hello,
>
> in OCL books , you often see code such as
>
> context LoyaltyAccount::points
> init: 0
>
> How do you set a property's initial value in Papyrus OCL?
>
> Should you use an OpaqueConstraint?
>
> Many thanks.
>
> phiroc



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Re: Setting a property's initial value on Papyrus OCL [message #1738367 is a reply to message #1738364] Tue, 19 July 2016 10:00 Go to previous messageGo to next message
Philippe de Rochambeau is currently offline Philippe de RochambeauFriend
Messages: 40
Registered: February 2013
Member
Things are a lot clearer now. Many thanks, Ed.
Re: Setting a property's initial value on Papyrus OCL [message #1738374 is a reply to message #1738367] Tue, 19 July 2016 10:28 Go to previous messageGo to next message
Philippe de Rochambeau is currently offline Philippe de RochambeauFriend
Messages: 40
Registered: February 2013
Member
In Papyrus, to create a Default Value, say 0 for a property with an Integer type, you have to create a LiteralInteger, give it a name, and then assign a value. As a result, the DefaultValue looks something like this "init=0". Isn't creating a literal integer label a bit of an overkill? Why can't you just directly specify the property's value?
Re: Setting a property's initial value on Papyrus OCL [message #1738376 is a reply to message #1738374] Tue, 19 July 2016 10:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6569
Registered: July 2009
Senior Member
Hi

IIRC you just set value now and the tooling sorts out the
LiteralInteger/LiteralString/...

Setting a name is gratuitous.

Again IIRC Older versions of Papyrus lacked the appropriate Literal
inference, with Enumeration instances a very recent fix (in Neon).

Regards

Ed Willink

On 19/07/2016 11:28, Philippe de Rochambeau wrote:
> In Papyrus, to create a Default Value, say 0 for a property with an
> Integer type, you have to create a LiteralInteger, give it a name, and
> then assign a value. As a result, the DefaultValue looks something
> like this "init=0". Isn't creating a literal integer label a bit of an
> overkill? Why can't you just directly specify the property's value?



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
Re: Setting a property's initial value on Papyrus OCL [message #1738389 is a reply to message #1738376] Tue, 19 July 2016 12:07 Go to previous message
Philippe de Rochambeau is currently offline Philippe de RochambeauFriend
Messages: 40
Registered: February 2013
Member
Hi Ed,

I have made some tests and found that in both Eclipse Mars + Papyrus 1.1.4 and stand-alone Papyrus 2.0, the default-value name is indeed gratuitous, but the type isn't: you must select one from a list (e.g., LiteralInteger, etc.)
Previous Topic:Model synchronization in Sequence diagram
Next Topic:Framework-Independent Types
Goto Forum:
  


Current Time: Wed Jan 29 16:54:18 GMT 2020

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

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

Back to the top