Hi Community!
I'm trying to get the tagged values of a stereotype and I cannot.
I am using this code for getting the stereotype but afterwards cannot find a method for its values:
var estereotipos = atributo.omfGetApplicableStereotypes().toArray()
I am sending a pic of what Im looking for.
Thank you!
Hi,
in order to get the tagged values of a UML element you have to analyse its stereotype applications. The following code snippet shows how to do this:
// Get all stereotype applications of the UML element
var stereotypeApplications = umlElement.omfGetStereotypeApplications();
// Iterate over the stereotype applications of the UML element
for (var itStereotypeApplications = stereotypeApplications.iterator(); itStereotypeApplications.hasNext();) {
var stereotypeApplication = itStereotypeApplications.next();
if (!stereotypeApplication.omfIsValid()) {
// skip this stereotype application if it is not valid
continue;
}
// Get the applied stereotype
var stereotype = stereotypeApplication.omfGetAppliedStereotype();
// Get all attributes of the stereotype
var stereotypeAttributes = stereotype.getAllAttributes();
// Iterate over all stereotype attributes
for (var itStereotypeAttributes = stereotypeAttributes.iterator(); itStereotypeAttributes.hasNext();) {
var stereotypeAttribute = itStereotypeAttributes.next();
// Get the corresponding tagged value
var taggedValue = stereotypeApplication.omfGet(stereotypeAttribute, null);
}
}
There is an example report "Create and assign profile" in the report category "UML sample scripts". Although it's more about creating profiles and stereotypes, applying them to UML elements and specifying tagged values, it should give some more information how to deal with stereotypes in a report script, e.g. how to access profiles, stereotypes and stereotype attributes by their name.
Regards,
Thomas Andres