2021x StereotypesHelper refactor

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

2021x StereotypesHelper refactor

Postby dustin.waguespack@gdit.com » Mon Sep 27, 2021 12:18 pm

The collectOwnedSlots() method was removed from the StereotypesHelper class in the 2021x release. Does anyone know the new, preferred way to obtain the Slot elements from a com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class object?
dustin.waguespack@gdit.com
Forum Newbie
Forum Newbie
 
Posts: 6
Posts Rating:3
Joined: Thu Mar 11, 2021 1:36 pm

Re: 2021x StereotypesHelper refactor

Postby clement.mezerette@Samares-Engineering.com » Wed Nov 10, 2021 2:12 am

Hello,

I'm trying to migrate to 2021x as well and I'm having the same issues with the Class StereotypesHelper; they're not exactly the same methods (mine are getSlot(), addSlotValue(), hasStereotypeByName()), but the same issue. Does anyone know how to solve the problem?
clement.mezerette@Samares-Engineering.com
Forum Newbie
Forum Newbie
 
Posts: 1
Posts Rating:0
Joined: Mon Feb 22, 2021 4:39 am

Re: 2021x StereotypesHelper refactor

Postby ogirdor » Tue Jun 21, 2022 3:33 am

Hello,

I am not sure if this is the most straight-forward way, but I do it like this (in java):

Code: Select all
myClass.getOwnedElement().stream()
.filter(o -> o instanceof TaggedValue)
.filter(t -> ((TaggedValue) t).getTagDefinition().getName().equals("slotName"))
.map(t -> (String)(((TaggedValue) t).getValue().get(0)))
.findFirst();
ogirdor
Forum Beginner
Forum Beginner
 
Posts: 66
Posts Rating:19
Joined: Wed Jun 03, 2020 4:41 am


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 0 guests

cron