Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Create containers
Create containers [message #1756101] Sat, 11 March 2017 09:13 Go to next message
Athanasios Zolotas is currently offline Athanasios ZolotasFriend
Messages: 52
Registered: November 2016
Location: York
Member
Hi,

This might be a stupid question but I wasn't able to find the answer online.

I try to create a DSL that needs to have elements that contain other elements. Take for a example a Zoo DSL where elements stereotyped as "Zoo" should containt elements stereotyped as "Animals". I suppose I can create an aggregation association to denote this notation, however is it possible to use "Zoo" instances as containers for "Animal" instances to denote this relation by grouping the latter inside the former? Just to make it clear, creating a "large" Zoo element and place the Animal elements on top of it is not what I am looking. I would like to have zoo and animals bound, so when I move the Zoo node the contained animal elements will follow.
Re: Create containers [message #1756111 is a reply to message #1756101] Sat, 11 March 2017 14:10 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi,

Stereotype instances can't (Or "shouldn't?" I'm not 100% sure) contain each other. So, aggregation associations between two Stereotypes are not allowed (Or discouraged; once again, I'm not sure).

Instead, your Stereotypes should extend 2 UML Metaclasses which already define a containment relationship to each other. For example, "Zoo" extends Package, and "Animal" extends Class.

The Package - Class relationship is quite limited, so usually I would recommend using "Class" and "Property" instead (i.e. similar to what is done for Component or Composite structures, or Blocks/Internal Blocks in SysML...). The benefit of Class/Property is that a property can be typed by a Class, allowing deeper recursion of ownership. It probably isn't necessary for such a simple example, but on real world applications, it's often required.

HTH,
Camille


Camille Letavernier
Re: Create containers [message #1756124 is a reply to message #1756111] Sun, 12 March 2017 10:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Your use of words rather than pictures is very confusing.

I see no reason why if Element can contain Element, <<Zoo>>Element cannot contain <<Animal>>Element, with a constraint to enforce this usage. However this use of Stereotypes to avoid modeling real Zoo and Animal classes seems very misguided.

Perhaps if you draw a UML diagram if what you really want, we may all understand what you are trying to do.

Regards

Ed Willink
Re: Create containers [message #1756158 is a reply to message #1756124] Mon, 13 March 2017 09:42 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
Hi when you create a profile you have to do a projection of a metamodel into UML. Composition Link must be supported by the metamodel of UML.
For example container - contained : in stereotype world could be based on package and classes.
For a reuse, Classes by using properties .

So I think that your problem is a problem of projection of your metamodel in UML: what will be my base metaclasses?
Patrick

Re: Create containers [message #1756163 is a reply to message #1756158] Mon, 13 March 2017 10:12 Go to previous messageGo to next message
Athanasios Zolotas is currently offline Athanasios ZolotasFriend
Messages: 52
Registered: November 2016
Location: York
Member
Hi,

Thanks for your replies.

I agree that my example is ambiguous. I agree with all your comments as these are things that I had in my mind. Camille and Patrick answered the first of my two questions (I could use UML relationships that support containment relationships e.g., Package and Class or Class and Property) and I think that Ed answered my second question that of having constraints to evaluate if the contained stereotype is appropriate for the container.

Another example based on your feedback: I have a stereotype called <<MyPackage>> that extends UML::Package and two others called <<MyClassType>> and <<MySecondClassType>> that extend UML::Class metaclass. I want instances of <<MyPackage>> to be able to contain only those elements that are stereotyped as <<MyClassType>> but not those stereotyped as <<MySecondClassType>>. I suppose that <<MyPackage>> would have an aggregation relationship pointing to <<MyClassType>>. Is there any way, other than writing OCL constraints, to force this (i.e., only allow <<MyClassType>> elements to be contained in the <<MyPackage>> instance) to the model level? I hope this makes more sense.
Re: Create containers [message #1756165 is a reply to message #1756163] Mon, 13 March 2017 10:29 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Are you an experienced UML user?

If so rethink.

If not, I think you are confusing modeling with metamodeling. It is not necessary, or rather it is very very undesirable, for your metamodel to extend the UML metamodel. UML is big enough and confusing enough without trying to make your concepts comfortable extensions of it. You will get the worst of all possible worlds and ensure that your project joins the long list of modeling failures. You should just define a UML model in which MyPackage, MyClassType etc are user-defined classes. Just because some of their characteristics are similar to UML does not mean that you want 100% of UML cluttering up your model. Once your classes are natural UML classes, you will find that the many UML modeling facilities that are short forms for OCL constraints mean that you can define your model with very few additional explicit OCL constraints.

Regards

Ed Willink
Re: Create containers [message #1756349 is a reply to message #1756165] Wed, 15 March 2017 17:10 Go to previous message
Athanasios Zolotas is currently offline Athanasios ZolotasFriend
Messages: 52
Registered: November 2016
Location: York
Member
I followed your suggestions and now my container element extends the Profile metaclass and the contents extend the Class metaclass. I can place the latter inside the former. However, when it comes to custom shapes there's a slight problem. More specifically, if I create a custom SVG symbol for my package (let's say a simple rectangle SVG) this is placed in a compartment which is beneath the compartment that acts as the container in the package. So, visually the contained classes are not inside but above the SVG symbol that supposedly represents the container.

First of all, could you please tell me if my understanding is correct, i.e., the symbol compartment and the contents compartment are two different things one beneath the other?

Secondly, if this is the case, I know that it is possible to set "placeholders" in the SVG shape to dictate Papyrus where to place the labels (if I recall correctly this is done via an invisible shape inside the symbol that has the id "PapyrusLabel"). Is there any way to say to Papyrus where to place the contained elements in the SVG so they're are moved to the symbol compartment and not the default one?

[Updated on: Wed, 15 March 2017 17:19]

Report message to a moderator

Previous Topic:[CSS] Adding sourceDecoration to a Connector?
Next Topic:Display text and id in a requirement diagram
Goto Forum:
  


Current Time: Thu Mar 28 20:05:14 GMT 2024

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

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

Back to the top