We have a Web Services connector (using REST API) implemented for a HR source with a single aggregation end point defined (getEmployees). The API does not support filtering on the endpoint itself and hence we need to read all the users.
My requirement is to be able to filter out unwanted users in the getEmployees After Operation Rule based on their externalId i.e. filter out users with non-numeric externalIds. Following is what we have implemented:
List finalList = new ArrayList();
Map updatedMapInfo = new HashMap();
if (processedResponseObject != null)
{
ArrayList list = processedResponseObject;
for (Map entry : list) {
String response = null;
if(entry != null)
{
if(entry.get("externalId").matches("\\d+") == true )
{
finalList.add(entry);
}else{
log.error(":::::Skipping the record from finalList"+ entry.get("externalId")+" "+ entry.get("userName"));
}
}
}
}
updatedMapInfo.put("data", finalList);
return updatedMapInfo;
The HR source contains around 64 records out of which we expect only 15 to be aggregated with the above logic. However, all 64 records are getting aggregated into IDN.
We do not want to filter out accounts using “account.filterstring” as we are looking at improving aggregation performance and need to filter out the accounts in the After Operation rule only.
Any ideas or pointers on what is missing or can be done differently?
I had logger attached and log statements printed at all necessary points. The “finalList” comes out correct with a size of 0 and then is being passed as updatedMapInfo. This is the case where I am trying to test an OU from which all accounts need to be filtered out.
However, I am unsure of how to further see where updatedMapInfo is getting passed and then confirm its value there.
@sonalaagrawal please try out below rule, I am not sure if you want to include numeric external ID or exclude it. I am adding the external ID if it is not matching the numeric value and removing with matches. Please make modification as per your requirement. let me know how it goes, make sure rule is attached and you should see the ccg logs to check if the rule is printing loggers.
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Map updatedMapInfo = new HashMap();
List<HashMap> finalList=new ArrayList<HashMap>();
ArrayList externalIdList = new ArrayList();
String externalID = null;
log.info("Entering example_AfterOperation_Rule_AccountAggregation Rule");
if(null != processedResponseObject)
{
Map userDataMap = new HashMap();
for(userDataMap : processedResponseObject)
{
if(null != userDataMap && !userDataMap.isEmpty() && null != userDataMap.get("externalId"))
{
log.info("Entered in if block where externalId is not null/empty");
externalID = userDataMap.get("externalId");
if (null != externalID && externalID.matches("\\d+"))
{
log.info("Entering if_block to check externalID matches numeric and remove from userDataMap");
userDataMap.remove("externalId");
}
else if(null != externalID && !externalID.matches("\\d+"))
{
log.info("Entering elseif_block to check externalID does not matches numeric then add in externalIdList");
externalIdList.add(externalID);
}
userDataMap.put("externalId", externalIdList);
}
}
finalList.add(userDataMap);
}
log.info("Exiting example_AfterOperation_Rule_AccountAggregation Rule");
updatedMapInfo.put("data", finalList);
log.info("printing updatedMapInfo before returing it" +updatedMapInfo);
return updatedMapInfo;