IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  selecting distinct documents from a doc list

    Posted Mon March 21, 2011 07:13 PM

    Hi,

    I have a document list as input to a flow service. There are duplicate documents in this doc list. How do I eliminate the duplicates.

    Sample input data:
    RecNo SSN Firstname Lastname Grade
    1 123 Tom Hanks 10
    2 143 Tomy Hanks 10
    3 123 Tom Hanks 10

    I want only the First and second records to be there my output document list. The filter condition should achieve what the following SQL query achieves.
    select distinct SSN, Firstname, Grade from inputdata

    Regards,
    kalravivar


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 2.  RE: selecting distinct documents from a doc list

    Posted Tue March 22, 2011 07:37 AM

    Hi kalravivar,
    Try creating a string list from your document list by concatenating all the values from the doc. list. For example you string list would be now
    123.Tom.Hanks.10
    143.Tomy.Hanks.10
    123.Tom.Hanks.10

    (I used a dot(.) to seperate the elements)

    Now pass this string list to a service which removes the duplicates. you will get service to remove duplicates from PSUtilities or any of your common services.
    After removing the duplicates again separate the string list into document list.(you can use tokenize on dots(.) to separate the elements and form a document list).

    regards,
    thanks,
    Napster


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 3.  RE: selecting distinct documents from a doc list

    Posted Tue March 22, 2011 10:51 AM

    Hi Napster,

    Thanks for providing a solution.
    I thought there is a single service something similar to ps.util.list:filterDocumentList.

    Regards,
    kalravivar


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 4.  RE: selecting distinct documents from a doc list

    Posted Fri March 25, 2011 08:06 PM

    Napster,

    What is the wm service that compares a string with a string list and checks whether the string is there in the string list or not?
    I am not able to find any in ps utilities.
    Regards,
    kalravivar


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services


  • 5.  RE: selecting distinct documents from a doc list

    Posted Mon March 28, 2011 07:45 AM

    Dear kalravivar,
    There seem to be no service in PSUtilities which does what you are asking for. Anway there is no need of comparig a string with a string list, just google for any java service which removes duplicates from a string list.

    regards,
    Napster


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 6.  RE: selecting distinct documents from a doc list

    Posted Fri April 15, 2011 01:58 PM

    Code For Eliminating duplicates from a string list:

    Create a java service – remDupFromStrList
    input/output parameters: inStrList and outStrList (Both are string lists)
    In the shared tab import the following:
    java.util.Arrays
    java.util.Hashset
    java.util.List
    java.util.Set
    --------------------Here is the code----------
    IDataCursor pipelineCursor = pipeline.getCursor();
    String inStrList = IDataUtil.getStringArray( pipelineCursor, “inStrList” );
    pipelineCursor.destroy();

    List list = Arrays.asList(inStrList);
    Set set = new HashSet(list);
    String result = new String[set.size()];
    set.toArray(result);
    IDataCursor pipelineCursor_1 = pipeline.getCursor();
    IDataUtil.put( pipelineCursor_1, “outStrList”, result);
    pipelineCursor_1.destroy();

    Cheers,
    Kalravivar


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 7.  RE: selecting distinct documents from a doc list

    Posted Fri April 15, 2011 05:38 PM

    Here are 2 other approaches to consider:

    • Sort the document list by SSN. Loop over the list, copying the record from the source list to the target list only if the SSN of the current record differs from the previous record. There are a couple of doc list sort services available. Search the forums.

    • Create a couple of Java services to use a java.util.HashSet to eliminate dupes. One service would accept the document, its key (SSN) and an optional HashSet object. It returns a HashSet object, which can be used as input to the next call. The other service would return a doc list from HashSet after all the docs have been added.


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 8.  RE: selecting distinct documents from a doc list

    Posted Tue March 27, 2012 09:09 PM

    Kalravivar,

    Will this work with documentList instead of a StringList?


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services