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