Page 1 of 1

Can't find all elements with a stereotype

PostPosted: Tue Jan 22, 2019 4:23 pm
by sean.conway.mbse@gmail.com
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?

Re: Can't find all elements with a stereotype

PostPosted: Wed Jan 23, 2019 11:50 am
by gdhardy1
Instead of using Finder, try using StereotypesHelper.getStereotype(Project, Stereotype, Profile) to find the "Requirement IBCS" stereotype.