[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2m] Re: [ATL] Launching (EMF) ATL programmatically and allow inter model references

Hello,

You need to pass the option to the ATL Launcher, using a String:
options.put("allowInterModelReferences", "true");

This is due to the fact that the option is usually provided by an Eclipse launch configuration. Anyway, Boolean.TRUE should be recognized as well... Feel free to report a bug about that.

Best regards,

William

Loïc Fejoz a écrit :
Hi,

I'am trying to make a plugin that contains an ATL transformation. By now I am able to get the resulting file but it does not contains intermodel references. Obviously I tried the option allowInterModelReferences but I cannot get it working...

First, is the name of the option contained somewhere in a static field? org.eclipse.m2m.atl.adt.launching.AtlLauncherTools is not in Galileo, does it?

Second, is it the same option name if I am calling method (EMF)Resource.save?

Do you need to pass it to the ATL Launcher (also it's not working)?

Do you need to put a Boolean or a string value (neither work)?

Here is what I think is the interesting code. Note that normally I use the EMF ATL VM hence I always get an EMFModel as a result.

public static Resource toXxResource(final IResource yyModelResource)
      throws ATLCoreException, IOException {
  // This is the basic call
  IModel outputModel = toXxModel(yyModelResource);
  // Now try to serialize the result
  URI outputURI = URI.createURI(yyModelResource.getLocationURI()
          .toString().concat(".xmi"));
  final Map<String, Object> options = new HashMap<String, Object>();
  options.put("allowInterModelReferences", Boolean.TRUE);
  options.put("AllowInterModelReferences", Boolean.TRUE);
  if (outputModel instanceof EMFModel) {
    EMFModel emfModel = (EMFModel) outputModel;
    Resource res = emfModel.getResource();
    assert res != null;
    ResourceSet set = res.getResourceSet();
    assert set != null
    OutputStream outputStream = set.getURIConverter()
            .createOutputStream(outputURI);
    res.save(outputStream, options);
    res.setURI(outputURI);
    assert res.getURI().equals(outputURI);
    return res;
 } else {
    IExtractor extractor = CoreService.getExtractor("EMF");
    extractor.extract(outputModel, outputURI.toString(), options);
    return null;
  }
}


-- Ne manquez pas notre prochaine formation ATL inter entreprises: ATL - Paris - du 7 au 8 Octobre 2009 Pour plus de dates et pour le détail de cette formation: http://www.obeo.fr/pages/formations/fr

Don't forget our next ATL training:
ATL     - Paris - 2009 October from 7th to 8th
More dates and training program on:
http://www.obeo.fr/pages/formations/fr
begin:vcard
fn:William Piers
n:Piers;William
org:Obeo
adr:2 rue Robert Schumann;;lot 24;NANTES;;44408;France
email;internet:william.piers@xxxxxxx
title:MDA Consultant
tel;work:+33 (0)2 51 13 50 53
url:http://www.obeo.fr
version:2.1
end:vcard