Hi Ana,
I have also applied the same logic(Implementing the hash set) for removing the duplicates.
The issue lies with converting the DocumentList to HashSet/ArrayList and then getting back the DocumentList from the JAVA collection type.
Though i have managed to do so as the service is running fine, but i am sure there is some more efficient way of doing so.
@Dingu Here is my JAVA code:
Input:
-input
—input/certInfo
-----input/certInfo[0]/certId
-----input/certInfo[0]/partnerId
-----input/certInfo[0]/ownerId
-----input/certInfo[0]/usage
Code:
IDataCursor idc = pipeline.getCursor();
try{
IDataCursor inCurs = IDataUtil.getIData(idc,“input”).getCursor();
IData certInfoList = IDataUtil.getIDataArray(inCurs,“certInfo”);
Set newSet = new HashSet();
for(IData obj : certInfoList){
String certId, partnerId, ownerId, usage;
certId = IDataUtil.getString(obj.getCursor(),"certId");
partnerId = IDataUtil.getString(obj.getCursor(),"partnerId");
ownerId = IDataUtil.getString(obj.getCursor(),"ownerId");
usage = IDataUtil.getString(obj.getCursor(),"usage");
newSet.add(new CertInfo(certId, partnerId, ownerId, usage));
}
ArrayList<CertInfo> outputArr = new ArrayList<CertInfo>(newSet);
IData[] idArr = new IData[outputArr.size()];
int i =0;
for(CertInfo ciObj : outputArr){
IData tempID = IDataFactory.create();
IDataCursor tempIDC = tempID.getCursor();
IDataUtil.put(tempIDC, "certId", ciObj.getCertId());
IDataUtil.put(tempIDC, "partnerId", ciObj.getPartnerId());
IDataUtil.put(tempIDC, "ownerId", ciObj.getOwnerId());
IDataUtil.put(tempIDC, "usage", ciObj.getUsage());
tempIDC.destroy();
//IDataUtil.append(idArr,tempID);
idArr[i] = tempID;
i++;
}
//IDataUtil.put(idc,"String1",newSet.toString());
IDataUtil.put(idc,"CertInfo",idArr);
inCurs.destroy();
}catch(Exception e){
IDataUtil.put(idc,"String1",e.toString());
}
finally{
idc.destroy();
}
Shared Code:
static class CertInfo implements Serializable{
private String certId, partnerId, ownerId, usage;
// Constructors, Getter(s)/Setter(s), Equals, Hashcode methods
}