Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » ATL API(Where can I download the ATL API?)
ATL API [message #1647801] Tue, 03 March 2015 16:14 Go to next message
Chung-Ling Lin is currently offline Chung-Ling LinFriend
Messages: 39
Registered: December 2011
Member
Dear All,

I am trying to write a java program to generate the ATL rules. When I open the ATL perspective to read a ATL program, the outline shows the structure of the ATL rules and the statements within a rule.

Since these information is available in this outline window, I assume that I can use the same API to create the ATL rules. But I can't find such information online.

Is there anyone knows where can I find the ATL API so I can import it to my java program to generate the ATL rules.

Thank you very much for your help.
Re: ATL API [message #1650332 is a reply to message #1647801] Wed, 04 March 2015 19:43 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

You can use the ATLParser class to load/save .atl files from/to EMF models. It's this EMF model that you see in the outline view. The EMF model conforms to the ATL metamodel, but it is a dynamic EMF model; as such, there is no generated API for easy interaction with Java, just DynamicEObjectImpl instances.

Cheers,
Dennis
Re: ATL API [message #1652076 is a reply to message #1650332] Thu, 05 March 2015 17:32 Go to previous messageGo to next message
Pinank Dagli is currently offline Pinank DagliFriend
Messages: 6
Registered: February 2015
Junior Member
Hey Dennis,

Is there any API of ATl that i can import in my java program, to generate ATL code. Like for example i want to create a rule, can i just instantiate MatchedRule class in ATL or LazyMatchedRule class in my java program.

Also how can I download OCL Expression API index.php/fa/21082/0/ and OCl primitive types API index.php/fa/21083/0/

I want Implementation of these classes, where can i find it.

Thank You
Re: ATL API [message #1653552 is a reply to message #1652076] Fri, 06 March 2015 09:17 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

Here's a bit of example Java code to generate an ATL file by metamodel structure, just to give you an idea:

ModelFactory mf = AtlParser.getDefault().getModelFactory();
IReferenceModel atlMM = AtlParser.getDefault().getAtlMetamodel();
IModel atlM = mf.newModel(atlMM);

EObject module = (EObject) atlM.newElement(atlMM.getMetaElementByName("Module"));
module.eSet(module.eClass().getEStructuralFeature("name"), "testmodule");
EObject rule = (EObject) atlM.newElement(atlMM.getMetaElementByName("MatchedRule"));
rule.eSet(rule.eClass().getEStructuralFeature("name"), "Test");
EList<EObject> moduleElements = (EList<EObject>) module.eGet(module.eClass().getEStructuralFeature("elements"));
moduleElements.add(rule);

FileOutputStream fos = new FileOutputStream("testmodule.atl");
try {
	AtlParser.getDefault().extract(atlM, fos, Collections.emptyMap());
} finally {
	if (fos != null) {
		fos.close();
	}
}


it will generate the following ATL code:

module testmodule;
create from;

rule Test {
 
}


It is generally much easier to use a template engine to generate ATL source code.


Cheers,
Dennis
Re: ATL API [message #1666692 is a reply to message #1653552] Wed, 11 March 2015 20:21 Go to previous messageGo to next message
Chung-Ling Lin is currently offline Chung-Ling LinFriend
Messages: 39
Registered: December 2011
Member
Thank you for your information. I am trying to create the InPattern section of a matched rule as below:
rule rule1{
	from
		sys:Source!System 
}


I check the structure of this matched rule, the "sys:Source!System" is a SimpleInPatternElement and Source!System is a OclModelElement within the SimpleInPatternElement. But when I read the ATL Metamodels from the "The ATL to Problem ATL transformation" document as below, I can't find the association between the SimpleInPatternElement and OclModelElement.

https://www.eclipse.org/atl/atlTransformations/ATL2Problem/ExampleATL2Problem%5bv00.01%5d.pdf

I am not sure if I found the correct document that matched to the API. Would you please show me where can I find such information? Thank you for your help
Re: ATL API [message #1668015 is a reply to message #1666692] Thu, 12 March 2015 09:37 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You should write manually your example result, transform it into xmi and open it to inspect how it's built and then use this information to code your transformation.
Re: ATL API [message #1668249 is a reply to message #1668015] Thu, 12 March 2015 11:54 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi,

if you want to generate ATL-Code for your model, would't it be easier to use a generator-framework linke Acceleo?

Acceleo: https://eclipse.org/acceleo/

Here you may iterate over YOUR model and create all the ATL-Code you need for all elements of your model.
But maybe I misunderstood your problem.

~Alex
Re: ATL API [message #1668673 is a reply to message #1668015] Thu, 12 March 2015 15:47 Go to previous messageGo to next message
Chung-Ling Lin is currently offline Chung-Ling LinFriend
Messages: 39
Registered: December 2011
Member
Hi Sylvain,

Thank you for your information.
Would you please tell me is there any tool I can use to transform an ATL program to xmi file?
Re: ATL API [message #1670514 is a reply to message #1668673] Fri, 13 March 2015 08:16 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
The reverse method of 'extract' in the AtlParser I guess.
Re: ATL API [message #1670660 is a reply to message #1670514] Fri, 13 March 2015 09:34 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

With ATL/EMFTVM installed, you can directly open an ATL file with the "Sample Reflective Ecore Model Editor":

  1. Right-click ATL file
  2. Open With -> Other...
  3. Sample Reflective Ecore Model Editor


Example:

-- @atlcompiler emftvm
-- @nsURI ECORE=http://www.eclipse.org/emf/2002/Ecore
-- Alphabetically sorts the contents of an Ecore model by name.
module SortEcore;

create OUT : ECORE refining IN : ECORE;

rule EPackage {
	from
		s : ECORE!EPackage
	to
		t : ECORE!EPackage (
			eClassifiers <- s.eClassifiers->sortedBy(e | e.name),
			eSubpackages <- s.eSubpackages->sortedBy(p | p.name)
		)
}


opens as:

index.php/fa/21175/0/
  • Attachment: SortEcore.png
    (Size: 25.11KB, Downloaded 697 times)


Cheers,
Dennis
Re: ATL API [message #1681242 is a reply to message #1670660] Tue, 17 March 2015 08:22 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
Yes that is nice but you can't see the names of the containment features so opening the xmi is still a must (or using modisco editor that displays the feature names).
Re: ATL API [message #1689445 is a reply to message #1681242] Mon, 23 March 2015 15:39 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

Sylvain EVEILLARD wrote on Tue, 17 March 2015 09:22
Yes that is nice but you can't see the names of the containment features so opening the xmi is still a must (or using modisco editor that displays the feature names).


That's true; the XMI is then very useful.


Cheers,
Dennis
Re: ATL API [message #1690116 is a reply to message #1689445] Wed, 25 March 2015 11:48 Go to previous messageGo to next message
Alexander R is currently offline Alexander RFriend
Messages: 211
Registered: July 2013
Senior Member
Hi Sylvian,

I use the Modisco Model Browser to examine my modules:

Here you can see all kinds of associations...containments and references:

https://dl.dropboxusercontent.com/u/18688378/MA/atl/xmi_editor.JPG

The browser ships with the modisco plugin:
https://eclipse.org/MoDisco/

~Alex
Re: ATL API [message #1767611 is a reply to message #1653552] Fri, 07 July 2017 14:52 Go to previous message
Chung-Ling Lin is currently offline Chung-Ling LinFriend
Messages: 39
Registered: December 2011
Member
Hi,

I am trying to create the .emftvm file from a .atl file programmatically. But there are two problems I have.

First, I can't find how to use the metamodel structure to add a comment "-- @atlcompiler emftvm" to an atl program. Could you give some information about how to add a comment in an ATL program? Thanks.

Second, I try to use a text editor to add -- @atlcompiler emftvm in an atl file manually, but I still need to go to the ATL project in eclipse to refresh the project and then the .emftvm file is generated. Is there any API I can use to generate the .emftvm file from .atl file in a java program?

Chung-Ling Lin
Previous Topic:ATL vs. ETL
Next Topic:Getting Stereotypes for Model transformations
Goto Forum:
  


Current Time: Fri Apr 19 15:25:37 GMT 2024

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

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

Back to the top