webMethods

webMethods

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.  Java service to check Null values in a document List

    Posted Fri May 14, 2010 11:15 AM

    we have a requirement, where i need to check a document which contains documentLists as well in side and almost 50 fields,if any value is missing,i need to write a message with missing field to a Flatfile.

    if 4 or 5 fields, we can check using branch step…but out 0f 50 fields if some 20 fields are missing, then i need to collect all the 20 fields and write a message to flatfile with all the details…

    can any one suggest me how can i do this…??


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


  • 2.  RE: Java service to check Null values in a document List

    Posted Fri May 14, 2010 06:20 PM

    Hello,
    You may want to consider making a single service that returns “true” if its input is null. Then you should have a MAP step in a second service that takes each input and using the previous service as a transformer, gets the value and populates a String List. Then you can loop over the String List and if the number of “true” values is over your threshold, you can take action. Good day.

    Yemi Bedu


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


  • 3.  RE: Java service to check Null values in a document List

    Posted Fri May 14, 2010 06:28 PM

    Thanks!! if you have some sample…can you share it…


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


  • 4.  RE: Java service to check Null values in a document List

    Posted Fri May 21, 2010 07:09 PM

    Hi Prashanth,
    I have coded the below and tested it, it should give you all the fields that are either null or empty. You have to import java.util.ArrayList.

    [highlight=java]IDataCursor pipelineCursor = pipeline.getCursor();
    IData inDoc = IDataUtil.getIData(pipelineCursor,“inDoc”);
    IDataCursor inDocCursor = inDoc.getCursor();
    IData inList = IDataUtil.getIDataArray(inDocCursor,“inList”);
    IData outList = new IData[inList.length];
    ArrayList errorArrList = new ArrayList();

    for (int i=0; i<inList.length; i++){
    IDataCursor inListCursor = inList[i].getCursor();
    outList[i] = IDataFactory.create();
    IDataCursor outListCursor = outList[i].getCursor();
    while(inListCursor.next()){
    String key = inListCursor.getKey();
    String value = (String) inListCursor.getValue();
    if(value == null || value.trim().equals(“”)){
    errorArrList.add(key);
    }
    }
    if(!errorArrList.isEmpty()){
    String errorStrList = new String [errorArrList.size()];
    errorArrList.toArray(errorStrList);
    IDataUtil.put(outListCursor, “errorList”, errorStrList);
    errorArrList.clear();
    }
    outListCursor.destroy();
    inListCursor.destroy();
    }
    if(outList != null){
    IDataUtil.put(pipelineCursor, “outList”, outList);
    }
    pipelineCursor.destroy();[/highlight]
    service_signature.jpg


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


  • 5.  RE: Java service to check Null values in a document List

    Posted Sat May 22, 2010 08:44 AM


  • 6.  RE: Java service to check Null values in a document List

    Posted Sun May 23, 2010 11:50 AM

    can you export that service and send…its not working…i tried.


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


  • 7.  RE: Java service to check Null values in a document List

    Posted Mon May 24, 2010 02:28 PM

    Hi Prasanth,
    I have attached the package here. It’s created using version 7.1.2.

    Thanks
    Test.zip (6.81 KB)


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


  • 8.  RE: Java service to check Null values in a document List

    Posted Mon May 31, 2010 12:07 PM

    By “if any value is missing” you mean that the document contains all the values even if there are null ? or that missing values are not present in the document ?

    In the second way you can’t just loop over the document because the values are not present…

    An other approach is to define constraints in the properties of the values in your document: “required → true and allow null → false” where you want to check for missing values.
    Then use the “WmPublic/pub.schema:validate” service to validate your doc with the “conformsTo” option with the name of your doc.
    You can get the missing values with the “error” document created.


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