Class AnyToAnyModelTransformation
java.lang.Object
com.nomagic.magicdraw.modeltransformations.impl.any_to_any.AnyToAnyModelTransformation
- All Implemented Interfaces:
ModelTransformation
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidMethod invoked after all custom transformations.protected voidchangeDiagramType(DiagramPresentationElement dpe, DiagramType createDiagramType) collectInnerElements(Collection<Element> objects, boolean update) protected ElementcopyElementInto(Element source, Element parent) Copies and pastes given element.protected com.nomagic.magicdraw.commands.MacroCommandcopyElements(List<Element> objects) Copies elementsprotected com.nomagic.magicdraw.modeltransformations.impl.any_to_any.ElementUpdaterprotected voidcustomTransformationForElement(Element original, Collection<Element> mapped) Custom transformations should override this method to add additional functionality.protected voidgetMappedElements(Element original) Returns transformed elements for given original element.protected Map<BaseElement,BaseElement> protected Collection<Element>getOriginalElement(Element mapped) Returns original elements which are mapped to given mapped element.<T extends Element>
Collection<T>getOriginalElement(Element mapped, Class<T> type) Returns original elements which are mapped to given mapped element.protected Collection<Element>protected ProgressStatusprotected Collection<Element><T extends Element>
TReturns transformed element that's transformation source is 'original' element and it's type is specified in 'type'protected com.nomagic.magicdraw.modeltransformations.impl.any_to_any.TypeMappervoidinvokeCustomTransformation(Element original) Invokes custom transformation for element.voidinvokeCustomTransformation(Collection<? extends Element> original) Invokes custom transformation for collection.protected booleanisAlreadyVisited(Element element) protected booleanisElementCopied(Element element) protected booleanisMappableElement(Element element) protected booleanisSkipElement(Element element) Check if element should be skippedbooleanbooleanprotected voidmarkAsAlreadyVisited(Element element) protected voidprocessMappedElements(Element original, Collection<Element> mappedElements, Collection<Element> originalMappedElements) protected voidprocessMappingResult(Element original, Collection<Element> mappedElements, Collection<Element> originalMappedElements) voidSets task for transformation.protected voidsetTransformationMapValue(Element original, Collection<Element> mappedElements) protected voidsortOriginalElements(List<Element> objects) Sorts elements before invoking custom transformationtransform(Collection selectedObjects, ModelTransformationInfo info, TypeMapProfile typeMap, PropertyManager propertyManager, Package destination) Performs transformation on specific set of objectsprotected com.nomagic.magicdraw.commands.MacroCommandUpdates diagram with newly added elements during transformation update phase.voidupdateTransform(Package transformationPackage, TypeMapProfile typeMap, PropertyManager propertyManager, boolean syncDestination) Updates transformation on specific set of objects
-
Field Details
-
mTransformationMap
-
-
Constructor Details
-
AnyToAnyModelTransformation
public AnyToAnyModelTransformation()
-
-
Method Details
-
createDefaultDoNotCopyTypes
-
createDefaultDoNotReconnectTypes
-
createDefaultDoNotSettableProperties
-
createDefaultMappedTypes
-
transform
@CheckForNull public Package transform(@CheckForNull Collection selectedObjects, @CheckForNull ModelTransformationInfo info, TypeMapProfile typeMap, PropertyManager propertyManager, Package destination) throws ReadOnlyElementException Description copied from interface:ModelTransformationPerforms transformation on specific set of objects- Specified by:
transformin interfaceModelTransformation- Parameters:
selectedObjects- set of objects to transforminfo- model transformation infotypeMap- type map profile to use for transformation, null for nonepropertyManager- transformation propertiesdestination- destination model packages, null for transformation in place- Returns:
- transformation model package (where transformation links are stored)
- Throws:
ReadOnlyElementException- in case target model elements are read-only
-
afterTransformation
Method invoked after all custom transformations.- Throws:
ReadOnlyElementException- in case of error
-
customTransformations
protected void customTransformations() -
isSkipElement
Check if element should be skipped- Parameters:
element- element- Returns:
- true if element can not be processed by custom transformation
-
invokeCustomTransformation
Invokes custom transformation for collection.- Parameters:
original- original elements- See Also:
-
invokeCustomTransformation
Invokes custom transformation for element. If custom transformation was already invoked, this method does nothing.- Parameters:
original- original element for which custom transformation is invoked.
-
processMappingResult
protected void processMappingResult(Element original, Collection<Element> mappedElements, Collection<Element> originalMappedElements) -
processMappedElements
protected void processMappedElements(Element original, Collection<Element> mappedElements, Collection<Element> originalMappedElements) -
setTransformationMapValue
-
customTransformationForElement
protected void customTransformationForElement(Element original, Collection<Element> mapped) throws ReadOnlyElementException Custom transformations should override this method to add additional functionality.- Parameters:
original- original element.mapped- collection of current mapped elements. Custom transformation can modify this collection. In case custom transformation needs to remove current mapping, it should remove element from this collection. In case it needs to map more elements it should add new elements to this collection.- Throws:
ReadOnlyElementException- in case of error
-
getMappedElements
Returns transformed elements for given original element.- Parameters:
original- original element.- Returns:
- mapped elements if original was mapped; empty collection if original was mapped to nothing;
-
updateTransform
public void updateTransform(Package transformationPackage, TypeMapProfile typeMap, PropertyManager propertyManager, boolean syncDestination) throws ReadOnlyElementException Description copied from interface:ModelTransformationUpdates transformation on specific set of objects- Specified by:
updateTransformin interfaceModelTransformation- Parameters:
transformationPackage- package containing transformation linkstypeMap- type map profile to use for transformation, null for nonepropertyManager- transformation propertiessyncDestination- true for destination overwrite- Throws:
ReadOnlyElementException- in case target model elements are read-only
-
getOriginalElements
- Returns:
- all original elements.
-
getOriginalElement
Returns original elements which are mapped to given mapped element.- Parameters:
mapped- original elements that are mapped to this element will be returnedtype- only this type of elements will be returned.- Returns:
- collection of original elements. If there is no original elements returns empty list.
-
getOriginalElement
Returns original elements which are mapped to given mapped element.- Parameters:
mapped- mapped element- Returns:
- collection of original elements. If there is no original elements returns empty list.
-
copyElements
Copies elements- Parameters:
objects- objects- Returns:
- command for copying
-
createElementUpdater
protected com.nomagic.magicdraw.modeltransformations.impl.any_to_any.ElementUpdater createElementUpdater()- Returns:
- element updater.
-
getOneToOneMap
- Returns:
- map where one key is mapped only to one element
-
getTypeMapper
protected com.nomagic.magicdraw.modeltransformations.impl.any_to_any.TypeMapper getTypeMapper()- Returns:
- type mapper.
-
getTarget
Returns transformed element that's transformation source is 'original' element and it's type is specified in 'type'- Parameters:
original- source model element.type- type of returned element.- Returns:
- transformed element. If no element found - null is returned.
-
updateDiagrams
protected com.nomagic.magicdraw.commands.MacroCommand updateDiagrams()Updates diagram with newly added elements during transformation update phase.- Returns:
- update macro command
-
sortOriginalElements
Sorts elements before invoking custom transformation- Parameters:
objects- objects
-
collectInnerElements
-
isMappableElement
- Parameters:
element- element to check.- Returns:
- true if transformation can be applied for this element.
-
getTransformationsPackage
- Returns:
- package where transformation information is stored
-
isTransformationInPlace
public boolean isTransformationInPlace()- Returns:
- true if transformation is in place (not copying)
-
getPropertyManager
- Returns:
- property manager for additional transformation properties
-
copyElementInto
Copies and pastes given element.- Parameters:
source- element to copy.parent- parent where place copied element.- Returns:
- copied element.
-
setTask
Description copied from interface:ModelTransformationSets task for transformation. Transformation can use Task for accesing progress status and etc.- Specified by:
setTaskin interfaceModelTransformation- Parameters:
task- transformation task
-
getProgressStatus
-
isElementCopied
-
isTypeMapSet
public boolean isTypeMapSet() -
getNotSettableProperties
-
changeDiagramType
-
getRemovedByCustomTransformation
-
markAsAlreadyVisited
-
isAlreadyVisited
-