Return a collection of diagrams from a list of diagrams filtered by types.
Name
Type
Description
Parameter(s)
diagramList
java.util.Collection
A collection of diagrams.
diagramTypes
java.util.Collection
A collection of diagram types used as filters.
Return
-
java.util.Collection
A collection of filtered diagrams.
For example:
Code Block
language
text
title
Sample of $report.filterDiagram(diagramList, diagramTypes)
#foreach($diagram in $report.filterDiagram($Diagram,["Class Diagram","Communication Diagram"]))
$diagram.name : $diagram.diagramType
#end
$report.filterElement(elementList, humanTypes)
Return a collection of elements from a list of elements filtered by human types.
Name
Type
Description
Parameter(s)
elementList
java.util.Collection
A collection of elements.
humanTypes
java.util.Collection
A collection of human types used as filters.
Return
-
java.util.Collection
A collection of filtered elements.
Note
title
Note
You can change the human type depending on the language used in MagicDrawthe modeling tool. For example, "Class" is the human type of the classes in the English MagicDraw modeling tool while "Classe" is humanu the human type for the classes in FrenchMagicDraw. The specified humanTypes needs to be changed when you change the language used in MagicDrawthe modeling tool.
For example:
Code Block
language
text
title
$report.filterElement(elementList, humanTypes)
#foreach($element in $report.filterElement($elements, ["Use Case", "Actor"]))
$element.name : $element.humanType
#end
#foreach($pp in $report.getElementProperties($element))
$pp.name > $pp.value
#end
Note
By default, all properties are exported. They can be filtered by adding a "STANDARD" or "EXPERT" argument, e.g. $report.getElementProperties($element, "STANDARD").
$report.getElementPropertiesName(element)
Return a list of property names, including UML properties and properties that are customized through DSL customization.
Return an image icon of an element. The icon name depends on the hashCode value if hashCode equals true, the icon’s name is set as ”icon_”+hash code value of the icon. If the hashCodevalue equals false, the icon name is set as
Name
Type
Description
Parameter(s)
element
com.nomagic.magicdraw.uml.BaseElement
A MagicDraw elementmodeling tool element.
prefix
java.lang.String
A prefix of an icon name.
suffix
java.lang.String
A suffix of an icon name.
hashCode
boolean
If true, use hash code of an icon as the icon name and exclude a prefix or suffix from the name.
This results in an Image object of a class whose name “icon_24676200”. The number in the icon name is hash code, which is regenerated whenever MagicDraw startsthe modeling tool starts.
Code Block
language
text
title
To get an icon and set a name for prefix and suffix
Return an image icon for an element type. The icon’s name depends on the hashCode value if hashCode equals true, the icon name is set as “icon_”+hash code value of the icon. If the hashCode value equals false, the icon name is set as prefix + element type + suffix.
Name
Type
Description
Parameter(s)
type
java.lang.String
A type name.
prefix
java.lang.String
A prefix for an icon name.
suffix
java.lang.String
A suffix for an icon name.
hashCode
boolean
If true, use hash code of an icon as the icon’s name and exclude a prefix or suffix from the name.
This results in an Image object of a class whose name “icon_24676200”. The number in the icon name is hash code, which is regenerated whenever MagicDraw startsthe modeling tool starts.
Code Block
language
text
title
To get an icon and set a name for prefix and suffix
Returns the rectangular bounds of an element. If the element is not found in the diagram, it will return null.
$report.getQualifiedName(namedElement, separator)
Get a qualified name. A qualified name is the name that allows a NamedElementto be identified within a hierarchy of nested Namespaces. It is constructed from the names of the containing namespaces starting at the root of the hierarchy and ending with the name of the NamedElementitself.
Name
Type
Description
Parameter(s)
namedElement
NamedElement
A NamedElement.
separator
java.lang.String
A separator symbol. If the value is null or an empty string, the '::' will be used.
Find and retrieve the values of a slot whose name and classifier’s name are DefiningFeatureNameand ClassifierNamerespectively. The code enables case-sensitivity queries such that only those case-sensitive matches will return.
stereotypeName is String. Please be aware of duplicate name of stereotype that may cause to random returned result. $report.getStereotypeProperty(element, profileName, stereotypeName, propertyName) may be an option.
stereotypeName is String. Please be aware of duplicate name of stereotype that may cause to random returned result. $report.getStereotypePropertyString(element, profileName, stereotypeName, propertyName) may be an option.
A collection of com.nomagic.magicdraw.propertygroup.PropertyGroup objects or empty if the stereotype has no group defined.
For example:
Code Block
language
text
#foreach($stereotype in $report.getStereotypes($element))
#foreach($propertyGroup in $report.getPropertyGroupsByStereotype($stereotype))
Group: $propertyGroup.name
#end
#end
Convert com.nomagic.magicdraw.hyperlinks.Hyperlink to com.nomagic.magicdraw.plugins.impl.magicreport.helper.Hyperlink. Report Wizard needs the com.nomagic.magicdraw.plugins.impl.magicreport.helper.Hyperlink class wrapper to return com.nomagic.magicdraw.hyperlinks.Hyperlink data.
Sample of $report.getProperty(element, propertyName)
#foreach($element in $elements)
$report.getProperty($element, "name")
#end
$element is the element.
name is the name of the property.
$report.findElementByName(source, regex)
Search and return elements that match the name using a regular expression.
Name
Type
Description
Parameter(s)
source
java.util.Collection
A collection of elements.
regex
java.lang.String
A regular expression with which the name is to be matched.
Return
-
java.util.Collection
A collection of matching elements.
For example:
Code Block
language
text
title
$report.findElementByName(source, regex)
#foreach($ele in $report.findElementByName($elements, "[A]+.*"))
$ele.name
#end
$elements is a collection of elements to be found.
“[A]+.*” is a regular expression to find which element matches the name. In this example, the following are the names that match, such as Auxiliary, AppServer, and Alternative Fragment.
$report.getPresentationElements(diagram)
Get a presentation element in a diagram. This method is equivalent to $report.getPresentationDiagramElements(diagram).
#foreach ($element in $elements)
$report.getElementURL($element)
#end
$report.isEmpty(obj)
Test and return true if an object is null, empty string, or empty collection.
Name
Type
Description
Parameter(s)
obj
java.lang.Object
An object being tested.
Return
-
boolean
True if the object is null, empty string, or empty collection.
For example:
Code Block
language
text
title
Sample of $report.isEmpty(obj)
#if ($report.isEmpty($var))
Object is null, empty string or empty collection
#end
Note
title
Note
When checking HTML String format, $report.isEmpty ignores all  , spaces, and line feeds in the returned tag value and returns false when there is one or more characters.
Find and return a list of basic flows from a given use case. If a use case scenario is not being used, it will retrieve the value from "requirementUseCase" stereotype tags.
A list of flow steps. A Flow Step is an object representing each step of a Use Case flow.
The <FlowStep> is a MagicDraw a "com.nomagic.magicdraw.usecasescenarios.scenarios.FlowStep" class.
The important properties of <FlowStep> are as follows:
name prints a name of a current step, for example: $flowStep.name.
element returns an element associates with a current step, for example: #set ($e = $flowStep.element).
alternativeConditions returns a list of alternative steps <AlternativeCondition> from a current step, for example: #foreach ($alter in $flowStep.alternativeConditions) #end.
exceptionTypes returns a list of exception steps <ExceptionType> from a current step, for example: #foreach ($alter in $flowStep.exceptionTypes) #end.
For example:
Code Block
language
text
title
Sample of $report.getBasicFlows(usecase:UseCase) : List<FlowStep>
#set ($basicFlowList = $report.getBasicFlows($useCase))
#foreach ($flowStep in $basicFlowList)
$flowStep.name
#foreach ($alter in $flowStep.alternativeConditions)
- $alter.name
#end
#end
Find and return all alternative flows from a given use case. The alternative flows will be listed from all possible branches of basic flows. If a use case scenario is not being used, it will retrieve the value from "requirementUseCase" stereotype tags.
Find and return all exceptional flows from a given use case. The alternative flows will be listed from all possible branches of basic flows. If the use case scenario is not being used, it will retrieve the value from "requirementUseCase" stereotype tags.