4.2.1.2 Additional Red Flag: Customer with more than certain No. of Accounts
This example tells how to add an additional red flag, which shows the number of customers with more than a certain number of accounts.
To update, follow these steps:
- Configuration for the Number of Accounts: Instead of fixing the
value, add it as a dynamic form where Investigation Toolkit users can update if
required.
Update it as given below.
// Code snippet to add a text box, with default value 3 and then additional validation to validate the user input is a valid integer.
String textBoxMessage = "Minimum number of associated account to consider it as a red flag"; String minAccountCountString = ds.textbox(textBoxMessage, "3", textBoxMessage).trim(); int minAccountCount = 0; minAccountCount = validateTextBoxAndGetIntValue(minAccountCountString, 3, textBoxMessage);
- Add a query to get the customer IDs with more than certain number of accounts:
Add a method in
GraphPgqlQueries#getCustomerCountWithMoreThanCertainAccount()
as given below.public String getCustomerCountWithMoreThanCertainAccount( PgxGraph resultGraph, GetInfoFromGraph getInfo, Integer minAccountCount, boolean forVisibleGraph) { if (getInfo.verifyIfNodeProviderExist( List.of("Customer", "Account"), resultGraph, true, false) && getInfo.verifyIfEdgeProviderExists("Cust Has Acct", resultGraph, false)) { return "SELECT n.\"Original Id\", count(n.\"Original Id\") as count_id " + " FROM MATCH (n:Customer) - [e] -> (acct: Account) " + (forVisibleGraph ? " where id(n) in ?" : "") + " group by n.\"Original Id\" " + " having count_id > " + minAccountCount; } else { return null; } }
- To add a row in the Red flag, either modify the
IHub#getRedFlag()
method or add a new method and then call that method inside thegetRedFlag()
method.public void addRedFlag(Table report, List<String> visibleNodeList) throws DynamicFormsException { String textBoxMessage = "Minimum number of associated account to consider it as a red flag"; String minAccountCountString = ds.textbox(textBoxMessage, "3", textBoxMessage).trim(); int minAccountCount = 0; minAccountCount = validateTextBoxAndGetIntValue(minAccountCountString, 3, textBoxMessage); log("Fetching entities with more than " + minAccountCount + " accounts"); long countVisibleGraph = queryVisibleGraph(resultGraph, graphPgqlQueries.getCustomerCountWithMoreThanCertainAccount(resultGraph, (GetInfoFromGraph) getInfo,minAccountCount, true), List.of(visibleNodeList)).getRows().size(); long countCaseGraph = queryCaseGraph(resultGraph, graphPgqlQueries.getCustomerCountWithMoreThanCertainAccount(resultGraph, (GetInfoFromGraph) getInfo,minAccountCount, false)).getRows().size(); report.addRow( "Customers with more than " + minAccountCount + " account(s)", formatScore(countCaseGraph), formatScore(countVisibleGraph)); } public void getRedFlag() { ... addRedFlag(report, visibleNodeList);
// calling the method,addRedFlag()
, before printing the final statement.printStatement(report.printTable(true)); }