On this page
$report is a utility tool enabling a template to get MagicDraw data.
$report.createValueSpecificationText(specification)
Create texts representing the ValueSpecification element.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | specification | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.ValueSpecification | A given Value Specification. |
Return | - | java.lang.String | A 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) | 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:
#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
For example:
#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.Collection | A collection of elements. |
elementTypes | java.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) | elementList | java.util.Collection | A collection of elements. |
propertyName | java.lang.String | A property name. | |
propertyValue | java.util.Collection | A collection of property names used as filters. | |
Return | java.util.Collection | A collection of filtered elements. |
For example:
#foreach ($e in $report.filter($elements, "name", ["foo", "bar"])) $e.name #end
$report.filterElementByStereotypeName(elementList, appliedStereotypeNameList)
Return a collection of elements from a list of elements filtered by applied stereotype names.
| Name | Type | Description |
Parameter(s) | elementList | java.util.Collection | A collection of elements. |
appliedStereotypeNameList | java.util.Collection | A collection of applied stereotype names. | |
Return | - | java.util.Collection | A collection of filtered elements. |
For example:
#foreach($element in $report.filterElementByStereotypeName($elements, ["Stereotype A", "Stereotype B"])) $element.name #end
$report.findElementInCollection(elementList, name)
Find an element from a collection of elements by name.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | elementList | java.util.Collection | A collection of elements. |
name | java.lang.String | An element name. | |
Return | - | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An 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) | modelPackage | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Package | A package element. |
Return | - | java.util.Collection | A 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) | modelPackage | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Package | A package element. |
recursive | boolean | If 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) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
stereotypeName | java.lang.String | A stereotype name. | |
Return | - | com.nomagic.uml2.ext.magicdraw.mdprofiles.Stereotype | An assigned stereotype with a specified name. |
$report.getBaseClassAssociations(classifier)
Obtain a collection of associations of a classifier.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | classifier | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier | A classifier. |
Return | - | java.util.Collection | A collection of associations. |
$report.getBaseClassInheritableAttributes(classifier)
Get a collection of inheritable attributes of a classifier.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | classifier | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier | A classifier. |
Return | - | java.util.Collection | A 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.Classifier | A classifier. |
Return | - | java.util.Collection | A collection of operations. |
$report.getBaseClassPorts(classifier)
Find a collection of ports of a classifier.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | classifier | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier | A classifier. |
Return | - | java.util.Collection | Collection of ports. |
$report.getBaseRealizedInterfaces(behavioredClassifier)
Find a collection of realized interfaces of a behaviored classifier.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | behavioredClassifier | com.nomagic.uml2.ext.magicdraw.commonbehaviors.mdbasicbehaviors.BehavioredClassifier | A BehavioredClassifier. |
Return | - | java.util.Collection | A collection of RealizedInterfaces. |
$report.getBaseRelations(classifier)
Find a collection of relations of a classifier.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | classifier | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier | A classifier. |
Return | - | java.util.Collection | A collection of relations. |
$report.getBaseClassifiers(child)
Return a collection of base elements of a classifier.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | child | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier | A child class. |
Return | - | java.util.Collection | A collection of base elements (classifiers). |
$report.getClientElement(element)
Return a client of a relationship.
Name | Type | Description | |
---|---|---|---|
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.Element | An element. |
Return | - | java.lang.String | The 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) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
stereotypeName | java.lang.String | A stereotype name. | |
propertyName | java.lang.String | A property name. | |
Return | - | java.lang.Object | A property tag 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) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
stereotypeName | java.lang.String | A stereotype name. | |
propertyName | java.lang.String | A property name. | |
Return | - | java.lang.String | A property tag value as String. |
$report.getDerivedClassifiers(parent)
Return a collection of derived elements of a classifier.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | parent | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier | A parent class. |
Return | - | java.util.Collection | A collection of derived elements (classifiers). |
$report.getDiagramElements(diagram)
Get a collection of elements from a diagram.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | diagram | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram | A diagram instance. |
Return | - | java.util.Collection | A collection of elements in a diagram. |
$report.getDiagramType(diagram)
Return a diagram type.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | diagram | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram | A diagram instance. |
Return | - | java.lang.String | A 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.Element | An element. |
Return | - | java.util.Collection | A collection of property names. |
For example:
#foreach($pp in $report.getElementProperties($element)) $pp.name > $pp.value #end
$report.getElementPropertiesName(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.Element | An element. |
Return | - | java.util.Collection | A collection of property names. |
For example:
#foreach($name in $report.getElementPropertiesName($element)) $name #end
$report.getDSLProperty(element, propertyName)
Return a DSL property.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
propertyName | java.lang.String | A property name. | |
Return | - | java.lang.Object | A 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) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
Return | - | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Comment | A comment |
$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()
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | java.lang.Object | An element. |
Return | - | java.lang.String | An 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) | element | com.nomagic.magicdraw.uml.BaseElement | A MagicDraw element. |
Return | - | com.nomagic.magicreport.Image | An image object of the element's icon. |
For example:
$report.getIconFor($classObject)
This results in an Image object of a class whose name is “icon_class”.
$report.getImageFor(element, dpi)
Return an image with specified DPI of an element.
Name | Type | Description | Description |
---|---|---|---|
Parameter(s) | element | com.nomagic.magicdraw.uml.BaseElement | A MagicDraw element. |
dpi | int | DPI of the element image. | |
Return | - | com.nomagic.magicreport.Image | An image object with specified DPI. |
Note
- The DPI value can be 1 to 4800.
- If less than 1, the value is not taken, and the DPI set in *Template* and *Global* will be used respectively. See "[Set DPI|xxx]"
- If more than 4800, the value will be rounded down to 4800.
$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.BaseElement | A MagicDraw 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. | |
Return | - | com.nomagic.magicreport.Image | An image object of an element’s icon. |
For example:
$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.
$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) | type | java.lang.String | A type name. |
Return | - | com.nomagic.magicreport.Image | An image object for the element’s icon. |
For example:
$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) | 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. | |
Return | - | com.nomagic.magicreport.Image | An image object for an element’s icon. |
For example:
$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.
$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.UseCase | A UseCase instance. |
Return | - | java.util.Collection | A collection of included UseCases. |
$report.getInnerElement(element)
Return a collection of inner elements.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
Return | - | java.util.Collection | A collection of inner elements. |
$report.getInteractionMessageType(message)
Return an interaction message type.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | message | com.nomagic.uml2.ext.magicdraw.interactions.mdbasicinteractions.Message | A message instance. |
Return | - | java.lang.String | A message type. |
$report.getMetaClass(stereotype)
Return a stereotype meta class.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | stereotype | com.nomagic.uml2.ext.magicdraw.mdprofiles.Stereotype | A stereotype instance. |
Return | - | java.util.Collection | A 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.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | diagram | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram | A 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) | diagram | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram | A diagram. |
include NonManipulator | boolean | True to include all non-manipulator elements. | |
Return | - | java.util.Collection | A 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) | diagram | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram | A target diagram. |
element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | A presentation element on a given diagram. | |
Return | - | java.util.List | Returns 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) | element | com.nomagic.magicdraw.uml.symbols.PresentationElement | A presentation element on a diagram. |
Return | - | com.nomagic.magicdraw.magicreport.helper.Polygon | Returns 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) | diagram | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram | A target diagram. |
element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | A presentation element on a given diagram. | |
Return | - | java.util.List | 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 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.String | A 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:
Design : Model -> com : Package -> nomagic : Package -> ui -> Package -> BaseDialog : Class
$report.getPackageQualifiedName($class, ".")
If $class is a “BaseDialog” element, the result from the above template code will be as follows.
com.nomagic.ui.BaseDialog
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.String | A qualified name. |
$report.getReceivingOperationalNode(element)
Get the needline association ends.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
Return | - | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | A needline association instance. |
$report.getRelationship(element)
Return an element’s relationship.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
Return | - | java.util.Collection | A collection of relationships. |
For example:
#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. |
recursive | boolean | If true, performs recursively. | |
Return | - | java.util.Collection | A 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.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
Return | - | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | A 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.Element | An element whose slot value you want to find. |
ClassifierName | java.lang.String | A classifier name. | |
DefiningFeatureName | java.lang.String | A slot name. | |
Return | - | java.util.Collection | A collection of ValueSpecifications of a slot. |
For example:
#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.Element | An element. |
stereotypeName | java.lang.String | A stereotype name. | |
propertyName | java.lang.String | A property name. | |
Return | - | java.lang.Object | A 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.Element | An element instance. |
profileName | java.lang.String | A profile name. | |
stereotypeName | java.lang.String | A stereotype name. | |
propertyName | java.lang.String | A property name. | |
Return | - | java.lang.Object | A property value. |
$report.getStereotypePropertyString(element, stereotypeName, propertyName)
Return a stereotype property as a String value.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element instance. |
stereotypeName | java.lang.String | A stereotype name. | |
propertyName | java.lang.String | A property name. | |
Return | java.lang.String | A 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.Element | An element instance. |
profileName | java.lang.String | A profile name. | |
stereotypeName | java.lang.String | A stereotype name. | |
propertyName | java.lang.String | A property name. | |
Return | - | java.lang.String | A property value as String. |
$report.getPropertyGroupsByStereotype(stereotype)
Return a collection of property groups for the given stereotype.
| Name | Type | Description |
Parameter(s) | stereotype | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Class | A stereotype element. |
Return | - | java.util.Collection | A collection of com.nomagic.magicdraw.propertygroup.PropertyGroup objects or empty if the stereotype has no group defined. |
For example:
#foreach($stereotype in $report.getStereotypes($element)) #foreach($propertyGroup in $report.getPropertyGroupsByStereotype($stereotype)) Group: $propertyGroup.name #end #end
$report.getPropertyGroupsByElement(element, addAlwaysVisible)
Return a set of property groups for the given element.
| Name | Type | Description |
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element that may have property groups. |
addAlwaysVisible | boolean | True if using all set stereotypes and all showWhenNotApplied stereotypes that can be set. False if using only all set stereotypes. | |
Return | - | java.util.Set | A set of com.nomagic.magicdraw.propertygroup.PropertyGroup objects that are directly associated with the element. |
For example:
#foreach($propertyGroup in $report.getPropertyGroupsByStereotype($element, true)) Group: $propertyGroup.name #end
$report.getQProperty(element, propertyName)
Get a property for an element with DSL property groups, and each property group has its own property.
| Name | Type | Description |
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
propertyName | java.lang.String | A property name. | |
Return | - | com.nomagic.magicdraw.properties.Property | A property object for a specific element and propertyName. |
For example:
#foreach($stereotype in $report.getStereotypes($element)) Stereotype: $stereotype.name #foreach($propertyGroup in $report.getPropertyGroupsByStereotype($stereotype)) Group: $propertyGroup.name #foreach($propertyName in $propertyGroup.getPropertyList()) #set($property = $report.getQProperty($element, $propertyName)) Property name: $property.name Property value: $property.value -------------------------------- #end #end #end
$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.List | A list of stereotype instances. |
$report.getSupplierElement(element)
Return the supplier of a relationship.
Name | Type | Description | |
---|---|---|---|
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 supplier. |
$report.getUsageElements(usagesMap, element)
Return the usage of a specified element.
Name | Type | 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.Collection | A 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.Object | An element. |
Return | - | java.util.Map | A Map instance of element usages. |
$report.hasStereotype(element)
Check if an element has stereotypes.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element to check. |
Return | - | boolean | 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.Element | An element to check. |
stereotypeName | java.lang.String | A stereotype name to be tested. | |
Return | - | boolean | True 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.Element | An element to test. |
stereotypeName | java.lang.String | A stereotype name to be tested. | |
includeDerived | boolean | True if the searched | |
Return | - | boolean | True 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) | parent | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier | A parent. |
child | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Classifier | A possible child. | |
Return | - | boolean | True if it is derived from the parent by generalization. |
$report.isNamedElement(element)
Return whether an element is a NamedElement.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An 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.Object | An object being tested. |
Return | - | boolean | True if the object is null. |
$report.isRelationship(element)
Test and return true if an element is a relationship.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element being tested. |
Return | - | boolean | True 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 | Type | Description | |
---|---|---|---|
Parameter(s) | hyperlink | com.nomagic.magicdraw.hyperlinks.Hyperlink | A MagicDraw hyperlink. |
Return | - | com.nomagic.magicdraw.plugins.impl.magicreport.helper.Hyperlink | A Report Wizard hyperlink instance. |
$report.getUsedBy(element)
Return a list of element(s) used by this element (except diagrams).
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element of which to determine the usage. |
Return | java.util.Collection | A 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) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
propertyName | java.lang.String | A property name. | |
Return | - | java.lang.Boolean | Return 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.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | An element. |
propertyName | java.lang.String | A property name. | |
Return | - | java.lang.Object | A property value. |
For example:
#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:
#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) | diagram | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Diagram | A diagram instance. |
Return | - | java.util.Collection | A collection of elements. |
For example:
#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) | baseElement | com.nomagic.magicdraw.uml.BaseElement | A model element to be formatted. |
bool | java.lang.Boolean | True if a full path is used, otherwise false. | |
Return | - | java.lang.String | A formatted element. |
For example:
#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.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | A model element. |
Return | - | java.lang.String | A use case number. |
For example:
#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. |
Return | elementURL | java.lang.String | An element URL. |
For example:
#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:
#if ($report.isEmpty($var)) Object is null, empty string or empty collection #end
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.
$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. |
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. |
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:
#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) | 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 step of a Use Case flow. |
For example:
#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:
#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) | element | com.nomagic.uml2.ext.magicdraw.classes.mdkernel.Element | A model element. |
includePureOwned | java.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.
#foreach($e in $elements) $e.name : $e.humanType #foreach($child in $report.getOwnedElementsIncludingAdditional($e, true)) $child.name : $child.humanType #end #end
#foreach($e in $SmartPackage) $e.name : $e.humanType #foreach($child in $report.getOwnedElementsIncludingAdditional($e, true)) $child.name : $child.humanType #end #end
#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