|
|
|
Re: ATL API [message #1653552 is a reply to message #1652076] |
Fri, 06 March 2015 09:17 |
|
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 #1689445 is a reply to message #1681242] |
Mon, 23 March 2015 15:39 |
|
Sylvain EVEILLARD wrote on Tue, 17 March 2015 09:22Yes 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.52263 seconds