Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Jouault2015-03-27 03:04:00 -0400
committerFrédéric Jouault2015-03-27 03:04:00 -0400
commita0d6648085e1d7ab478eabb1b5327bc368ad87bf (patch)
tree9ec5f5e7c00c03739d3fc2f6c000fcc0b2c4849f
parent559cc29ba4dda117aedef31772f60879da5c34a9 (diff)
downloadorg.eclipse.atl.tcs-a0d6648085e1d7ab478eabb1b5327bc368ad87bf.tar.gz
org.eclipse.atl.tcs-a0d6648085e1d7ab478eabb1b5327bc368ad87bf.tar.xz
org.eclipse.atl.tcs-a0d6648085e1d7ab478eabb1b5327bc368ad87bf.zip
added support for model.ext different from xmi & minor changes
-rw-r--r--plugins/org.eclipse.gmt.tcs.metadata/src/org/eclipse/gmt/tcs/metadata/InjectorForATL.java26
1 files changed, 19 insertions, 7 deletions
diff --git a/plugins/org.eclipse.gmt.tcs.metadata/src/org/eclipse/gmt/tcs/metadata/InjectorForATL.java b/plugins/org.eclipse.gmt.tcs.metadata/src/org/eclipse/gmt/tcs/metadata/InjectorForATL.java
index 12e6940..fedec46 100644
--- a/plugins/org.eclipse.gmt.tcs.metadata/src/org/eclipse/gmt/tcs/metadata/InjectorForATL.java
+++ b/plugins/org.eclipse.gmt.tcs.metadata/src/org/eclipse/gmt/tcs/metadata/InjectorForATL.java
@@ -15,13 +15,12 @@ package org.eclipse.gmt.tcs.metadata;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.Collections;
+import java.util.HashMap;
import java.util.Map;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.gmt.tcs.injector.ASMModelAdapter;
-import org.eclipse.gmt.tcs.metadata.adhoc.VirtualModelAdapter;
+import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.m2m.atl.core.ATLCoreException;
import org.eclipse.m2m.atl.core.IInjector;
import org.eclipse.m2m.atl.core.IModel;
@@ -29,9 +28,9 @@ import org.eclipse.m2m.atl.core.emf.EMFInjector;
import org.eclipse.m2m.atl.core.emf.EMFModel;
import org.eclipse.m2m.atl.drivers.emf4atl.ASMEMFModel;
import org.eclipse.m2m.atl.drivers.emf4atl.EMFModelLoader;
-import org.eclipse.m2m.atl.dsls.DSLResourceProvider;
import org.eclipse.m2m.atl.dsls.textsource.TextSource;
import org.eclipse.m2m.atl.engine.vm.AtlModelHandler;
+import org.eclipse.uml2.uml.util.UMLUtil;
/**
*
@@ -41,7 +40,7 @@ public class InjectorForATL implements IInjector {
public void inject(IModel targetModel, String source)
throws ATLCoreException {
- this.inject(targetModel, source, Collections.emptyMap());
+ this.inject(targetModel, source, new HashMap());
}
public void inject(IModel targetModel, String source, Map params) throws ATLCoreException {
@@ -54,6 +53,14 @@ public class InjectorForATL implements IInjector {
EMFModelLoader ml = null;
ModelFactory factory = ASMModelFactory.getDefault();
+ String extension = "xmi";
+ if(language.getSource() != null) {
+ String ext = language.getSource().getProperty("model.ext");
+ if(ext != null) {
+ extension = ext;
+ }
+ }
+
// ((EMFModel)targetModel).getResource() is not necessarily initialized yet.
// If we create an ASMEMFModel in a standard way, it will have a resource, however
// that resource will be dropped as soon as the (temporary) ASMEMFModel is dropped/garbage collected.
@@ -61,7 +68,10 @@ public class InjectorForATL implements IInjector {
// Moreover, we must use targetModel.getReferenceModel(), and not language.getMetamodel(factory).
// It is the responsibility of the caller to make sure that it is the right metamodel.
Resource resource =
- ((EMFModel)targetModel).getModelFactory().getResourceSet().createResource(URI.createFileURI("model.xmi"));
+ ((EMFModel)targetModel).getModelFactory().getResourceSet().createResource(URI.createFileURI("model." + extension));
+ resource.setURI(uri); // set actual URI so that dependencies (e.g., other resources) may be resolved
+ resource.getResourceSet().getLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
+ UMLUtil.init(resource.getResourceSet());
ASMEMFModel model = new ASMEMFModel("model", resource,
new ASMEMFModel(language.getName(), ((EMFModel)targetModel.getReferenceModel()).getResource(), (ASMEMFModel)ASMEMFModel.getMOF(), false, ml) {},
true, ml) {
@@ -69,7 +79,9 @@ public class InjectorForATL implements IInjector {
// For resolution to happen, WFR must be executed, for which we need the two following things:
params.put("vmLauncher", new RegularVMLauncher());
- params.put("problems", factory.newModel("pbs", AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF).createModelLoader().getBuiltInMetaModel("Problem.ecore")));
+ if(!params.containsKey("problems")) {
+ params.put("problems", factory.newModel("pbs", AtlModelHandler.getDefault(AtlModelHandler.AMH_EMF).createModelLoader().getBuiltInMetaModel("Problem.ecore")));
+ }
language.inject(factory, model, new TextSource() {
public InputStream openStream() throws IOException {

Back to the top