Class ReportHelper

java.lang.Object
java.util.Observable
com.nomagic.magicreport.engine.Tool
com.nomagic.magicdraw.magicreport.helper.ReportHelper
All Implemented Interfaces:
com.nomagic.magicreport.engine.ITool, com.nomagic.magicreport.IVariable, Serializable, 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:
  • Field Details

  • Constructor Details

    • ReportHelper

      public ReportHelper()
  • Method Details

    • getDSLProperty

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

      public Object getStereotypeProperty(Element element, String stereotypeName, String propertyName)
      Gets stereotype property.
      Parameters:
      element - the element.
      stereotypeName - the stereotype name.
      propertyName - the property name.
      Returns:
      the property value.
      See Also:
    • getStereotypeProperty

      public Object getStereotypeProperty(Element element, String stereotypeName, String propertyName, boolean checkMultiplicity)
      Gets stereotype property.
      Parameters:
      element - the element.
      stereotypeName - the stereotype name.
      propertyName - the property name.
      checkMultiplicity - check multiplicity before return value
      Returns:
      the property value.
      See Also:
    • parseObjectForPrinting

      public static Object parseObjectForPrinting(Object value)
      Parses Strings and Collections of Strings
    • getStereotypeProperty

      public Object getStereotypeProperty(Element element, Stereotype stereotype, String propertyName)
      Gets stereotype property.
      Parameters:
      element - the element.
      stereotype - the stereotype.
      propertyName - the property name.
      Returns:
      the property value.
      See Also:
    • getStereotypeProperty

      public Object getStereotypeProperty(Element element, Stereotype stereotype, String propertyName, boolean checkMultiplicity)
      Gets stereotype property.
      Parameters:
      element - the element.
      stereotype - the stereotype.
      propertyName - the property name.
      checkMultiplicity - check multiplicity before return value
      Returns:
      the property value.
      See Also:
    • getStereotypeProperty

      public static Object getStereotypeProperty(Element element, String profileName, String stereotypeName, 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 List<Object> getStereotypePropertyList(Element element, String stereotypeName, 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 String getStereotypePropertyString(Element element, String stereotypeName, 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 String getStereotypePropertyString(Element element, Stereotype stereotype, 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 String getStereotypePropertyString(Element element, Stereotype stereotype, String propertyName, 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 String getStereotypePropertyString(Element element, String profileName, String stereotypeName, 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 String getStereotypePropertyString(Element element, String profileName, String stereotypeName, String propertyName, 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 String getStereotypePropertyStringValue(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 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, 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, 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, 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, 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

      public boolean containsStereotype(Element element, 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:
    • hasProperty

      public boolean hasProperty(Element element, 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 Object getProperty(Element element, 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 List<Stereotype> getStereotypes(Element element) throws IllegalArgumentException
      Gets all stereotypes applied to element. This method is replaced with $element.appliedStereotype.
      Parameters:
      element - the element
      Returns:
      the stereotype instances
      Throws:
      IllegalArgumentException - from StereotypesHelper.getStereotypes
    • hasStereotype

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

      @CheckForNull public Element findElementInCollection(Collection<? extends Element> col, 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(String elementName)
    • findElementByName

      public Collection<Element> findElementByName(Collection<Element> source, 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 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, 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 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 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 Collection<Actor> getRelativeActor(Element element)
      Gets element relative actor.
      Parameters:
      element - the element
      Returns:
      the collection of Actor.
    • getUseCaseAssociatedElement

      @CheckForNull @Deprecated public 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 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 String trimString(String s)
      Deprecated.
      replaced with $s.trim()
      Trim string.
      Parameters:
      s - the String
      Returns:
      the trimmed String
    • createValueSpecificationText

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

      @Deprecated public Collection<PresentationElement> getPresentationElements(Diagram diagram)
      Deprecated.
      Gets presentation element in the diagram. This method equivalent to getPresentationDiagramElements(Diagram).
      Parameters:
      diagram - the diagram instance.
      Returns:
      the collection of elements.
      See Also:
    • getPresentationDiagramElements

      public 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

      public 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:
    • 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 List<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 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 String getDiagramType(Diagram diagram)
      Gets diagram type.
      Parameters:
      diagram - the diagram instance.
      Returns:
      the type of diagram.
    • getMetaClass

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

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

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

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

      @Deprecated public 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 String getQualifiedName(NamedElement namedElement, 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 String getPackageQualifiedName(NamedElement namedElement, 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 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 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 Collection<Element> getRelationship(Element element)
      Gets direct relationships of specified element.
      Parameters:
      element - Element element to be collect
      Returns:
      Collection of relationship
    • getRelationship

      public 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 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 Collection<Element> collectRelationships(Element element)
      Gets direct relationships of specified element.
      Parameters:
      element - Element element to be collect
      Returns:
      Collection of relationship
    • collectRelationships

      public 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 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 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, Map<String,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, Map<String,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, String prefix, 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, String prefix, String suffix, boolean hashCode, Map<String,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, String prefix, 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 String getIconId(BaseElement element, String prefix, String suffix, boolean hashCode, boolean allowDuplicate, ResizableIcon icon)
    • getIconFor

      @CheckForNull public com.nomagic.magicreport.Image getIconFor(BaseElement element, String prefix, String suffix, boolean hashCode, boolean allowDuplicate, @CheckForNull Map<String,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(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(String type, Map<String,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(String type, String prefix, 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(String type, String prefix, String suffix, boolean hashCode, Map<String,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(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(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(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 String getInteractionMessageType(Message message)
      Gets interaction message type.
      Parameters:
      message - Message
      Returns:
      type of message
    • getUsageRepresentationText

      public 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 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 Map<BaseElement,List<com.nomagic.magicdraw.uml.DependencyType>> getUsages(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 Collection<BaseElement> getUsageElements(Map<BaseElement,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 String getElementName(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 Collection<Diagram> filterDiagram(Collection<Diagram> diagramList, Collection<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 Collection<BaseElement> filterElement(Collection<BaseElement> elementList, Collection<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 Collection<BaseElement> filterElementByStereotypeName(Collection<BaseElement> elementList, Collection<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 Collection<BaseElement> filterElementType(Collection<BaseElement> elementList, Collection<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 Collection<BaseElement> filterClassName(Collection<BaseElement> elementList, Collection<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 Collection<Element> filter(Collection<Element> elementList, String propertyName, 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 Collection getBaseClassInheritableAttributes(Classifier classifier)
      Gets the classifier inheritable attributes.
      Parameters:
      classifier - the Classifier.
      Returns:
      the Collection of Attributes.
    • getBaseClassInheritableOperations

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

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

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

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

      public 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 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 String getActorNumber(Element element)
      Return the actor ID of Actor.
      Parameters:
      element - element
      Returns:
      the actor ID
    • getUCOwnerNumber

      public 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 String getElementURL(Element element)
      Retrieve MagicDraw's element URL.
      Parameters:
      element - element object
      Returns:
      MagicDraw's element URL
    • getBasicFlows

      public 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 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 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 List<Object> getSlotValue(Element element, String classifierName, 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 Object getSlotProperty(Element element, 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 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 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 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 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 List<Element> filterElementByElementFilters(List<Element> elements, List<com.nomagic.magicdraw.ui.ElementFilter> elementFilters)
    • getPackages

      public 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 Object getAttachedImage(Element element) throws IOException
      Throws:
      IOException
    • getAttachedImage

      @CheckForNull public Object getAttachedImage(Element element, @CheckForNull String cannotRenderImageMsg) throws 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:
      IOException
    • getAttachedFile

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

      @CheckForNull public File getTemplateFile(String templateFileName, String templateLocation, String extension, 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 File getTemplateFile(Element element) throws IOException
      Get template file from element.
      Parameters:
      element - attached file
      Returns:
      template file
      Throws:
      IOException
    • getImageFor

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

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

      public Object getImageFor(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 Object getImageFor(Object object, boolean allowDuplicate, @CheckForNull 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 Object getImageFor(Object object, boolean allowDuplicate, @CheckForNull 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 String getCustomizationPropertyString(Element element, Object aStereotype, 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 Object getCustomizationProperty(Element element, Object aStereotype, 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 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 List<Class> getAllCustomizationsByElement(Element element, @CheckForNull 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 List<Class> getAllCustomizationsByTarget(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 List<String> getElementPropertiesName(Element element)
      Get name of all properties from specific element.
      Parameters:
      element - element
      Returns:
      list of properties name
    • getElementPropertiesNameWithMode

      public List<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 List<String> getElementPropertiesNameWithMode(Element element, @CheckForNull 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 List<Property> getElementProperties(Element element)
      Get all properties from specific element.
      Parameters:
      element - element
      Returns:
      list of properties
    • getElementProperties

      public List<Property> getElementProperties(Element element, @CheckForNull 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 List<Element> filterVisibleElement(List<Element> elements)
    • filterVisibleElement

      public List<Element> filterVisibleElement(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 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 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, 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 List<Property> getQProperties(Element element, 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, 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, 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, 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.