Identifying object type in wM flow

Hi,
Does anybody know how to identify an object type in a flow service.

Specifically, I want to find out if an object is a document or a document list.

Shubhro

If you want just to know whether the pipeline variable is a document or documentList them may be you need to think of the having a loop on it and check to see if it repeats more than once…

if i mistook ur needs can you be more elaborate as what you are looking for…

PRY

You can’t loop over a document. So this might not help.
Thanks,
Shubhro

Are you trying to overcome the very common issue of a doc type defining a list and when a doc comes in but only has one element that a list isn’t created?

Rob,
My problem is a little different.
I am using “wm.b2b.edi.util:invoke” to call some services.
Some services return a document called MAP_OUTPUT while the others return a document list called MAP_OUTPUT.

So, depending on if the output is a Document or a Document List, I don’t need to loop over MAP_OUPTUT or I do.

Please let me know if you need some more info.
Shubhro

Rob,
Can you also tell me the solution of the problem you mentioned. That might help too.

Shubhro

I believe you can do a branch step the looks for an element of the output like /MAP_OUTPUT[0].someField. Then have a $null condition that handles the document condition and a $default condition that handles any looping that is required.

You could use a custom java service that takes an object as the input and returns the Object.getClass().getName() for any branching logic as well.

Hi spg,

What pryWM suggested is right.
Loop over the output of your flow service which in your case is MAP_OUTPUT. If it enters the loop, that means its a doument list, else it is a document. You can set a boolean variable like ‘isList’ to true or false in a map after either of the steps. Have this whole logic in one flow service. Call this to find out if its a document or document list. Let the input variable to this flow service be an object list.
Once you know what it is, either loop over it or just reference directly. This will solve your problem as I have applied the same techique in my project.

Thanks,
Rajesh

Or you can use “sizeOfList” built-in service and depending on the resultSet branch accordingly.

Rajesh,
What you have suggested above worked for me too.
Thanks,
Shubhro

Just to add to what I posted earlier, it might also be a good idea to convert the document to a document list, so that you have to code only for document list.

Hi spg,
Good that its working. But your last suggestion somehow does not fit in. Because, again you should know whether its a “document” or “documentList” to be added to your target documentList. Hope you get the point. I tried your suggestion with appendToDocumentList service. But even here you can map a source doumentList to fromList and source doucment to fromItem. Any interchange here will throw an exception.
Thus, pls. try the method I suggested. Otherwsie if you prefer java services better, try using the java.lang.ClassCastException to your advantage and derive if the input is a array or an element.

Thanks,
Rajesh

Rajesh,
Here are the steps that I did and it worked.

  1. Initialize isList to N.
  2. Loop over MAP_OUTPUT, within the loop set isList to Y.
  3. Once out of the loop, if islist is N, I call appendToDocumentList where toList is MAP_OUTPUT (document list) and fromItem is MAP_OUTPUT(document).

This makes MAP_OUTPUT a document list even if it was a document.
If MAP_OUTPUT was already a document list, it stays that way.

The rest of the logic deals with document list only.

Shubhro