Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsMapping in/output programmatically
https://www.eclipse.org/forums/index.php/mv/msg/476710/1041932/#msg_1041932
I try to execute an QVT operation programmatically. I follow the example given here.
While the eexample works perfectly for operations with one in/output it does not for operations with more. What I don't understand is why the TransformationExecutor only gets a list and gives a list back. I try to integrate QVT into a framework that gives me an unsorted list of input models with names corresponding to the ones in the qvto file. It also gives me a list of output files and the names from the corresponding output models in the qvto file.
As the TransformationExecutor only takes a list and not a Map, I see no possibility to know in which order the list given to the TransformationExecutor should be and in which files I have to save the outputs.
Could some one give me an example code of how to do that, please?
Thanks
Manuel]]>Manuel Hegner2013-04-15T19:40:30-00:00Re: Mapping in/output programmatically
https://www.eclipse.org/forums/index.php/mv/msg/476710/1042594/#msg_1042594
http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<title></title>
<meta name="Generator" content="Cocoa HTML Writer">
<meta name="CocoaVersion" content="1187.37">
<style type="text/css">
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.0px; font: 12.0px Helvetica; color: #000000}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 15.0px; font: 12.0px Helvetica; color: #000000; min-height: 14.0px}
p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px}
p.p5 {margin: 0.0px 0.0px 0.0px 12.0px; line-height: 14.0px; font: 12.0px Helvetica; color: #011892}
p.p6 {margin: 0.0px 0.0px 0.0px 12.0px; line-height: 14.0px; font: 12.0px Helvetica; color: #011892; min-height: 14.0px}
p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 14.0px; font: 12.0px Helvetica; color: #000000; min-height: 14.0px}
span.s1 {color: #931a68}
span.s2 {color: #0326cc}
span.Apple-tab-span {white-space:pre}
</style>
</head>
<body>
<p class="p1">Manuel,</p>
<p class="p2"><br></p>
<p class="p1">The order corresponds to the order in the QVTO file itself. One way around this if you don't know the order of your parameters is to load the QVTO file itself (the code itself can be loaded as a model) and locate the OperationalTransform object instance. On this OperationalTransform you can then do something like:</p>
<p class="p2"><br></p>
<p class="p3">OperationalTransform transform = <find it in the QVTO resource></p>
<p class="p3">// something like Resource qvtoRes = new ResourceSetImpl().getResource(qvtoURI, true) should return a QVTOResource</p>
<p class="p3">EList<ModelParameter> params = transform.getModelParameter();</p>
<p class="p3">Map<String, Integer> paramIndex = new HashMap<String, Integer>();</p>
<p class="p3"><span class="s1">for</span> (int i=0; i<params.size(); i++){</p>
<p class="p3"><span class="Apple-tab-span"> </span>ModelParameter p = params.get(i);</p>
<p class="p3"><span class="Apple-tab-span"> </span>String name = p.getName();</p>
<p class="p3"><span class="Apple-tab-span"> </span>paramIndex.put(name, i);</p>
<p class="p3"><span class="Apple-tab-span"> </span>// Of course you can also find out the types to see if it's in, inout, out etc.</p>
<p class="p3"><span class="Apple-tab-span"> </span>ParameterKind type;</p>
<p class="p3"><span class="Apple-tab-span"> </span><span class="s1">if</span>(p.getKind()==DirectionKind.<span class="s2">IN</span>) type = ParameterKind.<span class="s2">IN</span>;</p>
<p class="p3"><span class="Apple-tab-span"> </span><span class="s1">else</span> <span class="s1">if</span>(p.getKind()==DirectionKind.<span class="s2">INOUT</span>) type = ParameterKind.<span class="s2">INOUT</span>;</p>
<p class="p3"><span class="Apple-tab-span"> </span><span class="s1">else</span> type = ParameterKind.<span class="s2">OUT</span>;</p>
<p class="p3">}</p>
<p class="p4"><span class="Apple-tab-span"> </span></p>
<p class="p1">Alan</p>
<p class="p2"><br></p>
<p class="p1">On 2013-04-16 13:08:06 +0000, Manuel Hegner said:</p>
<p class="p2"><br></p>
<p class="p5">Hello,</p>
<p class="p6"><br></p>
<p class="p5">I try to execute an QVT operation programmatically. I follow the example given http://wiki.eclipse.org/QVTOML/Examples/InvokeInJava.</p>
<p class="p5">While the eexample works perfectly for operations with one in/output it does not for operations with more. What I don't understand is why the TransformationExecutor only gets a list and gives a list back. I try to integrate QVT into a framework that gives me an unsorted list of input models with names corresponding to the ones in the qvto file. It also gives me a list of output files and the names from the corresponding output models in the qvto file.</p>
<p class="p6"><br></p>
<p class="p5">As the TransformationExecutor only takes a list and not a Map, I see no possibility to know in which order the list given to the TransformationExecutor should be and in which files I have to save the outputs.</p>
<p class="p6"><br></p>
<p class="p5">Could some one give me an example code of how to do that, please?</p>
<p class="p6"><br></p>
<p class="p5">Thanks</p>
<p class="p5">Manuel</p>
<p class="p7"><br></p>
</body>
</html>]]>Alan McMorran2013-04-16T16:11:58-00:00