[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2m] Re: [ATL] Programmaticaly launch transformation involving UML models


your transfomation is create B : UML from A : UML;

so, the model A must be a InputStream but the B must be a OutputStream, and the ASMModel need be a newModel, dont a loadModel.

Netuh

karp wrote:

Hi,
I'm trying to write a small transformation involving UML2 models.
I have no problem to launch it through the atl perspective. I use "uri:http://www.eclipse.org/uml2/2.1.0/UML"; as the uri of the UML metamodel.
But I haven't managed to lauch it programmaticaly (I have no problem for standard non-UML models).

My atl transformation is like that, very simple :
----------------------8<------------------------
module SimpleUMLNoProfile; -- Module Template
create B : UML  from A  : UML;
rule Model {
	from
		s : UML!"uml::Model"
	to
		t : UML!"uml::Model"
}
---------------------8<-------------------------

My model in input is like that : (basically a model, a package, a class)
---------------------8<-------------------------
<?xml version="1.0" encoding="UTF-8"?>
<uml:Model xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"; xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"; xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML"; xmi:id="_eGIhADeTEd2OqNGrMp5Krw" name="ModelA">
<packageImport xmi:id="_eGIhATeTEd2OqNGrMp5Krw">
<importedPackage xmi:type="uml:Model" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#_0"/>
</packageImport>
<packagedElement xmi:type="uml:Package" xmi:id="_qbq6UDeTEd2OqNGrMp5Krw" name="PackageA">
<packagedElement xmi:type="uml:Class" xmi:id="_snfRoDeTEd2OqNGrMp5Krw" name="ClassA">
<ownedAttribute xmi:id="_usVeQDeTEd2OqNGrMp5Krw" name="PropertyA" isUnique="false">
<type xmi:type="uml:PrimitiveType" href="pathmap://UML_LIBRARIES/UMLPrimitiveTypes.library.uml#String"/>
</ownedAttribute>
</packagedElement>
</packagedElement>
<profileApplication xmi:id="_eGIhAjeTEd2OqNGrMp5Krw">
<eAnnotations xmi:id="_eGIhAzeTEd2OqNGrMp5Krw" source="http://www.eclipse.org/uml2/2.0.0/UML";>
<references xmi:type="ecore:EPackage" href="pathmap://UML_PROFILES/Standard.profile.uml#_yzU58YinEdqtvbnfB2L_5w"/>
</eAnnotations>
<appliedProfile href="pathmap://UML_PROFILES/Standard.profile.uml#_0"/>
</profileApplication>
</uml:Model>
--------------------8<-----------------------------

My code...
--------------------8<-----------------------------
		AtlModelHandler amh = null;
		amh = new AtlUML2ModelHandler();

		URL urlTransfo = null;		
		try { urlTransfo = asmFile.toURI().toURL();
		} catch (MalformedURLException e) {}			
		Map<String, ASMModel> mapASMModels = new HashMap<String, ASMModel>();

ResourceSet resourceSet = AtlEMFModelHandler.getResourceSet();


resourceSet.getPackageRegistry().put("http://www.eclipse.org/uml2/2.1.0/UML";,
UMLPackage.eINSTANCE);
URI uri =


URI.createURI("jar:file:/D:/eclipse/eclipse-modeling-ganymede-RC1-win32/ATL_LIBS_RC3/org.eclipse.uml2.uml.resources_2.2.0.v200805131030.jar!/");


resourceSet.getURIConverter().URI_MAP.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
uri.appendSegment("libraries").appendSegment(""));


resourceSet.getURIConverter().URI_MAP.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
uri.appendSegment("metamodels").appendSegment(""));


resourceSet.getURIConverter().URI_MAP.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
uri.appendSegment("profiles").appendSegment(""));


resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);

ASMModel asmUML = ((AtlEMFModelHandler)amh).loadModel("UML", amh.getMof(), "uri:http://www.eclipse.org/uml2/2.1.0/UML";);

		File fileA = new File(PATH + "ModelA.uml");
		InputStream inA = null;
		try { inA = fileA.toURI().toURL().openStream();
		} catch (MalformedURLException e) {} catch (IOException e) {}
		ASMModel asmA;
		asmA = amh.loadModel("A", asmUML, inA);


		File fileB = new File(PATH + "ModelB.uml");
		InputStream inB = null;
		try {inB = fileB.toURI().toURL().openStream();
		} catch (MalformedURLException e) {} catch (IOException e) {}
		ASMModel asmB = amh.loadModel("B", asmUML, inB);

		mapASMModels.put("A", asmA);
		mapASMModels.put("B", asmB);
		mapASMModels.put("UML", asmUML);

		Map params = Collections.EMPTY_MAP; // Parameters
		Map<String, URL> mapLibs = new HashMap<String, URL>();

// Launch ATL transformation
AtlLauncher.getDefault().launch(urlTransfo, mapLibs, mapASMModels, params,
Collections.EMPTY_LIST, Collections.EMPTY_MAP);
--------------------8<-----------------------------

And now the error : (sorry for the length)
--------------------8<-----------------------------
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.SimpleDebugger error
GRAVE: ****** BEGIN Stack Trace
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.SimpleDebugger error
GRAVE: exception:
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.SimpleDebugger error
GRAVE: argument type mismatch
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at


org.eclipse.m2m.atl.engine.vm.ClassNativeOperation.exec(ClassNativeOperation.java:69)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:143)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:101)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:338)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:143)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:101)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:143)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:101)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:299)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:169)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:111)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:87)
at UmlAtlLaunch.transfoRegularVM(UmlAtlLaunch.java:86)
at UmlAtlTest.main(UmlAtlTest.java:9)
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: A.main() : ??#22 null
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: local variables = {self=SimpleUMLNoProfile : ASMModule}
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: local stack = []
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: A.__matcher__() : ??#1 null
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: local variables = {self=SimpleUMLNoProfile : ASMModule}
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: local stack = []
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: A.__matchModel() : ??#35 null
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: local variables = {s=A!ModelA, self=SimpleUMLNoProfile : ASMModule}
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: local stack = [TransientLinkSet {}]
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: NativeOperation public static void


org.eclipse.m2m.atl.engine.vm.nativelib.ASMTransientLink.addTargetElement(org.eclipse.m2m.atl.engine.vm.StackFrame,org.eclipse.m2m.atl.engine.vm.nativelib.ASMTransientLink,org.eclipse.m2m.atl.engine.vm.nativelib.ASMString,org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny)
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.ExecEnv printStackTrace
GRAVE: args = [TransientLink {rule = 'Model', sourceElements = {s = A!ModelA}, targetElements = {}, variables = {}}, TransientLink {rule = 'Model', sourceElements = {s = A!ModelA}, targetElements = {}, variables = {}}, 't']
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.SimpleDebugger error
GRAVE: ****** END Stack Trace
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.vm.SimpleDebugger error
INFO: Execution terminated due to error (see launch configuration to allow continuation after errors).
11 juin 2008 15:10:11 org.eclipse.m2m.atl.engine.AtlLauncher launch
GRAVE: null
java.lang.RuntimeException
at org.eclipse.m2m.atl.engine.vm.SimpleDebugger.error(SimpleDebugger.java:195)
at org.eclipse.m2m.atl.engine.vm.StackFrame.printStackTrace(StackFrame.java:95)
at org.eclipse.m2m.atl.engine.vm.StackFrame.printStackTrace(StackFrame.java:87)
at


org.eclipse.m2m.atl.engine.vm.ClassNativeOperation.exec(ClassNativeOperation.java:74)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:143)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:101)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:338)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:143)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:101)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:143)
at org.eclipse.m2m.atl.engine.vm.nativelib.ASMOclAny.invoke(ASMOclAny.java:101)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.realExec(ASMOperation.java:240)
at org.eclipse.m2m.atl.engine.vm.ASMOperation.exec(ASMOperation.java:171)
at org.eclipse.m2m.atl.engine.vm.ASMInterpreter.<init>(ASMInterpreter.java:299)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:169)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:111)
at org.eclipse.m2m.atl.engine.AtlLauncher.launch(AtlLauncher.java:87)
at UmlAtlLaunch.transfoRegularVM(UmlAtlLaunch.java:86)
at UmlAtlTest.main(UmlAtlTest.java:9)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at


org.eclipse.m2m.atl.engine.vm.ClassNativeOperation.exec(ClassNativeOperation.java:69)
... 19 more

--------------------8<-----------------------------