Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Plugin ATL
Plugin ATL [message #1059551] Mon, 20 May 2013 12:32 Go to next message
ransou RMG is currently offline ransou RMGFriend
Messages: 15
Registered: February 2013
Junior Member
Hi everybody,
I created an ATL PROJECT which runs successfully.Now I would like to do the transformation by using the a project which its type is "Plugin ATL".
I created it and and I chose the ATL launch configuration the one related to the first ATL project.The CREATION of the ATL plugin is done sccessfully.My problem now is in tha java class generated by the plugin.it is like this:

/*******************************************************************************
* Copyright (c) 2010, 2012 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.m2m.atl.Project.files;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
import org.eclipse.m2m.atl.common.ATLExecutionException;
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.emf.EMFExtractor;
import org.eclipse.m2m.atl.core.emf.EMFInjector;
import org.eclipse.m2m.atl.core.emf.EMFModelFactory;
import org.eclipse.m2m.atl.core.launch.ILauncher;
import org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher;

/**
* Entry point of the 'Tpf3' transformation module.
*/
public class Families2Persons {

/**
* The property file. Stores module list, the metamodel and library locations.
* @generated
*/
private Properties properties;

/**
* The IN model.
* @generated
*/
protected IModel inModel;

/**
* The OUT model.
* @generated
*/
protected IModel outModel;

/**
* The main method.
*
* @param args
* are the arguments
* @generated
*/
public static void main(String[] args) {
try {
// if (args.length < 2) {
// System.out.println("Arguments not valid : {IN_model_path, OUT_model_path}.");
//} else {
Families2Persons runner = new Families2Persons();
//runner.loadModels(args[0]);
runner.loadModels("sample-Families.xmi");
runner.doFamilies2Persons(new NullProgressMonitor());
//runner.saveModels(args[1]);
runner.saveModels("sample-Persons.xmi");
//}
} catch (ATLCoreException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ATLExecutionException e) {
e.printStackTrace();
}
}

/**
* Constructor.
*
* @generated
*/
public Families2Persons() throws IOException {
properties = new Properties();
properties.load(getFileURL("Families2Persons.properties").openStream());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
//System.out.println(properties);
}

/**
* Load the input and input/output models, initialize output models.
*
* @param inModelPath
* the IN model path
* @throws ATLCoreException
* if a problem occurs while loading models
*
* @generated
*/
public void loadModels(String inModelPath) throws ATLCoreException {
ModelFactory factory = new EMFModelFactory();
IInjector injector = new EMFInjector();
IReferenceModel sourceMetamodel = factory.newReferenceModel();
injector.inject(sourceMetamodel, getMetamodelUri("Families.ecore"));
IReferenceModel targetMetamodel = factory.newReferenceModel();
injector.inject(targetMetamodel, getMetamodelUri("Persons.ecore"));
this.inModel = factory.newModel(sourceMetamodel);
injector.inject(inModel, inModelPath);
this.outModel = factory.newModel(targetMetamodel);
}

/**
* Save the output and input/output models.
*
* @param outModelPath
* the OUT model path
* @throws ATLCoreException
* if a problem occurs while saving models
*
* @generated
*/
public void saveModels(String outModelPath) throws ATLCoreException {
IExtractor extractor = new EMFExtractor();
extractor.extract(outModel, "/org.eclipse.m2m.atl.Project/sample-Persons.xmi");
}

/**
* Transform the models.
*
* @param monitor
* the progress monitor
* @throws ATLCoreException
* if an error occurs during models handling
* @throws IOException
* if a module cannot be read
* @throws ATLExecutionException
* if an error occurs during the execution
*
* @generated
*/
public Object doFamilies2Persons(IProgressMonitor monitor) throws ATLCoreException, IOException, ATLExecutionException {
ILauncher launcher = new EMFVMLauncher();
Map<String, Object> launcherOptions = getOptions();
launcher.initialize(launcherOptions);
launcher.addInModel(inModel, "IN", "source");
launcher.addOutModel(outModel, "OUT", "target");
return launcher.launch("run", monitor, launcherOptions, (Object[]) getModulesList());
}

/**
* Returns an Array of the module input streams, parameterized by the
* property file.
*
* @return an Array of the module input streams
* @throws IOException
* if a module cannot be read
*
* @generated
*/
protected InputStream[] getModulesList() throws IOException {
InputStream[] modules = null;
String modulesList = properties.getProperty("Families2Persons.modules");
if (modulesList != null) {
String[] moduleNames = modulesList.split(",");
modules = new InputStream[moduleNames.length];
for (int i = 0; i < moduleNames.length; i++) {
String asmModulePath = new Path(moduleNames[i].trim()).removeFileExtension().addFileExtension("asm").toString();
modules[i] = getFileURL(asmModulePath).openStream();
}
}
return modules;
}

/**
* Returns the URI of the given metamodel, parameterized from the property file.
*
* @param metamodelName
* the metamodel name
* @return the metamodel URI
*
* @generated
*/
protected String getMetamodelUri(String metamodelName) {
return properties.getProperty("Families2Persons.metamodels." + metamodelName);
}

/**
* Returns the file name of the given library, parameterized from the property file.
*
* @param libraryName
* the library name
* @return the library file name
*
* @generated
*/
protected InputStream getLibraryAsStream(String libraryName) throws IOException {
return getFileURL(properties.getProperty("Families2Persons.libraries." + libraryName)).openStream();
}

/**
* Returns the options map, parameterized from the property file.
*
* @return the options map
*
* @generated
*/
protected Map<String, Object> getOptions() {
Map<String, Object> options = new HashMap<String, Object>();
for (Entry<Object, Object> entry : properties.entrySet()) {
if (entry.getKey().toString().startsWith("Families2Persons.options.")) {
options.put(entry.getKey().toString().replaceFirst("Families2Persons.options.", ""),
entry.getValue().toString());
}
}
return options;
}

/**
* Finds the file in the plug-in. Returns the file URL.
*
* @param fileName
* the file name
* @return the file URL
* @throws IOException
* if the file doesn't exist
*
* @generated
*/
protected static URL getFileURL(String fileName) throws IOException {
final URL fileURL;
if (isEclipseRunning()) {
URL resourceURL = Families2Persons.class.getResource(fileName);
if (resourceURL != null) {
fileURL = FileLocator.toFileURL(resourceURL);
} else {
fileURL = null;
}
} else {
fileURL = Families2Persons.class.getResource(fileName);
}
if (fileURL == null) {
throw new IOException("'" + fileName + "' not found");
} else {
return fileURL;
}
}

/**
* Tests if eclipse is running.
*
* @return <code>true</code> if eclipse is running
*
* @generated
*/
public static boolean isEclipseRunning() {
try {
return Platform.isRunning();
} catch (Throwable exception) {
// Assume that we aren't running.
}
return false;
}
}


The console seems like this:

Exception in thread "main" java.lang.NullPointerException
at org.eclipse.m2m.atl.core.emf.EMFInjector.inject(EMFInjector.java:58)
at org.eclipse.m2m.atl.core.emf.EMFInjector.inject(EMFInjector.java:84)
at org.eclipse.m2m.atl.Project.files.Families2Persons.loadModels(Families2Persons.java:118)
at org.eclipse.m2m.atl.Project.files.Families2Persons.main(Families2Persons.java:78)



My question is where can I place the metamodels(in format "ecore")and the models (in format .xmi).I mean their path because I place them in the plugin.What are my errors.


Please help me and I will be thankful very much Smile
Re: Plugin ATL [message #1059610 is a reply to message #1059551] Mon, 20 May 2013 19:30 Go to previous messageGo to next message
ransou RMG is currently offline ransou RMGFriend
Messages: 15
Registered: February 2013
Junior Member
No Message Body
Re: Plugin ATL [message #1059691 is a reply to message #1059610] Tue, 21 May 2013 08:58 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
Hello,

There is no specific place to put your models and metamodels, it's up to you to decide.

According to your choice, the paths of the input/output metamodels can be set via the generated ".properties" file.
The paths of the input/output models are determined when calling to the generated loadModels and saveModels methods.


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Plugin ATL [message #1059716 is a reply to message #1059691] Tue, 21 May 2013 10:43 Go to previous messageGo to next message
ransou RMG is currently offline ransou RMGFriend
Messages: 15
Registered: February 2013
Junior Member
Thank you but the action of loading doesn't work.I place my models "sample-Families.xmi" which is not empty and "sample-Persons.xmi" which is empty in the same project "org.eclipse.m2m.atl.Families2Persons".

/*******************************************************************************
* Copyright (c) 2010, 2012 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.m2m.atl.Families2Persons.files;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
import org.eclipse.m2m.atl.common.ATLExecutionException;
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.emf.EMFExtractor;
import org.eclipse.m2m.atl.core.emf.EMFInjector;
import org.eclipse.m2m.atl.core.emf.EMFModelFactory;
import org.eclipse.m2m.atl.core.launch.ILauncher;
import org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher;

/**
* Entry point of the 'Families2Persons' transformation module.
*/
public class Families2Persons {

/**
* The property file. Stores module list, the metamodel and library locations.
* @generated
*/
private Properties properties;

/**
* The IN model.
* @generated
*/
protected IModel inModel;

/**
* The OUT model.
* @generated
*/
protected IModel outModel;

/**
* The main method.
*
* @param args
* are the arguments
* @generated
*/
public static void main(String[] args) {
try {
//if (args.length < 2) {
// System.out.println("Arguments not valid : {IN_model_path, OUT_model_path}.");
//} else {
Families2Persons runner = new Families2Persons();
//System.out.println("bj");
runner.loadModels("sample-Families.xmi");
//System.out.println("xx");
runner.doFamilies2Persons(new NullProgressMonitor());
runner.saveModels("sample-Persons.xmi");
//}
} catch (ATLCoreException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ATLExecutionException e) {
e.printStackTrace();
}
}

/**
* Constructor.
*
* @generated
*/
public Families2Persons() throws IOException {
properties = new Properties();
properties.load(getFileURL("Families2Persons.properties").openStream());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
//System.out.println("Bsr");
}

/**
* Load the input and input/output models, initialize output models.
*
* @param inModelPath
* the IN model path
* @throws ATLCoreException
* if a problem occurs while loading models
*
* @generated
*/
public void loadModels(String inModelPath) throws ATLCoreException {
ModelFactory factory = new EMFModelFactory();
IInjector injector = new EMFInjector();
IReferenceModel familiesMetamodel = factory.newReferenceModel();
injector.inject(familiesMetamodel, getMetamodelUri("families"));
IReferenceModel personsMetamodel = factory.newReferenceModel();
injector.inject(personsMetamodel, getMetamodelUri("persons"));
this.inModel = factory.newModel(familiesMetamodel);
injector.inject(inModel,inModelPath);
this.outModel = factory.newModel(personsMetamodel);
}

/**
* Save the output and input/output models.
*
* @param outModelPath
* the OUT model path
* @throws ATLCoreException
* if a problem occurs while saving models
*
* @generated
*/
public void saveModels(String outModelPath) throws ATLCoreException {
IExtractor extractor = new EMFExtractor();
extractor.extract(outModel,outModelPath);
}

/**
* Transform the models.
*
* @param monitor
* the progress monitor
* @throws ATLCoreException
* if an error occurs during models handling
* @throws IOException
* if a module cannot be read
* @throws ATLExecutionException
* if an error occurs during the execution
*
* @generated
*/
public Object doFamilies2Persons(IProgressMonitor monitor) throws ATLCoreException, IOException, ATLExecutionException {
ILauncher launcher = new EMFVMLauncher();
Map<String, Object> launcherOptions = getOptions();
launcher.initialize(launcherOptions);
launcher.addInModel(inModel, "IN", "Families");
launcher.addOutModel(outModel, "OUT", "Persons");
return launcher.launch("run", monitor, launcherOptions, (Object[]) getModulesList());
}

/**
* Returns an Array of the module input streams, parameterized by the
* property file.
*
* @return an Array of the module input streams
* @throws IOException
* if a module cannot be read
*
* @generated
*/
protected InputStream[] getModulesList() throws IOException {
InputStream[] modules = null;
String modulesList = properties.getProperty("Families2Persons.modules");
if (modulesList != null) {
String[] moduleNames = modulesList.split(",");
modules = new InputStream[moduleNames.length];
for (int i = 0; i < moduleNames.length; i++) {
String asmModulePath = new Path(moduleNames[i].trim()).removeFileExtension().addFileExtension("asm").toString();
modules[i] = getFileURL(asmModulePath).openStream();
}
}
return modules;
}

/**
* Returns the URI of the given metamodel, parameterized from the property file.
*
* @param metamodelName
* the metamodel name
* @return the metamodel URI
*
* @generated
*/
protected String getMetamodelUri(String metamodelName) {
return properties.getProperty("Families2Persons.metamodels." + metamodelName);
}

/**
* Returns the file name of the given library, parameterized from the property file.
*
* @param libraryName
* the library name
* @return the library file name
*
* @generated
*/
protected InputStream getLibraryAsStream(String libraryName) throws IOException {
return getFileURL(properties.getProperty("Families2Persons.libraries." + libraryName)).openStream();
}

/**
* Returns the options map, parameterized from the property file.
*
* @return the options map
*
* @generated
*/
protected Map<String, Object> getOptions() {
Map<String, Object> options = new HashMap<String, Object>();
for (Entry<Object, Object> entry : properties.entrySet()) {
if (entry.getKey().toString().startsWith("Families2Persons.options.")) {
options.put(entry.getKey().toString().replaceFirst("Families2Persons.options.", ""),
entry.getValue().toString());
}
}
return options;
}

/**
* Finds the file in the plug-in. Returns the file URL.
*
* @param fileName
* the file name
* @return the file URL
* @throws IOException
* if the file doesn't exist
*
* @generated
*/
protected static URL getFileURL(String fileName) throws IOException {
final URL fileURL;
if (isEclipseRunning()) {
URL resourceURL = Families2Persons.class.getResource(fileName);
if (resourceURL != null) {
fileURL = FileLocator.toFileURL(resourceURL);
} else {
fileURL = null;
}
} else {
fileURL = Families2Persons.class.getResource(fileName);
}
if (fileURL == null) {
throw new IOException("'" + fileName + "' not found");
} else {
return fileURL;
}
}

/**
* Tests if eclipse is running.
*
* @return <code>true</code> if eclipse is running
*
* @generated
*/
public static boolean isEclipseRunning() {
try {
return Platform.isRunning();
} catch (Throwable exception) {
// Assume that we aren't running.
}
return false;
}
}



the file of Families2Persons.properties seems like this:

# ==============================================================================
# Families2Persons properties
# ==============================================================================

# ATL modules: if several, by order of superimposition (the latter ones overrides the former ones)
Families2Persons.modules = Families2Persons.atl

# Metamodels paths or nsUris
Families2Persons.metamodels.Families = /Families2Persons/Families.ecore
Families2Persons.metamodels.Persons = /Families2Persons/Persons.ecore



# Libraries paths

# ATL Launching options



==>I need to find a solution the loading of models doesn't work.Can body tell me how can I do to solve the problem of loading.My program doesn't work and the console seems like this:


Exception in thread "main" java.lang.NullPointerException
at org.eclipse.m2m.atl.core.emf.EMFInjector.inject(EMFInjector.java:58)
at org.eclipse.m2m.atl.core.emf.EMFInjector.inject(EMFInjector.java:84)
at org.eclipse.m2m.atl.Families2Persons.files.Families2Persons.loadModels(Families2Persons.java:118)
at org.eclipse.m2m.atl.Families2Persons.files.Families2Persons.main(Families2Persons.java:78)
Re: Plugin ATL [message #1059722 is a reply to message #1059716] Tue, 21 May 2013 11:35 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
You don't need to create manually any Persons model as it is going to be produced by the transformation (what you have to provide is just a String expressing the selected path).
Concerning the metamodels and input model, you have to check that the provided paths/URIs are actually correct (and that the corresponding IDs are right in the properties file).
If everything is set correctly, then it should work properly.


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Plugin ATL [message #1059725 is a reply to message #1059722] Tue, 21 May 2013 12:08 Go to previous messageGo to next message
ransou RMG is currently offline ransou RMGFriend
Messages: 15
Registered: February 2013
Junior Member
Please Mr.Hugo help me more:as the file "Families2Persons.properties" the Paths of both metamodels are:

Families2Persons.metamodels.Families = /Families2Persons/Families.ecore
Families2Persons.metamodels.Persons = /Families2Persons/Persons.ecore

The path of the inModel is "/org.eclipse.m2m.atl.Families2Persons/src/sample-Families.xmi"

Could you show me where exactly can me place the paths in the code and thank you so much Smile
Re: Plugin ATL [message #1059753 is a reply to message #1059725] Tue, 21 May 2013 14:03 Go to previous messageGo to next message
Hugo Bruneliere is currently offline Hugo BruneliereFriend
Messages: 674
Registered: July 2009
Senior Member
As written in the generated code, you have to provide the input model path when calling to the loadModels method.
* @param inModelPath
* the IN model path
* @throws ATLCoreException
* if a problem occurs while loading models
*
* @generated
*/
public void loadModels(String inModelPath)


--------------------------------------------------------
Hugo Bruneliere, PhD
NaoMod team (IMT Atlantique & LS2N-CNRS)
Nantes - France
--------------------------------------------------------
Re: Plugin ATL [message #1060070 is a reply to message #1059753] Wed, 22 May 2013 20:56 Go to previous messageGo to next message
ransou RMG is currently offline ransou RMGFriend
Messages: 15
Registered: February 2013
Junior Member
Finally it runs successfully Smile
Re: Plugin ATL [message #1220137 is a reply to message #1059551] Tue, 10 December 2013 03:57 Go to previous messageGo to next message
michel souza is currently offline michel souzaFriend
Messages: 18
Registered: December 2013
Junior Member
I'm still having problems with Plugin ATL.. I'm using exactly the same example Families2Persons. It works fine without the programmatically way of trying.

My Class:

/*******************************************************************************
* Copyright (c) 2010, 2012 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.m2m.atl.Families2Persons.files;

import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Map.Entry;

import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
import org.eclipse.m2m.atl.common.ATLExecutionException;
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.emf.EMFExtractor;
import org.eclipse.m2m.atl.core.emf.EMFInjector;
import org.eclipse.m2m.atl.core.emf.EMFModelFactory;
import org.eclipse.m2m.atl.core.launch.ILauncher;
import org.eclipse.m2m.atl.engine.emfvm.launch.EMFVMLauncher;

/**
* Entry point of the 'Families2Persons' transformation module.
*/
public class Families2Persons {

/**
* The property file. Stores module list, the metamodel and library locations.
* @generated
*/
private Properties properties;

/**
* The IN model.
* @generated
*/
protected IModel inModel;

/**
* The OUT model.
* @generated
*/
protected IModel outModel;

/**
* The main method.
*
* @param args
* are the arguments
* @generated
*/
public static void main(String[] args) {
try {
// if (args.length < 2) {
// System.out.println("Arguments not valid : {IN_model_path, OUT_model_path}.");
// } else {
Families2Persons runner = new Families2Persons();
runner.loadModels("/org.eclipse.m2m.atl.Families2Persons/src/sample-Families.xmi");
runner.doFamilies2Persons(new NullProgressMonitor());
runner.saveModels("/org.eclipse.m2m.atl.Families2Persons/src/sample-Families.xmi");
// }
} catch (ATLCoreException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ATLExecutionException e) {
e.printStackTrace();
}
}

/**
* Constructor.
*
* @generated
*/
public Families2Persons() throws IOException {
properties = new Properties();
properties.load(getFileURL("Families2Persons.properties").openStream());
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
}

/**
* Load the input and input/output models, initialize output models.
*
* @param inModelPath
* the IN model path
* @throws ATLCoreException
* if a problem occurs while loading models
*
* @generated
*/
public void loadModels(String inModelPath) throws ATLCoreException {
ModelFactory factory = new EMFModelFactory();
IInjector injector = new EMFInjector();
IReferenceModel familiesMetamodel = factory.newReferenceModel();
injector.inject(familiesMetamodel, getMetamodelUri("Families"));
IReferenceModel personsMetamodel = factory.newReferenceModel();
injector.inject(personsMetamodel, getMetamodelUri("Persons"));
this.inModel = factory.newModel(familiesMetamodel);
injector.inject(inModel, inModelPath);
this.outModel = factory.newModel(personsMetamodel);
}

/**
* Save the output and input/output models.
*
* @param outModelPath
* the OUT model path
* @throws ATLCoreException
* if a problem occurs while saving models
*
* @generated
*/
public void saveModels(String outModelPath) throws ATLCoreException {
IExtractor extractor = new EMFExtractor();
extractor.extract(outModel, outModelPath);
}

/**
* Transform the models.
*
* @param monitor
* the progress monitor
* @throws ATLCoreException
* if an error occurs during models handling
* @throws IOException
* if a module cannot be read
* @throws ATLExecutionException
* if an error occurs during the execution
*
* @generated
*/
public Object doFamilies2Persons(IProgressMonitor monitor) throws ATLCoreException, IOException, ATLExecutionException {
ILauncher launcher = new EMFVMLauncher();
Map<String, Object> launcherOptions = getOptions();
launcher.initialize(launcherOptions);
launcher.addInModel(inModel, "IN", "Families");
launcher.addOutModel(outModel, "OUT", "Persons");
return launcher.launch("run", monitor, launcherOptions, (Object[]) getModulesList());
}

/**
* Returns an Array of the module input streams, parameterized by the
* property file.
*
* @return an Array of the module input streams
* @throws IOException
* if a module cannot be read
*
* @generated
*/
protected InputStream[] getModulesList() throws IOException {
InputStream[] modules = null;
String modulesList = properties.getProperty("Families2Persons.modules");
if (modulesList != null) {
String[] moduleNames = modulesList.split(",");
modules = new InputStream[moduleNames.length];
for (int i = 0; i < moduleNames.length; i++) {
String asmModulePath = new Path(moduleNames[i].trim()).removeFileExtension().addFileExtension("asm").toString();
modules[i] = getFileURL(asmModulePath).openStream();
}
}
return modules;
}

/**
* Returns the URI of the given metamodel, parameterized from the property file.
*
* @param metamodelName
* the metamodel name
* @return the metamodel URI
*
* @generated
*/
protected String getMetamodelUri(String metamodelName) {
return properties.getProperty("Families2Persons.metamodels." + metamodelName);
}

/**
* Returns the file name of the given library, parameterized from the property file.
*
* @param libraryName
* the library name
* @return the library file name
*
* @generated
*/
protected InputStream getLibraryAsStream(String libraryName) throws IOException {
return getFileURL(properties.getProperty("Families2Persons.libraries." + libraryName)).openStream();
}

/**
* Returns the options map, parameterized from the property file.
*
* @return the options map
*
* @generated
*/
protected Map<String, Object> getOptions() {
Map<String, Object> options = new HashMap<String, Object>();
for (Entry<Object, Object> entry : properties.entrySet()) {
if (entry.getKey().toString().startsWith("Families2Persons.options.")) {
options.put(entry.getKey().toString().replaceFirst("Families2Persons.options.", ""),
entry.getValue().toString());
}
}
return options;
}

/**
* Finds the file in the plug-in. Returns the file URL.
*
* @param fileName
* the file name
* @return the file URL
* @throws IOException
* if the file doesn't exist
*
* @generated
*/
protected static URL getFileURL(String fileName) throws IOException {
final URL fileURL;
if (isEclipseRunning()) {
URL resourceURL = Families2Persons.class.getResource(fileName);
if (resourceURL != null) {
fileURL = FileLocator.toFileURL(resourceURL);
} else {
fileURL = null;
}
} else {
fileURL = Families2Persons.class.getResource(fileName);
}
if (fileURL == null) {
throw new IOException("'" + fileName + "' not found");
} else {
return fileURL;
}
}

/**
* Tests if eclipse is running.
*
* @return <code>true</code> if eclipse is running
*
* @generated
*/
public static boolean isEclipseRunning() {
try {
return Platform.isRunning();
} catch (Throwable exception) {
// Assume that we aren't running.
}
return false;
}
}

Error Log:

org.eclipse.m2m.atl.core.ATLCoreException: Error loading /Families2Persons/Families.ecore: java.io.FileNotFoundException: \Families2Persons\Families.ecore (O sistema não pode encontrar o caminho especificado)
at org.eclipse.m2m.atl.core.emf.EMFInjector.inject(EMFInjector.java:70)
at org.eclipse.m2m.atl.core.emf.EMFInjector.inject(EMFInjector.java:84)
at org.eclipse.m2m.atl.Families2Persons.files.Families2Persons.loadModels(Families2Persons.java:115)
at org.eclipse.m2m.atl.Families2Persons.files.Families2Persons.main(Families2Persons.java:77)
Caused by: org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.io.FileNotFoundException: \Families2Persons\Families.ecore (O sistema não pode encontrar o caminho especificado)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at org.eclipse.m2m.atl.core.emf.EMFInjector.inject(EMFInjector.java:65)
... 3 more
Caused by: java.io.FileNotFoundException: \Families2Persons\Families.ecore (O sistema não pode encontrar o caminho especificado)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at org.eclipse.emf.ecore.resource.impl.FileURIHandlerImpl.createInputStream(FileURIHandlerImpl.java:99)
at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1269)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
... 5 more

"O sistema não pode encontrar o caminhado especificado" means The system couldn't find the specified path.

The thing here is.. I'm having troubles to load even the metamodel. They are in another project.. but I checked the .properties files and the key/id is fine. I tried to copy the metamodels to my project called "org.eclipse.m2m.atl.Families2Persons" and change the .properties file to match but even like this.. not working.

Any Help please. Thanks in advance!
Re: Plugin ATL [message #1770685 is a reply to message #1220137] Wed, 16 August 2017 09:00 Go to previous message
Inaki Berrio is currently offline Inaki BerrioFriend
Messages: 4
Registered: August 2017
Junior Member
I am having the same problem. When I try to set the metamodel path in the .properties file I am getting the same error.

My atl Plugin structure looks like this
- es.berrio.atl (plugin)
+ es.berrio.atl.files (package)
- Vehicle2cars.java
- vehicle2cars.asm
- vehicle2cars.atl
- vehicle2cars.properties
+ metamodels (folder)
- vehicle.ecore
- cars.ecore

I have tried to change the path in the vehicle2cars.properties file, but with no success. I how should I specify this path?

I would appreciate any help

Regards!
Previous Topic:Difference between launch transformation via Eclipse Run configuration and via Java
Next Topic:Problem Creating a Dependency relation in UML with ATL
Goto Forum:
  


Current Time: Tue Apr 23 15:36:01 GMT 2024

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

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

Back to the top