Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Issues with Merging 2 Ecore models
Issues with Merging 2 Ecore models [message #1728328] Sat, 02 April 2016 04:13 Go to next message
dy A is currently offline dy AFriend
Messages: 8
Registered: August 2014
Junior Member
Hi,

I am working on merging two ecore models by following ATL use-case in the zoo at http://www.eclipse.org/m2m/atl/atlTransformations/#UMLMergeModel. I selected MOF as the meta metamodel

I got stuck at the point I realized that UML features differ from Ecore features. For example a UML class attribute has "owner" as one of its features, I tried using the feature "eContainingClass" for Ecore class attribute but can't seem to get past this.

Can you show me how I can successfully achieve merging 2 ecore models?

Thank you.

[Updated on: Sat, 02 April 2016 08:58]

Report message to a moderator

Re: Issues with Merging 2 Ecore models [message #1728363 is a reply to message #1728328] Sun, 03 April 2016 16:56 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

That depends on how you want it merged; just add classes from the other model, or also merge attributes/operations of classes with the same name, etc.

Also, in EMF it is possible to reference other models, so you may want to link your ecore models instead. The reason I developed UMLMergeModel in the first place, was because UML 1.4 / MDR did not support referencing of other models. In order to reference elements in the other model, the models had to be merged first.


Cheers,
Dennis
Re: Issues with Merging 2 Ecore models [message #1728417 is a reply to message #1728363] Mon, 04 April 2016 09:46 Go to previous messageGo to next message
dy A is currently offline dy AFriend
Messages: 8
Registered: August 2014
Junior Member
I have a class with the same name in two packages and I want to merge these classes. These classes also have references to other classes within the same package

So far I have successfully copied all the classes into one package which leaves me having duplicate classes.

Here is the structure of my packages

Package 1
Class A
Class B -> Class A
Class C

Package 2
Class B -> Class D
Class D


This is the structure I want to achieve

Package Merged
Class A
Class B-> Class A, Class D
Class C
Class D

Thank you.
Re: Issues with Merging 2 Ecore models [message #1728533 is a reply to message #1728417] Tue, 05 April 2016 08:59 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

You could write something like this:

create MERGED : ECORE from LEFT : ECORE, RIGHT : ECORE;

helper def : eClassifierByName : Map(String, ECORE!EClassifier) =
  ECORE!EClassifier.allInstances()->iterate(e; acc : Map(String, ECORE!EClassifier) = Map{} |
    if (acc.get(e.name).oclIsUndefined()) then
      acc.including(e.name, e)
    else
      acc
    endif
  );

rule EPackage {
  from
    s : ECORE!EPackage in LEFT
  to
    t : ECORE!EPackage (
      ...
      eClassifiers <- ECORE!EClassifier.allInstances()->select(c | thisModule.eClassifierByName.get(c.name) = c)
    )
}

rule EClass {
  from
    s : ECORE!EClass (thisModule.eClassifierByName.get(s.name) = s)
  using {
    -- TODO find other EClasses with the same name to merge superclasses, etc.
  }
  to
    t : ECORE!EClass (
      ...
    )
}

-- TODO other metaclasses


See also http://git.eclipse.org/c/mmt/org.eclipse.atl.git/tree/tests/org.eclipse.m2m.atl.emftvm.tests/test-data/EcoreCopy/EcoreCopy.atl as a reference. https://wiki.eclipse.org/ATL/Design_Patterns#Object_indexing will give you some design patterns for ATL.


Cheers,
Dennis
Re: Issues with Merging 2 Ecore models [message #1728580 is a reply to message #1728533] Tue, 05 April 2016 14:55 Go to previous message
dy A is currently offline dy AFriend
Messages: 8
Registered: August 2014
Junior Member
It worked! Thank you so much, Dennis.

I however had issues with dangling attributes, references and operations from RIGHT model. I fixed it this way i.e., using your idea from TODO comment " find other EClasses with the same name to merge superclasses, etc.";

rule EClass {
from
s : Ecore!EClass (thisModule.eClassifierByName.get(s.name) = s)
to
t : Ecore!EClass (
name <- s.name,
....
eOperations <- s.eOperations->union(Ecore!EOperation.allInstancesFrom('RIGHT')->select(e | e.refImmediateComposite().name = s.name )),
eStructuralFeatures <- s.eStructuralFeatures->union(Ecore!EStructuralFeature.allInstancesFrom('RIGHT')->select(e | e.refImmediateComposite().name = s.name ))
)
}


Previous Topic:Cross-referencing UML profiles in ATL
Next Topic:Issue with an ATL transformation
Goto Forum:
  


Current Time: Thu Apr 25 11:00:55 GMT 2024

Powered by FUDForum. Page generated in 0.03406 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top