Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » Using M2M in C#
Using M2M in C# [message #537717] Thu, 03 June 2010 09:10 Go to next message
Ton Tu is currently offline Ton Tu
Messages: 16
Registered: June 2010
Junior Member
I've created neccessary models, model rules and transformed successfully in an ATL project. Could you introduce me some ways to call those transformations at runtime in C#. I'm using VS 2008 to develop my application. Thanks in advance
Re: Using M2M in C# [message #537724 is a reply to message #537717] Thu, 03 June 2010 09:18 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHE
Messages: 129
Registered: July 2009
Senior Member
Le 03/06/2010 15:10, Ton Tu a écrit :
> I've created neccessary models, model rules and transformed successfully
> in an ATL project. Could you introduce me some ways to call those
> transformations at runtime in C#. I'm using VS 2008 to develop my
> application. Thanks in advance

If you are able to launch a java program from C#, you may execute an
Eclipse application.
ATL runs in Eclipse/Java world, so you have to wrap your (ATL)
tranformation environnement in order to execute it from a C# program.
--
Cordialement

Vincent MAHÉ

Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
Re: Using M2M in C# [message #537740 is a reply to message #537724] Thu, 03 June 2010 10:09 Go to previous messageGo to next message
Ton Tu is currently offline Ton Tu
Messages: 16
Registered: June 2010
Junior Member
Hi Vincent MAHE,
Thanks for your reply but I still have some questions to ask.
Even if it's possible to run a Java application from C#, could you show me how to deploy an ATL project to ... a jar file for instance ? I'm new to ATL. So, I really need your help.
Re: Using M2M in C# [message #537748 is a reply to message #537740] Thu, 03 June 2010 10:27 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHE
Messages: 129
Registered: July 2009
Senior Member
Le 03/06/2010 16:09, Ton Tu a écrit :
> Hi Vincent MAHE,
> Thanks for your reply but I still have some questions to ask.
> Even if it's possible to run a Java application from C#, could you show
> me how to deploy an ATL project to ... a jar file for instance ? I'm new
> to ATL. So, I really need your help.

You may have a look on ATL 3 new API in order to know how to wrap an ATL
transformation: http://wiki.eclipse.org/ATL/Developer_Guide#Core

I never did a jar packaging of Eclipse application so you will have to
explore this question by yourself :-(
--
Cordialement

Vincent MAHÉ

Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
Re: Using M2M in C# [message #537767 is a reply to message #537748] Thu, 03 June 2010 11:19 Go to previous messageGo to next message
Ton Tu is currently offline Ton Tu
Messages: 16
Registered: June 2010
Junior Member
Anyway, thank a lot for your enthusiasm Smile
Re: Using M2M in C# [message #537913 is a reply to message #537767] Fri, 04 June 2010 03:26 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHE
Messages: 129
Registered: July 2009
Senior Member
Le 03/06/2010 17:19, Ton Tu a écrit :
> Anyway, thank a lot for your enthusiasm :)

You may be interested by this AmmA.Net :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=284848
--
Cordialement

Vincent MAHÉ

Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
Re: Using M2M in C# [message #538168 is a reply to message #537913] Sat, 05 June 2010 20:57 Go to previous messageGo to next message
Ton Tu is currently offline Ton Tu
Messages: 16
Registered: June 2010
Junior Member
I still cannot use those namespaces to run ATL rules successfully. Could you please give me a snippet of code to run those namespaces ? I will appreciate you a lot ...
I'm getting tired of not being able to run ATL rules which are neccessary for my university thesis ... I've come through many articles instructing how to wrap ATL but none of them is compilable ... I wonder if there's any problem with Eclipse configuration ? Would you mind helping me ?

[Updated on: Sat, 05 June 2010 20:59]

Report message to a moderator

Re: Using M2M in C# [message #538269 is a reply to message #538168] Mon, 07 June 2010 03:50 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHE
Messages: 129
Registered: July 2009
Senior Member
Le 06/06/2010 02:57, Ton Tu a écrit :
> I still cannot use those namespaces to run ATL rules successfully. Could
> you please give me a snippet of code to run those namespaces ? I will
> appreciate you a lot ... I'm getting tired of not being able to run ATL
> rules which are neccessary for my university thesis ...

As an example of ATL Java launcher :


> import java.net.URL;
> import java.util.Collections;
> import java.util.HashMap;
> import java.util.Map;
>
> import org.eclipse.core.runtime.NullProgressMonitor;
> import org.eclipse.core.runtime.Platform;
> import org.eclipse.m2m.atl.core.ATLCoreException;
> import org.eclipse.m2m.atl.core.IExtractor;
> import org.eclipse.m2m.atl.core.IInjector;
> import org.eclipse.m2m.atl.core.IModel;
> import org.eclipse.m2m.atl.core.IReferenceModel;
> import org.eclipse.m2m.atl.core.ModelFactory;
> import org.eclipse.m2m.atl.core.launch.ILauncher;
> import org.eclipse.m2m.atl.core.service.CoreService;
>
> public class ATLInterface
> {
> /**
> * The injector used to load models to XMI files
> */
> private static IInjector injector;
>
> /**
> * The extractor used to save models in XMI files
> */
> private static IExtractor extractor;
>
> /**
> * The URL of the compiled transformation
> */
> private static URL transfoURL;
>
> /*
> * This initializes the ATL interface at first load
> */
> static {
> transfoURL = Platform.getBundle("org.xx.zz.my.plugin")
> .getEntry("transformation/myTransfo.asm");
>
> try {
> injector = CoreService.getInjector(EMF);
> extractor = CoreService.getExtractor(EMF);
> } catch (ATLCoreException e) {
> e.printStackTrace();
> }
> }
>
> /**
> * Call the transformation onto the <code>inFilePath</code> and store the result in the
> * <code>outFilePath</code> file.
> *
> * @param inFilePath
> * The path to the input model
> * @param outFilePath
> * The path to the output model
> */
> public static void transform(String inFilePath, String outFilePath)
> {
> try
> {
> ModelFactory factory = CoreService.getModelFactory(EMF);
>
> ILauncher launcher = CoreService.getLauncher(EMF-specific VM);
> launcher.initialize(Collections.<String, Object> emptyMap()) ;
>
> IReferenceModel inMM = factory.newReferenceModel();
> injector.inject(inMM, "**inMetamodelUri**");
>
> IReferenceModel outMM = factory.newReferenceModel();
> injector.inject(outMM, "**outMetamodelUri**");
>
> // get/create models
> IModel inModel = factory.newModel(inMM);
> injector.inject(inModel, inFilePath);
> launcher.addInModel(inModel, "IN", "IN_MM"); // use ATL transfo codes
>
> IModel outModel = factory.newModel(outMM);
> launcher.addOutModel(outModel, "OUT", "OUT_MM");
>
> // add the continue after errors options
> Map<String, Object> options = new HashMap<String, Object>();
> options.put("continueAfterError", "true");
> options.put("printExecutionTime", "true");
>
> // launch the transformation
> launcher.launch(ILauncher.RUN_MODE, new NullProgressMonitor(),
> options, transfoURL.openStream());
>
> extractor.extract(outModel, outFilePath);
> }
> catch (Exception e)
> {
> e.printStackTrace();
> }
> }
> }


--
Cordialement

Vincent MAHÉ

Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
Re: Using M2M in C# [message #538676 is a reply to message #538269] Tue, 08 June 2010 08:01 Go to previous message
AlainXuan  is currently offline AlainXuan
Messages: 1
Registered: June 2010
Junior Member
I try to follow your instructions. But the method "Platform.getBundle ()" always returns the exception java.lang.NullPointerException.

I do not know yet how to fix it. Can you help me?

http://i149.photobucket.com/albums/s69/alainnguyen00/Untitled.png

[Updated on: Tue, 08 June 2010 08:02]

Report message to a moderator

Previous Topic:[QVTo] Mapping 1 to many objects results in output object appearing as siblings
Next Topic:[ATL] ant tasks problem: 'Unable to load launcher EMF-specific VM'
Goto Forum:
  


Current Time: Sat Apr 19 16:12:56 EDT 2014

Powered by FUDForum. Page generated in 0.02895 seconds