Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Xpand] Calling Java from Xpand
[Xpand] Calling Java from Xpand [message #483551] Wed, 02 September 2009 03:21 Go to next message
RefuX Zanzeebarr is currently offline RefuX ZanzeebarrFriend
Messages: 51
Registered: July 2009
Member
My source model has GUIDs in it and as part of my transformation I need
convert these GUIDs into int IDs. These int ids need to be consistent
across conversions, i.e. GUID to ID needs to be the same across multiple
runs.

I figured I would create a service I can call:
RelationshipService.getIdForGuid(String guid);


However I can't figure out how to call this service from Xpand :(

One way I think could work would be change the source model and add the
RelationshipService service and operation to that model, however I don't
want to pollute the source model with transformation concerns.

So, I'm not too sure where to go next...

Any thoughts would be wonderful!
Re: [Xpand] Calling Java from Xpand [message #483557 is a reply to message #483551] Wed, 02 September 2009 05:56 Go to previous message
ekkehard gentz is currently offline ekkehard gentzFriend
Messages: 118
Registered: July 2009
Location: rosenheim, Germany, bavar...
Senior Member

This is a multi-part message in MIME format.
--------------090201030800010707040102
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

RefuX schrieb:
> My source model has GUIDs in it and as part of my transformation I
> need convert these GUIDs into int IDs. These int ids need to be
> consistent across conversions, i.e. GUID to ID needs to be the same
> across multiple runs.
>
> I figured I would create a service I can call:
> RelationshipService.getIdForGuid(String guid);
>
>
> However I can't figure out how to call this service from Xpand :(
>
> One way I think could work would be change the source model and add
> the RelationshipService service and operation to that model, however I
> don't want to pollute the source model with transformation concerns.
>
> So, I'm not too sure where to go next...
>
> Any thoughts would be wonderful!
should be easy ... do something like this:

----------------------
a Java class:

public class RelationshipService {
public static int getID(String guid) {
return 42;
}
}

----------------
a Xtend template:

int getIdForGuid(String guid):
JAVA your.package.RelationshipService.getID(
java.lang.String);

----------
and now you can use xxx.getIdForGuid() as usual

hope it helps

ekke
--

ekke (ekkehard gentz)
independent software-architect
senior erp-consultant
eclipse | osgi | equinox | mdsd | oaw | emf | uml
max-josefs-platz 30, D-83022 rosenheim, germany
mailto:ekke@ekkes-corner.org
homepage (de): http://gentz-software.de
blog (en): http://ekkes-corner.org
twitter: @ekkescorner
skype: ekkes-corner
Steuer-Nr: 156/220/30931 FA Rosenheim, UST-ID: DE189929490


--------------090201030800010707040102
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
RefuX schrieb:
<blockquote cite="mid:h7kob8$sft$1@build.eclipse.org" type="cite">My
source model has GUIDs in it and as part of my transformation I need
convert these GUIDs into int IDs. These int ids need to be consistent
across conversions, i.e. GUID to ID needs to be the same across
multiple runs.
<br>
<br>
I figured I would create a service I can call:
RelationshipService.getIdForGuid(String guid);
<br>
<br>
<br>
However I can't figure out how to call this service from Xpand :(
<br>
<br>
One way I think could work would be change the source model and add the
RelationshipService service and operation to that model, however I
don't want to pollute the source model with transformation concerns.
<br>
<br>
So, I'm not too sure where to go next...
<br>
<br>
Any thoughts would be wonderful!
<br>
</blockquote>
should be easy ... do something like this:<br>
<br>
----------------------<br>
a Java class:<br>
<br>
public class RelationshipService {<br>
&nbsp;&nbsp;&nbsp; public static int getID(String guid) {<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return 42;<br>
&nbsp;&nbsp;&nbsp; }<br>
}<br>
<br>
----------------<br>
a Xtend template:<br>
<br>
int getIdForGuid(String guid):<br>
&nbsp;&nbsp;&nbsp; JAVA your.package.RelationshipService.getID(<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; java.lang.String);<br>
<br>
----------<br>
and now you can use xxx.getIdForGuid() as usual<br>
<br>
hope it helps<br>
<br>
ekke<br>
<div class="moz-signature">-- <br>
<p style="margin-bottom: 0cm;"> <font ,="" color="#808080"
face="Verdana, sans-serif"> <font size="4">ekke (ekkehard gentz)<br>
</font> <font size="3"> independent software-architect<br>
senior erp-consultant<br>
</font> <font size="2">eclipse | osgi | equinox | mdsd | oaw | emf |
uml<br>
max-josefs-platz 30, D-83022 rosenheim, germany<br>
<a class="moz-txt-link-freetext" href="mailto:ekke@ekkes-corner.org">mailto:ekke@ekkes-corner.org</a><br>
homepage (de): <a class="moz-txt-link-freetext" href="http://gentz-software.de">http://gentz-software.de</a><br>
blog (en): <a class="moz-txt-link-freetext" href="http://ekkes-corner.org">http://ekkes-corner.org</a><br>
twitter: @ekkescorner<br>
skype: ekkes-corner<br>
</font> <font size="1"> Steuer-Nr: 156/220/30931 FA Rosenheim, UST-ID:
DE189929490<br>
</font> </font> </p>
</div>
</body>
</html>

--------------090201030800010707040102--


ekke
independent software architect

blog: http://ekkes-corner.org
twitter: @ekkescorner
Previous Topic:[Announce] Eclipse Modeling Days
Next Topic:Dynamically call another xtend method from current xtend method
Goto Forum:
  


Current Time: Fri Apr 19 08:08:05 GMT 2024

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

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

Back to the top