Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Class Object and Attributes issues(can't set the value of an object's attribute for a class)
Class Object and Attributes issues [message #668425] Thu, 05 May 2011 15:49 Go to next message
Valerian Merkling is currently offline Valerian MerklingFriend
Messages: 71
Registered: May 2011
Member
Hi !

I'm working with Papyrus 0.7, and with uml2

Here is what i want to do :

A class Transport, with an atribute Distance: Integer.

Now i want to make a class DeliveryA, which own an instance of Transport, with a fixed value of 1000 for Distance.

I'm aiming code generation(with Acceleo), and be able to say that each instance of DeliveryAcreate a new Transport with 1000 in its constructor.

Right now i'm trying to add a Property to DeliveryA, set its type to Transport, and now looking for somethings like a subproperty field, but i'm a bit lost.

And i don't want to use stereotypefor this.

I don't really know if my problem come from a bad understanding of UML or Papyrus, or maybe i'm doing it all wrong ... Can someone help me ?

Thanks !
Re: Class Object and Attributes issues [message #668614 is a reply to message #668425] Fri, 06 May 2011 12:41 Go to previous messageGo to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
What comes up to my mind is an OCL constraint on the Transport property of DeliveryA. But I don't know if Acceleo can generate what you want from it.

Another option would be to model the constructor of DeliveryA as an operation with the <<Create>> stereotype from the standard profile and to add an appropriate method to it depending on what Acceleo requires, but you said you don't want to use a stereotype.

You could probably ask the Acceleo people, I don't think it depends on Papyrus.
Re: Class Object and Attributes issues [message #668636 is a reply to message #668425] Fri, 06 May 2011 14:12 Go to previous messageGo to next message
Valerian Merkling is currently offline Valerian MerklingFriend
Messages: 71
Registered: May 2011
Member
Ok thanks i'll have a look on what OCL can do and how.

But isn't here a way in UML2, after building some attribute, to fix its value somewhere ?
I don't understand why i can do that for stereotype's attributes, but not for classes attributes.
Re: Class Object and Attributes issues [message #668766 is a reply to message #668425] Sat, 07 May 2011 07:50 Go to previous messageGo to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
You could also model an initial value for the class property. That initial value would construc a Transport object with a value of 1000 for Distance.

This would either require a constructor for Transport, or a subclass of Transport (e.g. Transport1000) with an initial value for Distance. In the latter case the class property of DeliveryA would have the type Transport1000.
Re: Class Object and Attributes issues [message #669232 is a reply to message #668425] Mon, 09 May 2011 14:50 Go to previous messageGo to next message
Valerian Merkling is currently offline Valerian MerklingFriend
Messages: 71
Registered: May 2011
Member
This sounds pretty good !

Just to be sure to understand, by initial value, you mean default Value, right?
Re: Class Object and Attributes issues [message #669426 is a reply to message #668425] Tue, 10 May 2011 10:18 Go to previous messageGo to next message
Thomas Neustupny is currently offline Thomas NeustupnyFriend
Messages: 75
Registered: October 2009
Member
Yes, or even more precisely: the defaultValue of a Property (class attribute), which is a ValueSpecification object.
Re: Class Object and Attributes issues [message #669448 is a reply to message #668425] Tue, 10 May 2011 11:33 Go to previous messageGo to next message
Valerian Merkling is currently offline Valerian MerklingFriend
Messages: 71
Registered: May 2011
Member
Ok thanks a lot, it works. The problem was not with Papyrus but about me and UML.

Little question to conclude, in the model explorer, sometimes the Property icon got a little green cross on its bottom-right corner, what does it mean ?
Re: Class Object and Attributes issues [message #672338 is a reply to message #669448] Fri, 20 May 2011 17:53 Go to previous messageGo to next message
Patrick Tessier is currently offline Patrick TessierFriend
Messages: 341
Registered: July 2009
Location: Paris Saclay, France
Senior Member
this is a decorator to express that your property is public
Re: Class Object and Attributes issues [message #672394 is a reply to message #669448] Fri, 20 May 2011 22:02 Go to previous messageGo to next message
Sébastien Gérard is currently offline Sébastien GérardFriend
Messages: 121
Registered: July 2009
Senior Member
I think that means the property is public.
Re: Class Object and Attributes issues [message #672395 is a reply to message #672394] Fri, 20 May 2011 22:14 Go to previous message
Sébastien Gérard is currently offline Sébastien GérardFriend
Messages: 121
Registered: July 2009
Senior Member
To complete the previous answer on the constant property, you may set to true the isReadOnly meta-property of the Property that should hold a constant value.
Previous Topic:Port and Connectors Question
Next Topic:(no subject)
Goto Forum:
  


Current Time: Thu Mar 28 09:52:05 GMT 2024

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

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

Back to the top