Multiple stereotype instances

UML related questions and discussions

Moderator: Moderators

Multiple stereotype instances

Postby jvernonjpmc » Fri Oct 06, 2017 11:15 am

I want to be able to record the mapping of database elements, e.g. tables, to elements in class models, e.g. classes.

Sometimes a table maps to multiple classes. When I record a mapping, I want to record the element and the reason. Therefore, for each table, there may be multiple element / reason value pairs.

I have implemented this as a stereotype, where metaclass type is Element, and there are two attributes, mappedElement: Element and reason : String.

This only allows me to record the mapping of each table to one class. How do I define the stereotype to allow me to record the mapping of each table to multiple classes?

Thank you
jvernonjpmc
Forum Beginner
Forum Beginner
 
Posts: 42
Posts Rating:0
Joined: Mon Aug 15, 2016 3:56 pm

Re: Multiple stereotype instances

Postby Rolandas » Mon Oct 09, 2017 8:16 am

Hello,

Change the multiplicity mappedElement: Element to *. Or to number your require.

Regards,
No Magic Support Team
Rolandas
Customer Support
Customer Support
 
Posts: 186
Posts Rating:14
Joined: Mon Jul 30, 2012 3:59 am

Re: Multiple stereotype instances

Postby jvernonjpmc » Tue Oct 10, 2017 6:39 am

Sorry I should have been more specific.

Your solution allows me to record the mapping of each table to multiple classes. How do I define the stereotype to allow me to record the mapping of each table to multiple classes, and with each mapping, record the reason? That is, for each mapping, I want to record the mapped element and the reason. So I could map Table T to classes C1 and C2 and for the mapping of T to C1 I record reason R1, and for the mapping of T to C2 I record reason R2.

Thank you
jvernonjpmc
Forum Beginner
Forum Beginner
 
Posts: 42
Posts Rating:0
Joined: Mon Aug 15, 2016 3:56 pm

Re: Multiple stereotype instances

Postby Rolandas » Tue Oct 10, 2017 11:31 pm

Hello,

There is no simple solution to that. You need to make another class probably, that has the tags you need. Then your main object mapping should be that type. You create and fill tags for newly created class and set tags, then set that class as mapping object. Mapping should be multiplicity *. Or similar. Depends how you fill it, how you want to handle it.

Regards,
No Magic Support Team
Rolandas
Customer Support
Customer Support
 
Posts: 186
Posts Rating:14
Joined: Mon Jul 30, 2012 3:59 am

Re: Multiple stereotype instances

Postby jvernonjpmc » Wed Oct 11, 2017 8:42 am

Can you provide an example, or point me to a tutorial?

Thank you
jvernonjpmc
Forum Beginner
Forum Beginner
 
Posts: 42
Posts Rating:0
Joined: Mon Aug 15, 2016 3:56 pm

Re: Multiple stereotype instances

Postby Rolandas » Thu Oct 12, 2017 12:48 am

Hello,

You want example/tutorial of code how to create it? Or model how to create?
From model. You have a Stereotype A, that has mappedElement: Element and reason : String
Ok, now you create another Stereotype B that has, list: Stereotype A [*]

When you importing elements, you create Element with Stereotype A and fill mappedElement, reason. Then add that element to your Element that has Stereotype B, to list.
How to work with OpenAPI from code, you can find here: https://docs.nomagic.com/display/MD185/ ... l+elements


Regards,
No Magic Support Team
Rolandas
Customer Support
Customer Support
 
Posts: 186
Posts Rating:14
Joined: Mon Jul 30, 2012 3:59 am

Re: Multiple stereotype instances

Postby jvernonjpmc » Wed Nov 08, 2017 12:44 pm

> You want example/tutorial of code how to create it? Or model how to create?
I'd like a tutorial on how to create and instantiate the stereotype in Magic Draw.

> From model. You have a Stereotype A, that has mappedElement: Element and reason : String
> Ok, now you create another Stereotype B that has, list: Stereotype A [*]
I followed your directions above and now have the attached diagram. I want to apply the stereotype B to record that My Class has multiple mappings, one to class Mapped to X and one to class Mapped to Y. I tried the following:

1. Bring up the specification of class My Class
2. Select Tags
3. Select Mappings under stereotype B
4. Create Value

I was hoping to search for class Mapped to X then enter a reason, then create value again and search for class Mapped to Y then enter a reason. But that doesn't work. On one attempt nothing appeared in the tree dialog. On a second attempt with a different example, a class appeared, but Create and Clone were greyed out.

Remember, for My Class, I want to record two mappings, the first to Mapped to X with Reason R1 and the second to Mapped to Y with reason R2. Please explain how I do this.
You do not have the required permissions to view the files attached to this post.
jvernonjpmc
Forum Beginner
Forum Beginner
 
Posts: 42
Posts Rating:0
Joined: Mon Aug 15, 2016 3:56 pm

Re: Multiple stereotype instances

Postby Rolandas » Thu Nov 09, 2017 1:15 am

Hello,

You need another elements for mapping reason.

So you have MyClass with StereotypeB, then you create MyClass Map1 with StereotypeA and in it's tags you select Mapped to X and Reason1, then in MyClass tag, select MyClass Map1.
Same goes for second reason and mapping. You will need additional elements to create your mapping reason and element.

Regards,
No Magic Support Team
Rolandas
Customer Support
Customer Support
 
Posts: 186
Posts Rating:14
Joined: Mon Jul 30, 2012 3:59 am


Return to Software Modeling (UML)

Who is online

Users browsing this forum: No registered users and 2 guests