<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>randomice.net &#187; Java</title>
	<atom:link href="http://www.randomice.net/category/all/nice-stuff/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.randomice.net</link>
	<description>by Enrico Schnepel</description>
	<lastBuildDate>Fri, 30 Jul 2010 06:58:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Copying EMF objects accross namespaces</title>
		<link>http://www.randomice.net/2008/11/copying-emf-objects-accross-namespaces/</link>
		<comments>http://www.randomice.net/2008/11/copying-emf-objects-accross-namespaces/#comments</comments>
		<pubDate>Tue, 11 Nov 2008 11:51:48 +0000</pubDate>
		<dc:creator>Enrico Schnepel</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.randomice.net/2008/11/copying-emf-objects-accross-namespaces/</guid>
		<description><![CDATA[I am currently preparing a new release for my GenGMF project. Because the new meta model contains important but incompatible changes I have migrated the GenGMF tooling to a new name space and created a migration script for converting the specific editor models. The new meta model is much smaller than the old one which [...]]]></description>
			<content:encoded><![CDATA[<p>I am currently preparing a new release for my <a href="http://gengmf.randomice.net/" >GenGMF</a> project. Because the new meta model contains important but incompatible changes I have migrated the GenGMF tooling to a new name space and created a migration script for converting the specific editor models. The new meta model is much smaller than the old one which results in smaller models &#8212; I&#8217;ve eliminated the need for the mapping elements in the templates. To make the migration as easy as possible I&#8217;ve created some helper functions to <a href="http://www.xaption.net/sap/bc/docu?name=ABAPMOVE-CORRESPONDING_SHORTREF" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.xaption.net');">move</a> <a href="http://www.cse.ohio-state.edu/~sgomori/314/langref.html#corr" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.cse.ohio-state.edu');">corresponding</a> attributes and references. Only the &#8220;real&#8221; changes in the meta model are migrated using a Xtend script.</p>
<p>To demonstrate the facilities of the <code>CrossNamespaceCopier</code> I&#8217;ve created a small meta model&#8230;</p>
<p><a href="http://www.randomice.net/files/2008/11/crossnscopierdemomm.png" ><img width='500px' src='http://www.randomice.net/files/2008/11/crossnscopierdemomm.png' alt='Demo meta model' /></a></p>
<p>As you see the <code>Class2</code> from the &#8220;<code>http://source.namespace</code>&#8221; has been eliminated in the &#8220;<code>http://target.namespace</code>&#8221; and both attributes have been moved &#8211; <code>attribute2</code> to <code>Class1</code> and <code>attribute3</code> to <code>Class3</code>. In order to migrate a model instance one has to call the <code>CrossNamespaceCopier</code> which copies the objects while migrating the name spaces according to rules previously set. <code>OtherClass</code> objects from the &#8220;<code>http://other.namespace</code>&#8221; will be copied as they are. All references and attributes which could not be automatically migrated need to copied in a small script manually. </p>
<p><code>extension CrossNamespaceCopier;</code><br />
<code></code><br />
<code>namespace::target::Class1 migrate(namespace::source::Class1 sc1)</code><br />
<code>:&nbsp;&nbsp;&nbsp;let tc1 =</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;// initialization for the copier, but the</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;// let statement needs to be in the beginning</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;crossNsInitStaticInstance()</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;&nbsp;crossNsSetupNamespaceMapping(</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"http://source.namespace",</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"http://target.namespace")</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;// the content for the tc1 variable</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;-&gt;&nbsp;&nbsp;(&nbsp;&nbsp;&nbsp;(namespace::target::Class1)</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;crossNsCopy(sc1)))</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;// skipping Class2 in source</code><br />
<code>:&nbsp;&nbsp;&nbsp;tc1.setClass3Reference(</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(namespace::target::Class3)</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc1.class2Reference.class3Reference</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.crossNsCopy())</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;// pull up attribute2</code><br />
<code>-&gt;&nbsp;&nbsp;tc1.setAttribute2(</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc1.class2Reference.attribute2)</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;// pull down attribute3</code><br />
<code>-&gt;&nbsp;&nbsp;tc1.class3Reference.setAttribute3(</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sc1.class2Reference.attribute3)</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;// uninitializing</code><br />
<code>-&gt;&nbsp;&nbsp;crossNsReleaseStaticInstance()</code><br />
<code>-&gt;&nbsp;&nbsp;tc1</code><br />
<code>;</code></p>
<p>You will find the <code>CrossNamespaceCopier</code> as well as the demo files contained in a <a href="http://www.randomice.net/files/CrossNamespaceCopier.zip" onclick="javascript:pageTracker._trackPageview('/downloads/files/CrossNamespaceCopier.zip');">zip file</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.randomice.net/2008/11/copying-emf-objects-accross-namespaces/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
