Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » UML primitive types(Set a type to a UML primitive type during a transformation)
UML primitive types [message #1736120] Sun, 26 June 2016 19:43 Go to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 40
Registered: November 2012
Member
Hello,

I have an ATL transformation which takes an input model. The input model is an instance of a previously created UML profile called MM1. The transformation transforms the input model to an output model which it is an instance of another UML profile called MM2.
During the transformation, for a transformed class in the output model, I want to create an operation. For the created operation, I need to specify the parameters and their types. I was unable to set the type to Integer. Does any one know how I can set the type to a UML primitive type when the model is an instance of a profile?

Thank you very much.
Re: UML primitive types [message #1737203 is a reply to message #1736120] Wed, 06 July 2016 12:18 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 351
Registered: September 2012
Location: Belgium
Senior Member

You can refer to the UMLPrimitiveTypes library model for that: pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml

Here's some example code (using EMFTVM) that adds one extra property of type Integer to each Stereotype:
-- @atlcompiler emftvm
-- @nsURI UML=http://www.eclipse.org/uml2/5.0.0/UML
module AddStereotypeAttribute;

create MM2 : UML from MM1 : UML, PT : UML;

helper def : IntegerType : UML!PrimitiveType =
	UML!PrimitiveType.allInstancesFrom('PT')->any(p | p.name = 'Integer');

rule Profile {
	from
		s : UML!Profile
	to
		t : UML!Profile (
			name <- s.name,
			packageImport <- s.packageImport,
			packagedElement <- s.packagedElement
		)
}

rule PackageImport {
	from
		s : UML!PackageImport
	to
		t : UML!PackageImport (
			importedPackage <- s.importedPackage
		)
}

rule Stereotype {
	from
		s : UML!Stereotype
	to
		t : UML!Stereotype (
			name <- s.name,
			ownedAttribute <- s.ownedAttribute->including(p)
		),
		p : UML!Property (
			name <- 'Bonus',
			type <- thisModule.IntegerType
		)
}

rule Property {
	from
		s : UML!Property
	to
		t : UML!Property (
			name <- s.name,
        	type <- s.type,
        	upperValue <- s.upperValue,
        	lowerValue <- s.lowerValue
		)
}


I've attached an example Eclipse project that you can actually run.


Cheers,
Dennis
Previous Topic:2 models to model transformation
Next Topic:Can't use lazy rules with EMFTVM in Refining mode
Goto Forum:
  


Current Time: Tue Nov 21 08:31:50 GMT 2017

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

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