Class ReportHelper

  • All Implemented Interfaces:
    com.nomagic.magicreport.engine.ITool, com.nomagic.magicreport.IVariable, java.io.Serializable, java.lang.Cloneable

    @OpenApiAll
    public class ReportHelper
    extends com.nomagic.magicreport.engine.Tool
    Contains utilities functions for template report. Context name of this class is "report". Public functions of this class are able to access via template by using $report

    For example:

     <code>
        #foreach ($rel in $report.getRelationships($package))
           $rel.name
        #end
     </code>
     
    Since:
    Jun 13, 2007e
    See Also:
    Serialized Form
    • Field Detail

      • ICON_PROPERTY_RETINASCALING

        public static final java.lang.String ICON_PROPERTY_RETINASCALING
        See Also:
        Constant Field Values
    • Constructor Detail

      • ReportHelper

        public ReportHelper()
    • Method Detail

      • getDSLProperty

        public java.lang.Object getDSLProperty​(Element element,
                                               java.lang.String propertyName)
        Get DSL Property.
        Parameters:
        element - the element.
        propertyName - the property name.
        Returns:
        the property value.
      • parseObjectForPrinting

        public static java.lang.Object parseObjectForPrinting​(java.lang.Object value)
        Parses Strings and Collections of Strings
      • getStereotypeProperty

        public static java.lang.Object getStereotypeProperty​(Element element,
                                                             java.lang.String profileName,
                                                             java.lang.String stereotypeName,
                                                             java.lang.String propertyName)
        Get Stereotype Property.
        Parameters:
        element - the element.
        profileName - profile name
        stereotypeName - the stereotype name.
        propertyName - the property name.
        Returns:
        the property value.
      • getStereotypePropertyList

        @Deprecated
        public java.util.List<java.lang.Object> getStereotypePropertyList​(Element element,
                                                                          java.lang.String stereotypeName,
                                                                          java.lang.String propertyName)
        Deprecated.
        value return from this method is improperly converted.
        Gets stereotype property value as list of strings.
        Parameters:
        element - element with assigned stereotype
        stereotypeName - stereotype name
        propertyName - name of the property
        Returns:
        List of the property name.
      • getStereotypePropertyString

        public static java.lang.String getStereotypePropertyString​(Element element,
                                                                   java.lang.String stereotypeName,
                                                                   java.lang.String propertyName)
        Gets stereotype property as String value.
        Parameters:
        element - the element instance
        stereotypeName - the stereotype name
        propertyName - the property name
        Returns:
        the value as String
      • getStereotypePropertyString

        public static java.lang.String getStereotypePropertyString​(Element element,
                                                                   Stereotype stereotype,
                                                                   java.lang.String propertyName)
        Gets stereotype property as String value.
        Parameters:
        element - the element instance
        stereotype - the stereotype instance
        propertyName - the property name
        Returns:
        the value as String
      • getStereotypePropertyString

        public static java.lang.String getStereotypePropertyString​(Element element,
                                                                   Stereotype stereotype,
                                                                   java.lang.String propertyName,
                                                                   java.lang.String separator)
        Gets stereotype property as String value.
        Parameters:
        element - the element instance
        stereotype - the stereotype instance
        propertyName - the property name
        separator - when property value is list, the string will be added when convert list to string
        Returns:
        the value as String
      • getStereotypePropertyString

        public static java.lang.String getStereotypePropertyString​(Element element,
                                                                   java.lang.String profileName,
                                                                   java.lang.String stereotypeName,
                                                                   java.lang.String propertyName)
        Gets stereotype property as String value.
        Parameters:
        element - the element instance
        profileName - profile name
        stereotypeName - the stereotype name
        propertyName - the property name
        Returns:
        the value as String
      • getStereotypePropertyString

        public static java.lang.String getStereotypePropertyString​(Element element,
                                                                   java.lang.String profileName,
                                                                   java.lang.String stereotypeName,
                                                                   java.lang.String propertyName,
                                                                   java.lang.String separator)
        Gets stereotype property as String value.
        Parameters:
        element - the element instance
        profileName - profile name
        stereotypeName - the stereotype name
        propertyName - the property name
        separator - when property value is list, the string will be added when convert list to string
        Returns:
        the value as String
      • getStereotypePropertyStringValue

        @Deprecated
        public java.lang.String getStereotypePropertyStringValue​(java.lang.Object o)
        Deprecated.
        value return from this method is improperly converted.
        Gets Stereotype Property As String value.
        Parameters:
        o - the property
        Returns:
        the value as String
      • getRepresentationText

        public java.lang.String getRepresentationText​(BaseElement e)
      • isNamedElement

        public boolean isNamedElement​(Element element)
        Returns whether the element an NamedElement.
        Parameters:
        element - element to test
        Returns:
        true if given element is NamedElement; otherwise false
      • getAppliedStereotypeByString

        @CheckForNull
        @Deprecated
        public Stereotype getAppliedStereotypeByString​(Element element,
                                                       java.lang.String stereotype)
        Returns stereotype assigned to element.
        Parameters:
        element - element
        stereotype - name of stereotype
        Returns:
        assigned stereotype with that name.
      • getAppliedStereotypeByName

        @CheckForNull
        public Stereotype getAppliedStereotypeByName​(Element element,
                                                     java.lang.String stereotypeName)
        Returns stereotype assigned to element.
        Parameters:
        element - element
        stereotypeName - name of stereotype
        Returns:
        assigned stereotype with that name.
      • hasStereotype

        @Deprecated
        public boolean hasStereotype​(Element element,
                                     java.lang.String stereotype)
        Checks if element has assigned stereotype with given name.
        Parameters:
        element - element to check
        stereotype - stereotype name to check
        Returns:
        true if element has assigned stereotype with given name
      • containsStereotype

        public boolean containsStereotype​(Element element,
                                          java.lang.String stereotypeName)
        Returns true if element contains a stereotype (include all derived stereotype) for the specified stereotype name.
        Parameters:
        element - element to test
        stereotypeName - stereotype name to be tested
        Returns:
        true if element contains a stereotype for the specified stereotype name.
        See Also:
        containsStereotype(Element, String, boolean)
      • containsStereotype

        public boolean containsStereotype​(Element element,
                                          java.lang.String stereotypeName,
                                          boolean includeDerived)
        Returns true if element contains a stereotype for the specified stereotype name.
        Parameters:
        element - element to test
        stereotypeName - stereotype name to be tested
        includeDerived - true if search target include all derived stereotypes; otherwise false
        Returns:
        true if element contains a stereotype for the specified stereotype name.
        See Also:
        containsStereotype(Element, String)
      • hasProperty

        public boolean hasProperty​(Element element,
                                   java.lang.String propertyName)
        Returns true when a property with a given name is specified on this element, false otherwise.
        Parameters:
        element - element to test
        propertyName - property name
        Returns:
        true when a property with a given name is specified on this element, false otherwise.
      • getProperty

        public java.lang.Object getProperty​(Element element,
                                            java.lang.String propertyName)
                                     throws com.nomagic.magicdraw.magicreport.helper.PropertyNotFoundException
        Get the element property value.
        Parameters:
        element - the object that will be gotten that data.
        propertyName - the field of the element.
        Returns:
        the data of that field in the element.
        Throws:
        com.nomagic.magicdraw.magicreport.helper.PropertyNotFoundException - when a request property name is not found on target element.
      • getStereotypes

        public java.util.List<Stereotype> getStereotypes​(Element element)
                                                  throws java.lang.IllegalArgumentException
        Gets all stereotypes applied to element. This method is replaced with $element.appliedStereotype.
        Parameters:
        element - the element
        Returns:
        the stereotype instances
        Throws:
        java.lang.IllegalArgumentException - from StereotypesHelper.getStereotypes
      • hasStereotype

        public boolean hasStereotype​(Element element)
                              throws java.lang.IllegalArgumentException
        Checks if element has stereotypes.
        Parameters:
        element - element to check
        Returns:
        true if has
        Throws:
        java.lang.IllegalArgumentException - if element is null
      • findElementInCollection

        @CheckForNull
        public Element findElementInCollection​(java.util.Collection<? extends Element> col,
                                               java.lang.String elementName)
        Search and return the element in the collection by element name.
        Parameters:
        col - the collection of elements
        elementName - the name of element
        Returns:
        the element instance, If it does not find, it will return null.
      • findDiagramByName

        public Element findDiagramByName​(java.lang.String elementName)
      • findElementByName

        public java.util.Collection<Element> findElementByName​(java.util.Collection<Element> source,
                                                               java.lang.String regex)
        Search and return the elements from name by regular expression.
        Parameters:
        source - source
        regex - the regular expression to which name is to be matched
        Returns:
        collection of matches element
      • getDerivedClassifiers

        public java.util.Collection<Classifier> getDerivedClassifiers​(Classifier parentClassifier)
        Returns classifier derived elements.
        Parameters:
        parentClassifier - the parent class
        Returns:
        collection of derived elements (classifiers)
      • hasBaseClassifier

        public static boolean hasBaseClassifier​(Classifier classifier,
                                                java.lang.String baseClassifier)
        Checks if element has base classifier with given name.
        Parameters:
        classifier - the classifier
        baseClassifier - base classifier name
        Returns:
        true if the element contains specific base classifiers.
      • getBaseClassifiers

        public static java.util.List<Classifier> getBaseClassifiers​(Classifier classifier)
        Return classifier based elements. The list contains all base classifiers include all its derived classifiers.
        Parameters:
        classifier - the classifier
        Returns:
        collection of based elements (classifiers)
      • getComment

        public java.lang.String getComment​(Element element)
        Returns documentation of given element.
        Parameters:
        element - the element which will be gotten the name.
        Returns:
        the document
      • getElementComment

        @CheckForNull
        public Comment getElementComment​(Element element)
        Returns comment annotated to this element. If comment is attached to this element, returns null.
        Parameters:
        element - the element which will be gotten the Comment.
        Returns:
        Comment instance of this element.
      • getRelativeActor

        public java.util.Collection<Actor> getRelativeActor​(Element element)
        Gets element relative actor.
        Parameters:
        element - the element
        Returns:
        the collection of Actor.
      • getUseCaseAssociatedElement

        @CheckForNull
        @Deprecated
        public java.util.Collection<Element> getUseCaseAssociatedElement​(Element obj)
        Deprecated.
        Gets associated Element.
        Parameters:
        obj - the element that we would like to find the other part
        Returns:
        the other parts
      • getIncludeUseCase

        @CheckForNull
        public java.util.Collection<Element> getIncludeUseCase​(UseCase useCase)
        Gets use case included element.
        Parameters:
        useCase - the UseCase instance
        Returns:
        the collection of included use case.
      • trimString

        @Deprecated
        public java.lang.String trimString​(java.lang.String s)
        Deprecated.
        replaced with $s.trim()
        Trim string.
        Parameters:
        s - the String
        Returns:
        the trimmed String
      • createValueSpecificationText

        public java.lang.String createValueSpecificationText​(ValueSpecification specification)
        Create text represents the ValueSpecification element.
        Parameters:
        specification - The given ValueSpecification.
        Returns:
        the String value for ValueSpecification
      • getPresentationDiagramElements

        public java.util.Collection<PresentationElement> getPresentationDiagramElements​(Diagram diagram)
        Gets presentation element in the diagram. This method will return all presentation elements from diagram except non-manipulator symbols.
        Parameters:
        diagram - the diagram instance.
        Returns:
        the collection of elements.
        See Also:
        getPresentationDiagramElements(Diagram, boolean)
      • getPresentationDiagramElements

        public java.util.Collection<PresentationElement> getPresentationDiagramElements​(Diagram diagram,
                                                                                        boolean includeNonManipulator)
        Gets presentation element in the diagram.
        Parameters:
        diagram - the diagram instance.
        includeNonManipulator - true for include all non-manipulator element.
        Returns:
        the collection of elements.
        See Also:
        getPresentationDiagramElements(Diagram)
      • getPresentationElementBounds

        @CheckForNull
        public com.nomagic.magicdraw.magicreport.helper.Polygon getPresentationElementBounds​(PresentationElement element)
        Gets the bounds of this element in the form of a Polygon object. The bounds specify this component's coordinate to its diagram.
        Parameters:
        element - the presentation element on diagram.
        Returns:
        the bound of element as Polygon
      • getPresentationElementBounds

        @CheckForNull
        public com.nomagic.magicdraw.magicreport.helper.Polygon getPresentationElementBounds​(PresentationElement element,
                                                                                             ImageExportResult exportResult)
        Gets the bounds of this element in the form of a Polygon object. The bounds specify this component's coordinate to its diagram.
        Parameters:
        element - the presentation element on diagram.
        Returns:
        the bound of element as Polygon
      • getPresentationElementRectangle

        public java.util.List<java.awt.Rectangle> getPresentationElementRectangle​(Diagram diagram,
                                                                                  Element element)
        Gets the bounds of this element in the form of a Rectangle object. The bounds specify this component's coordinate to its diagram.
        Parameters:
        diagram - the target diagram.
        element - the presentation element on given diagram.
        Returns:
        the bound of element as Rectangle. If element is not found in the diagram, it will return null.
      • getPresentationElementBounds

        public java.util.List<com.nomagic.magicdraw.magicreport.helper.Polygon> getPresentationElementBounds​(Diagram diagram,
                                                                                                             Element element)
        Gets the bounds of this element in the form of a Polygon object. The bounds specify this component's coordinate to its diagram.
        Parameters:
        diagram - the target diagram.
        element - the presentation element on given diagram.
        Returns:
        the bound of element as Polygon. If element is not found in the diagram, it will return null.
      • getDiagramType

        public java.lang.String getDiagramType​(Diagram diagram)
        Gets diagram type.
        Parameters:
        diagram - the diagram instance.
        Returns:
        the type of diagram.
      • getMetaClass

        public java.util.Collection<Class> getMetaClass​(Stereotype stereotype)
        Get stereotype meta class.
        Parameters:
        stereotype - the stereotype
        Returns:
        the collection of Meta Class
      • getMetaClass

        public java.lang.Object getMetaClass​(Element element)
        Get meta class of specific element
        Parameters:
        element - element
        Returns:
        a Meta Class or Collection of Meta Class
      • getDiagramElements

        public java.util.Collection<Element> getDiagramElements​(Diagram diagram)
        Gets elements from this diagram.
        Parameters:
        diagram - the target diagram.
        Returns:
        the collection of elements.
      • getDiagramElements

        public java.util.Collection<Element> getDiagramElements​(DiagramPresentationElement diagram)
        Gets presentation elements from this diagram.
        Parameters:
        diagram - the target diagram.
        Returns:
        the collection of elements.
      • getQualifiedOwnerName

        @Deprecated
        public java.lang.String getQualifiedOwnerName​(NamedElement obj)
        Deprecated.
        result from this method is incorrect. Use $element.owner.qualifiedName
        Get qualified owner name.
        Parameters:
        obj - the object instance
        Returns:
        the qualified owner name
      • getQualifiedName

        public static java.lang.String getQualifiedName​(NamedElement namedElement,
                                                        java.lang.String separator)
        Get a qualified name. Qualified is a name which allows the 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.
        Parameters:
        namedElement - NamedElement
        separator - separator symbol. If value is null or empty string, the '::' will be used.
        Returns:
        a qualified name.
      • getPackageQualifiedName

        public static java.lang.String getPackageQualifiedName​(NamedElement namedElement,
                                                               java.lang.String separator)
        Get a qualified name by consider only Package and given element. Model and Profile will not be included on the qualified name.

        For example: The element hierarchy is

                Design : Model -> com : Package -> nomagic : Package -> ui -> Package -> BaseDialog : Class
         
        When template code is:
            $report.getPackageQualifiedName($class, ".")
         
        Where $class is "BaseDialog" element, the result from above code will be:
            com.nomagic.ui.BaseDialog
         

        Parameters:
        namedElement - NamedElement
        separator - separator symbol. If value is null or empty string, the '::' will be used.
        Returns:
        a qualified name.
      • serialize

        public com.nomagic.magicdraw.magicreport.helper.Hyperlink serialize​(Hyperlink hyperlink)
        Convert com.nomagic.magicdraw.hyperlinks.Hyperlink to Hyperlink.
        Parameters:
        hyperlink - the magicdraw hyperlink
        Returns:
        the magic report hyperlink instance
      • getSendingOperationalNode

        public Element getSendingOperationalNode​(Element element)
        Get needline association ends.
        Parameters:
        element - element
        Returns:
        needline association ends
      • getRecievingOperationalNode

        public Element getRecievingOperationalNode​(Element element)
        Get needline association ends.
        Parameters:
        element - element
        Returns:
        needline association ends
      • findRelationship

        public java.util.Collection<Element> findRelationship​(Package modelPackage)
        Search and return a collection of relationship element inside package.
        Parameters:
        modelPackage - package element
        Returns:
        Collection of relationship in this package
      • findRelationship

        public java.util.Collection<Element> findRelationship​(Package modelPackage,
                                                              boolean recursive)
        Search and return a collection of relationship element inside package.
        Parameters:
        modelPackage - package element
        recursive - if true, perform recursively
        Returns:
        Collection of relationship in this package
      • getRelationship

        public java.util.Collection<Element> getRelationship​(Element element)
        Gets direct relationships of specified element.
        Parameters:
        element - Element element to be collect
        Returns:
        Collection of relationship
      • getRelationship

        public java.util.Collection<Element> getRelationship​(Element element,
                                                             boolean recursive)
        Gets direct relationships of specified element.
        Parameters:
        element - Element element to be collect
        recursive - if true, perform recursively
        Returns:
        Collection of relationship
      • getRelationship

        public java.util.Collection<Element> getRelationship​(Element element,
                                                             boolean recursive,
                                                             boolean includeIndirect)
        Gets relationships of specified element.
        Parameters:
        element - element to be collect
        recursive - if true, perform recursively
        includeIndirect - true to include indirect relationships
        Returns:
        Collection of relationship
      • collectRelationships

        public java.util.Collection<Element> collectRelationships​(Element element)
        Gets direct relationships of specified element.
        Parameters:
        element - Element element to be collect
        Returns:
        Collection of relationship
      • collectRelationships

        public java.util.Collection<Element> collectRelationships​(Element element,
                                                                  boolean includeIndirect)
        Gets relationships of specified element.
        Parameters:
        element - element to be collect
        includeIndirect - true to include indirect relationships
        Returns:
        Collection of relationship
      • collectRelationships

        public java.util.Collection<Element> collectRelationships​(Element element,
                                                                  boolean includeIndirect,
                                                                  boolean isRecursive)
        Gets relationships of specified element.
        Parameters:
        element - element to be collect
        includeIndirect - true to include indirect relationships
        isRecursive - if true, perform recursively
        Returns:
        Collection of relationship
      • getClientElement

        public Element getClientElement​(Element element)
        Gets relationship client.
        Parameters:
        element - relationship model element.
        Returns:
        client element
      • getSupplierElement

        public Element getSupplierElement​(Element element)
        Gets relationship supplier.
        Parameters:
        element - relationship model element.
        Returns:
        supplier element
      • getInnerElement

        public java.util.Collection<Element> getInnerElement​(Element element)
        Return a collection of inner element.
        Parameters:
        element - Element element to be collect
        Returns:
        Collection of inner
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(BaseElement element)
        Return image icon for element.
        Parameters:
        element - a Magic Draw element
        Returns:
        Image object for element's icon
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(BaseElement element,
                                                        java.util.Map<java.lang.String,​java.lang.String> iconProperty)
        Return image icon for element.
        Parameters:
        element - a Magic Draw element
        iconProperty - custom property to create icon
        Returns:
        Image object for element's icon
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(BaseElement element,
                                                        boolean allowDuplicate)
        Return image icon for element.
        Parameters:
        element - a Magic Draw element
        allowDuplicate - true to always create new icon and don't keep the icon in map
        Returns:
        Image object for element's icon
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(BaseElement element,
                                                        boolean allowDuplicate,
                                                        java.util.Map<java.lang.String,​java.lang.String> iconProperty)
        Return image icon for element.
        Parameters:
        element - a Magic Draw element
        allowDuplicate - true to always create new icon and don't keep the icon in map
        iconProperty - custom property to create icon
        Returns:
        Image object for element's icon
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(BaseElement element,
                                                        java.lang.String prefix,
                                                        java.lang.String suffix,
                                                        boolean hashCode)
        Return image icon for element. In case of hashCode equals true, icon's name format is set to "icon_"+hash code and doesn't include prefix/suffix.
        Parameters:
        element - a MagicDraw element
        prefix - prefix for icon's name
        suffix - suffix for icon's name
        hashCode - uses hash code in icon's name
        Returns:
        Image object for element's icon
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(BaseElement element,
                                                        java.lang.String prefix,
                                                        java.lang.String suffix,
                                                        boolean hashCode,
                                                        java.util.Map<java.lang.String,​java.lang.String> iconProperty)
        Return image icon for element. In case of hashCode equals true, icon's name format is set to "icon_"+hash code and doesn't include prefix/suffix.
        Parameters:
        element - a MagicDraw element
        prefix - prefix for icon's name
        suffix - suffix for icon's name
        hashCode - uses hash code in icon's name
        iconProperty - custom property to create icon
        Returns:
        Image object for element's icon
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(BaseElement element,
                                                        java.lang.String prefix,
                                                        java.lang.String suffix,
                                                        boolean hashCode,
                                                        boolean allowDuplicate)
        Return image icon for element. In case of hashCode equals true, icon's name format is set to "icon_"+hash code and doesn't include prefix/suffix.
        Parameters:
        element - a MagicDraw element
        prefix - prefix for icon's name
        suffix - suffix for icon's name
        hashCode - uses hash code in icon's name
        allowDuplicate - true to always create new icon and don't keep the icon in map
        Returns:
        Image object for element's icon
      • getIconId

        public java.lang.String getIconId​(BaseElement element,
                                          java.lang.String prefix,
                                          java.lang.String suffix,
                                          boolean hashCode,
                                          boolean allowDuplicate,
                                          ResizableIcon icon)
      • getIconFor

        @CheckForNull
        public com.nomagic.magicreport.Image getIconFor​(BaseElement element,
                                                        java.lang.String prefix,
                                                        java.lang.String suffix,
                                                        boolean hashCode,
                                                        boolean allowDuplicate,
                                                        @CheckForNull
                                                        java.util.Map<java.lang.String,​java.lang.String> iconProperty)
        Return image icon for element. In case of hashCode equals true, icon's name format is set to "icon_"+hash code and doesn't include prefix/suffix.
        Parameters:
        element - a MagicDraw element
        prefix - prefix for icon's name
        suffix - suffix for icon's name
        hashCode - uses hash code in icon's name
        allowDuplicate - true to always create new icon and don't keep the icon in map
        iconProperty - custom property to create icon
        Returns:
        Image object for element's icon
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(java.lang.String type)
        Return image icon for element.
        Parameters:
        type - element type
        Returns:
        Image object for element's icon
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(java.lang.String type,
                                                        java.util.Map<java.lang.String,​java.lang.String> iconProperty)
        Return image icon for element.
        Parameters:
        type - element type
        Returns:
        Image object for element's icon
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(java.lang.String type,
                                                        java.lang.String prefix,
                                                        java.lang.String suffix,
                                                        boolean hashCode)
        Return image icon for element. In case of hashCode equals true, icon's name format is set to "icon_"+hash code and doesn't include prefix/suffix.
        Parameters:
        type - element type
        prefix - prefix for icon's name
        suffix - suffix for icon's name
        hashCode - uses hash code in icon's name
        Returns:
        Image object for element's icon
      • getIconFor

        public com.nomagic.magicreport.Image getIconFor​(java.lang.String type,
                                                        java.lang.String prefix,
                                                        java.lang.String suffix,
                                                        boolean hashCode,
                                                        java.util.Map<java.lang.String,​java.lang.String> iconProperty)
        Return image icon for element. In case of hashCode equals true, icon's name format is set to "icon_"+hash code and doesn't include prefix/suffix.
        Parameters:
        type - element type
        prefix - prefix for icon's name
        suffix - suffix for icon's name
        hashCode - uses hash code in icon's name
        iconProperty - custom property to create icon
        Returns:
        Image object for element's icon
      • getCustomImage

        public com.nomagic.magicreport.Image getCustomImage​(PresentationElement presentationElement)
        Return original image of Image property from presentationElement
        Parameters:
        presentationElement - a presentationElement
        Returns:
        original image in Image property
      • getCustomImage

        public com.nomagic.magicreport.Image getCustomImage​(Element element)
        Return original image of Image property
        Parameters:
        element - an element
        Returns:
        original image in Image property
      • getCustomImageInformation

        public ElementImageHelper.ImageInformation getCustomImageInformation​(Element element)
        Return a CustomImageHolder information
        Parameters:
        element - element
        Returns:
        CustomImageHolder
      • isNull

        public boolean isNull​(java.lang.Object obj)
        Test and return true if object is null.
        Parameters:
        obj - object being tested.
        Returns:
        true if object is null
      • isEmpty

        public boolean isEmpty​(java.lang.Object obj)
        Test and return true if object is null, empty string or empty collection.
        Parameters:
        obj - object being tested.
        Returns:
        true if object is null, empty string or empty collection.
      • isEmpty

        public boolean isEmpty​(java.lang.Object obj,
                               boolean isIgnoreSpace)
        Test and return true if object is null, empty string or empty collection.
        Parameters:
        obj - object being tested.
        isIgnoreSpace - true for ignoring all spaces, line feeds, etc. for html string only
        Returns:
        true if object is null, empty string or empty collection.
      • isRelationship

        public boolean isRelationship​(Element element)
        Test and return true if element is relationship.
        Parameters:
        element - element being tested.
        Returns:
        true if object is relationship
      • getInteractionMessageType

        public java.lang.String getInteractionMessageType​(Message message)
        Gets interaction message type.
        Parameters:
        message - Message
        Returns:
        type of message
      • getUsageRepresentationText

        public java.lang.String getUsageRepresentationText​(BaseElement be,
                                                           boolean addFullPath)
        Formats the usage subject. The output string is the same as Result column of Used by table in Magic Draw.
        Parameters:
        be - ModelElement to format.
        addFullPath - use full path.
        Returns:
        formatted element, String.
      • getUsedBy

        public java.util.Collection<BaseElement> getUsedBy​(Element element)
        Return a list of element used by this element (except diagram).
        Parameters:
        element - the the element which will be gotten the list of element name that uses the specified element.
        Returns:
        Collection of elements used by input element.
      • getUsages

        public java.util.Map<BaseElement,​java.util.List<com.nomagic.magicdraw.uml.DependencyType>> getUsages​(java.lang.Object selectedObjects)
        Returns Usage Map of MD and then use getUsageElements method for returning the usage of the specified element.
        Parameters:
        selectedObjects - the elements that this method will find the usage.
        Returns:
        Map of Usages of elements
      • getUsageElements

        @CheckForNull
        public java.util.Collection<BaseElement> getUsageElements​(java.util.Map<BaseElement,​java.util.List<com.nomagic.magicdraw.uml.DependencyType>> usagesMap,
                                                                  Element element)
        Gets the element usages from usage map.
        Parameters:
        usagesMap - the Usages Map of MagicDraw.
        element - the element which will be gotten the list of element name that uses the specified element.
        Returns:
        Collection of usage name of elements.
      • getElementName

        public java.lang.String getElementName​(java.lang.Object element)
        Gets name of the element. If the name of element is empty, it will return "<unnamed>". This method performs the following procedures:
        1. If element is generalized from NamedElement, return $element.name
        2. If element is generalized from Slot, return $element.definingFeature.name
        3. If element is an UML element, return $element.humanName
        4. else return $element.toString()
        Parameters:
        element - the element.
        Returns:
        element name
      • filterDiagram

        public java.util.Collection<Diagram> filterDiagram​(java.util.Collection<Diagram> diagramList,
                                                           java.util.Collection<java.lang.String> digramTypes)
        Return the collection from the diagram list filtered by types.

        Example:

         #foreach ($d in $report.filterElement($Diagram, ['Use Case Diagram', 'Class Diagram'])
            $d.name
         #end
         

        Parameters:
        diagramList - the collection of diagrams.
        digramTypes - the collection of diagram types which is used to filter.
        Returns:
        the collection of filtered diagrams.
      • filterElement

        public java.util.Collection<BaseElement> filterElement​(java.util.Collection<BaseElement> elementList,
                                                               java.util.Collection<java.lang.String> humanTypes)
        Return the collection from the element list filtered by human types.

        Example:

         #foreach ($e in $report.filterElement($elements, ['Class', 'Interface'])
            $e.name $e.humanType
         #end
         

        Parameters:
        elementList - the collection of element.
        humanTypes - the collection of human types which is used to filter.
        Returns:
        the collection of filtered elements.
      • filterElementByStereotypeName

        public java.util.Collection<BaseElement> filterElementByStereotypeName​(java.util.Collection<BaseElement> elementList,
                                                                               java.util.Collection<java.lang.String> stereotypesNames)
        Return the collection from the element list filtered by stereotype.
        Parameters:
        elementList - the collection of element.
        stereotypesNames - the collection of stereotypes names which is used to filter.
        Returns:
        the collection of filtered elements.
      • filterElementType

        public java.util.Collection<BaseElement> filterElementType​(java.util.Collection<BaseElement> elementList,
                                                                   java.util.Collection<java.lang.String> elementTypes)
        Return the collection from the element list filtered by element types.

        Example:

         #foreach ($e in $report.filterElementType($elements, ['class', 'interface'])
            $e.name $e.elementType
         #end
         

        Parameters:
        elementList - the collection of element.
        elementTypes - the collection of element types which is used to filter.
        Returns:
        the collection of filtered elements.
      • filterClassName

        public java.util.Collection<BaseElement> filterClassName​(java.util.Collection<BaseElement> elementList,
                                                                 java.util.Collection<java.lang.String> shortNameForClassTypes)
        Return the collection from the element list filtered by short name for class types.

        Example:

         #foreach ($e in $report.filterClassName($elements, ['Diagram', 'UseCase'])
            $e.name $e.className
         #end
         

        Parameters:
        elementList - the collection of element.
        shortNameForClassTypes - the collection of short name for class type which is used to filter.
        Returns:
        the collection of filtered elements.
      • filter

        public java.util.Collection<Element> filter​(java.util.Collection<Element> elementList,
                                                    java.lang.String propertyName,
                                                    java.util.Collection<?> propertyValue)
        Return the collection from the element list filtered by specified property name.

        Example:

         #foreach ($e in $report.filter($elements, 'name', ['foo', 'bar'])
            $e.name
         #end
         

        Parameters:
        elementList - the collection of element.
        propertyName - the property name which is used to filter.
        propertyValue - the collection of element property values which is used to filter.
        Returns:
        the collection of filtered elements.
      • getBaseClassInheritableAttributes

        public java.util.Collection getBaseClassInheritableAttributes​(Classifier classifier)
        Gets the classifier inheritable attributes.
        Parameters:
        classifier - the Classifier.
        Returns:
        the Collection of Attributes.
      • getBaseClassInheritableOperations

        public java.util.Collection getBaseClassInheritableOperations​(Classifier classifier)
        Gets the classifier inheritable operations.
        Parameters:
        classifier - the Classifier.
        Returns:
        the Collection of Operations.
      • getBaseClassAssociations

        public java.util.Collection getBaseClassAssociations​(Classifier classifier)
        Gets the classifier associations.
        Parameters:
        classifier - the Classifier.
        Returns:
        the Collection of Associations.
      • getBaseRelations

        public java.util.Collection getBaseRelations​(Classifier classifier)
        Gets the classifier relations.
        Parameters:
        classifier - the Classifier.
        Returns:
        the Collection of Relations.
      • getBaseClassPorts

        public java.util.Collection getBaseClassPorts​(Classifier classifier)
        Gets the classifier port.
        Parameters:
        classifier - the Classifier.
        Returns:
        the Collection of Ports.
      • getBaseRealizedInterfaces

        public java.util.Collection getBaseRealizedInterfaces​(BehavioredClassifier behavioredClassifier)
        Gets the behavior classifier realized interfaces.
        Parameters:
        behavioredClassifier - the BehavioredClassifier.
        Returns:
        the Collection of RealizedInterfaces.
      • isDerivedClassifier

        public boolean isDerivedClassifier​(Classifier parent,
                                           Classifier child)
        Checks if child is derived from parent by generalization.
        Parameters:
        parent - parent
        child - possible parent
        Returns:
        true if derived
      • getUseCaseNumber

        public java.lang.String getUseCaseNumber​(Element element)
        Return the use case number or use case ID of element.
        Parameters:
        element - the element
        Returns:
        the use case number.
      • getActorNumber

        public java.lang.String getActorNumber​(Element element)
        Return the actor ID of Actor.
        Parameters:
        element - element
        Returns:
        the actor ID
      • getUCOwnerNumber

        public java.lang.String getUCOwnerNumber​(Element element)
        Return the use case number or use case ID of element.
        Parameters:
        element - the element
        Returns:
        the use case owner number or ID.
      • getElementURL

        public java.lang.String getElementURL​(Element element)
        Retrieve MagicDraw's element URL.
        Parameters:
        element - element object
        Returns:
        MagicDraw's element URL
      • getBasicFlows

        public java.util.List<FlowStep> getBasicFlows​(UseCase useCase)
        Find and return a list of basic flows from given use case. If use case scenario is not being used, it will retrieve the value from "requirementUseCase" stereotype tags.
        Parameters:
        useCase - a use case.
        Returns:
        a list of flow step FlowStep
      • getAlternativeFlows

        public java.util.List<FlowStep> getAlternativeFlows​(UseCase useCase)
        Find and return all alternative flows from given use case. The alternative flows will be listed from all possible branches of basic flows. If use case scenario is not being used, it will the retrieve value from "requirementUseCase" stereotype tags.
        Parameters:
        useCase - a use case.
        Returns:
        a list of flow step FlowStep
      • getExceptionalFlows

        public java.util.List<FlowStep> getExceptionalFlows​(UseCase useCase)
        Find and return a basic flow from given use case. If use case scenario is not being used, it will the retrieve value from "requirementUseCase" stereotype tags.
        Parameters:
        useCase - a use case.
        Returns:
        a list of flow step FlowStep
      • getSlotValue

        public java.util.List<java.lang.Object> getSlotValue​(Element element,
                                                             java.lang.String classifierName,
                                                             java.lang.String definingFeatureName)
        Get slot value by classifier name and definingFeature name. If there are more than one slots matching with specified parameters, return only the value of first matching slot.
        Parameters:
        element - an element.
        classifierName - classifier name. [case-sensitive]
        definingFeatureName - defining feature name. [case-sensitive]
        Returns:
        result value in ValueSpecification or value in array of ValueSpecification, up to multiplicity.
      • getSlotProperty

        @CheckForNull
        public java.lang.Object getSlotProperty​(Element element,
                                                java.lang.String classifierName)
        Get slot property by classifier name If there are more than one classifier matching with specified parameters, return only the property of first matching classifier.
        Parameters:
        element - an element.
        classifierName - classifier name. [case-sensitive]
        Returns:
        slot property
      • getOwnedElementsIncludingAdditional

        public java.util.List<Element> getOwnedElementsIncludingAdditional​(Element element,
                                                                           boolean includePureOwned)
        Return owned elements of the given Element including additional owned elements defined in DSL specification by additionalContentProperty.
        Parameters:
        element - an element to be found owned element
        includePureOwned - include element owned directly in ownedElement UML metaproperty
        Returns:
        owned elements of the given Element
      • getOwnedElementsIncludingAdditional

        public java.util.List<Element> getOwnedElementsIncludingAdditional​(Element element,
                                                                           boolean includePureOwned,
                                                                           boolean excludeRelationship)
        Return owned elements of the given Element including additional owned elements defined in DSL specification by additionalContentProperty.
        Parameters:
        element - an element to be found owned element
        includePureOwned - include element owned directly in ownedElement UML metaproperty
        excludeRelationship - true to exclude relationship
      • getOwnedElementsIncludingAdditional

        public java.util.List<Element> getOwnedElementsIncludingAdditional​(Element element,
                                                                           boolean includePureOwned,
                                                                           boolean excludeRelationship,
                                                                           boolean excludeAuxiliaryResources)
        Return owned elements of the given Element including additional owned elements defined in DSL specification by additionalContentProperty.
        Parameters:
        element - an element to be found owned element
        includePureOwned - include element owned directly in ownedElement UML metaproperty
        excludeRelationship - true to exclude relationship of given element
        excludeAuxiliaryResources - true to exclude auxiliary resoures
        Returns:
        owned elements of the given Element
      • getOwnedElementsIncludingAdditional

        public java.util.List<Element> getOwnedElementsIncludingAdditional​(Element element,
                                                                           boolean includePureOwned,
                                                                           boolean excludeRelationship,
                                                                           boolean excludeAuxiliaryResources,
                                                                           boolean excludeInvisibleElement)
        Return owned elements of the given Element including additional owned elements defined in DSL specification by additionalContentProperty.
        Parameters:
        element - an element to be found owned element
        includePureOwned - include element owned directly in ownedElement UML metaproperty
        excludeRelationship - true to exclude relationship of given element
        excludeAuxiliaryResources - true to exclude auxiliary resources
        excludeInvisibleElement - true to exclude invisible element
        Returns:
        owned elements of the given Element
      • filterElementByElementFilters

        public java.util.List<Element> filterElementByElementFilters​(java.util.List<Element> elements,
                                                                     java.util.List<com.nomagic.magicdraw.ui.ElementFilter> elementFilters)
      • getPackages

        public java.util.Collection<Element> getPackages​(boolean includeSmartPackage)
      • isAttachedFile

        public boolean isAttachedFile​(Element element)
        Check if element is attached file.
        Parameters:
        element - specific element
        Returns:
        true if element is attached element, otherwise; false
      • isAttachedImage

        public boolean isAttachedImage​(Element element)
        Check if element is attached image.
        Parameters:
        element - specific element
        Returns:
        true if element is attached image, otherwise; false
      • getAttachedImage

        public java.lang.Object getAttachedImage​(Element element)
                                          throws java.io.IOException
        Throws:
        java.io.IOException
      • getAttachedImage

        @CheckForNull
        public java.lang.Object getAttachedImage​(Element element,
                                                 @CheckForNull
                                                 java.lang.String cannotRenderImageMsg)
                                          throws java.io.IOException
        Get image from attached image.
        Parameters:
        element - specific element
        cannotRenderImageMsg - in case the element is attached file but not image, return this msg instead.
        Returns:
        image of attached image.
        Throws:
        java.io.IOException
      • getAttachedFile

        public java.io.File getAttachedFile​(Element element)
                                     throws java.io.IOException
        Get file from attached file.
        Parameters:
        element - specific element
        Returns:
        image of attached image.
        Throws:
        java.io.IOException
      • getTemplateFile

        @CheckForNull
        public java.io.File getTemplateFile​(java.lang.String templateFileName,
                                            java.lang.String templateLocation,
                                            java.lang.String extension,
                                            java.lang.Object marker)
        Get Template file from template file name/path.
        Parameters:
        templateFileName - template file name or path
        templateLocation - template location/dir
        extension - extension for template file. in case it has no extension
        marker - The marker object used to track the file.
        Returns:
        template file
      • getTemplateFile

        public java.io.File getTemplateFile​(Element element)
                                     throws java.io.IOException
        Get template file from element.
        Parameters:
        element - attached file
        Returns:
        template file
        Throws:
        java.io.IOException
      • getImageFor

        public java.lang.Object getImageFor​(Element element)
        Create image from element.
        The image is always created.
        Parameters:
        element - target element
        Returns:
        image
      • getImageFor

        public java.lang.Object getImageFor​(Element element,
                                            int dpi)
        Create image from element.
        The image is always created.
        Parameters:
        element - target element
        dpi -
        Returns:
        image
      • getImageFor

        public java.lang.Object getImageFor​(java.lang.Object object,
                                            boolean allowDuplicate)
        Create image from object.
        The image is newly created or returned old image from map up to 'allowDuplicate'.
        Parameters:
        object - object to be exported as image
        allowDuplicate - allowDuplicated true to always create new image and don't keep the image in map
        Returns:
        Image
      • getImageFor

        public java.lang.Object getImageFor​(java.lang.Object object,
                                            boolean allowDuplicate,
                                            @CheckForNull
                                            java.lang.String cannotRenderImageMsg)
        Create image from object.
        The image is newly created or returned old image from map up to 'allowDuplicate'.
        Parameters:
        object - object to be exported as image
        allowDuplicate - allowDuplicated true to always create new image and don't keep the image in map
        cannotRenderImageMsg - in case the element is attached file but not image, return error message instead.
        Returns:
        Image
      • getImageFor

        public java.lang.Object getImageFor​(java.lang.Object object,
                                            boolean allowDuplicate,
                                            @CheckForNull
                                            java.lang.String cannotRenderImageMsg,
                                            int dpi)
        Create image from object.
        The image is newly created or returned old image from map up to 'allowDuplicate'.
        Parameters:
        object - object to be exported as image
        allowDuplicate - allowDuplicated true to always create new image and don't keep the image in map
        cannotRenderImageMsg - in case the element is attached file but not image, return error message instead.
        dpi - image dpi
        Returns:
        Image
      • getCustomizationPropertyString

        public java.lang.String getCustomizationPropertyString​(Element element,
                                                               java.lang.Object aStereotype,
                                                               java.lang.String propertyName)
        Return property value as string from Customization element of the specified stereotype, on the element.
        Parameters:
        element - an element
        aStereotype - stereotype name or element
        propertyName - property name
        Returns:
        property value as string from Customization element
      • getCustomizationProperty

        public java.lang.Object getCustomizationProperty​(Element element,
                                                         java.lang.Object aStereotype,
                                                         java.lang.String propertyName)
        Return property value from Customization element of the specified stereotype, on the element.
        Parameters:
        element - an element
        aStereotype - stereotype name or element
        propertyName - property name
        Returns:
        property value from Customization element
      • getAllCustomizationsByElement

        public java.util.List<Class> getAllCustomizationsByElement​(Element element)
        Get all customizations from specific element.
        Parameters:
        element - an element
        Returns:
        all customization elements of the stereotype on the element.
      • getAllCustomizationsByElement

        public java.util.List<Class> getAllCustomizationsByElement​(Element element,
                                                                   @CheckForNull
                                                                   java.lang.Object aStereotype)
        Get all customizations from specific stereotype on element.
        Parameters:
        element - an element
        aStereotype - stereotype name or element
        Returns:
        all customization elements of the stereotype on the element.
      • getAllCustomizationsByTarget

        public java.util.List<Class> getAllCustomizationsByTarget​(java.lang.Object targetElement)
        Get all customizations from specific target element of customization element.
        Parameters:
        targetElement - a target element
        Returns:
        all customizations from specific target element of customization element.
      • getElementPropertiesName

        public java.util.List<java.lang.String> getElementPropertiesName​(Element element)
        Get name of all properties from specific element.
        Parameters:
        element - element
        Returns:
        list of properties name
      • getElementPropertiesNameWithMode

        public java.util.List<java.lang.String> getElementPropertiesNameWithMode​(Element element)
        Get name of all properties from specific element and current mode.
        Parameters:
        element - element
        Returns:
        list of properties name
      • getElementPropertiesNameWithMode

        public java.util.List<java.lang.String> getElementPropertiesNameWithMode​(Element element,
                                                                                 @CheckForNull
                                                                                 java.lang.String mode)
        Get name of all properties from specific element and specific mode.
        Parameters:
        element - element
        mode - view mode from PropertiesModeHelper.MODES
        Returns:
        list of properties name
      • getElementProperties

        public java.util.List<Property> getElementProperties​(Element element)
        Get all properties from specific element.
        Parameters:
        element - element
        Returns:
        list of properties
      • getElementProperties

        public java.util.List<Property> getElementProperties​(Element element,
                                                             @CheckForNull
                                                             java.lang.String mode)
        Collects properties that appears in element's specification dialog tree at specific view mode (Standard/Expert/All)
        Parameters:
        element - element
        mode - view mode from PropertiesModeHelper.MODES -- STANDARD, EXPERT, ALL
        Returns:
        list of properties
      • getDefaultElementFilter

        public com.nomagic.magicdraw.ui.ElementFilter getDefaultElementFilter()
      • getExcludeAuxiliaryResourceFilter

        public com.nomagic.magicdraw.ui.ElementFilter getExcludeAuxiliaryResourceFilter()
      • getVisibleElementFilter

        public com.nomagic.magicdraw.ui.ElementFilter getVisibleElementFilter()
      • getExcludeRelationshipElementFilter

        public com.nomagic.magicdraw.ui.ElementFilter getExcludeRelationshipElementFilter()
      • filterVisibleElement

        public java.util.List<Element> filterVisibleElement​(java.util.List<Element> elements)
      • filterVisibleElement

        public java.util.List<Element> filterVisibleElement​(java.util.List<Element> elements,
                                                            boolean includeAuxiliaryResources)
      • isInvisibleElement

        public boolean isInvisibleElement​(BaseElement element)
      • isInvisibleElement

        public boolean isInvisibleElement​(BaseElement element,
                                          boolean isTypeFilter)
      • isInvisibleElement

        public boolean isInvisibleElement​(BaseElement element,
                                          @CheckForNull
                                          com.nomagic.magicdraw.ui.ElementFilter elementFilter)
      • getRootNodeOfContainmentTree

        public static Node getRootNodeOfContainmentTree​(boolean startWithPrimaryModel)
        Get root node from containment tree.
        Parameters:
        startWithPrimaryModel - true to filter only primary model,
        otherwise it will return Project node that may contain primary model and usage project
        Returns:
        root node from containment tree
      • getRootNodeOfDiagramTree

        public Node getRootNodeOfDiagramTree()
        Get root node from diagram tree.
        Returns:
        root node from diagram tree
      • getPropertyGroupsByStereotype

        public java.util.Collection<com.nomagic.magicdraw.propertygroup.PropertyGroup> getPropertyGroupsByStereotype​(Class stereotype)
        Get collection of PropertyGroup by specific stereotype.
        Parameters:
        stereotype - a stereotype
        Returns:
        collection of PropertyGroup
      • getPropertyGroupsByElement

        public java.util.Set<com.nomagic.magicdraw.propertygroup.PropertyGroup> getPropertyGroupsByElement​(Element element,
                                                                                                           boolean addAlwaysVisible)
        Get set of PropertyGroup by specific element.
        Parameters:
        element - an element
        addAlwaysVisible - true to use all set stereotypes + all settable showWhenNotApplied stereotypes, false to use only all set stereotypes.
        Returns:
        set of PropertyGroup
      • getQProperty

        @CheckForNull
        public Property getQProperty​(Element element,
                                     java.lang.String propertyName)
        Get a property for element with DSL property groups, and each property group has its own property.
        Parameters:
        element - an element.
        propertyName - property name
        Returns:
        a Property
      • getQProperties

        public java.util.List<Property> getQProperties​(Element element,
                                                       java.lang.String propertyName)
        Get list of properties for element with DSL property groups, and each property group has its own property.
        Parameters:
        element - an element.
        propertyName - property name
        Returns:
        a list of Property
      • setActiveValidationEnabled

        public void setActiveValidationEnabled​(boolean enable)
      • ensureLoad

        public void ensureLoad​(Diagram diagram)
      • isTypeOf

        public boolean isTypeOf​(Element element,
                                java.lang.String typeName)
        A function for checking super type of the specific element.
        Parameters:
        element - an element
        typeName - stereotype name or java class name
        Returns:
        return true, if the element is subtype of the specific stereotype name or class name.
      • isTypeOf

        public boolean isTypeOf​(Element element,
                                java.lang.String typeName,
                                boolean checkClassTypeName)
        A function for checking super type of the specific element.
        Parameters:
        element - an element
        typeName - stereotype name or java class name
        checkClassTypeName - false to check type by stereotype name only
        Returns:
        return true, if the element is subtype of the specific stereotype name or class name.
      • isAssignableFrom

        public boolean isAssignableFrom​(Element element,
                                        java.lang.String classTypeName)
        A function for checking super type of the specific element.
        Parameters:
        element - an element
        classTypeName - java class name
        Returns:
        return true, if the element is subtype of the specific class type name.