Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Mapping in/output programmatically(I don't understand how to map the in/output programmatically.)
Mapping in/output programmatically [message #1041932] Mon, 15 April 2013 19:40 Go to next message
Manuel Hegner is currently offline Manuel HegnerFriend
Messages: 4
Registered: April 2013
Junior Member
Hello,

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
Re: Mapping in/output programmatically [message #1042594 is a reply to message #1041932] Tue, 16 April 2013 16:11 Go to previous message
Alan McMorran is currently offline Alan McMorranFriend
Messages: 55
Registered: July 2009
Member
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "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 = &lt;find it in the QVTO resource&gt;</p>
<p class="p3">// something like Resource qvtoRes = new ResourceSetImpl().getResource(qvtoURI, true) should return a QVTOResource</p>
<p class="p3">EList&lt;ModelParameter&gt; params = transform.getModelParameter();</p>
<p class="p3">Map&lt;String, Integer&gt; paramIndex = new HashMap&lt;String, Integer&gt;();</p>
<p class="p3"><span class="s1">for</span> (int i=0; i&lt;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>
Previous Topic:subobjects() order of elements
Next Topic:Re: Mapping in/output programmatically
Goto Forum:
  


Current Time: Fri Apr 26 23:21:11 GMT 2024

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

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

Back to the top