Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Launching (EMF) ATL programmatically and allow inter model references
[ATL] Launching (EMF) ATL programmatically and allow inter model references [message #486069] Wed, 16 September 2009 08:47 Go to next message
Eclipse UserFriend
Originally posted by: loic.fejoz.realtimeatwork.com

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;
}
}

--
regards,
Loïc Fejoz
Re: [ATL] Launching (EMF) ATL programmatically and allow inter model references [message #486078 is a reply to message #486069] Wed, 16 September 2009 09:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: loic.fejoz.realtimeatwork.com

By luck, I found the following thread [1]. It tells that the options
should be pass to the ILauncher.launch call! The option must be a String
(and not a Boolean). The option's name starts with a lower-case 'a'.

options.put("allowInterModelReferences", "true");
final Object result = launcher.launch(ILauncher.RUN_MODE, new
NullProgressMonitor(), options, asmURL.openStream());


[1]
< http://www.eclipse.org/forums/index.php?t=msg&goto=10345 1&S=7469d14bf19de722271dc05f93e4cdac>

--
regards,
Loïc Fejoz


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;
> }
> }
>
Re: [ATL] Launching (EMF) ATL programmatically and allow inter model references [message #486079 is a reply to message #486069] Wed, 16 September 2009 09:38 Go to previous messageGo to next message
William Piers is currently offline William PiersFriend
Messages: 303
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020704000903030706080505
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

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
Re: [ATL] Launching (EMF) ATL programmatically and allow inter model references [message #486146 is a reply to message #486079] Wed, 16 September 2009 13:48 Go to previous message
Eclipse UserFriend
Originally posted by: loic.fejoz.realtimeatwork.com

Done.
Bug number is #289609.

<https://bugs.eclipse.org/bugs/show_bug.cgi?id=289609>

--
regards,
Loïc Fejoz

William Piers a écrit :
> 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
> [...]
Previous Topic:[QVTO] Help on "SimpleUML to RDB" example
Next Topic:[QVTO] How to handle optional attributes with primitive types?
Goto Forum:
  


Current Time: Sat Jan 25 06:46:04 GMT 2025

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

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

Back to the top