Class TypeMapProfile


  • @OpenApi
    public class TypeMapProfile
    extends java.lang.Object
    TypeMapProfile - class for type mapping.
    • Field Detail

      • modelPackage

        @CheckForNull
        private final Package modelPackage
        Profile package
      • forwardTransformationTable

        private java.lang.String[][] forwardTransformationTable
      • reverseTransformationTable

        private java.lang.String[][] reverseTransformationTable
      • brokenString

        private java.lang.String brokenString
      • forwardMap

        private final java.util.HashMap<Element,​com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap> forwardMap
      • reverseMap

        private final java.util.HashMap<Element,​com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap> reverseMap
      • mappings

        private final java.util.Set<com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap> mappings
      • defaultMappingIndex

        private final java.util.Map<Element,​com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap> defaultMappingIndex
      • isForward

        private boolean isForward
      • isBroken

        private boolean isBroken
      • isForwardBroken

        private boolean isForwardBroken
      • isReversBroken

        private boolean isReversBroken
      • anySourceType

        private Element anySourceType
      • anyDestinationType

        private Element anyDestinationType
      • emptySourceType

        private Element emptySourceType
      • emptyDestinationType

        private Element emptyDestinationType
      • EMPTY_TYPE_MODIFIER

        public static final com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeModifier EMPTY_TYPE_MODIFIER
    • Constructor Detail

      • TypeMapProfile

        public TypeMapProfile​(@CheckForNull
                              Package mp)
        Constructor
        Parameters:
        mp - profile package
    • Method Detail

      • getImportedTypeMapPackages

        private static java.util.List<Package> getImportedTypeMapPackages​(Package root)
      • addTypeMapPackages

        private static void addTypeMapPackages​(Element root,
                                               java.util.List<Package> importedPackages,
                                               java.util.Set<Package> index)
      • setProfileElements

        private void setProfileElements()
        Sets profile elements from Model Transformation profile
      • getDirection

        private int getDirection​(Dependency dependency)
        Returns default mapping direction
        Returns:
        default mapping direction
      • parseRelationships

        private void parseRelationships​(Element modelPackage)
        Parses type map relationships and generates mapping list
        Parameters:
        modelPackage - package containing mapping relations
      • isDependencyDefaultMapping

        private static boolean isDependencyDefaultMapping​(Element dependency)
      • isDefault

        public boolean isDefault​(@CheckForNull
                                 com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMap)
      • addTypeMap

        private void addTypeMap​(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMapToAdd,
                                java.util.Collection<com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap> mappings)
      • fillDefaultMappingRulesIndex

        private void fillDefaultMappingRulesIndex​(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMapToAdd)
      • setDefaultForwardMappingRule

        private void setDefaultForwardMappingRule​(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMapToAdd)
      • setDefaultReverseMappingRule

        private void setDefaultReverseMappingRule​(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMapToAdd)
      • checkForBrokenMapping

        private void checkForBrokenMapping()
        Checks for broken mapping
      • getTransitiveMappingElementName

        @CheckForNull
        private java.lang.String getTransitiveMappingElementName​(Element me,
                                                                 boolean forward)
        Checks if there is mapping from element and next transitive element in chain
        Parameters:
        me - model element
        forward - true for forward mapping, false for revese
        Returns:
        name of next transitive element in chain
      • countLinks

        private int countLinks​(Element me,
                               boolean forward,
                               boolean defaultMapping)
        Counts type maps for model element
        Parameters:
        me - model element
        forward - true for forward mappings, false for reverse
        defaultMapping - true for default mapping, false for normal
        Returns:
        number of mapping links
      • generateMapping

        private void generateMapping()
        Generates mapping map
      • isForwardDefault

        private boolean isForwardDefault​(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMap)
      • isReverseDefault

        private boolean isReverseDefault​(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMap)
      • createTypeTable

        private void createTypeTable()
        Creates type table array
      • getTransformationTypeTableElements

        private java.lang.String[][] getTransformationTypeTableElements()
        Returns transformation type table elements
        Returns:
        table elements
      • getTransformationTypeTableModel

        public javax.swing.table.TableModel getTransformationTypeTableModel()
        Returns transformation type table model
        Returns:
        transformation type table model
      • getDocumentation

        public java.lang.String getDocumentation()
        Returns type map documentation
        Returns:
        documentation
      • toString

        public java.lang.String toString()
        Returns type map name
        Overrides:
        toString in class java.lang.Object
        Returns:
        name
      • getTypeMapModelPackage

        @CheckForNull
        public Package getTypeMapModelPackage()
        Returns model package of type map
        Returns:
        model package of type map
      • isForwardMapping

        public boolean isForwardMapping()
        Is forward mapping set
        Returns:
        true for forward mapping, false for reverse
      • isBroken

        public boolean isBroken()
        Is type map broken
        Returns:
        true if broken
      • isForwardMappingBroken

        public boolean isForwardMappingBroken()
      • isReverseMappingBroken

        public boolean isReverseMappingBroken()
      • getErrorMessage

        public java.lang.String getErrorMessage()
        Returns error message for broken type map
        Returns:
        error message
      • setForwardMapping

        public void setForwardMapping​(boolean forward)
        Sets forward mapping
        Parameters:
        forward - true for forward mapping, false for reverse
      • getTypeMapFromElementParent

        @CheckForNull
        private com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap getTypeMapFromElementParent​(Element original)
        Returns type map of parent model element
        Parameters:
        original - model element
        Returns:
        model element for parent type map
      • getTypeMapForElement

        @CheckForNull
        private com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap getTypeMapForElement​(Element original)
        Returns type map for element
        Parameters:
        original - original element
        Returns:
        type map
      • getMappedType

        public com.nomagic.magicdraw.modeltransformations.TypeMapProfile.Type getMappedType​(Element original)
        Returns mapped type
        Parameters:
        original - original type, null for EmptySourceType/EmptyDestinationType
        Returns:
        mapped (default) type for original type. If there is no maping return original element. Return null for EmtyTypes.
      • isMappingValid

        public boolean isMappingValid​(Element original,
                                      Element mapped)
        Checks if type mapping is valid. This check should check generalizations/specifications.
        Parameters:
        original - original type
        mapped - mapped type
        Returns:
        true if mapped type conforms to original type
      • isChildOf

        private static boolean isChildOf​(Element child,
                                         Element parent)
        Checks generalization links if child element is child of parent element
        Parameters:
        child - child element
        parent - parent element
        Returns:
        true if child
      • getAllTypeMapsByKey

        @CheckForNull
        private java.util.List<com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap> getAllTypeMapsByKey​(Element key)
        Returns list of possible type maps for element
        Parameters:
        key - key element
        Returns:
        list of type maps, null for empty
      • getRelativeAnySourceType

        private Element getRelativeAnySourceType()
        Returns AnySourceType relative to mapping direction
        Returns:
        AnySourceType/AnyDestinationType
      • getRelativeEmptySourceType

        private Element getRelativeEmptySourceType()
        Returns EmptySourceType relative to mapping direction
        Returns:
        EmptySourceType/EmptyDestinationType
      • getRelativeEmptyDestinationType

        private Element getRelativeEmptyDestinationType()
        Returns EmptyDestinationType relative to mapping direction
        Returns:
        EmptySourceType/EmptyDestinationType
      • isAnyType

        private boolean isAnyType​(Element me)
        Checks if element is any type
        Parameters:
        me - element to check
        Returns:
        true if element is any type
      • isEmptyType

        private boolean isEmptyType​(Element me)
        Checks if element is empty type
        Parameters:
        me - element to check
        Returns:
        true if element is empty type