Can't find all elements with a stereotype

MagicDraw OpenAPI, scripting related questions and discussions

Moderator: Moderators

Can't find all elements with a stereotype

Postby sean.conway.mbse@gmail.com » Tue Jan 22, 2019 4:23 pm

I have a main model with about 8 used packages. Each of the used packages contains requirements with a stereotype that extends the basic "Requirement" stereotype.

I am using the following code to try and get a list of all of the elements with this stereotype, so that I can iterate over them in a java program to create traces based on a spreadsheet.

// find the stereotype
List<Element> requirements = null;
Stereotype stereotype = Finder.byNameRecursively().find(project, Stereotype.class, "Requirement IBCS");
if (stereotype != null){
// elements with the applied stereotype
requirements = StereotypesHelper.getExtendedElements(stereotype);
}

When I run this code it only finds the requirements in one of the used packages and it seems to be random. It never finds all of the requirements and it never find the requirements in more than one of the used packages.

Any ideas?
sean.conway.mbse@gmail.com
Forum Newbie
Forum Newbie
 
Posts: 4
Posts Rating:0
Joined: Mon Nov 26, 2018 1:18 pm

Re: Can't find all elements with a stereotype

Postby gdhardy1 » Wed Jan 23, 2019 11:50 am

Instead of using Finder, try using StereotypesHelper.getStereotype(Project, Stereotype, Profile) to find the "Requirement IBCS" stereotype.
gdhardy1
Forum Newbie
Forum Newbie
 
Posts: 8
Posts Rating:2
Joined: Thu Oct 18, 2018 11:24 am


Return to Programmatic Extendibility

Who is online

Users browsing this forum: No registered users and 1 guest