Hi All,
I have
DocList
Doc
Name
Age
I want to sort this DocList using FlowService by order of Age
I can do it by java service, but i dont want that.
Thanks a lot
Hi All,
I have
DocList
Doc
Name
Age
I want to sort this DocList using FlowService by order of Age
I can do it by java service, but i dont want that.
Thanks a lot
Hi,
There is no build in service for sorting…you have to write a java service for it…or you can build on the logic in flow too
Regards,
Pradeep
Here is a sample how you can do it…
input:
itemList(document List)
keyField(String)
sortDecending(String)
output:
itemList(document List)
sorted(String)
IData[] sortedItemList = null;
// pipeline
IDataCursor pipelineCursor = pipeline.getCursor();
IData[] itemList = IDataUtil.getIDataArray( pipelineCursor, "itemList" );
String keyField = IDataUtil.getString( pipelineCursor, "keyField" );
boolean sortDescending =
(Boolean.valueOf(IDataUtil.getString( pipelineCursor,
"sortDescending" ))).booleanValue();
pipelineCursor.destroy();
if(itemList != null)
{
sortedItemList =
IDataUtil.sortIDataArrayByKey(itemList,
keyField,
IDataUtil.COMPARE_TYPE_COLLATION,
null,
sortDescending);
}
// pipeline
pipelineCursor = pipeline.getCursor();
IDataUtil.put( pipelineCursor,
"sorted", sortedItemList==null ? "false" : "true");
pipelineCursor.destroy();