[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.modeling.m2t] Re: [Xpand] Calling Java from Xpand

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@xxxxxxxxxxxxxxxx
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