Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » How to add a new UML Property as subset of an UML Class in EML
How to add a new UML Property as subset of an UML Class in EML [message #1731705] Mon, 09 May 2016 12:20 Go to next message
Mohammadreza Sharbaf is currently offline Mohammadreza SharbafFriend
Messages: 17
Registered: February 2016
Junior Member

Hi,

I would like to merge two UML Class Diagrams. For this purpose first I compare two models using ECL and it works correctly. After that I merge them together by following EML code:


pre{
	for (p in Target!Package) { 
		delete p ; 
	}
	var Pack  ;
}

rule MergePackage
	merge l : Left!Package with r : Right!Package into t : Target!Package {
	
	t.name = l.name + " and " + r.name;
	Pack := t ; 	
}

rule MergeClass
	merge l : Left!Class with r : Right!Class  into t : Target!Class {
	
	t.name = l.name;
	t.isAbstract = l.isAbstract;
	
	Pack.packagedElement.add(t);
}

rule MergeProperty
	merge l : Left!Property with r : Right!Property into t : Target!Property{
	
	t.name = l.name ; 
}


By using ".packagedElement.add()" I can add new Class to my package, But I don't know how must add new Property to my Class.

This figure shows the result obtained :
https://i.imgsafe.org/c251d6a.png

and this figure shows the expected result:
https://i.imgsafe.org/ee8791b.png

I've attached a MinimalExample for you. Can you help me?

Best Regards,
Mohammadreza
Re: How to add a new UML Property as subset of an UML Class in EML [message #1731934 is a reply to message #1731705] Wed, 11 May 2016 08:04 Go to previous messageGo to next message
Antonio Garcia-Dominguez is currently offline Antonio Garcia-DominguezFriend
Messages: 470
Registered: January 2010
Senior Member
Hi Mohammadreza,

You can use eContainer to access the Class of the left Property, for instance, and then use equivalent() or equivalents() to obtain the target class that was produced by MergeClass. It's easy from there:

rule MergeProperty
	merge l : Left!Property with r : Right!Property into t : Target!Property{
	
	t.name = l.name ;
	l.eContainer.equivalent().ownedAttributes.add(t); 	 
}


Kind regards,
Antonio

[Updated on: Wed, 11 May 2016 08:05]

Report message to a moderator

Re: How to add a new UML Property as subset of an UML Class in EML [message #1731959 is a reply to message #1731934] Wed, 11 May 2016 09:59 Go to previous message
Mohammadreza Sharbaf is currently offline Mohammadreza SharbafFriend
Messages: 17
Registered: February 2016
Junior Member

Hi Antonio,

Thank you very much for your solution,

Best regards,
Mohammadreza
Previous Topic:Query in ETL -Accessing the Target Node Parent?
Next Topic:EOL: How to create a stereotype in an existing UML profile
Goto Forum:
  


Current Time: Wed Jan 17 18:27:46 GMT 2018

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

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