IBM Sterling Transformation Extender

Sterling Transformation Extender

Come for answers, stay for best practices. All we're missing is you.


#Sterling
#Supplychain
 View Only
Expand all | Collapse all

JEXIT for creating UUID

  • 1.  JEXIT for creating UUID

    Posted 09/02/15 11:37 PM

    Originally posted by: PrriyaT


    Hi

    I am using below code to generate a UUID

    TEXT(JEXIT("java.util.UUID","randomUUID"))

    It is generating and output like- Ref.20305761 instaed of something like 322c2e7e-b8f3-43b5-9cfc-20c2b50d1fb7.

    Could somebody help on how to go about achieving this?

    Thanks!


    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 2.  Re: JEXIT for creating UUID

    Posted 09/08/15 04:03 AM
      |   view attached

    Originally posted by: paul.brett


    It seems like your Java code is returning some sort of memory location reference.  Without posting your Java code, I'm not sure if we can help you.

    I enclose a working example.

    Thank-you.

    Paul.

    Follow me on Twitter


    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange

    Attachment(s)

    zip
    UUID.zip   6 KB 1 version


  • 3.  Re: JEXIT for creating UUID

    Posted 09/08/15 04:14 AM

    Originally posted by: paul.brett


    By the way.  Great topic.

    It really got me thinking, and I got to put my Java hat on for a change.

    Thank-you.

    Paul.

    Follow me on Twitter


    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange


  • 4.  Re: JEXIT for creating UUID

    Posted 04/13/16 10:00 PM

    Originally posted by: johnxp


    Hi Paul,

    Can you guide me how to make the JEXIT work in WTX design studio and launcher?

    I have added jar in dtx.ini and CLASSPATH, but still not working.

    Thanks

     


    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 5.  Re: JEXIT for creating UUID

    Posted 09/10/15 06:51 AM

    Originally posted by: PrriyaT


    Hi Paul

    I believe the direct JEXIT call is not able to achive the toString conversion.

    Thanks much for a working solution!

     


    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange


  • 6.  Re: JEXIT for creating UUID

    Posted 04/13/16 10:40 PM
      |   view attached

    Originally posted by: paul.brett


    I re-tested this example in Design Studio, Command Server and Launcher.  It worked in all environments.

    Did you create a JAR file from the Test1.java example?  I enclose mine for convenience.

    My dtx.ini file has:

    [External Jar Files]
    jar1=Y:\JavaProject1\testjexit.jar

    Thank-you.

    Paul.

    Follow me on Twitter


    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange

    Attachment(s)

    jar
    testjexit.jar   847 B 1 version


  • 7.  Re: JEXIT for creating UUID

    Posted 04/13/16 11:23 PM

    Originally posted by: johnxp


    Yes, your example is working fine in my environment, but mine is not.

     

    May I know which version you are using (JVM and WTX)?

    I remembered last time I was having a Java version issue.

     


    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender
    #DataExchange


  • 8.  Re: JEXIT for creating UUID

    Posted 04/13/16 11:46 PM

    Originally posted by: paul.brett


    C:\IBM\WebSphereTX8.3\java\bin>java -version
    java version "1.6.0"
    Java(TM) SE Runtime Environment (build pwi3260sr15-20131017_01(SR15))
    IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Windows 7 x86-32 jvmwi3260sr15-201310
    16_170922 (JIT enabled, AOT enabled)
    J9VM - 20131016_170922
    JIT  - r9_20130920_46510ifx2
    GC   - GA24_Java6_SR15_20131016_1337_B170922)
    JCL  - 20131015_01

     

    I am building the JAR file using Design Studio.

    Thank-you.

    Paul.

    Follow me on Twitter


    #DataExchange
    #IBM-Websphere-Transformation-Extender
    #IBMSterlingTransformationExtender


  • 9.  Re: JEXIT for creating UUID

    Posted 04/14/16 02:19 AM

    Originally posted by: johnxp


    Thanks Paul.

    I managed to make it work, but not sure what happened, maybe it's the version issue.

     

    By the way, do you know how to pass more than 2 parameters to Java class in JEXIT?


    #IBMSterlingTransformationExtender
    #IBM-Websphere-Transformation-Extender
    #DataExchange


  • 10.  Re: JEXIT for creating UUID

    Posted 04/14/16 02:45 AM

    Originally posted by: paul.brett


    The JEXIT() examples with the product show:

    =VALID(JEXIT("TestJExit", "Concat", "JExit ", "Example"), FAIL(LASTERRORMSG()))

    Thank-you.

    Paul.

    Follow me on Twitter


    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 11.  Re: JEXIT for creating UUID

    Posted 04/14/16 02:55 AM

    Originally posted by: johnxp


    Hi Paul,

    I am referring below the sample:

    =VALID(JEXIT("JavaClass", "Function", "Param1 ", "Param2"), FAIL(LASTERRORMSG()))

    How about if I need to pass more than 2 params to the function? (Param3, Param4,...)


    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 12.  Re: JEXIT for creating UUID

    Posted 04/14/16 03:14 AM

    Originally posted by: paul.brett


    http://www.ibm.com/support/knowledgecenter/SSVSD8_8.4.1/com.ibm.websphere.dtx.funcexp.doc/references/r_funcs_express_jexit.htm?lang=en

    It seems two is the maximum.

    You could pass all of your parameters in 1, and then split inside the Java code:

    =VALID(JEXIT("TestJExit", "Concat", "Param1|Param2|Param3|Param4 "), FAIL(LASTERRORMSG()))

    Thank-you.

    Paul.

    Follow me on Twitter


    #IBM-Websphere-Transformation-Extender
    #DataExchange
    #IBMSterlingTransformationExtender


  • 13.  Re: JEXIT for creating UUID

    Posted 04/14/16 03:52 AM

    Originally posted by: Ejay


    Hi ,

    One example of parsing and splitting a parameter here ;

    https://www.ibm.com/developerworks/community/forums/html/topic?id=e05068cc-997a-4204-8349-6f2eaddea76e&ps=25

    =VALID(JEXIT("EJ.TestCases.CalculateTimeZone","getTimeZone",DATETOTEXT(CURRENTDATETIME("CCYYMMDDHH24MMSS+/-ZZ:ZZ")),"yyyyMMddHHmmssXXX!yyyy-MM-dd'T'HH:mm:ss.SSSXXX"),

     FAIL(LASTERRORMSG()+LASTERRORCODE())))

    The second argument is delimited by a ! that we parse and split in the javacode .

     

    import java.text.DateFormat;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    import java.util.TimeZone;
    public class CalculateTimeZone {
        public static String getTimeZone(String zone,String zone2) {
             //reset date
            Date date = null;
            String dateout =null;
                    String part1 = null; 
                    String part2 = null; 
              try {
                              String[] parts = zone2.split("!");
                    part1 = parts[0]; 
                    part2 = parts[1];
            DateFormat df = new SimpleDateFormat(part1);
            DateFormat dfout = new SimpleDateFormat(part2);
                date = df.parse(zone);
                dateout = dfout.format(date);
                return dateout;
           }
            catch (ParseException pe) {
                pe.printStackTrace();
            }
            return "Error parsing or formatting date.\r\nInput date given "+zone+"\r\nInput and output Format given : "+zone2+"\r\nParsed input format ="+part1+"\r\nParsed output format="+part2;
                    
    }
    }
    


    Hope this Help .

     

    Ej

     


    #IBMSterlingTransformationExtender
    #DataExchange
    #IBM-Websphere-Transformation-Extender


  • 14.  Re: JEXIT for creating UUID

    Posted 04/14/16 04:03 AM

    Originally posted by: johnxp


    Great multiple parameters example! Thanks.


    #IBM-Websphere-Transformation-Extender
    #DataExchange
    #IBMSterlingTransformationExtender