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
Expand all | Collapse all

Removing duplicates in doclist

  • 1.  Removing duplicates in doclist

    Posted Wed May 11, 2022 06:53 AM

    someone please provide removing duplicates in doclist

    i dont have java service for removing duplicates in my designer


    #webMethods
    #webMethods-cloud
    #webMethods-io-Integration


  • 2.  RE: Removing duplicates in doclist

    Posted Wed May 11, 2022 07:12 AM

    You need to provide more info,
    i.e. what dictates a duplicate, a keyword in a complex type, a simple string, the name of a child document etc. etc.


    #webMethods-io-Integration
    #webMethods
    #webMethods-cloud


  • 3.  RE: Removing duplicates in doclist

    Posted Wed May 11, 2022 07:58 AM

    i’m grouping with configId, im getting duplicates in child doclist


    #webMethods
    #webMethods-cloud
    #webMethods-io-Integration


  • 4.  RE: Removing duplicates in doclist

    Posted Wed May 11, 2022 08:29 AM

    Hi Akhil,

    would be interesting to learn from where this data is originally coming from and how this is aggregated into the displayed doc.
    Most likely there is an issue in the code before the doc is finally populated.

    Regards,
    Holger


    #webMethods
    #webMethods-cloud
    #webMethods-io-Integration


  • 5.  RE: Removing duplicates in doclist

    Posted Wed May 11, 2022 02:51 PM

    Are you saying that the duplicates shouldn’t be there ?
    or asking how you could write code to remove duplicates that you expect to be there ?

    That’s two different things, the former as @Holger_von_Thomsen has indicated; you will need to backtrack to identify the data that is coming into your service and also perhaps include a screenshot of the code.

    If it’s code example to clean up duplicates that you are after, then you can do this most efficiently with a java service. In which case I could post you an example here.

    regards,
    John.


    #webMethods-cloud
    #webMethods
    #webMethods-io-Integration


  • 6.  RE: Removing duplicates in doclist

    Posted Thu May 12, 2022 05:19 AM

    if there is any java service for removing duplicates records in document list … pls provide


    #webMethods-io-Integration
    #webMethods
    #webMethods-cloud


  • 7.  RE: Removing duplicates in doclist

    Posted Mon May 16, 2022 05:51 AM

    Sorry for the delay getting back to you.

    Here is a copy of a java service that I have in my own tools package

    /** 
    * The primary method for the Java service
    *
    * @param pipeline
    *            The IData pipeline
    * @throws ServiceException
    */
    public static final void removeDuplicates(IData pipeline) throws ServiceException {
    // pipeline in
    
    IDataCursor pipelineCursor = pipeline.getCursor();
    IData[] docIn = IDataUtil.getIDataArray(pipelineCursor, "docListIn");
    String searchKey = IDataUtil.getString(pipelineCursor, "key");
    
    // process
    
    List<Object> docOut = null;
    
    if (docIn != null) {					
    ArrayList<String> processedKeys = new ArrayList<String>();
    docOut = new ArrayList<Object>();
    
    for (IData doc : docIn) {
    
    IData notDupedDoc = checkForDuplicates(doc, searchKey, processedKeys);
    
    if (notDupedDoc != null)
    docOut.add(notDupedDoc);
    }
    }
    
    // pipeline out
    
    if (docOut != null)
    IDataUtil.put(pipelineCursor, "docListOut", docOut.toArray(new IData[docOut.size()]));
    
    pipelineCursor.destroy();
    }
    
    // --- <<IS-BEGIN-SHARED-SOURCE-AREA>> ---
    
    
    private static IData checkForDuplicates(IData doc, String searchKey, ArrayList<String> processedKeys) {
    
    IDataCursor docCursor = doc.getCursor();
    docCursor.home();
    
    while(docCursor.hasMoreData()) {
    docCursor.next();
    
    String key = docCursor.getKey();
    Object value = docCursor.getValue();
    
    if (searchKey != null && value instanceof String) {
    
    if (key.equals(searchKey) && !processedKeys.contains(value)) {
    
    processedKeys.add((String) value);
    return doc;
    }
    } else if (value instanceof IData) {
    if (checkForDuplicates((IData) value, searchKey, processedKeys) != null) {
    return doc;
    }
    }
    }
    
    docCursor.destroy();
    
    return null;
    }
    

    You can also download my package from here

    service is

    jc.tools.pub.idata:removeDuplicates

    regards,
    John.


    #webMethods-io-Integration
    #webMethods
    #webMethods-cloud


  • 8.  RE: Removing duplicates in doclist

    Posted Thu May 19, 2022 05:46 AM


  • 9.  RE: Removing duplicates in doclist

    Posted Thu May 26, 2022 03:38 AM

    could u plz provide what are the inputs and outputs for this code. Because I’m unable to run this code properly


    #webMethods
    #webMethods-io-Integration
    #webMethods-cloud


  • 10.  RE: Removing duplicates in doclist

    Posted Tue June 07, 2022 10:13 PM

    From the code:

    /* Input */
    IData[] docIn = IDataUtil.getIDataArray(pipelineCursor, "docListIn");
    String searchKey = IDataUtil.getString(pipelineCursor, "key");
    
    /* Output */
    IDataUtil.put(pipelineCursor, "docListOut", docOut.toArray(new IData[docOut.size()]));
    
    

    Input
    Document List/Array: docListIn
    String: key

    Output
    Document List/Array: docListOut


    #webMethods-io-Integration
    #webMethods-cloud
    #webMethods