Skip to main content



      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 15:43 Go to next message
Eclipse UserFriend
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 08:18 Go to previous message
Eclipse UserFriend
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.
Previous Topic:2 models to model transformation
Next Topic:Can't use lazy rules with EMFTVM in Refining mode
Goto Forum:
  


Current Time: Sat Jul 05 11:49:01 EDT 2025

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

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

Back to the top