Page tree

MagicDraw 19.0 LTR SP2 Documentation


On this page

$report is a utility tool enabling a template to get MagicDraw data.

$report.createValueSpecificationText(specification)

Create texts representing the ValueSpecification element.


NameTypeDescription
Parameter(s)specificationcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ValueSpecificationA given Value
Specification.
Return-java.lang.StringA String value
for ValueSpecification.


$report.filterDiagram(diagramList, diagramTypes)

Return a collection of diagrams from a list of diagrams filtered by types.


Name Type Description 
Parameter(s)  diagramListjava.util.CollectionA collection of diagrams.
diagramTypesjava.util.CollectionA collection of diagram types
used as filters.
Return-java.util.CollectionA collection of filtered diagrams.

For example:

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.CollectionA collection of elements.
humanTypesjava.util.Collection A collection of human types
used as filters.
Return -java.util.Collection A collection of filtered elements.

Note

You can change the human type depending on the language used in MagicDraw. For example, "Class" is human type of the classes in English MagicDraw while "Classe" is humanu type for the classes in French MagicDraw. The specified humanTypes needs to be changed when you change the language used in MagicDraw.

For example:

$report.filterElement(elementList, humanTypes)
#foreach($element in $report.filterElement($elements, ["Use Case", "Actor"]))
$element.name : $element.humanType
#end


$report.filterElementType(elementList, elementType)

Return a collection of elements from a list of elements filtered by element types.



Name Type Description 
Parameter(s)  elementList java.util.CollectionA collection of elements.
elementTypesjava.util.Collection A collection of element types
used as filters.
Return -java.util.Collection A collection of filtered elements.


$report.filter(elementList, propertyName, propertyValue)

Return a collection of elements filtered by a specified property name.


Name  Type Description 
Parameter(s)   elementListjava.util.Collection A collection of elements. 
propertyNamejava.lang.String 

A property name.

propertyValue java.util.Collection A collection of property names
used as filters.
Return
java.util.CollectionA collection of filtered elements.

For example: 

$report.filter(elementList, propertyName, propertyValue)
#foreach ($e in $report.filter($elements, "name", ["foo", "bar"]))
   $e.name
#end


$report.findElementInCollection(elementList, name)

Find an element from a collection of elements by name.


 NameType Description 
Parameter(s) elementListjava.util.CollectionA collection of elements.
namejava.lang.StringAn element name.
Returncom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element instance.
If it cannot find the
element, it will return
a null value.


For example:

#set($myClass = $report.findElementInCollection($Class, "MyClass"))
$myClass.humanType $myClass.name



$report.findRelationship(modelPackage)

Search and return a collection of relationship elements inside a package.


Name Type Description 
Parameter(s) modelPackagecom.nomagic.uml2.ext.magicdraw.classes.mdkernel.PackageA package
element.
Return-java.util.CollectionA collection of
relationships in
a package.


$report.findRelationship(modelPackage, recursive)

Search and return a collection of relationship elements inside a package.


Name Type Description 
Parameter(s)  modelPackagecom.nomagic.uml2.ext.magicdraw.classes.mdkernel.PackageA package
element. 
recursivebooleanIf true, performs
recursively.
Return-java.util.Collection A collection of
relationships
in a package.


$report.getAppliedStereotypeByName(element, stereotypeName)

Return a stereotype assigned to an element.


Name Type Description 
Parameter(s)   elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element An element.
stereotypeNamejava.lang.StringA stereotype
name.
Return-com.nomagic.uml2.ext.magicdraw.mdprofiles.StereotypeAn assigned
stereotype with
a specified name.


$report.getBaseClassAssociations(classifier)

Obtain a collection of associations of a classifier.


NameTypeDescription
Parameter(s)classifiercom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ClassifierA classifier.
Return-java.util.CollectionA collection of associations.


$report.getBaseClassInheritableAttributes(classifier)

Get a collection of inheritable attributes of a classifier.


Name Type Description 
Parameter(s) classifiercom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ClassifierA classifier. 
Return-java.util.CollectionA collection
of attributes.


$report.getBaseClassInheritableOperations(classifier)

Obtain a collection of inheritable operations of a classifier.


 Name Type Description 
Parameter(s) classifier com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ClassifierA classifier.
Return-java.util.CollectionA collection of operations.


$report.getBaseClassPorts(classifier)

Find a collection of ports of a classifier.


 NameType Description 
Parameter(s) classifiercom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ClassifierA classifier.
Return-java.util.CollectionCollection of ports.


$report.getBaseRealizedInterfaces(behavioredClassifier)

Find a collection of realized interfaces of a behaviored classifier.


Name Type Description 
Parameter(s)behavioredClassifiercom.nomagic.uml2.ext.magicdraw.commonbehaviors.mdbasicbehaviors.BehavioredClassifierA BehavioredClassifier. 
Return-java.util.CollectionA collection of RealizedInterfaces.


$report.getBaseRelations(classifier)

Find a collection of relations of a classifier.


Name Type  Description 
Parameter(s) classifiercom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ClassifierA classifier. 
Return-java.util.CollectionA collection of relations.


$report.getBaseClassifiers(child)

Return a collection of base elements of a classifier.


Name Type Description 
Parameter(s) childcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ClassifierA child class. 
Return -java.util.Collection A collection of base elements
(classifiers). 


$report.getClientElement(element)

Return a client of a relationship.


Name  TypeDescription
Parameter(s)element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element A relationship model
element.
Return-com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element The relationship’s client.


$report.getComment(element)

Return a documentation of a given element.


Name Type Description 
Parameter(s) element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element.
Return-java.lang.StringThe documentation
of an element.


$report.getCustomizationProperty(element, stereotypeName, propertyName)

Get a customization property from the specified applied stereotype of the element.


Name Type Description 
Parameter(s) elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element.
stereotypeNamejava.lang.StringA stereotype name.
propertyNamejava.lang.StringA property name.
Return-java.lang.ObjectA property value.


$report.getCustomizationPropertyString(element, stereotypeName, propertyName)

Get a customization property as a String value from the specified applied stereotype of the element.


Name Type Description 
Parameter(s) elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element.
stereotypeNamejava.lang.StringA stereotype name.
propertyNamejava.lang.StringA property name.
Return-java.lang.StringA property value as String.


$report.getDerivedClassifiers(parent)

Return a collection of derived elements of a classifier.


Name Type Description 
Parameter(s) parentcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ClassifierA parent class.
Returnjava.util.CollectionA collection of
derived elements
(classifiers). 


$report.getDiagramElements(diagram)

Get a collection of elements from a diagram.


Name Type Description 
Parameter(s)diagramcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.DiagramA diagram instance.
Return-java.util.CollectionA collection
of elements in a diagram.


$report.getDiagramType(diagram)

Return a diagram type.


Name Type  Description
Parameter(s) diagramcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.DiagramA diagram instance.
Return-java.lang.StringA diagram type.


$report.getElementProperties(element)

Return a list of property names, including UML properties and properties that are customized through DSL customization.


 Name Type Description 
Parameter(s)  element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element.
Return-java.util.CollectionA collection of property names.

$report.getDSLProperty(element, propertyName)

Return a DSL Property.


 Name Type Description 
Parameter(s)  element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element.
propertyName java.lang.StringA property
name. 
Return-java.lang.ObjectA property
value.


$report.getElementComment(element)

Return a comment attached to an element. If no comment is attached, it will return a null value.


Name Type Description 
Parameter(s) elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element. 
Return -com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Comment

A comment
instance of
the element.


$report.getElementName(element)

Get an element’s name. If the name is empty, it will return "<unnamed>". This method performs the following procedures:

  • If the element is generalized from the NamedElement metaclass, it will return $element.name
  • If the element is generalized from the Slot metaclass, it will return $element.definingFeature.name
  • If the element is a UML element, it will return $element.humanName
  • Else returns $element.toString()

 NameType Description 
Parameter(s) elementjava.lang.ObjectAn element.
Return -java.lang.StringAn element name.


$report.getIconFor(element)

Return an image icon of an element with a default icon filename (“icon_”+element type).


Name Type   Description
Parameter(s) elementcom.nomagic.magicdraw.uml.BaseElement A MagicDraw
element.
Return-com.nomagic.magicreport.ImageAn image object
of the element's icon.

For example:

$report.getIconFor(element)
$report.getIconFor($classObject)

This results in an Image object of a class whose name is “icon_class”.


$report.getIconFor(element, prefix, suffix, hashCode)

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 hashCode value equals false, the icon name is set as


Name Type Description 
Parameter(s)   element com.nomagic.magicdraw.uml.BaseElementA MagicDraw element.
prefixjava.lang.StringA prefix of an icon name.
suffixjava.lang.StringA suffix of an icon name.
hashCodebooleanIf true, use hash code of an icon
as the icon name and exclude a
prefix or suffix from the name. 
Return -com.nomagic.magicreport.ImageAn image object of
an element’s icon.

For example:

To get an icon and set a name for hash code
$report.getIconFor($classObject, “prefix_”, “_suffix”, true)

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 starts.

To get an icon and set a name for prefix and suffix
$report.getIconFor($classObject, “prefix_”, “_suffix”, false)

This results in an Image object of a class whose name is “prefix_class_suffix”.



$report.getIconFor(type)

Return an image icon for an element type with a default icon’s filename ((“icon_”+element type).


Name Type Description 
Parameter(s) typejava.lang.StringA type name.
Return -com.nomagic.magicreport.ImageAn image object for the element’s icon.

For example:

$report.getIconFor(type)
$report.getIconFor("class")

This results in an Image object of a class whose name is “icon_class”.



$report.getIconFor(type, prefix, suffix, hashCode)

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)   typejava.lang.String A type name.
prefixjava.lang.StringA prefix for an icon name.
suffixjava.lang.StringA suffix for an icon name.
hashCodebooleanIf true, use hash code of
an icon as the icon’s name
and exclude a prefix
or suffix from the name.
Return-com.nomagic.magicreport.ImageAn image object
for an element’s icon.

For example:

To get an icon and set a name for hash code
$report.getIconFor(“class”, “prefix_”, “_suffix”, true)

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 starts.

To get an icon and set a name for prefix and suffix
$report.getIconFor(“class”, “prefix_”, “_suffix”, false)

This results in an Image object of a class whose name is “prefix_class_suffix”.



$report.getIncludeUseCase(useCase)

Return a collection of included elements of a UseCase.


Name Type Description 
Parameter(s)  useCase com.nomagic.uml2.ext.magicdraw.mdusecases.UseCaseA UseCase
instance.
Return -java.util.CollectionA collection
of included
UseCases.


$report.getInnerElement(element)

Return a collection of inner elements.


Name  Type Description 
Parameter(s)elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element.
Return-java.util.CollectionA collection of
inner elements. 


$report.getInteractionMessageType(message)

Return an interaction message type.


 Name Type Description 
Parameter(s) messagecom.nomagic.uml2.ext.magicdraw.interactions.mdbasicinteractions.MessageA message
instance. 
Return-java.lang.StringA message
type.


$report.getMetaClass(stereotype)

Return a stereotype meta class.


Name  Type  Description
Parameter(s) stereotypecom.nomagic.uml2.ext.magicdraw.mdprofiles.StereotypeA stereotype
instance.
Return -java.util.CollectionA collection of
Meta Classes.


$report.getPresentationDiagramElements(diagram)

Return presentation elements in a diagram. This method will return all presentation elements from the diagram, except non-manipulator symbols.


 NameType Description 
Parameter(s)diagramcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.DiagramA diagram
instance. 
Return-java.util.Collection A collection
of elements. 

For example:

#foreach($symbol in $report.getPresentationDiagramElements($diagram))
#set($element = $symbol.getElement())
$element.humanType $element.name
#end

$report.getPresentationDiagramElements(diagram, includeNonManipulator)

Return presentation elements in a diagram.


Name Type Description 
Parameter(s) diagramcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.DiagramA diagram. 
include NonManipulatorbooleanTrue to include
all non-manipulator
elements.
Returnjava.util.CollectionA collection of
elements.


$report.getPresentationElementBounds(diagram, element)

Return the polygonal bounds of an element. The bounds specify the component coordinates to its diagram.


Name Type Description 
Parameter(s) diagramcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.DiagramA target diagram.
elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementA presentation element
on a given diagram.
Returnjava.util.ListReturns the polygonal
bounds of an element.
If the element is not found
in the diagram, it will return
null.


$report.getPresentationElementBounds(element)

Return the polygonal bounds of an element. The bounds specify this component's coordinate to its diagram.


Name Type Description 
Parameter(s)elementcom.nomagic.magicdraw.uml.symbols.PresentationElement A presentation element
on a diagram. 
Return-com.nomagic.magicdraw.magicreport.helper.PolygonReturns the polygonal
bounds of an element.


$report.getPresentationElementRectangle(diagram, element)

Return the rectangular bounds of an element. The bounds specify the component coordinates to its diagram.


Name Type Description 
Parameter(s)   diagramcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.DiagramA target diagram. 
elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementA presentation element
on a given diagram. 
Return -java.util.ListReturns 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 NamedElement to 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 NamedElement itself.


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.
Return-java.lang.StringA qualified name.


$report.getPackageQualifiedName(namedElement, separator)

Get a qualified name by considering only Packages and a given element. Models and Profiles will not be included in the qualified name.

For example, given the element hierarchy:

Sample of element hierarchy
Design : Model -> com : Package -> nomagic : Package -> ui -> Package -> BaseDialog : Class
Sample of a template code of the element hierarchy
$report.getPackageQualifiedName($class, ".")

If $class is a “BaseDialog” element, the result from the above template code will be as follows.

The result of the template code
com.nomagic.ui.BaseDialog

Name Type Description 
Parameter(s)  namedElement NamedElement A NamedElement.
separatorjava.lang.StringA separator symbol. If the value is null or an empty string, the '::' will be used. 
Return-java.lang.StringA qualified name. 


$report.getReceivingOperationalNode(element)

Get the needline association ends.


Name Type Description 
Parameter(s)  elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element. 
Return-com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementA needline
association
instance. 


$report.getRelationship(element)

Return an element’s relationship.


 NameType Description 
Parameter(s) element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element  An element. 
Return-java.util.CollectionA collection
of relationships.
#foreach($relationship in $report.getRelationship($element))
Name: $relationship.name
#end

$report.getRelationship(element, recursive)

Return a collection of element relationships.


Name  Type  Description 
Parameter(s)  element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.element An element.
recursivebooleanIf true, performs
recursively.
Return -java.util.CollectionA collection of
relationships.


$report.getRelativeActor(element)

Return an element’s relative actor.


Name Type  Description
Parameter(s)element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element An element.
Return-java.util.Collection A collection
of actors. 


$report.getSendingOperationalNode(element)

Return the needline’s association ends.


 NameType Description 
Parameter(s) elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element. 
Return-com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementA needline
association
instance.


$report.getSlotValue(element, ClassifierName, DefiningFeatureName)

Find and retrieve the values of a slot whose name and classifier’s name are DefiningFeatureName and ClassifierName respectively. The code enables case-sensitivity queries such that only those case-sensitive matches will return.


Name  Type Description 
Parameter(s)  

element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element whose
slot value you want
to find. 
ClassifierNamejava.lang.StringA classifier name.
DefiningFeatureNamejava.lang.StringA slot name.
Return -java.util.CollectionA collection of
ValueSpecifications
of a slot.

For example:

Use the code to retrieve the value of a slot whose name and classifier’s name are Name and Personal Data respectively.
#foreach($instance in $InstanceSpecification)
Slot value is $report.getSlotValue($instance, "Personal Data", "Name")
#end
  • “Personal Data” is the name of the classifier.
  • Name” is the name of the slot.


$report.getStereotypeProperty(element, stereotypeName, propertyName)

Get a stereotype property.


Name Type Description 
Parameter(s)

element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element.
stereotypeNamejava.lang.StringA stereotype name.
propertyNamejava.lang.StringA property name.
Return-java.lang.ObjectA property value.

For example:

#set($obj = $report.getStereotypeProperty($element, "MyStereotype", "myObject"))
$obj.name

Warning: Duplicate stereotype name

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.


$report.getStereotypeProperty(element, profileName, stereotypeName, propertyName)

Get a stereotype property.


Name Type Description 
Parameter(s)    element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element instance.
profileNamejava.lang.StringA profile name.
stereotypeNamejava.lang.StringA stereotype name.
propertyNamejava.lang.StringA property name. 
Return-java.lang.ObjectA property value.



$report.getStereotypePropertyString(element, stereotypeName, propertyName)

Return a stereotype property as a String value.


Name  Type Description 
Parameter(s)    elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element An element instance. 
stereotypeNamejava.lang.StringA stereotype name. 
propertyNamejava.lang.String A property name.
Return
java.lang.StringA property value as String.

For example:

#set($str = $report.getStereotypePropertyString($element, "MyStereotype", "myString"))
$str

Warning: Duplicate stereotype name

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.


$report.getStereotypePropertyString(element, profileName, stereotypeName, propertyName)

Get a stereotype property as a String value.


Name Type Description 
Parameter(s)    element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element instance.
profileNamejava.lang.StringA profile name.
stereotypeNamejava.lang.StringA stereotype name.
propertyNamejava.lang.StringA property name. 
Return-java.lang.StringA property value as String.



$report.getStereotypes(element)

Return all stereotypes applied to an element. This method is replaced by $element.appliedStereotype.


Name Type Description 
Parameter(s) element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element An element. 
Return -java.util.ListA list of stereotype instances. 


$report.getSupplierElement(element)

Return the supplier of a relationship.


NameType Description 
Parameter(s) element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element  A relationship model element. 
Returncom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementThe relationship’s supplier.


$report.getUsageElements(usagesMap, element)

Return the usage of a specified element.


 NameType Description 
Parameter(s) usagesMap java.util.Map The Usage Map of MagicDraw.
element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element An element. 
Return -java.util.CollectionA collection of element usages. 


$report.getUsages(selectedObjects)

Return the Usage Map of MagicDraw. It uses the getUsageElements method to return the usage of a specified element.


Name Type Description 
Parameter(s) selectedObjects java.lang.ObjectAn element.
Return -java.util.MapA Map instance of element usages.


$report.hasStereotype(element)

Check if an element has stereotypes.


Name  Type   Description
Parameter(s) elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element to check.
Returnboolean True if it has a stereotype. 


$report.containsStereotype(element, stereotypeName)

Return true if an element contains a stereotype (including all derived stereotypes) for a specified stereotype name.


Name Type Description 
Parameter(s) element  com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element to check. 
stereotypeNamejava.lang.StringA stereotype name to be
tested.
Return -booleanTrue if the element
contains a stereotype
for the specified
stereotype name. 

For example:

#if($report.containsStereotype($element, "MyStereotype"))
$element.name has been applied <<MyStereotype>>.
#end

$report.containsStereotype(element, stereotypeName, includeDerived)

Return true if an element contains a stereotype for a specified stereotype name.


Name Type Description 
Parameter(s)  

element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element to test. 
stereotypeNamejava.lang.StringA stereotype name
to be tested. 
includeDerivedboolean

True if the searched
target includes all
derived stereotypes;
otherwise, false.

Return-booleanTrue if the element
contains a stereotype
for the specified
stereotype name.


$report.isDerivedClassifier(parent, child)

Check if a child is derived from the parent by generalization.


 Name Type Description 
Parameter(s)parentcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ClassifierA parent. 
childcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ClassifierA possible child.
Return-booleanTrue if it is derived from
the parent by generalization. 


$report.isNamedElement(element)

Return whether an element is a NamedElement.


Name TypeDescription
Parameter(s) elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element
to test.
Return-boolean 

True if the given element is a NamedElement; otherwise, false


$report.isNull(obj)

Test and return true if an object is null.


Name Type Description 
Parameter(s) obj java.lang.ObjectAn object being tested.
ReturnbooleanTrue if the object is null.


$report.isRelationship(element)

Test and return true if an element is a relationship.


Name Type Description 
Parameter(s) elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element being tested.
Return

-

booleanTrue if the object is a
relationship.


$report.serialize(hyperlink)

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.


Name  TypeDescription 
Parameter(s) hyperlinkcom.nomagic.magicdraw.hyperlinks.Hyperlink A MagicDraw
hyperlink.
Return -com.nomagic.magicdraw.plugins.impl.magicreport.helper.HyperlinkA Report Wizard
hyperlink instance.


$report.getUsedBy(element)

Return a list of element(s) used by this element (except diagrams).


Name  Type  Description 
Parameter(s)  elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element An element of which
to determine the usage. 
 Return
 java.util.CollectionA collection of elements
used by an input element.


$report.hasProperty(element, propertyName)

Return true when a property with a given name is specified in this element, otherwise returns false.


Name Type  Description
Parameter(s) elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element An element.

propertyNamejava.lang.StringA property name.
Return   -java.lang.BooleanReturn true when
a property with a
given name is specified
in this element,
otherwise returns false. 

For example:

#foreach($element in $elements)
$report.hasProperty($element, "name")
#end


  • $element is the element.
  • data is the name of the property.


$report.getProperty(element, propertyName)

Get element property.


NameType Description 
Parameter(s)element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementAn element.

propertyNamejava.lang.StringA property name.
Return -java.lang.Object A property value. 

For example:

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) sourcejava.util.CollectionA collection of elements.

regexjava.lang.String A regular expression with which the name is to be matched.
Return-java.util.Collection A collection of matching elements.

For example:

$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).


Name Type Description 
Parameter(s)diagramcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.DiagramA diagram instance.
Return -java.util.Collection A collection of elements.

For example:

$report.getPresentationElements(diagram)
#foreach($diagram in $Diagram)
$foreach($d in $report.getPresentationElements($diagram))
$d.name
#end
#end

  

  • $diagram is the diagram instance.


$report.getUsageRepresentationText(baseElement, bool)

Format the usage subject. The output string is the same as the Result column of Used by table in Magic Draw.


 Name Type  Description 
Parameter(s) baseElementcom.nomagic.magicdraw.uml.BaseElementA model element
to be formatted.

booljava.lang.Boolean True if a full path
is used, otherwise
false.
Return -java.lang.StringA formatted element.

For example:

$report.getUsageRepresentationText(baseElement, bool)
#foreach($baseElement in $Elements)
$report.getUsageRepresentationText($baseElement, false)
#end


  • $baseElement is the model element to be formatted.
  • false if a full path is not used. In this example, a full path is not used.

$report.getUseCaseNumber(element)

Return a use case number of an element.


 NameType Description 
Parameter(s)  elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element A model element. 
Return -java.lang.StringA use case number.

  

For example:

Sample of $report.getUseCaseNumber(element)
#foreach ($uc in $RequirementsUseCase)
$report.getUseCaseNumber($uc) $uc.name
#end


$report.getElementURL(element)

Return a MagicDraw's element URL.


 Name Type  Description 
Parameter(s)element com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element An element.
ReturnelementURL java.lang.StringAn element URL.

For example:

Sample of $report.getElementURL(element)
#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) objjava.lang.ObjectAn object being tested.
Return  -booleanTrue if the object is null, empty string,
or empty collection.

For example:

Sample of $report.isEmpty(obj)
#if ($report.isEmpty($var))
Object is null, empty string or empty collection
#end 


$report.getBasicFlows(usecase:UseCase) : List<FlowStep>

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.


Name Type Description 
Parameter(s) usecase com.nomagic.uml2.ext.magicdraw.mdusecases.UseCase A targeted Use Case.
ReturnList<com.nomagic.magicdraw.usecasescenarios.scenarios.FlowStep>A list of flow steps.
A Flow Step is an
object representing
each step of a Use
Case flow.

The <FlowStep> is a MagicDraw "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:

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


$report.getAlternativeFlows(usecase:UseCase) : List<FlowStep>

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.


Name  Type Description 
Parameter(s) usecasecom.nomagic.uml2.ext.magicdraw.mdusecases.UseCaseA targeted Use Case.
Return  -List<com.nomagic.magicdraw.usecasescenarios.scenarios.FlowStep>A list of flow steps.
A Flow Step is an
object representing
each step of a Use
Case flow. 

For example:

Sample of $report.getAlternativeFlows(usecase:UseCase) : List<FlowStep>
#set ($alternativeFlowList = $report.getAlternativeFlows($useCase))
$useCase.name
 #foreach ($flowStep in $alternativeFlowList)
   $flowStep.name
   #foreach ($alternative in $flowStep.alternativeConditions)
      $alternative.name
         #foreach ($alternativeFlow in $alternative.alternativeFlowSteps)
         $alternativeFlow.name
         #end
   #end
 #end


$report.getExceptionalFlows(usecase:UseCase) : List<FlowStep>

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.


Name Type Description 
Parameter(s)usecase com.nomagic.uml2.ext.magicdraw.mdusecases.UseCase A targeted Use Case.
Return  List<com.nomagic.magicdraw.usecasescenarios.scenarios.FlowStep> A list of flow steps.
A flow step is an object
representing each steps
of a Use Case flow.

For example:

Sample of $report.getExceptionalFlows(usecase:UseCase) : List<FlowStep>
#set ($exceptionFlowList = $report.getExceptionalFlows($useCase))
     #foreach ($flowStep in $exceptionFlowList)
         $flowStep.name
         #foreach (#exception in $flowStep.exceptionTypes)
             $exception.name
             #foreach ($exceptionalFlow in $exception.exceptionalFlowSteps)
                  $exceptionalFlow.name
             #end
         #end
     #end


$report.getOwnedElementsIncludingAdditional(element, includePureOwned) : List<Element>

This code returns owned elements of a given element including additional owned elements defined in the DSL specification by additionalContentProperty.


Name Type Description 
Parameter(s) elementcom.nomagic.uml2.ext.magicdraw.classes.mdkernel.ElementA model element.

includePureOwnedjava.lang.Boolean True if includes an
element owned directly
in the ownedElement
UML metaproperty.
Otherwise False.
Return -java.util.List A list of owned elements
of a given element.

The following are the examples of using the code.

Sample 1: $report.getOwnedElementsIncludingAdditional(element, includePureOwned) : List<Element>
#foreach($e in $elements)
$e.name : $e.humanType
  #foreach($child in $report.getOwnedElementsIncludingAdditional($e, true))
    $child.name : $child.humanType
  #end
#end
Sample 2: $report.getOwnedElementsIncludingAdditional(element, includePureOwned) : List<Element>
#foreach($e in $SmartPackage)
$e.name : $e.humanType
    #foreach($child in $report.getOwnedElementsIncludingAdditional($e, true))
       $child.name : $child.humanType
    #end
#end
Sample 3: $report.getOwnedElementsIncludingAdditional(element, includePureOwned) : List<Element>
#set($packages = $array.createArray())
#set($void = $array.addCollection($packages, $Package))
#set($void = $array.addCollection($packages, $SmartPackage))
#foreach($e in $packages)
$e.name : $e.humanType
    #foreach($child in $report.getOwnedElementsIncludingAdditional($e, true))
        $child.name : $child.humanType
    #end
#end
  • No labels