UML Import Model Mapper

From Eclipsepedia

Revision as of 07:15, 9 May 2008 by (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

< To: Tigerstripe Extension Points

  • Full name : org.eclipse.tigerstripe.workbench.ui.UML2Import.umlImportModelMapper

Purpose : During a UML2 import, the Model that is being imported can be "mapped" to Tigerstripe artifacts based on user defined rules. There may be stereotypes in the model that indicate that a Class should be imported as a Datatype rather than an Entity for example. This is most useful for UML Classes which can potentially be mapped to many types of Tigerstripe Artifact.

The String returned should be the class name of a Tigerstripe Artifact.

  • Example :

This example does a very basic mapping, and is a good starting point for any Mapper.

 public Map<EObject, String> getMapping(Model model) {
   Map<EObject, String> classMap = new HashMap<EObject, String>();
   TreeIterator t = model.eAllContents();
   t = model.eAllContents();
   while (t.hasNext()) {
       EObject eObject = (EObject);
       if (eObject instanceof AssociationClass) {
           classMap.put( eObject, IAssociationClassArtifact.class.getName());
       } else if (eObject instanceof Association) {
           classMap.put( eObject, IAssociationArtifact.class.getName());
       } else if (eObject instanceof Enumeration) {
           classMap.put( eObject, IEnumArtifact.class.getName());
       } else if (eObject instanceof Interface) {
           classMap.put( eObject,  ISessionArtifact.class.getName());
       } else if (eObject instanceof Class) {
           // We cannot determine "Class" types - could be Entity, Datatype, Exception etc
           classMap.put( eObject, "");
       if (eObject instanceof Classifier) {
       Classifier element = (Classifier) eObject;
           for (Object depO : element.getClientDependencies()) {
               if (depO instanceof Dependency && !(depO instanceof InterfaceRealization)) {
                   Dependency dep = (Dependency) depO;
                   classMap.put( dep, IDependencyArtifact.class.getName());
   return classMap;