de.cau.cs.kieler.ktm.extensions

## Class TransformationTreeExtensions

- java.lang.Object
- - de.cau.cs.kieler.ktm.extensions.TransformationTreeExtensions

-     public class TransformationTreeExtensions
      extends java.lang.Object

  Extension for easier access and manipulation of TranformationTrees.
  Author:
    als

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TransformationTreeExtensions()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `de.cau.cs.kieler.ktm.transformationtree.ModelWrapper` | `addTransformationToTree(com.google.common.collect.ImmutableMultimap<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject> mapping, de.cau.cs.kieler.ktm.transformationtree.ModelWrapper modelNode, java.lang.String transformationID, org.eclipse.emf.ecore.EObject sourceModelRoot, org.eclipse.emf.ecore.EObject targetModelRoot, java.lang.String targetModelTypeID)` Appends transformation mapping information about source- and target-model to given tree.
    `java.util.List<de.cau.cs.kieler.ktm.transformationtree.EObjectWrapper>` | `children(de.cau.cs.kieler.ktm.transformationtree.EObjectWrapper element, de.cau.cs.kieler.ktm.transformationtree.ModelTransformation tranformation)` Returns all child objects in target model of given ModelTransformation associated with given element.
    `java.util.List<de.cau.cs.kieler.ktm.transformationtree.ModelWrapper>` | `children(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper model)` Returns all child models of this node in tree, where given model is transformed into.
    `de.cau.cs.kieler.ktm.transformationtree.ModelWrapper` | `findModelInTree(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper tree, org.eclipse.emf.ecore.EObject modelRoot, java.lang.String modelTypeID)` Searches given transformation tree for matching model-nodes for given model instance and typeID If tree is malformed and there are more than one fully matching model the first one is returned.
    `de.cau.cs.kieler.ktm.transformationtree.ModelWrapper` | `initializeTransformationTree(com.google.common.collect.ImmutableMultimap<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject> mapping, java.lang.String transformationID, org.eclipse.emf.ecore.EObject sourceModelRoot, java.lang.String sourceModelTypeID, org.eclipse.emf.ecore.EObject targetModelRoot, java.lang.String targetModelTypeID)` Creates a new transformation tree containing given mapping as first transformation.
    `de.cau.cs.kieler.ktm.transformationtree.ModelWrapper` | `makeTransient(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper modelNode)` Sets ModelWrapper's transient flag and removes references to concrete Objects in all elements of given model.
    `java.util.Map<de.cau.cs.kieler.ktm.transformationtree.EObjectWrapper,org.eclipse.emf.ecore.EObject>` | `objectMapping(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper modelNode, org.eclipse.emf.ecore.EObject model)` Returns a mapping from Elements of a model in tree to a model instance.
    `de.cau.cs.kieler.ktm.transformationtree.ModelWrapper` | `parent(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper model)` Returns source model-node in tree, where given model is transformed from.
    `java.util.List<de.cau.cs.kieler.ktm.transformationtree.EObjectWrapper>` | `parents(de.cau.cs.kieler.ktm.transformationtree.EObjectWrapper element, de.cau.cs.kieler.ktm.transformationtree.ModelTransformation tranformation)` Returns all parent objects in source model of given ModelTransformation associated with given element.
    `de.cau.cs.kieler.ktm.transformationtree.ModelWrapper` | `removeModelFromTree(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper modelNode)` Removes given model from tree including all succeeding Models and EObjectWrapper-Mappings Returns parent in tree Returns null tree does not contain given model or model has no root
    `com.google.common.collect.Multimap<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject>` | `resolveMapping(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper sourceModelNode, org.eclipse.emf.ecore.EObject sourceModel, de.cau.cs.kieler.ktm.transformationtree.ModelWrapper targetModelNode, org.eclipse.emf.ecore.EObject targetModel)` Resolves a mapping between all elements of source and target model instances by their nodes in transformation tree.
    `de.cau.cs.kieler.ktm.transformationtree.ModelWrapper` | `root(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper model)` Returns root model-node of tree.
    `java.util.List<de.cau.cs.kieler.ktm.transformationtree.ModelWrapper>` | `succeedingModels(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper model)` Returns all succeeding models for given model.
    `java.util.List<de.cau.cs.kieler.ktm.transformationtree.ModelTransformation>` | `succeedingTransformations(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper model)` Returns all succeeding ModelTransformations for given model-node.

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TransformationTreeExtensions

          public TransformationTreeExtensions()

  - ### Method Detail

    - #### addTransformationToTree

          public de.cau.cs.kieler.ktm.transformationtree.ModelWrapper addTransformationToTree(com.google.common.collect.ImmutableMultimap<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject> mapping,
                                                                                     de.cau.cs.kieler.ktm.transformationtree.ModelWrapper modelNode,
                                                                                     java.lang.String transformationID,
                                                                                     org.eclipse.emf.ecore.EObject sourceModelRoot,
                                                                                     org.eclipse.emf.ecore.EObject targetModelRoot,
                                                                                     java.lang.String targetModelTypeID)

      Appends transformation mapping information about source- and target-model to given tree.

      If this is the first transformation use `initializeTransformationTree`.

      New transformation will be appended to modelNode representing source model.

      Transformations CANNOT appended to transient models!

      Completeness of mapping will not be checked. Only objects from mapping are created as Elements of Models in TransformationTree. If previous transformation mapping of source model was incomplete and current mapping contains information about missing objects in source model additional Elements of source model model in transformation tree will be created. If mapping is incomplete (model contains unmapped elements) later resolved mapping my be incomplete. If mapping contains entries for objects not contained in given model instances they will omitted.

      Returns new leaf in tree as ModelWrapper representing target model.

      Return null if sourceModel is not modelNode or model is transient.

      Parameters:
        `mapping` - object mapping data
        `modelNode` - node in tree to append transformation, representing source model
        `transformationID` - a unique identifier for initial transformation
        `sourceModelRoot` - root element of source model instance
        `targetModelRoot` - root element of target model instance
        `targetModelTypeID` - unique identifier for this kind of model and its applied transformation
      Returns:
        newly created leaf in tree or null
      Throws:
        `java.lang.NullPointerException` - if any argument is null.

    - #### children

          public java.util.List<de.cau.cs.kieler.ktm.transformationtree.EObjectWrapper> children(de.cau.cs.kieler.ktm.transformationtree.EObjectWrapper element,
                                                                                        de.cau.cs.kieler.ktm.transformationtree.ModelTransformation tranformation)

      Returns all child objects in target model of given ModelTransformation associated with given element.

      If source model of given ModelTransformation does not contain given element returned list is empty.

      Parameters:
        `element` - element of a model in transformation tree.
        `tranformation` - model transformation to resolve parent relation.
      Returns:
        List of child elements.

    - #### children

          public java.util.List<de.cau.cs.kieler.ktm.transformationtree.ModelWrapper> children(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper model)

      Returns all child models of this node in tree, where given model is transformed into.
      Parameters:
        `model` - model in tree
      Returns:
        child models

    - #### findModelInTree

          public de.cau.cs.kieler.ktm.transformationtree.ModelWrapper findModelInTree(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper tree,
                                                                             org.eclipse.emf.ecore.EObject modelRoot,
                                                                             java.lang.String modelTypeID)

      Searches given transformation tree for matching model-nodes for given model instance and typeID

      If tree is malformed and there are more than one fully matching model the first one is returned.

      Returns null if no model is found or can not be identified because it is transient.

      Parameters:
        `tree` - root model of tree
        `modelRoot` - root element of a model instance to search for.
        `modelTypeID` - unique identifier for searched kind of models.
      Returns:
        Pair with matching modelNode in tree and map of model matching or null.

    - #### initializeTransformationTree

          public de.cau.cs.kieler.ktm.transformationtree.ModelWrapper initializeTransformationTree(com.google.common.collect.ImmutableMultimap<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject> mapping,
                                                                                          java.lang.String transformationID,
                                                                                          org.eclipse.emf.ecore.EObject sourceModelRoot,
                                                                                          java.lang.String sourceModelTypeID,
                                                                                          org.eclipse.emf.ecore.EObject targetModelRoot,
                                                                                          java.lang.String targetModelTypeID)

      Creates a new transformation tree containing given mapping as first transformation.

      Completeness of mapping will not be checked. Only objects from mapping are created as Elements of Models in TransformationTree. If mapping is incomplete (model contains unmapped elements) later resolved mapping my be incomplete. If mapping contains entries for objects not contained in given model instances they will omitted.

      Returns leaf of new tree as ModelWrapper representing target model.

      Parameters:
        `mapping` - object mapping data
        `transformationID` - a unique identifier for initial transformation
        `sourceModelRoot` - root element of source model instance
        `sourceModelTypeID` - unique identifier for this kind of model
        `targetModelRoot` - root element of target model instance
        `targetModelTypeID` - unique identifier for this kind of model and its applied transformation
      Returns:
        leaf of new tree
      Throws:
        `java.lang.NullPointerException` - if any argument is null.

    - #### makeTransient

          public de.cau.cs.kieler.ktm.transformationtree.ModelWrapper makeTransient(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper modelNode)

      Sets ModelWrapper's transient flag and removes references to concrete Objects in all elements of given model.

      Transient model can't be source model of any new transformation and has no association to it's concrete model.

      This will improve scalability because transient models will not be kept in memory or persistent.

      Can't be reverted.

      Parameters:
        `modelNode` - model to convert
      Returns:
        modelNode itself

    - #### objectMapping

          public java.util.Map<de.cau.cs.kieler.ktm.transformationtree.EObjectWrapper,org.eclipse.emf.ecore.EObject> objectMapping(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper modelNode,
                                                                                                                          org.eclipse.emf.ecore.EObject model)

      Returns a mapping from Elements of a model in tree to a model instance.

      ReferencedObjects of Elements in ModelWrapper in transformation tree are only copies of their origin instances. Returned mapping provides relations between Elements and their represented objects in given model instance.

      Return null if any argument is null or model and model of modelNode does not match. If transformation tree was created on incomplete mappings returned mapping may be incomplete.

      Parameters:
        `modelNode` - node in tree which models elements shall be mapped
        `model` - root element of a model instance to map to

    - #### parent

          public de.cau.cs.kieler.ktm.transformationtree.ModelWrapper parent(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper model)

      Returns source model-node in tree, where given model is transformed from.

      If model is root-node, returns null.

      Parameters:
        `model` - model in tree
      Returns:
        parent model or null

    - #### parents

          public java.util.List<de.cau.cs.kieler.ktm.transformationtree.EObjectWrapper> parents(de.cau.cs.kieler.ktm.transformationtree.EObjectWrapper element,
                                                                                       de.cau.cs.kieler.ktm.transformationtree.ModelTransformation tranformation)

      Returns all parent objects in source model of given ModelTransformation associated with given element.

      If target model of given ModelTransformation does not contain given element returned list is empty.

      Parameters:
        `element` - element of a model in transformation tree.
        `tranformation` - model transformation to resolve parent relation.
      Returns:
        List of parent elements.

    - #### removeModelFromTree

          public de.cau.cs.kieler.ktm.transformationtree.ModelWrapper removeModelFromTree(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper modelNode)

      Removes given model from tree including all succeeding Models and EObjectWrapper-Mappings

      Returns parent in tree

      Returns null tree does not contain given model or model has no root

      Parameters:
        `modelNode` - node in tree to remove
      Returns:
        parent node or null

    - #### resolveMapping

          public com.google.common.collect.Multimap<org.eclipse.emf.ecore.EObject,org.eclipse.emf.ecore.EObject> resolveMapping(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper sourceModelNode,
                                                                                                                       org.eclipse.emf.ecore.EObject sourceModel,
                                                                                                                       de.cau.cs.kieler.ktm.transformationtree.ModelWrapper targetModelNode,
                                                                                                                       org.eclipse.emf.ecore.EObject targetModel)

      Resolves a mapping between all elements of source and target model instances by their nodes in transformation tree.

      Returns a multi-mapping from elements of source model to target model elements. Mapping is created by resolving all transformations on a path from source to target. Source and target can be arbitrary model in tree, so path can be bottom up, top down or leaf to leaf.

      Returns null if source or target model do not match to their models in tree or if they are not in the same tree. If transformation tree was created on incomplete mappings returned mapping may be incomplete.

      Parameters:
        `sourceModelNode` - model in transformation tree representing sourceModel model
        `sourceModel` - root element of a source model instance
        `targetModelNode` - model in transformation tree representing targetModel model
        `targetModel` - root element of a target model instance
      Returns:
        multi-mapping from source model objects to target model objects or null

    - #### root

          public de.cau.cs.kieler.ktm.transformationtree.ModelWrapper root(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper model)

      Returns root model-node of tree.
      Parameters:
        `model` - any model-node in tree
      Returns:
        root model-node.

    - #### succeedingModels

          public java.util.List<de.cau.cs.kieler.ktm.transformationtree.ModelWrapper> succeedingModels(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper model)

      Returns all succeeding models for given model.

      BFS will be performed on sub tree.

      Parameters:
        `model` - model in tree
      Returns:
        list of succeeding models.

    - #### succeedingTransformations

          public java.util.List<de.cau.cs.kieler.ktm.transformationtree.ModelTransformation> succeedingTransformations(de.cau.cs.kieler.ktm.transformationtree.ModelWrapper model)

      Returns all succeeding ModelTransformations for given model-node.

      BFS will be performed on sub tree.

      Parameters:
        `model` - model in tree
      Returns:
        list of succeeding ModelTransformation.