Class TypeMapProfile
- java.lang.Object
-
- com.nomagic.magicdraw.modeltransformations.TypeMapProfile
-
@OpenApi public class TypeMapProfile extends java.lang.Object
TypeMapProfile - class for type mapping.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
com.nomagic.magicdraw.modeltransformations.TypeMapProfile.Type
private class
com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap
Private class to store type map dependency linksstatic class
com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeModifier
-
Field Summary
Fields Modifier and Type Field Description private Element
anyDestinationType
private Element
anySourceType
private java.lang.String
brokenString
private java.util.Map<Element,com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap>
defaultMappingIndex
static com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeModifier
EMPTY_TYPE_MODIFIER
private Element
emptyDestinationType
private Element
emptySourceType
private java.util.HashMap<Element,com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap>
forwardMap
private java.lang.String[][]
forwardTransformationTable
private boolean
isBroken
private boolean
isForward
private boolean
isForwardBroken
private boolean
isReversBroken
private java.util.Set<com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap>
mappings
private Package
modelPackage
Profile packageprivate java.util.HashMap<Element,com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap>
reverseMap
private java.lang.String[][]
reverseTransformationTable
-
Constructor Summary
Constructors Constructor Description TypeMapProfile(Package mp)
Constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addTypeMap(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMapToAdd, java.util.Collection<com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap> mappings)
private static void
addTypeMapPackages(Element root, java.util.List<Package> importedPackages, java.util.Set<Package> index)
private void
checkForBrokenMapping()
Checks for broken mappingprivate int
countLinks(Element me, boolean forward, boolean defaultMapping)
Counts type maps for model elementprivate void
createTypeTable()
Creates type table arrayprivate void
fillDefaultMappingRulesIndex(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMapToAdd)
private void
generateMapping()
Generates mapping mapprivate java.util.List<com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap>
getAllTypeMapsByKey(Element key)
Returns list of possible type maps for elementprivate int
getDirection(Dependency dependency)
Returns default mapping directionjava.lang.String
getDocumentation()
Returns type map documentationjava.lang.String
getErrorMessage()
Returns error message for broken type mapprivate static java.util.List<Package>
getImportedTypeMapPackages(Package root)
com.nomagic.magicdraw.modeltransformations.TypeMapProfile.Type
getMappedType(Element original)
Returns mapped typeprivate Element
getRelativeAnySourceType()
Returns AnySourceType relative to mapping directionprivate Element
getRelativeEmptyDestinationType()
Returns EmptyDestinationType relative to mapping directionprivate Element
getRelativeEmptySourceType()
Returns EmptySourceType relative to mapping directionprivate java.lang.String[][]
getTransformationTypeTableElements()
Returns transformation type table elementsjavax.swing.table.TableModel
getTransformationTypeTableModel()
Returns transformation type table modelprivate java.lang.String
getTransitiveMappingElementName(Element me, boolean forward)
Checks if there is mapping from element and next transitive element in chainprivate com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap
getTypeMapForElement(Element original)
Returns type map for elementprivate com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap
getTypeMapFromElementParent(Element original)
Returns type map of parent model elementPackage
getTypeMapModelPackage()
Returns model package of type mapprivate boolean
isAnyType(Element me)
Checks if element is any typeboolean
isBroken()
Is type map brokenprivate static boolean
isChildOf(Element child, Element parent)
Checks generalization links if child element is child of parent elementboolean
isDefault(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMap)
private static boolean
isDependencyDefaultMapping(Element dependency)
private boolean
isEmptyType(Element me)
Checks if element is empty typeprivate boolean
isForwardDefault(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMap)
boolean
isForwardMapping()
Is forward mapping setboolean
isForwardMappingBroken()
boolean
isMappingValid(Element original, Element mapped)
Checks if type mapping is valid.private boolean
isReverseDefault(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMap)
boolean
isReverseMappingBroken()
private void
parseRelationships(Element modelPackage)
Parses type map relationships and generates mapping listprivate void
setDefaultForwardMappingRule(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMapToAdd)
private void
setDefaultReverseMappingRule(com.nomagic.magicdraw.modeltransformations.TypeMapProfile.TypeMap typeMapToAdd)
void
setForwardMapping(boolean forward)
Sets forward mappingprivate void
setProfileElements()
Sets profile elements from Model Transformation profilejava.lang.String
toString()
Returns type map name
-
-
-
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 elementforward
- 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 elementforward
- true for forward mappings, false for reversedefaultMapping
- 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 classjava.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 typemapped
- 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 elementparent
- 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
-
-