Advertisement
Advertisement
| 08.07.2008 at 03:57PM PDT, ID: 23631298 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848: 849: 850: 851: 852: 853: 854: 855: 856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866: 867: 868: 869: 870: 871: 872: 873: 874: 875: 876: 877: 878: 879: 880: 881: 882: 883: 884: 885: 886: 887: 888: 889: 890: 891: 892: 893: 894: 895: 896: 897: 898: 899: 900: 901: 902: 903: 904: 905: 906: 907: 908: 909: 910: 911: 912: 913: 914: 915: 916: 917: 918: 919: 920: 921: 922: 923: 924: 925: 926: 927: 928: 929: 930: 931: 932: 933: 934: 935: 936: 937: 938: 939: 940: 941: 942: 943: 944: 945: 946: 947: 948: 949: 950: 951: 952: 953: 954: 955: 956: 957: 958: 959: 960: 961: 962: 963: 964: 965: 966: 967: 968: 969: 970: 971: 972: 973: 974: 975: 976: 977: 978: 979: 980: 981: 982: 983: 984: 985: 986: 987: 988: 989: 990: 991: 992: 993: 994: 995: 996: 997: 998: 999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287: 1288: 1289: 1290: 1291: 1292: 1293: 1294: 1295: 1296: 1297: 1298: 1299: 1300: 1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316: 1317: 1318: 1319: 1320: 1321: 1322: 1323: 1324: 1325: 1326: 1327: 1328: 1329: 1330: 1331: 1332: 1333: 1334: 1335: 1336: 1337: 1338: 1339: 1340: 1341: 1342: 1343: 1344: 1345: 1346: 1347: 1348: 1349: 1350: 1351: 1352: 1353: 1354: 1355: 1356: 1357: 1358: 1359: 1360: 1361: 1362: 1363: 1364: 1365: 1366: 1367: 1368: 1369: 1370: 1371: 1372: 1373: 1374: 1375: 1376: 1377: 1378: 1379: 1380: 1381: 1382: 1383: 1384: 1385: 1386: 1387: 1388: 1389: 1390: 1391: 1392: 1393: 1394: 1395: 1396: 1397: 1398: 1399: 1400: 1401: 1402: 1403: 1404: 1405: 1406: 1407: 1408: 1409: 1410: 1411: 1412: 1413: 1414: 1415: 1416: 1417: 1418: 1419: 1420: 1421: 1422: 1423: 1424: 1425: 1426: 1427: 1428: 1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439: 1440: 1441: 1442: 1443: 1444: 1445: 1446: 1447: 1448: 1449: 1450: 1451: 1452: 1453: 1454: 1455: 1456: 1457: 1458: 1459: 1460: 1461: 1462: 1463: 1464: 1465: 1466: 1467: 1468: 1469: 1470: 1471: 1472: 1473: 1474: 1475: 1476: 1477: 1478: 1479: 1480: 1481: 1482: 1483: 1484: 1485: 1486: 1487: 1488: 1489: 1490: 1491: 1492: 1493: 1494: 1495: 1496: 1497: 1498: 1499: 1500: 1501: 1502: 1503: 1504: 1505: 1506: 1507: 1508: 1509: 1510: 1511: 1512: 1513: 1514: 1515: 1516: 1517: 1518: 1519: 1520: 1521: 1522: 1523: 1524: 1525: 1526: 1527: 1528: 1529: 1530: 1531: 1532: 1533: 1534: 1535: 1536: 1537: 1538: 1539: 1540: 1541: 1542: 1543: 1544: 1545: 1546: 1547: 1548: 1549: 1550: 1551: 1552: 1553: 1554: 1555: 1556: 1557: 1558: 1559: 1560: 1561: 1562: 1563: 1564: 1565: 1566: 1567: 1568: 1569: 1570: 1571: 1572: 1573: 1574: 1575: 1576: 1577: 1578: 1579: 1580: 1581: 1582: 1583: 1584: 1585: 1586: 1587: 1588: 1589: 1590: 1591: 1592: 1593: 1594: 1595: 1596: 1597: 1598: 1599: 1600: 1601: 1602: 1603: 1604: 1605: 1606: 1607: 1608: 1609: 1610: 1611: 1612: 1613: 1614: 1615: 1616: 1617: 1618: 1619: 1620: 1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629: 1630: 1631: 1632: 1633: 1634: 1635: 1636: 1637: 1638: 1639: 1640: 1641: 1642: 1643: 1644: 1645: 1646: 1647: 1648: 1649: 1650: 1651: 1652: 1653: 1654: 1655: 1656: 1657: 1658: 1659: 1660: 1661: 1662: 1663: 1664: 1665: 1666: 1667: 1668: 1669: 1670: 1671: 1672: 1673: 1674: 1675: 1676: 1677: 1678: 1679: 1680: 1681: 1682: 1683: 1684: 1685: 1686: 1687: 1688: 1689: 1690: 1691: 1692: 1693: 1694: 1695: 1696: 1697: 1698: 1699: 1700: 1701: 1702: 1703: 1704: 1705: 1706: 1707: 1708: 1709: 1710: 1711: 1712: 1713: 1714: 1715: 1716: 1717: 1718: 1719: 1720: 1721: 1722: 1723: 1724: 1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732: 1733: 1734: 1735: 1736: 1737: 1738: 1739: 1740: 1741: 1742: 1743: 1744: 1745: 1746: 1747: 1748: 1749: 1750: 1751: 1752: 1753: 1754: 1755: 1756: 1757: 1758: 1759: 1760: 1761: 1762: 1763: 1764: 1765: 1766: 1767: 1768: 1769: 1770: 1771: 1772: 1773: 1774: 1775: 1776: 1777: 1778: 1779: |
public class Rc_PGMmodel extends Rc_baseModel {
public static final String MODULE_SERVICE_CODE = "DADM05";
// These columns are set by rowProcessor in Rc_ModelsDataHelper
// and have no meaning otside of this module
public static final String COL_SUGGESTED_HAT = "SUGGESTED_HAT";
public static final String COL_READ_ONLY_FLAG = "READ_ONLY_FLAG";
public static final String COL_COMMENT_ON_CHANGE = "COMMENT_ON_CHANGE";
public static final String COL_CUST_CATEGORY = "CUST_CATEGORY";
// Restricts number of accounts per page
public static final int ACCOUNTS_NUMBER_PER_PAGE = 50;
public static ArrayList mLS_HATS_ADD = new ArrayList();
/** This date is used to set default start date - depends on DADM config */
//private static String DEFAULT_START_DATE = null;
/** Default end date is current calendar date */
//private static String DEFAULT_END_DATE = null;
// References to the record's sructure in the PAGE_1.PAGINATED_LIST_1
public static final int iposMODIFY_ACCOUNT = 0;
public static final int iposACCT_SUN = 1;
public static final int iposACCT_NUMBER = 2;
public static final int iposACCT_LAT = 4;
public static final int iposPREVIOUS_HAT = 5;
public static final int iposSUGGESTED_HAT = 6;
public static final int iposCOMMENT_ON_CHANGE = 7;
public static final int iposCUST_CATEGORY = 11;
static final String ACTIVITY_TOTAL = "ACTIVITY_TOTAL";
static final String TRX_COUNT_TOTAL = "TRX_COUNT_TOTAL";
static final String CONSIDER_MONTH = "CONSIDER_MONTH";
static final String ACTIVITY_MIN = "ACTIVITY_MIN";
static final String ACTIVITY_MAX = "ACTIVITY_MAX";
static final String ACTIVITY_AVER = "ACTIVITY_AVER";
static final String PERIOD_NAME = "PERIOD_NAME";
static final BigDecimal BD_ZERO = new BigDecimal(0);
static final BigDecimal BD_MIN1 = new BigDecimal(-1);
static {
Calendar CAL_start = Rc_ValidatorUtils.getCurrentAppDate();
//DEFAULT_END_DATE = Rc_DateUtils.calendarToString(CAL_start,
// Rc_Symbols.CONSTS.DATE_FORMAT_FOR_CALENDAR);
CAL_start.add(Calendar.YEAR, -10);
//DEFAULT_START_DATE = Rc_DateUtils.calendarToString(CAL_start,
// Rc_Symbols.CONSTS.DATE_FORMAT_FOR_CALENDAR);
mLS_HATS_ADD.add("UNKNOWN|Default HAT");
mLS_HATS_ADD.add("SMBCBR|SMBC Branch");
mLS_HATS_ADD.add("SMBCHO|SMBC Head Office");
} // @
/**
*
* @author A V Durga Prasad
* @date 28 Jul 2008
* @since : Version
* @param pRequest
* @return
* @throws Rc_BaseException
* @Description :
*/
public static int init ( HttpServletRequest pRequest) throws Rc_BaseException {
HashMap <String, Object> nHM_baseForm = new HashMap <String, Object>();
Rc_NotificationsListModel.init (pRequest, nHM_baseForm, MODULE_SERVICE_CODE );
return initPage1 (nHM_baseForm);
} //#
/**
* Initializes page#1 - criteria for accounts selection.
* If/when invoked re-sets all fields on the page#1 to their
* default values.
*
* @param pHM_baseForm
* @return iFlag (@see Rc_Symbols.FLAGS)
*/
@SuppressWarnings("unchecked")
public static int initPage1 ( HashMap <String, Object> pHM_baseForm ) {
pHM_baseForm.remove(ERRORS);
resetEntriesOnPage(pHM_baseForm, PAGE_1, true);
setEntryValue(pHM_baseForm, PAGE_1, PARAM_6, ITEM_SELECTED, "");
// priorly DEFAULT_START_DATE
setEntryValue(pHM_baseForm, PAGE_1, PARAM_7, ITEM_SELECTED, "");
// priorly DEFAULT_END_DATE
return Rc_Symbols.FLAGS.iACTION_OK;
} //#
/**
* Executes search in the SS_ACCOUNTS accordingly to the criteria set
* in the page#1.
*
* If search returns no values - sets error in the page#1, otherwise -
*
* @param pHM_baseForm
* @return i_ret see Rc_Symbols#FLAGS
*/
public static int doPage1 (HashMap <String, Object> pHM_baseForm ) {
pHM_baseForm.remove(ERRORS);
pHM_baseForm.remove(INF_MESSAGE);
int i_ret = Rc_Symbols.FLAGS.iACTION_OK;
pHM_baseForm.put(Ri_Logging.EVENT.ACTION_CODE, Ri_Logging.ACTION.INQR);
pHM_baseForm.put(Ri_Logging.EVENT.DESCRIPTION, Ri_Logging.DESCRIPTION.INQR_PGM);
HashMap nHM_qParams = (HashMap) getEntryValue( pHM_baseForm, PAGE_1,
PAGINATED_LIST_1, PAGINATED_LIST.QUERY_PARAMS);
if (nHM_qParams == null) nHM_qParams = new HashMap();
nHM_qParams.put(PAGINATED_LIST.ROWS_ON_PAGE, ACCOUNTS_NUMBER_PER_PAGE);
setEntryValue( pHM_baseForm, PAGE_1, PAGINATED_LIST_1, PAGINATED_LIST.QUERY_PARAMS,
nHM_qParams);
try {
i_ret = Rc_InquiryHelper.doSearch(pHM_baseForm, MODULE_SERVICE_CODE);
} catch (Rc_BaseException e) {
addErrorAndLogException(pHM_baseForm, e, "Failed select accounts for PGM.");
i_ret = Rc_Symbols.FLAGS.iERROR_VALIDATION;
}
int i_rowsCount = Rc_StringUtils.getInt((String) getEntryValue(pHM_baseForm,
PAGE_1, PAGINATED_LIST_1, PAGINATED_LIST.TOTAL_ROWS_COUNT), -1);
if (i_rowsCount < 1) {
i_ret = Rc_Symbols.FLAGS.iERROR_VALIDATION;
}
return i_ret;
} //#
/**
* Re-sets Params of the Screen#1
*
* PARAM_1 Tran.Code <= empty string
* PARAM_2 Tran.Descr <= empty string
* PARAM_3 DR/CR <= Any
* PARAM_4 Trans.Type <= Any
*
* @param pHM_baseForm
* @return i_flag
*/
public static int resetPage1(HashMap pHM_baseForm) {
pHM_baseForm.remove(ERRORS);
pHM_baseForm.remove(MODE);
resetEntriesOnPage(pHM_baseForm, PAGE_1, false);
return Rc_Symbols.FLAGS.iACTION_OK;
} //#
/**
* Checks out status of process running against particular
* Paginated list in the separate thread.
*
* Returns 0 when completed
* 1 while working
* @param pHM_baseForm
* @param pStr_pageID
* @param pStr_listName
* @return i_flag
*/
public static int getPGprocessState (HashMap <String, Object> pHM_baseForm,
String pStr_pageID, String pStr_listName) {
return getThreadedProcessState(pHM_baseForm, pStr_pageID, pStr_listName);
} //#
/**
* Initializes page#2 - accounts activity details
* This page does not contain active element - only button "Close"
*
* @param pHM_baseForm
* @return iFlag (Always OK @see Rc_Symbols.FLAGS)
*/
@SuppressWarnings("unchecked")
public static int getActivityStats ( HashMap <String, Object> pHM_baseForm ) {
pHM_baseForm.remove(ERRORS);
final String Str_serviceCode = MODULE_SERVICE_CODE + "a";
pHM_baseForm.put(SERVICE_CODE, Str_serviceCode);
int i_ret = Rc_Symbols.FLAGS.iACTION_OK;
try {
renderPage2(Rc_NotificationsListModel.getPagesConfig(),
pHM_baseForm, Str_serviceCode, PAGE_2);
} catch (Rc_DataException e) {
addErrorMessage(pHM_baseForm, 12009,
new String[] {"Failed buiid page#2"});
return Rc_Symbols.FLAGS.iERROR_VALIDATION; // ###
}
String Str_key = null;
String Str_errMsg = null;
try {
setPageNumber(pHM_baseForm, Str_serviceCode);
// Gets key to the account as SUNID|ACCT_NUMBER from
// the PAGE_1.PARAM_1
Str_key = ((String) getEntryValue(pHM_baseForm, PAGE_1, PARAM_1, ITEM_SELECTED)).trim();
if (Rc_StringUtils.nullOrEmpty(Str_key)) {
addErrorMessage(pHM_baseForm, 11002);
i_ret = Rc_Symbols.FLAGS.iERROR_VALIDATION;
} else {
HashMap <String, Object> nHM_qParams = new HashMap <String, Object>();
String[] Stra_keys = Rc_StringUtils.toArray(Str_key, "|");
if (Rc_CollectionUtils.elemNum(Stra_keys) == 2) {
nHM_qParams.put(Ri_SQL.SS_ACCOUNTS.ACCT_SUN,Stra_keys[0].trim());
nHM_qParams.put(Ri_SQL.SS_ACCOUNTS.ACCT_NUMBER, Stra_keys[1].trim());
// TODO - check out logging settings
pHM_baseForm.put(Ri_Logging.EVENT.REQ_PARAMETERS,
Rc_CollectionUtils.MapToString(nHM_qParams, ":", "|"));
// Retrieves data and propagate data in the PAGE_2
// Rc_Logger.logMessage(".............retrieve account activity");
retrieveAccountActivity(pHM_baseForm, Stra_keys[0].trim(), Stra_keys[1].trim());
} else {
addErrorMessage(pHM_baseForm, 11002);
i_ret = Rc_Symbols.FLAGS.iERROR_VALIDATION;
}
}
} catch (Rc_BaseException ex) {
int i_excID = ex.getExcID();
Str_errMsg = ex.getUserMessage();
if (i_excID == 336) {
i_ret = Rc_Symbols.FLAGS.iERROR_VALIDATION;
addErrorMessage(pHM_baseForm, "accnt.err.inv.number",
new String[] { Str_key});
} else if (i_excID == 303){
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL;
addErrorMessage(pHM_baseForm, 303, ex.getExcParams());
} else if (i_excID == 337) {
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL;
addErrorMessage(pHM_baseForm, 337);
} else if (i_excID == 825) {
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL;
addErrorMessage(pHM_baseForm, 825);
} else {
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL;
addErrorMessage(pHM_baseForm, 10001);
}
} catch (Exception ex) {
Str_errMsg = ex.getMessage();
addErrorMessage(pHM_baseForm, UNEXP_ERROR_CODE, new String[] {
String.valueOf(Rc_Symbols.DEFAULTS.iUNEXPECTED_EXCEPTION_CODE), "(" + Str_errMsg + ")"});
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL;
}
// TODO TBR
if (i_ret != 0) {
Rc_Logger.logMessage("Errors:\n" + Rc_CollectionUtils.ListToString(
(ArrayList) pHM_baseForm.get(ERRORS)), Rc_Symbols.LOG_LEVEL.INFO);
}
//TODO - check out Logging parameters
pHM_baseForm.put(Ri_Logging.EVENT.ACTION_CODE, Ri_Logging.ACTION.VITM);
pHM_baseForm.put(Ri_Logging.EVENT.DESCRIPTION, Ri_Logging.DESCRIPTION.VITM_ACCT);
logEvent(pHM_baseForm, i_ret, System.currentTimeMillis());
return i_ret;
} //#
/**
* Sets pointer onto requested page and invokes paginated list
* processor. If data were already fetched - just re-sets pointer,
* otherwise fetches them from the database.
*
* @param HM_baseForm
* @param pStr_pageID
* @param Str_pgListRQnum
*
* @return <code>true</code> on success
* <code>false</code> on error
*/
@SuppressWarnings("unchecked")
public static boolean getPageFromPaginatedList (HashMap <String, Object> pHM_baseForm,
String pStr_pageID, String pStr_pgListRQnum) {
return Rc_InquirySearchData.getSearchResultsPage (pHM_baseForm,
pStr_pageID, PAGINATED_LIST_1, pStr_pgListRQnum);
} //#
/**
* Loops through all pages of paginated PAGE_1.PgList_1
* - on success moves invormation to the Page3 for review.
* @param pHM_baseForm
* @return i_flag (see Rc_Symbols#FLAGS)
*/
public static int applyPage1 (HashMap pHM_baseForm) {
int i_ret = Rc_Symbols.FLAGS.iACTION_OK;
pHM_baseForm.remove(ERRORS);
HashMap nHM_resps = (HashMap)
getEntryValue(pHM_baseForm, PAGE_1, PAGINATED_LIST_1, PAGINATED_LIST.RESPONSES);
if (Rc_CollectionUtils.elemNum(nHM_resps) < 1) {
addErrorMessage(pHM_baseForm, 12009,
new String[] {"No responces found in PgList1 to Analyze"});
return Rc_Symbols.FLAGS.iERROR_VALIDATION; // ###
}
HashMap nHM_respsPG = new HashMap();
ArrayList nLS_pagePG = null;
ArrayList nLS_errors = new ArrayList();
Iterator iter = nHM_resps.entrySet().iterator();
String Str_ppg = null;
int i_sizePG = (Integer) getEntryValue(pHM_baseForm, PAGE_1, PAGINATED_LIST_1,
PAGINATED_LIST.ROWS_ON_PAGE);
int i_rowPG = 0;
int i_sizeP = 0;
int i_errPP = 0;
int i_errT = 0;
int i_pagePG= 1;
while (iter.hasNext()) {
Map.Entry C_Entry = (Entry) iter.next();
ArrayList nLS_page = (ArrayList) C_Entry.getValue();
i_sizeP = Rc_CollectionUtils.elemNum(nLS_page);
if (i_sizeP < 1) continue; // =>>
i_errPP = 0;
for (int i_x = 0; i_x < i_sizeP; i_x++) {
ArrayList nLS_row = (ArrayList) nLS_page.get(i_x);
if (((String) nLS_row.get(iposMODIFY_ACCOUNT)).equals("1")) {
if (Rc_StringUtils.nullOrEmpty( (String) nLS_row.get(iposCOMMENT_ON_CHANGE))) {
i_errPP++ ;
}
if ( i_errT == 0) {
if (i_rowPG == 0) nLS_pagePG = new ArrayList();
ArrayList nLS_new = copyRowContent(nLS_row);
if (nLS_new == null) continue; // =>>
nLS_pagePG.add(nLS_new);
i_rowPG++ ;
if (i_rowPG == (i_sizePG -1)) {
i_rowPG = 0;
nHM_respsPG.put(i_pagePG, nLS_pagePG);
i_pagePG++ ;
}
}
}
} // == for All rows in paginated list page
if (i_errPP > 0) {
nLS_errors.add (Str_ppg + "[" + String.valueOf(i_errPP) + "]");
i_errT += i_errPP;
}
} //== All Pages of paginated list
if (i_rowPG > 0) {
nHM_respsPG.put(i_pagePG, nLS_pagePG);
}
if (i_rowPG == 0 && i_pagePG == 1) {
addErrorMessage(pHM_baseForm,"dadm.pgm.modified.none");
return Rc_Symbols.FLAGS.iERROR_VALIDATION; // ###
}
if (i_errT > 0) {
addErrorMessage(pHM_baseForm,"dadm.pgm.comments.missed",
new String[] {Rc_CollectionUtils.ListToDelimitedString(nLS_errors, ", ", true)});
return Rc_Symbols.FLAGS.iERROR_VALIDATION; // ###
} else {
// Initialize page 3 and place paginated list content PAGE_3.pgList1
String Str_serviceCode = MODULE_SERVICE_CODE + "b";
pHM_baseForm.put(SERVICE_CODE, Str_serviceCode);
try {
if (pHM_baseForm.get(PAGE_3) == null) {
renderPage2(Rc_NotificationsListModel.getPagesConfig(),
pHM_baseForm, Str_serviceCode, PAGE_3);
} else {
purgePage(pHM_baseForm, PAGE_3);
}
setPageNumber(pHM_baseForm, Str_serviceCode);
setEntryValue(pHM_baseForm, PAGE_3, PAGINATED_LIST_1, PAGINATED_LIST.RESPONSES,
nHM_respsPG);
setEntryValue(pHM_baseForm, PAGE_3, PAGINATED_LIST_1, PAGINATED_LIST.ACTIVE_RESPONSE, 1);
} catch (Rc_BaseException e) {
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL;
addErrorAndLogException(pHM_baseForm, e, "12009",
new String[] {"Failed initialize Page3"});
}
}
return i_ret;
} //#
/**
* Invoked when button [Calculate HAT] is clicked on.
*
* To be started in parallel thread and presented with progress bar.
*
* Loops through current active page of paginated list
* and calculate HAT accordingly to the actual activity.
*
* @param pHM_baseForm
* @return i_ret
*/
public static int calculateHATs (HashMap pHM_baseForm) {
// System.out.println("................calculateHATs....button pressed");
int i_ret = Rc_Symbols.FLAGS.iACTION_OK;
pHM_baseForm.remove(ERRORS);
pHM_baseForm.remove(INF_MESSAGE);
try {
@SuppressWarnings("unused")
// Legitimately unused - because this syntax starts new thread.
CalculateHATonPage C_calcHAT = new CalculateHATonPage( pHM_baseForm);
} catch (Rc_DataException e) {
addErrorAndLogException(pHM_baseForm, e,
"Failed start HAT calculation in separate Thread.");
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL;
}
return i_ret;
} //#
/**
* For 1st run - copies all PgList_1 content into PgList_2
* If it has been done - does nothing.
*
* @param pHM_baseForm
* @return i_ret
*/
public static int doPage3export (HashMap pHM_baseForm) {
int i_ret = Rc_Symbols.FLAGS.iACTION_OK;
HashMap nHM_respsPG2 = (HashMap) getEntryValue(pHM_baseForm, PAGE_3, PAGINATED_LIST_2,
PAGINATED_LIST.RESPONSES);
if (Rc_CollectionUtils.elemNum(nHM_respsPG2) > 0) {
return i_ret; // ###
}
nHM_respsPG2 = new HashMap();
HashMap nHM_respsPG1 = (HashMap)
getEntryValue(pHM_baseForm, PAGE_3, PAGINATED_LIST_1, PAGINATED_LIST.RESPONSES);
ArrayList nLS_pagePG2 = new ArrayList();
Iterator iter = nHM_respsPG1.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry C_Entry = (Entry) iter.next();
ArrayList nLS_page = (ArrayList) C_Entry.getValue();
nLS_pagePG2.addAll(nLS_page);
} // all pages of PgList_1
nHM_respsPG2.put(1, nLS_pagePG2);
setEntryValue(pHM_baseForm, PAGE_3, PAGINATED_LIST_2, PAGINATED_LIST.RESPONSES, nHM_respsPG2);
setEntryValue(pHM_baseForm, PAGE_3, PAGINATED_LIST_2, PAGINATED_LIST.ACTIVE_RESPONSE, 1);
return i_ret;
} //#
/**
* Applies changes listed on Page3 to the database.
* Sets status string into PAGE_4
*
* @param pHM_baseForm
* @return i_ret
*/
public static int doPage3 (HashMap pHM_baseForm) {
int i_ret = Rc_Symbols.FLAGS.iACTION_OK;
// == Create Page_4 with confirmation message
try {
if (pHM_baseForm.get(PAGE_4) == null) {
renderPage2(Rc_NotificationsListModel.getPagesConfig(), pHM_baseForm,
MODULE_SERVICE_CODE + "c", PAGE_4);
}
} catch (Rc_BaseException e) {
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL;
addErrorAndLogException(pHM_baseForm, e, "12009", new String[] {"Failed initialize Page4"});
}
try {
@SuppressWarnings("unused")
// Legitimately unused - because this syntax starts new thread.
UpdateHATforList C_updHAT = new UpdateHATforList(pHM_baseForm);
String Str_serviceCode = MODULE_SERVICE_CODE + "c";
pHM_baseForm.put(SERVICE_CODE, Str_serviceCode);
setPageNumber(pHM_baseForm, Str_serviceCode);
} catch (Rc_BaseException e) {
addErrorAndLogException(pHM_baseForm, e,
"Failed start HAT update in separate Thread.");
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL; // ###
}
return i_ret;
} //#
/**
* Cancels applying changes from Page_3 - they all discarded.
* Sets status string into PAGE_4
*
* @param pHM_baseForm
* @return i_ret
*/
public static int cancelPage3 (HashMap pHM_baseForm) {
int i_ret = Rc_Symbols.FLAGS.iACTION_OK;
// == Create Page_4 with message on form cancellation
try {
if (pHM_baseForm.get(PAGE_4) == null) {
renderPage2(Rc_NotificationsListModel.getPagesConfig(), pHM_baseForm,
MODULE_SERVICE_CODE + "c", PAGE_4);
}
String Str_serviceCode = Rc_PGMmodel.MODULE_SERVICE_CODE + "c";
pHM_baseForm.put(Ri_formFields.SERVICE_CODE, Str_serviceCode);
Rc_baseModel.setPageNumber(pHM_baseForm, Str_serviceCode);
Rc_baseModel.setEntryValue( pHM_baseForm, Ri_formFields.PAGE_4,
Ri_formFields.PARAM_1, Ri_formFields.ITEM_SELECTED,
Rc_Messages.getUserMessage("dadm.pgm.update.cancel"));
} catch (Rc_BaseException e) {
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL;
addErrorAndLogException(pHM_baseForm, e, "12009",
new String[] {"Failed initialize Page4"});
i_ret = Rc_Symbols.FLAGS.iERROR_FATAL;
}
return i_ret;
} //#
/**
* Aborts Search/another process started
* in new thread against Paginated List.
* (is invoked when [Abort] button is clicked)
* @param pHM_baseForm
* @param pStr_pageID
* @param pStr_listName
*/
public static void abortPGlistThreadedProcess(HashMap <String, Object> pHM_baseForm,
String pStr_pageID, String pStr_listName) {
pHM_baseForm.remove(ERRORS);
terminateProcessInThread(pHM_baseForm, Rc_Symbols.THREADS.DO_SEARCH, pStr_pageID,
pStr_listName, false);
} //#
/**
* Calculates average Account Activity,
* ignoring months without activity.
*
* If details flag is set - also calculates low/high monthly activity
* inside the period.
*
* @param nLS_monthlyAAT - analyzed data (list of HM)
* @param b_detail provide details (min/max activity)
*
* @return HM_data (see class fields)
*/
static HashMap calculateAverageActivity (ArrayList pLS_monthlyAAT, boolean pb_details) {
// System.out.println("........calculate Average Activity");
HashMap nHM_data = new HashMap();
int i_size = pLS_monthlyAAT.size();
int i_count = 0;
BigDecimal BD_total = new BigDecimal(0);
BigDecimal BD_min = null;
BigDecimal BD_max = null;
if (pb_details) {
BD_max = new BigDecimal(0);
BD_min = new BigDecimal(Integer.MAX_VALUE);
}
for (int i_x = 1; i_x < i_size; i_x++) {
HashMap HM = (HashMap) pLS_monthlyAAT.get(i_x);
if (HM == null) {
Rc_Logger.logMessage("No Monthly AAT where expected!");
continue; // =>>
}
if (HM.get(CONSIDER_MONTH) == null) {
continue;
}
i_count++ ;
BigDecimal BD_period = Rc_UtilsDB.getDecimal(HM, ACTIVITY_TOTAL, BD_ZERO);
BD_total = BD_total.add(BD_period);
if (pb_details) {
if (BD_period.compareTo(BD_min) < 0 ) {
BD_min = BD_period;
}
if (BD_period.compareTo(BD_max) > 0) {
BD_max = BD_period;
}
}
} // == for All items
if (i_count > 0 ) {
// 2 Decimals, Ariphmetic round up
BD_total = BD_total.divide(new BigDecimal(i_count), 2, BigDecimal.ROUND_HALF_DOWN);
nHM_data.put(ACTIVITY_AVER, BD_total);
if (pb_details) {
nHM_data.put(ACTIVITY_MIN, BD_min);
nHM_data.put(ACTIVITY_MAX, BD_max);
}
} else {
nHM_data.put(ACTIVITY_AVER, BD_MIN1);
BD_min = BD_MIN1;
BD_max = BD_MIN1;
}
//
// this just has a single value of only the monthly average
//
//System.out.println("..............nHM_data = " + nHM_data);
return nHM_data;
} //#
/**
* <BDS!> <HCL!>
* Copies content of PG list row into another row
* with extraction of HashMap content and placing into target
* list ITEM_SELECTED
*
* @param pLS_pgRow
* @return LS_newRow - May return <code>null</code>
* if previous HAT equal to suggested HAT.
*/
static ArrayList copyRowContent (ArrayList pLS_pgRow) {
// System.out.println(".................copy row content");
ArrayList nLS_ret = new ArrayList();
int i_size = Rc_CollectionUtils.elemNum(pLS_pgRow);
String Str_x = null;
for (int i_x = 0; i_x < i_size; i_x++) {
// Skip first column
if (i_x == 0) continue; // =>>
if (i_x == iposSUGGESTED_HAT) {
HashMap nHM = (HashMap) pLS_pgRow.get(i_x);
Str_x = (String) nHM.get(ITEM_SELECTED);
if (Rc_StringUtils.compare(Str_x, (String) pLS_pgRow.get(iposPREVIOUS_HAT), true)) {
return (null); // ###
}
} else {
Str_x = (String) pLS_pgRow.get(i_x);
}
nLS_ret.add(Str_x);
} // == for All items
return nLS_ret;
} //#
/**************************************************************************************************
* <HCL!>
* Calculates HAT for the account from Active page
* @param LS_account (see PAGINATED_LIST_1 definition)
*
* @param LS_periods (dates)
* @return Str_HAT (HAT code)
*
*
* Reason: This is the logical place for reassigning th suggestedHAT. After following
* the logic chain, this Java method returns back the character String for the
* HAT after dumping out the various HashMaps and ArrayLists etc., it is evident that
* the best data structure reclassifying a given account to "UNKNOWN" is the
* ArrayList nLS_monthlyAAT
*
*
*
* nLS_monthlyAAT = [{}, {TRX_COUNT_TOTAL=0, PERIOD_NUM=1, ACTIVITY_TOTAL=null},
* {TRX_COUNT_TOTAL=0, PERIOD_NUM=2, ACTIVITY_TOTAL=null},
* {TRX_COUNT_TOTAL=0, PERIOD_NUM=3, ACTIVITY_TOTAL=null},
* {TRX_COUNT_TOTAL=0, PERIOD_NUM=4, ACTIVITY_TOTAL=null},
* {TRX_COUNT_TOTAL=0, PERIOD_NUM=5, ACTIVITY_TOTAL=null},
* {TRX_COUNT_TOTAL=0, PERIOD_NUM=6, ACTIVITY_TOTAL=null},
* {TRX_COUNT_TOTAL=0, PERIOD_NUM=7, ACTIVITY_TOTAL=null},
* {TRX_COUNT_TOTAL=8, CONSIDER_MONTH=TRUE, PERIOD_NUM=8, ACTIVITY_TOTAL=93408325.77},
* {TRX_COUNT_TOTAL=64, CONSIDER_MONTH=TRUE, PERIOD_NUM=9, ACTIVITY_TOTAL=324171898.45},
* {TRX_COUNT_TOTAL=39, CONSIDER_MONTH=TRUE, PERIOD_NUM=10, ACTIVITY_TOTAL=83101813.69},
* {TRX_COUNT_TOTAL=0, PERIOD_NUM=11, ACTIVITY_TOTAL=null},
* {TRX_COUNT_TOTAL=0, PERIOD_NUM=12, ACTIVITY_TOTAL=null}]
*
* consider the TRX_COUNT_TOTAL values who have non-zero values using the
* same calculation as retrieveAccount activity Java method.
*
*
* this method's signature went from 2 to 3 parameters, need the legacy HAT !!!
*
*
*
*
*
**************************************************************************************************/
// static String calculateHATforAccount (ArrayList pLS_account, ArrayList pLS_periods) {
static String calculateHATforAccount (ArrayList pLS_account, ArrayList pLS_periods, String str_PrevHat) {
String Str_SUNID = (String) pLS_account.get(iposACCT_SUN);
String Str_accountNumber = (String) pLS_account.get(iposACCT_NUMBER);
String Str_LAT = (String) pLS_account.get(iposACCT_LAT);
String Str_custCateg = (String) pLS_account.get(iposCUST_CATEGORY);
/*
ArrayList nLS_monthlyAAT = get12monthlyAAT(Str_SUNID,
Str_accountNumber,
pLS_periods);
*/
ArrayList nLS_monthlyAAT = getAccountStatistic(Str_SUNID,
Str_accountNumber,
pLS_periods);
// System.out.println(" ");
// System.out.println(" ");
// System.out.println("................massive data dump");
// System.out.println("................pLS_periods = " + pLS_periods);
// System.out.println("................nLS_monthlyAAT = " + nLS_monthlyAAT);
HashMap nHM_data = calculateAverageActivity (nLS_monthlyAAT, false);
// System.out.println("................nHM_data = " + nHM_data);
// System.out.println(" ");
// System.out.println(" ");
// System.out.println(" ");
//
// THE MOMENT OF TRUTH !!!!!!!!! MKYu II August 2008
//
// get the size of this ArrayList
//
int i_size = nLS_monthlyAAT.size();
String str_transaction_count = null;
int i_monthly_activity_count = 0;
int i_HashMap_size = 0;
for (int i_x = 1; i_x < i_size; i_x++) {
HashMap HM = (HashMap) nLS_monthlyAAT.get(i_x);
if (HM != null) {
//
// first check fo size of this HashMap; it better be three,
// or if it is equal to 4 there is activity
// values like 2, 5, 6, whoops !!!!
//
i_HashMap_size = HM.size();
if (i_HashMap_size == 3){
i_monthly_activity_count++;
}
else {
if (i_HashMap_size != 4){
log.debug("Fatal error......inside Peer Group Manager");
log.debug(".................PGMmodel.java::calculateAverageActivity method");
}
}
}
} // end of for loop
//
// now the acid test what the suggested HAT depends upon the amount of real monthly
// and what is in the current SS_Account database use the thrid parameter in this method
// which is the previous HAT String !!!!
//
// the i_monthly_activity_count keeps track of how many months which have zero ttansactions
// thus the logic for the Peer Group Manager must be months with
//
// System.out.println("..........i_monthly_activity_count =" + i_monthly_activity_count);
if (i_monthly_activity_count >= 10) {
//
// now check for the previous HAT value !!!
//
if (str_PrevHat != null)
{return str_PrevHat;}
else
{return "UNKNOWN";}
}
else
//
// greater than or equal three months; it is SMBC business as usual
//
return obtainHAT(nHM_data.get(ACTIVITY_AVER), Str_LAT, Str_custCateg);
} //#
/**
* Gathers HashMaps with Total Activity and Transaction Count
* for the specified account and periods.
*
* @param pStr_SUNID
* @param pStr_accountNumber
* @param pLS_12periods
* @return LS of HashMaps with ACTIVITY_TOTAL and TRX_COUNT_TOTAL
*/
static ArrayList get12monthlyAAT (String pStr_SUNID, String pStr_accountNumber,
ArrayList pLS_12periods) {
ArrayList nLS_mAAT = new ArrayList();
int i_size = pLS_12periods.size();
for (int i_x = 0; i_x < i_size; i_x++ ) {
HashMap nHM_qParams = (HashMap) pLS_12periods.get(i_x);
nHM_qParams.put(Ri_SQL.SMBC_TRX_VW.HIST_SUN,
pStr_SUNID);
nHM_qParams.put(Ri_SQL.SMBC_TRX_VW.HIST_ACCT_NUMBER,
pStr_accountNumber);
HashMap nHM = getMonthlyActivity(nHM_qParams);
nLS_mAAT.add(nHM);
} //==
return nLS_mAAT;
} //#
/**
* Gathers HashMaps with Total Activity and Transaction Count
* for the specified account and periods.
* Issues 1 query to the database that is made of 12
* (joint together through UNION)
*
* @param pStr_SUNID
* @param pStr_accountNumber
* @param pLS_12periods
* @return LS of HashMaps with ACTIVITY_TOTAL and TRX_COUNT_TOTAL
*/
static ArrayList getAccountStatistic (String pStr_SUNID, String pStr_accountNumber,
ArrayList pLS_anPeriods) {
int i_size = pLS_anPeriods.size();
HashMap nHM_qParams = new HashMap();
nHM_qParams.put(Ri_SQL.SMBC_TRX_VW.HIST_SUN,
pStr_SUNID);
nHM_qParams.put(Ri_SQL.SMBC_TRX_VW.HIST_ACCT_NUMBER,
pStr_accountNumber);
// Prepare nHM_qParams for all requested periods
final String START_DATE_PREF = "DS_";
final String END_DATE_PREF = "DE_";
final String PERIOD_NUM = "PERIOD_NUM";
for (int i_x = 0; i_x < i_size; i_x++ ) {
HashMap nHM = (HashMap) pLS_anPeriods.get(i_x);
nHM_qParams.put(START_DATE_PREF + String.valueOf(i_x + 1),
nHM.get(Ri_SQL.SERVICE_PARAMS.START_DATE));
nHM_qParams.put(END_DATE_PREF + String.valueOf(i_x + 1),
nHM.get(Ri_SQL.SERVICE_PARAMS.END_DATE));
} //==
// fire up query
ArrayList nLS_res = null;
try {
nLS_res = (ArrayList) Rc_UtilsDB
.executeQuery(Ri_SQL.SQL_MAPS.GET_ACCOUNT_ACTIVITY_12,
Rc_Symbols.MODES.iGET_LIST,
nHM_qParams);
} catch (Exception e) {
Rc_Logger.logException(
"Failed obtain account activity for ALL periods",
Rc_Symbols.LOG_LEVEL.ERROR,
e,
false);
}
int i_sizeRes = Rc_CollectionUtils.elemNum(nLS_res);
// process results and break them down into the processed periods
int i_trxCount = 0;
int i_periodNum = 0;
BigDecimal BD_aa = BD_ZERO;
TreeMap nTM_res = new TreeMap();
for (int i_x = 0; i_x < i_sizeRes; i_x++ ) {
HashMap nHM = (HashMap) nLS_res.get(i_x);
if (nHM == null) nHM = new HashMap();
i_periodNum = Rc_UtilsDB.getInt( nHM,
PERIOD_NUM, -1);
if (i_periodNum < 0) continue; // =>>
i_trxCount = Rc_UtilsDB.getInt(nHM,
TRX_COUNT_TOTAL, 0);
if (i_trxCount > 0) {
nHM.put(CONSIDER_MONTH, Rc_Symbols.TRUE);
BD_aa = Rc_UtilsDB.getDecimal(nHM,
ACTIVITY_TOTAL,
BD_MIN1);
if (BD_aa.intValue() < 0) {
nHM.put(Rc_PGMmodel.ACTIVITY_TOTAL, BD_ZERO);
} else {
nHM.put(Rc_PGMmodel.ACTIVITY_TOTAL, BD_aa);
}
}
nTM_res.put(i_periodNum, nHM);
} //==
// Fill in the gaps (if there are any)
for (int i_x = 0; i_x < i_size; i_x++ ) {
if (nTM_res.get(i_x) == null) nTM_res.put(i_x, new HashMap());
} //=
// Move from TreeMap into the ArrayList
ArrayList nLS_mAAT = new ArrayList();
Iterator iter = nTM_res.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry C_Entry = (Entry) iter.next();
nLS_mAAT.add(C_Entry.getValue());
} //==
// System.out.println(".........Array List = " + nLS_mAAT);
return nLS_mAAT;
} //#
/**
* <BDS!> <HCL!>
* Calculates 12 full monthly periods before current date
*
* @param pCAL_now
* @return LS with HashMaps where beginning and end of periods
* stored as SERVICE_PARAMS.START_DATE
* and SERVICE_PARAMS.END_DATE
* respectively
*/
static ArrayList getPeriods (Calendar pCAL_now) {
ArrayList nLS_ret = new ArrayList();
Calendar CAL_ytd = (Calendar) pCAL_now.clone();
CAL_ytd.add(Calendar.MONTH, -12);
CAL_ytd.set(Calendar.DAY_OF_MONTH, 1);
String Str_month = null;
java.sql.Date DT_x = null;
for (int i_x = 0; i_x < 12; i_x++ ) {
HashMap HM = new HashMap();
DT_x = new java.sql.Date(CAL_ytd.getTimeInMillis());
HM.put(Ri_SQL.SERVICE_PARAMS.START_DATE, DT_x);
Str_month = Rc_DateUtils.monthNameByIndex(
CAL_ytd.get(Calendar.MONTH)).toUpperCase();
HM.put(PERIOD_NAME, Str_month + " - " +
String.valueOf(CAL_ytd.get(Calendar.YEAR)));
// Get EOM for previous month
CAL_ytd.add(Calendar.MONTH, 1);
CAL_ytd.add(Calendar.DATE, -1);
DT_x = new java.sql.Date(CAL_ytd.getTimeInMillis());
HM.put(Ri_SQL.SERVICE_PARAMS.END_DATE, DT_x);
nLS_ret.add(HM);
// Return back to the beginning of next month
CAL_ytd.add(Calendar.DATE, +1);
} //#
return nLS_ret;
} //#
/**
* Retrieves Monthly activity for the specified account
* for the specified period (month) along with number of transactions
* posted within the period.
*
* @param HM_qParams with pre-setup dates
* SUNID is set as SS_ACCOUNTS.ACCT_SUN
* AcctNumber as SS_ACCOUNTS.ACCT_NUMBER
* @return HM with Activity and Trx count for the period
* (see keys in the class header)
* Returns an empty hashmap on errors
*/
static HashMap getMonthlyActivity (HashMap pHM_qParams) {
HashMap HM_ret = null;
try {
HM_ret = Rc_UtilsDB.getObject(Ri_SQL.SQL_MAPS.GET_ACCOUNT_ACTIVITY,
pHM_qParams);
} catch (Exception e) {
Rc_Logger.logException("Failed obtain account activity for period",
Rc_Symbols.LOG_LEVEL.ERROR,
e,
false);
}
if (HM_ret == null) HM_ret = new HashMap();
if (Rc_UtilsDB.getInt(HM_ret, TRX_COUNT_TOTAL, 0) > 0) {
HM_ret.put(CONSIDER_MONTH, Rc_Symbols.TRUE);
if (Rc_UtilsDB.getDecimal(HM_ret, Rc_PGMmodel.ACTIVITY_TOTAL,
new BigDecimal(-1)).intValue() < 0) {
HM_ret.put(Rc_PGMmodel.ACTIVITY_TOTAL, new BigDecimal(0));
// HM_ret.put("50000", new BigDecimal(0));
}
}
return HM_ret;
} //#
/**
* <BDS!> <HCL!>
* @param Obj_avActivity
* @param pStr_LAT
* @param pStr_custCateg
* @return
*/
//
// Analysis of the sequence of events for HATs !!!!!!
//
//
// sequence Java method
//
// 1 fire of the button >>>>>>>>> calculateHATs
//
// 2 calculate HAT on Page
//
// 3 calculate HAT for Active Page
//
// 4 calculate HAT for Account
//
// 5 get Account Statistic
//
// 6 calculate Average Activity
//
// 7 obtain HAT
//
//
static String obtainHAT (Object Obj_avActivity, String pStr_LAT, String pStr_custCateg) {
// System.out.println(".....................obtain HAT");
String Str_HAT = null;
if (Obj_avActivity == null) return (null); // ###
if (!(Obj_avActivity instanceof BigDecimal)) return (null); // ###
HashMap nHM_qParams = new HashMap();
nHM_qParams.put(Ri_SQL.SERVICE_PARAMS.CONTROL_1,
(BigDecimal) Obj_avActivity);
nHM_qParams.put(Ri_SQL.CHUB_REFS.PARAM_1, pStr_LAT);
nHM_qParams.put(Ri_SQL.CHUB_REFS.PARAM_2, pStr_custCateg);
HashMap nHM_ret = null;
try {
nHM_ret = Rc_UtilsDB.getObject(Ri_SQL.SQL_MAPS.GET_HAT, nHM_qParams);
System.out.println("............nHM_ret = " + nHM_ret);
} catch (Rc_BaseException e) {
Rc_Logger.logException("Failed get HAT for LAT: " +
pStr_LAT + " CustCateg: " + pStr_custCateg
+ " Activity: " + Obj_avActivity.toString(),Rc_Symbols.LOG_LEVEL.ERROR,
e, false);
}
if (Rc_CollectionUtils.elemNum(nHM_ret) < 1) nHM_ret = new HashMap();
Str_HAT = (String) nHM_ret.get(Ri_SQL.CHUB_REFS.PARAM_5);
System.out.println(".......inside Obtain HAT routine");
System.out.println(".......Str_HAT = " + Str_HAT);
return Str_HAT;
} //#
/**
* <BDS!> <HCL!>
* Loops through the database and obtains data on the 12 last full months
* for the specified account.
*
* @param pHM_baseForm
* @param Str_SUNID
* @param Str_accountNumber
*/
/* Reason: The purpose of this routine is to calculate the various
* values on the Peer Group Manager - Additional information Page
* The local values Str_calcHAT and Str_prevHAT are used
* to retrieve and display the HATs.
* The new logic will examine in detail the HM_monAAT
*
* This is the data structure layout of the HM_monAAT
*
* HM_monAAT HashMap is = {TRX_COUNT_TOTAL=0, PERIOD_NUM=1, ACTIVITY_TOTAL=null}
*
*
*
*/
static void retrieveAccountActivity (HashMap pHM_baseForm, String pStr_SUNID,
String pStr_accountNumber) {
// System.out.println(" ");
// System.out.println(" ");
// System.out.println(".............retrieve account activity and paint detail screen");
Rc_AppContext C_AppContext = getAppContext(pHM_baseForm);
Rc_Formatter C_Formatter = C_AppContext.getFormatter();
HashMap nHM_qParams = new HashMap();
nHM_qParams.put(Ri_SQL.SS_ACCOUNTS.ACCT_SUN, pStr_SUNID);
nHM_qParams.put(Ri_SQL.SS_ACCOUNTS.ACCT_NUMBER, pStr_accountNumber);
HashMap nHM_accountData = null;
try {
nHM_accountData = Rc_UtilsDB.getObject(Ri_SQL.SQL_MAPS.GET_SS_ACCOUNT, nHM_qParams);
} catch (Rc_BaseException e) {
addErrorAndLogException( pHM_baseForm, e, "Failed get Account data with Cust.Category");
return; // ###
}
// set out periods
ArrayList nLS_periods = getPeriods ( Rc_DateUtils.getCurrentDateAsCalendar());
ArrayList nLS_monthlyAAT = getAccountStatistic(pStr_SUNID, pStr_accountNumber, nLS_periods);
// Obtain average actual account activity for last 12 full months
// Calculate low/high/average (ignoring months without activity)
HashMap nHM_data = calculateAverageActivity (nLS_monthlyAAT, true);
BigDecimal BD_actAVER = Rc_UtilsDB.getDecimal(nHM_data, ACTIVITY_AVER, BD_MIN1);
BigDecimal BD_actMIN = Rc_UtilsDB.getDecimal(nHM_data, ACTIVITY_MIN, BD_ZERO);
BigDecimal BD_actMAX = Rc_UtilsDB.getDecimal(nHM_data, ACTIVITY_MAX, BD_ZERO);
int i_transaction_count = 0;
int i_month_activity_count = 0;
boolean b_NOaverActivity = BD_actAVER.compareTo(BD_MIN1) == 0;
String Str_custCateg = (String) nHM_accountData.get(Ri_SQL.SS_CUSTOMERS_VW.CUS_CATEGORY_TYPE);
String Str_accountTitle = (String) nHM_accountData.get(Ri_SQL.SS_ACCOUNTS.ACCT_TITLE);
String Str_accountLAT = (String) nHM_accountData.get(Ri_SQL.SS_ACCOUNTS.LOW_ACCOUNT_TYPE);
String Str_previousHAT = (String) nHM_accountData.get(Ri_SQL.SS_ACCOUNTS.HIGH_ACCOUNT_TYPE);
// b_NOaverActivity = true;
// Str_previousHAT = "Ivan the Terrible";
// we have to intercept the suggested HAT before it gets written back onto the screen
String Str_suggestedHAT = b_NOaverActivity ?"UNKNOWN" :obtainHAT (BD_actAVER,
Str_accountLAT, Str_custCateg);
// propagate data in the PAGE_2
String Str_baseCRCD = Rc_System.getSysProp( Rc_Symbols.PROPS.HOME_CURRENCY);
setEntryValue(pHM_baseForm, PAGE_2, PARAM_1, ITEM_SELECTED,
pStr_accountNumber);
setEntryValue(pHM_baseForm, PAGE_2, PARAM_2, ITEM_SELECTED,
Str_accountTitle);
setEntryValue(pHM_baseForm, PAGE_2, PARAM_3, ITEM_SELECTED,
pStr_SUNID);
setEntryValue(pHM_baseForm, PAGE_2, PARAM_4, ITEM_SELECTED,
Str_custCateg);
setEntryValue(pHM_baseForm, PAGE_2, PARAM_5, ITEM_SELECTED,
Str_accountLAT);
setEntryValue(pHM_baseForm, PAGE_2, PARAM_6, ITEM_SELECTED, b_NOaverActivity
?Rc_Symbols.NA :C_Formatter.formatAmount( Str_baseCRCD,
BD_actAVER));
setEntryValue(pHM_baseForm, PAGE_2, PARAM_7, ITEM_SELECTED, b_NOaverActivity
?Rc_Symbols.NA :C_Formatter.formatAmount( Str_baseCRCD,
BD_actMAX));
setEntryValue(pHM_baseForm, PAGE_2, PARAM_8, ITEM_SELECTED, b_NOaverActivity
?Rc_Symbols.NA :C_Formatter.formatAmount( Str_baseCRCD,
BD_actMIN));
//
// the next two statements casts the previous and current HAT values into the
// HashMap of the base for,
//
// here it is too early to stuff Str_suggestedHAT
//
// see the new business logic 07/13/08
//
setEntryValue(pHM_baseForm, PAGE_2, PARAM_9, ITEM_SELECTED, Str_previousHAT);
//
// setEntryValue(pHM_baseForm, PAGE_2, PARAM_10, ITEM_SELECTED, Str_suggestedHAT);
int i_size = nLS_periods.size();
//
//
// this is the routine that will scan the two HashMaps
//
//
ArrayList nLS = new ArrayList();
for (int i_x = 0; i_x < i_size; i_x++) {
HashMap HM_period = (HashMap) nLS_periods.get(i_x);
HashMap HM_monAAT = (HashMap) nLS_monthlyAAT.get(i_x + 1);
// System.out.println(".........................i_x = " + i_x);
// System.out.println(".........................HM_period HashMap is = " + HM_period);
// System.out.println(".........................HM_monAAT HashMap is = " + HM_monAAT);
//
// now establish a set
//
// System.out.println("........transaction account total = " + HM_monAAT.get("TRX_COUNT_TOTAL"));
if(HM_monAAT.get("ACTIVITY_TOTAL") != null) {i_month_activity_count++;}
// System.out.println(" ");
ArrayList nLS_row = new ArrayList();
nLS_row.add(HM_period.get(PERIOD_NAME)); // #0
nLS_row.add(C_Formatter.formatAmount(Str_baseCRCD, Rc_UtilsDB.getDecimal(HM_monAAT,
ACTIVITY_TOTAL, BD_ZERO))); // #1
nLS_row.add(String.valueOf(Rc_UtilsDB.getDecimal(HM_monAAT,
TRX_COUNT_TOTAL, BD_ZERO).intValue())); // #2
nLS.add(nLS_row);
// System.out.println("");
} // == for All items cycled through all twelve full months
//
// Specifications per C. Lloyd 7/31/08
//
// implmented by M.K. Yu Jr.
//
//
// now check for the number of months of activity
//
// business logic table
//
//
// Current HAT # of months Suggested HAT
//
//
// null value < 3 UNKNOWN
//
// null value >= 3 Suggested(Corp-M)
//
// CORP - M < 3 CORP - M (retain)
//
// CORP - M >= 3 Suggested(Corp - H)
//
// UNKNOWN < 3 UNKNOWN
//
// UNKNOWN > = 3 Suggested(CORP - L)
//
//
// separate the wheat from the chaff - does it met the 3 month test ?????
//
// if you follow the logic table, anything greater than 2 months do
// suggested HAT !!!!!!!!! only scrutinize if 0, 1 or 2 months !!!!!
// interrogate the the current HAT value in this case
// System.out.println(".......i_month_activity_count = " + i_month_activity_count);
if (i_month_activity_count < 3) {
if (Str_previousHAT == null){Str_suggestedHAT = "UNKNOWN";}
else
{
if (Str_previousHAT == "UNKNOWN"){Str_suggestedHAT = "UNKNOWN";}
else
{
Str_suggestedHAT = Str_previousHAT;
}
}
}
//
// at this juncture of the new business logic we can put out the correct suggested HAT
//
setEntryValue(pHM_baseForm, PAGE_2, PARAM_10, ITEM_SELECTED, Str_suggestedHAT);
// System.out.println("nLS_row = " + nLS);
// Show list
// System.out.println ( "list1 size: " + nLS_row.size ( ) ) ;
// for ( int i = 0; i < list1.size ( ) ; i++ ) {
// System.out.println ( list1.get ( i ) ) ;
// }
setEntryValue(pHM_baseForm, PAGE_2, LIST_1, nLS);
} //#
/**
* Sets Screen#1
* @param pHM_baseForm
* @return i_flag
*/
public static int setScreen1(HashMap pHM_baseForm) {
setEntryValue(pHM_baseForm, PAGE_1, BUTTON_3, ITEM_HIDE,
Rc_Symbols.FALSE);
setEntryValue(pHM_baseForm, PAGE_1, BUTTON_4, ITEM_HIDE,
Rc_Symbols.FALSE);
setEntryValue(pHM_baseForm, PAGE_1, BUTTON_5, ITEM_HIDE,
Rc_Symbols.TRUE);
setEntryValue(pHM_baseForm, PAGE_1, BUTTON_6, ITEM_HIDE,
Rc_Symbols.TRUE);
setEntryValue(pHM_baseForm, PAGE_1, "export", ITEM_HIDE,
Rc_Symbols.TRUE);
return Rc_Symbols.FLAGS.iACTION_OK;
} //#
/**
* Sets Screen#2
*
* @param pHM_baseForm
* @return i_flag
*/
public static int setScreen2(HashMap pHM_baseForm) {
setEntryValue(pHM_baseForm, PAGE_3, BUTTON_3, ITEM_HIDE,
Rc_Symbols.TRUE);
setEntryValue(pHM_baseForm, PAGE_3, BUTTON_4, ITEM_HIDE,
Rc_Symbols.TRUE);
setEntryValue(pHM_baseForm, PAGE_3, BUTTON_5, ITEM_HIDE,
Rc_Symbols.FALSE);
setEntryValue(pHM_baseForm, PAGE_3, BUTTON_6, ITEM_HIDE,
Rc_Symbols.FALSE);
setEntryValue(pHM_baseForm, PAGE_3, "export", ITEM_HIDE,
Rc_Symbols.FALSE);
return Rc_Symbols.FLAGS.iACTION_OK;
} //#
} // ### Rc_PGMmodel.java
// *************************************************************************************************
//
// PGM uses 2 threaded classes to accomplish the report/Web generation. They must be
// defined with a super, run() method is overriden and the specific application method
// fo the update. Also note that the current implementation of these application
// methods are not thread safe. They are currently using the ArrayList and should
// be rewritten using the Vector data structure.
//
// Mason Yu Jr. July 25, 2008
//
//
// *************************************************************************************************
/**
* This class is started in new thread.
* Calculates HAT's for the flagged accounts on the PAGE_1.PAGINATED_LIST_1
*
* Maintains HeartBeat and Status information in the nHM_baseForm
* (to control process status)
*/
@SuppressWarnings("unchecked")
class CalculateHATonPage extends Rc_ThreadedPGlistProcess {
public static final String CLASS = "CalculateHATonPage";
CalculateHATonPage ( HashMap <String, Object>pHM_baseForm) throws Rc_DataException {
super (pHM_baseForm, Rc_Symbols.THREADS.CALCULATE_HAT,Ri_formFields.PAGE_1,
Ri_formFields.PAGINATED_LIST_1, true);
pHM_baseForm.remove(Ri_formFields.ERRORS);
pHM_baseForm.remove(Ri_formFields.INF_MESSAGE);
// System.out.println("..........calculateHAT on Page");
} //@ CalculateHATonPage
/**
*
* (non-Javadoc)
* @author :
* @date :
* @since : Version
* @see com.rbf.chub.web.base.Rc_ThreadedPGlistProcess#run()
*/
public void run() {
try {
// System.out.println("...........execute run");
calculateHATforActivePage() ;
} catch (Rc_BaseException e) {
Rc_Logger.logException("Failed recalculate HAT for paginated list",
Rc_Symbols.LOG_LEVEL.ERROR, e, false);
}
}//#
/**
* Number of requested page of paginated list is
* retrieved from PAGINATED_LIST.ACTIVE_RESPONSE property
*
* @return b_ret <code>false</code> if there is mode data
* <code>truth</code> otherwise
* (if it has been used to extract last portion)
* @throws Rc_BaseException
*/
synchronized boolean calculateHATforActivePage() throws Rc_BaseException{
// System.out.println(".............calculateHAT for Active Page");
// get PAGINATED_LIST1.Active page
int i_activePageID = -1;
try {
i_activePageID = (Integer) Rc_baseModel.getEntryValue(mHM_baseForm,
mStr_pageID, mStr_pgListID, PAGINATED_LIST.ACTIVE_RESPONSE);
} catch (Exception ex) {
//==
}
if (i_activePageID < 0) {
Rc_baseModel.addErrorMessage(mHM_baseForm, 12009,
new String[] {"Active page ID is not setup!"});
setStoppedStatus();
return (false); // ###
}
HashMap nHM_resps = (HashMap) Rc_baseModel.getEntryValue(mHM_baseForm,
mStr_pageID, mStr_pgListID, PAGINATED_LIST.RESPONSES);
if (nHM_resps == null) {
Rc_baseModel.addErrorMessage(mHM_baseForm, 12009,
new String[] {"No responces found in PgList1"});
setStoppedStatus();
return (false); // ###
}
// get active page
ArrayList nLS_activePage = (ArrayList) nHM_resps.get(i_activePageID);
if (nLS_activePage == null) {
Rc_baseModel.addErrorMessage(mHM_baseForm, 12009,
new String[] {"Active Page is empty!"});
setStoppedStatus();
return (false); // ###
}
ArrayList nLS_periods = Rc_PGMmodel.getPeriods (Rc_DateUtils.getCurrentDateAsCalendar());
// Loop through all accounts of active page
String Str_calcHAT = null;
String Str_prevHAT = null;
int i_size = nLS_activePage.size();
int i_errC = 0;
int i_modC = 0;
// System.out.println("....... .the total number of boxes = " + i_size);
for (int i_x = 0; i_x < i_size; i_x++) {
ArrayList nLS_entry = (ArrayList) nLS_activePage.get(i_x);
if (Rc_StringUtils.compare((String)nLS_entry.get(0), "0", false)) {
continue; // =>>
}
resetHeartBeat();
// Calculate HAT for every of accounts
// And then set Calculated HAT back into SuggestedHAT ITEM_SELECTED
// if it is not null and not equal to previous value.
Str_prevHAT = (String) nLS_entry.get(Rc_PGMmodel.iposPREVIOUS_HAT);
//
// signature of this method went from 2 to 3, key logic change
// called method must know what the previous HAT in the SS_Account table is !!!
//
Str_calcHAT = Rc_PGMmodel.calculateHATforAccount(nLS_entry, nLS_periods, Str_prevHAT);
//
// nLS_entry is an ArrayList
//
// System.out.println("................nLS_entry = " + nLS_entry);
// System.out.println("................nLS_periods " + nLS_periods);
// Get an object of ListIterator using listIterator() method
// ListIterator listIterator = nLS_entry.listIterator();
/*
Traverse the ArrayList in forward direction using hasNext and next methods
of ListIterator. hasNext method returns true if ListIterator has more
elements to traverse in forward direction. Next method returns next element
in the list.
*/
// System.out.println("Traversing ArrayList in forward direction using ListIterator");
if (Str_calcHAT != null) {
// Str_prevHAT = (String) nLS_entry.get(Rc_PGMmodel.iposPREVIOUS_HAT);
//
// this is the better place for the before and after snapshot
//
// System.out.println("................Str_calcHAT = " + Str_calcHAT);
// System.out.println("................Str_prevHAT = " + Str_prevHAT);
HashMap nHM_suggestedHAT = (HashMap)nLS_entry.get(Rc_PGMmodel.iposSUGGESTED_HAT);
//
// get current ItemList
//
// ArrayList dropdown = (ArrayList) nHM_suggestedHAT.get("ItemsList");
// System.out.println("...........dropdown = " + dropdown);
//
// put new entry UNKNOWN in ArrayList dropdown
//
// dropdown.add("UNKNOWN|UNKNOWN-> see detail");
nHM_suggestedHAT.put("ItemSelected", Str_calcHAT);
nHM_suggestedHAT.get("ItemSelected");
// System.out.println(".............nHM_suggestedHAT = " + nHM_suggestedHAT);
if (! Str_prevHAT.equals(Str_calcHAT) || !Rc_StringUtils.compare(Str_calcHAT,
(String)nHM_suggestedHAT.get(Ri_formFields.ITEM_SELECTED), true)) {
nHM_suggestedHAT.put(Ri_formFields.ITEM_SELECTED, Str_calcHAT);
i_modC++ ;
}
} else {
i_errC++ ;
}
} // ==
// Create message on result of calculation
if (i_modC == 0) {
Rc_baseModel.addInfoMessage(mHM_baseForm, "dadm.pgm.reclassify.none", null);
} else {
}
if (i_errC == 0) {
Rc_baseModel.addErrorMessage(mHM_baseForm, "dadm.pgm.reclassify.failed",
new String[] {String.valueOf(i_errC)});
}
setStoppedStatus();
return (false);
} //#
} //### CalculateHATonPAGE
// this is a separate Class which implments the Runnable Interface
//
//
/**
* This class is started in new thread.
* Updates HAT for the list of accounts from the PAGE_3.PAGINATED_LIST_1
*
* Maintains HeartBeat and Status information in the nHM_baseForm
* (to control process status)
*/
@SuppressWarnings("unchecked")
class UpdateHATforList extends Rc_ThreadedPGlistProcess implements Runnable {
public static final String CLASS = "UpdateListOfHATs";
UpdateHATforList ( HashMap <String, Object>pHM_baseForm) throws Rc_DataException {
super (pHM_baseForm, Rc_Symbols.THREADS.UPDATE_HAT, Ri_formFields.PAGE_3,
Ri_formFields.PAGINATED_LIST_1, true);
} //@ UpdateHATforList
/**
*
* (non-Javadoc)
* @author :
* @date :
* @since : Version
* @see com.rbf.chub.web.base.Rc_ThreadedPGlistProcess#run()
*/
public void run() {
// System.out.println(".....................execute run method");
String Str_result = updateHATs() ;
// == Finalizing - create Page_4 with confirmation message
try {
String Str_serviceCode = Rc_PGMmodel.MODULE_SERVICE_CODE + "c";
mHM_baseForm.put(Ri_formFields.SERVICE_CODE, Str_serviceCode);
if (mHM_baseForm.get(Ri_formFields.PAGE_4) == null) {
Rc_baseModel.renderPage2(Rc_NotificationsListModel.getPagesConfig(),
mHM_baseForm, Str_serviceCode, Ri_formFields.PAGE_4);
}
Rc_baseModel.setPageNumber(mHM_baseForm, Str_serviceCode);
Rc_baseModel.setEntryValue(
mHM_baseForm,
Ri_formFields.PAGE_4,
Ri_formFields.PARAM_1,
Ri_formFields.ITEM_SELECTED,
Str_result);
} catch (Rc_BaseException e) {
Rc_baseModel.addErrorAndLogException(mHM_baseForm, e, "12009",
new String[] {"Failed initialize Page4"});
}
}//#
/**
* Scans all pages in the paginated list and modifies
* accounts listed there in.
*
* @return Str_result for PAGE_4
* @throws Rc_BaseException
*/
private synchronized String updateHATs() {
String Str_message = null;
// System.out.println("..............................updateHATs");
// For every next processed account - reset HeartBeat
HashMap nHM_resps = (HashMap)
Rc_baseModel.getEntryValue(mHM_baseForm,
mStr_pageID,
mStr_pgListID,
PAGINATED_LIST.RESPONSES);
if (Rc_CollectionUtils.elemNum(nHM_resps) < 1) {
Str_message = "Failed. No responces found to process in "
+ mStr_pageID + "." + mStr_pgListID;
Rc_baseModel.addErrorMessage(mHM_baseForm, 12009,
new String[] {Str_message});
setStoppedStatus();
return Str_message;
}
Iterator iter = nHM_resps.entrySet().iterator();
int i_aCount = 0;
int i_aModErr = 0;
int i_sizeP = 0;
String Str_SUN = null;
String Str_previousHAT = null;
String Str_suggestedHAT = null;
String Str_accountNumber = null;
String Str_comment = null;
String Str_updateDetails = null;
boolean b_updateStatusOK = false;
HashMap nHM_qParams = new HashMap();
while (iter.hasNext()) {
Map.Entry C_Entry = (Entry) iter.next();
ArrayList nLS_page = (ArrayList) C_Entry.getValue();
i_sizeP = Rc_CollectionUtils.elemNum(nLS_page);
if (i_sizeP < 1) continue; // =>>
for (int i_x = 0; i_x < i_sizeP; i_x++) {
resetHeartBeat();
ArrayList nLS_row = (ArrayList) nLS_page.get(i_x);
// System.out.println("...............ArrayList nLS_row = " + nLS_row);
Str_SUN = (String)
nLS_row.get(Rc_PGMmodel.iposACCT_SUN -1);
Str_accountNumber = (String)
nLS_row.get(Rc_PGMmodel.iposACCT_NUMBER -1);
Str_previousHAT = (String)
nLS_row.get(Rc_PGMmodel.iposPREVIOUS_HAT -1);
Str_suggestedHAT = (String)
nLS_row.get(Rc_PGMmodel.iposSUGGESTED_HAT -1);
Str_comment = (String)
nLS_row.get(Rc_PGMmodel.iposCOMMENT_ON_CHANGE -1);
nHM_qParams.put(Ri_SQL.SS_ACCOUNTS.ACCT_SUN,
Str_SUN);
nHM_qParams.put(Ri_SQL.SS_ACCOUNTS.ACCT_NUMBER,
Str_accountNumber);
// System.out.println("..............Str_accountNumber = " + Str_accountNumber);
// System.out.println("..............Str_suggestedHAT = " + Str_suggestedHAT);
nHM_qParams.put(Ri_SQL.SS_ACCOUNTS.HIGH_ACCOUNT_TYPE,
Str_suggestedHAT);
i_aCount++ ;
b_updateStatusOK = true;
//
// this is the place to update the SS_ACCOUNTS_HAT
//
//
try {
Rc_UtilsDB.executeQuery(Ri_SQL.SQL_MAPS.UPDATE_SS_ACCOUNT_HAT,
Rc_Symbols.MODES.iUPDATE, nHM_qParams);
} catch (Rc_BaseException e) {
Rc_Logger.logException("Failed update HAT for: " +
Str_SUN + " " + Str_accountNumber,
Rc_Symbols.LOG_LEVEL.ERROR, e, false);
i_aModErr++ ;
b_updateStatusOK = false;
}
// CONFIG CHECK OUT STRING BELOW for AUDIT REPORTS!
// Logging for every account!!!
//
// this routine is to pump to the CHUB Activity Log
//
Str_updateDetails="HAT=>" + Str_previousHAT + "=>" + Str_suggestedHAT;
mHM_baseForm.put(Ri_Logging.EVENT.OBJECT_CODE,
Str_accountNumber);
mHM_baseForm.put(Ri_Logging.EVENT.ACTION_CODE,
Ri_Logging.ACTION.EDIT);
mHM_baseForm.put(Ri_Logging.EVENT.DESCRIPTION,
Ri_Logging.DESCRIPTION.EDIT_HAT);
mHM_baseForm.put(Ri_Logging.EVENT.EVENT_COMMENT,
Str_comment);
mHM_baseForm.put(Ri_Logging.EVENT.REQ_PARAMETERS,
Str_updateDetails);
Rc_baseModel.logEvent( mHM_baseForm,
b_updateStatusOK
?Rc_Symbols.FLAGS.iACTION_OK
:Rc_Symbols.FLAGS.iACTION_FAIL,
System.currentTimeMillis());
} // == for All rows in paginated list page
} //== All Pages of paginated list
StringBuffer Stb = new StringBuffer();
if ((i_aCount - i_aModErr) > 0) {
Stb.append(Rc_Messages.getUserMessage("dadm.pgm.reclassify",
new String[]
{String.valueOf(i_aCount - i_aModErr)})) ;
}
if (i_aModErr > 0) {
if (Stb.length() > 0) Stb.append("<br>");
Stb.append(Rc_Messages.getUserMessage("dadm.pgm.reclassify.failed",
new String[]
{String.valueOf(i_aModErr)})) ;
}
return Stb.toString();
}// #
}
|