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.  Sorting a documentList

    Posted Mon December 05, 2011 05:34 AM

    Can someone please help me to sort a documentList based on a particular value from a field within that documentList??


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


  • 2.  RE: Sorting a documentList

    Posted Mon December 05, 2011 07:35 AM

    Hi Ganesh,

    Use the service sortDocuments service present in WmPublic to sort the document list based on the key value. Also this service allows you to sort in ascending / descending order based on the key value.

    Note: While specifying the key field name, it is sufficient to mention the field name and not the entire path.

    Regards,
    Shriraksha A N


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


  • 3.  RE: Sorting a documentList

    Posted Mon December 05, 2011 02:12 PM


  • 4.  RE: Sorting a documentList

    Posted Tue December 06, 2011 07:17 AM

    You got to implement a java service using the API functions I suppose. There is a function sortIDataArrayByKey in IDataUtil class. Just refer the Developer JAVA API docs for more information. Check if the below works in WM6.5

    / pipeline
    IDataCursor pipelineCursor = pipeline.getCursor(); 
    // documentList
    IData[]    documentList = IDataUtil.getIDataArray( pipelineCursor, "documentList" );
    String    keyname = IDataUtil.getString( pipelineCursor, "keyname" );
    String    compareType = IDataUtil.getString( pipelineCursor, "compareType" );
    
    
    try{
    if (documentList.length > 0){
    if(compareType.equals("EQUALS"))
    IDataUtil.put(pipelineCursor,"sortedDocumentList", IDataUtil.sortIDataArrayByKey(documentList,keyname,IDataUtil.COMPARE_TYPE_EQUALS,null,false));
    
    else if(compareType.equals("NUMERIC"))
    IDataUtil.put(pipelineCursor,"sortedDocumentList", IDataUtil.sortIDataArrayByKey(documentList,keyname,IDataUtil.COMPARE_TYPE_NUMERIC,null,false));
    
    else if(compareType.equals("TIME"))
    IDataUtil.put(pipelineCursor,"sortedDocumentList", IDataUtil.sortIDataArrayByKey(documentList,keyname,IDataUtil.COMPARE_TYPE_TIME,null,false));
    
    documentList = null;
    }
    
    }catch(Exception e){
    
    throw new ServiceException(e);
    }
    finally{
    
    if(pipelineCursor != null)
    pipelineCursor.destroy();
    
    }
    


    Cheers
    Guna


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