public ActionForward List( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws TPlusException, Exception { int pageNo = 0; if (request.getParameter("mode") != null && ((String) request.getParameter("mode")).equals("NEXT")) { if (request.getParameter("pageNo") != null) { pageNo = Integer.parseInt((String) request.getParameter("pageNo")) + 1; } } if (request.getParameter("mode") != null && ((String) request.getParameter("mode")).equals("PREV")) { if (request.getParameter("pageNo") != null) { pageNo = Integer.parseInt((String) request.getParameter("pageNo")) - 1; } } RenewalCardBPForm objForm = (RenewalCardBPForm) form; CardBatchProcessManager objCardBatchProcessManager = new CardBatchProcessManager(); // generate the new batch id if (objForm.getBatchId() == null || "".equals(objForm.getBatchId())) { String batchId = IdsGenartion.GenerateBatchId(); objForm.setBatchId(batchId); } try { String issuerId = (String) request.getSession(false).getAttribute("ISSUER"); Collection applicationsList = objCardBatchProcessManager.listRenewalCardApps(issuerId, pageNo); objForm.setAppList(applicationsList); int totApps = objCardBatchProcessManager.getTotalRenewalCardsApps(issuerId); objForm.setTotalNoOfApps(String.valueOf(totApps)); request.setAttribute("SEARCHLIST", applicationsList); request.setAttribute("PAGENO", new Integer(pageNo).toString()); } catch (Exception e) { logger.error(new Object(), e); System.out.println( "Error converting to form bean in RenewalCardsDispatchAction : " + e.getMessage()); throw new TPlusException( "Error converting to form bean in RenewalCardsDispatchAction : " + e); } return mapping.findForward("success"); }
public ActionForward process( ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws TPlusException, Exception { ActionErrors errors = null; boolean isError = false; int pageNo = 0; if (request.getParameter("pageNo") != null) { pageNo = Integer.parseInt((String) request.getParameter("pageNo")); } String issuerId = (String) request.getSession(false).getAttribute("ISSUER"); String userId = (String) request.getSession(false).getAttribute("USERID"); RenewalCardBPForm objForm = (RenewalCardBPForm) form; CardBatchProcessManager objCardBatchProcessManager = new CardBatchProcessManager(); CardManager objCardManager = new CardManager(); CardProductManager objCardProductManager = new CardProductManager(); SystemParamManager objSystemParamManager = new SystemParamManager(); try { errors = objForm.validate(mapping, request); if (errors != null && !errors.isEmpty()) { saveErrors(request, errors); isError = true; } else { errors = new ActionErrors(); if (objForm.getUserId().equals(objForm.getAuthUserId())) { errors.add("Error", new ActionError("error.batchprocesssameusercannot")); saveErrors(request, errors); isError = true; } else { AdminLoginDto objDto = new AdminLoginDto(); objDto.setIssuerId(objForm.getIssuerId()); objDto.setUserId(objForm.getAuthUserId()); objDto.setPassword(objForm.getAuthPassword()); String remoteIp = InetAddress.getLocalHost().getHostAddress(); objDto.setRemoteIp(remoteIp); AdminLoginManager objManager = new AdminLoginManager(); String rtnMsg = objManager.validateBatchProcessAuthUser(objDto); if (!"VALIDUSER".equals(rtnMsg)) { errors.add("Error", new ActionError("error.batchprocessauthfailed")); saveErrors(request, errors); isError = true; } } } if (isError) { Collection applicationsList = objCardBatchProcessManager.listRenewalCardApps(issuerId, pageNo); objForm.setAppList(applicationsList); int totApps = objCardBatchProcessManager.getTotalRenewalCardsApps(issuerId); objForm.setTotalNoOfApps(String.valueOf(totApps)); request.setAttribute("SEARCHLIST", applicationsList); request.setAttribute("PAGENO", new Integer(pageNo).toString()); return mapping.findForward("success"); } else { Map indexesList = new HashMap(); KeyIndexManager objKeyIndexManager = new KeyIndexManager(); // check all the card products have PPK values try { indexesList = objKeyIndexManager.getIndexesList(issuerId); if (indexesList.isEmpty()) { errors = new ActionErrors(); errors.add("Error", new ActionError("error.cardproductsnoindexes")); saveErrors(request, errors); Collection applicationsList = objCardBatchProcessManager.listRenewalCardApps(issuerId, pageNo); objForm.setAppList(applicationsList); int totApps = objCardBatchProcessManager.getTotalRenewalCardsApps(issuerId); objForm.setTotalNoOfApps(String.valueOf(totApps)); request.setAttribute("SEARCHLIST", applicationsList); request.setAttribute("PAGENO", new Integer(pageNo).toString()); return mapping.findForward("success"); } } catch (Exception e) { logger.error(new Object(), e); System.out.println("Error on checking PPK for card products " + e); throw new TPlusException("Error on checking PPK for card products " + e); } SystemParamDto objSystemParamDto = objSystemParamManager.get("ASP"); if (objSystemParamDto == null) { errors = new ActionErrors(); errors.add("Error", new ActionError("error.nosystemparam")); saveErrors(request, errors); Collection applicationsList = objCardBatchProcessManager.listReplacementCardApps(issuerId, pageNo); objForm.setAppList(applicationsList); request.setAttribute("SEARCHLIST", applicationsList); request.setAttribute("PAGENO", new Integer(pageNo).toString()); return mapping.findForward("success"); } int totalApps = 0; RenewalBatchProcessSuccess objRenewalBatchProcessSuccess = null; ArrayList appCardsList = new ArrayList(); StringBuilder genAppsIds = new StringBuilder(); StringBuilder newCardsNos = new StringBuilder(); // get all the applications ArrayList allApps = objCardBatchProcessManager.getAllRenewalApplication(issuerId); totalApps = allApps.size(); int count = 0; int cardCount = 0; ArrayList successApps = new ArrayList(); Iterator itr = allApps.iterator(); while (itr.hasNext()) { CardsRenewalDto objCardsRenewalDto = (CardsRenewalDto) itr.next(); CardsDto objCardsDto = objCardManager.getCard(String.valueOf(objCardsRenewalDto.getCardNumber())); CardProductDto objCardProductDto = objCardProductManager.getCardProductDto(objCardsDto.getCardProductId()); ApplicationProcessDto objApplicationProcessDto = objCardBatchProcessManager.getCustomerById(objCardsDto.getCustomerId()); String oldExpDate = objCardsDto.getCardExpDate(); String extendInterval = ""; try { if (objApplicationProcessDto != null) { // assign required fields objApplicationProcessDto.setUserId(objForm.getUserId()); boolean appProcessRes = objCardBatchProcessManager.renewalBatchProcess( objApplicationProcessDto, objCardsDto, indexesList, objCardProductDto, objCardsRenewalDto, objForm.getBatchId(), userId, extendInterval, oldExpDate); if (appProcessRes) { count++; successApps.add(objCardsRenewalDto); cardCount++; genAppsIds.append("'"); genAppsIds.append(objCardsRenewalDto.getCardRenewalSerial()); genAppsIds.append("',"); newCardsNos.append("'"); newCardsNos.append(String.valueOf(objCardsRenewalDto.getCardNumber())); newCardsNos.append("',"); objRenewalBatchProcessSuccess = new RenewalBatchProcessSuccess(); objRenewalBatchProcessSuccess.setApplicationId( objCardsRenewalDto.getCardRenewalSerial()); objRenewalBatchProcessSuccess.setCustomerName( objApplicationProcessDto.getCustomerName()); objRenewalBatchProcessSuccess.setOldCardNumber( String.valueOf(objCardsRenewalDto.getCardNumber())); objRenewalBatchProcessSuccess.setNewCardNumber( String.valueOf(objCardsRenewalDto.getCardNumber())); objRenewalBatchProcessSuccess.setReason(""); objRenewalBatchProcessSuccess.setAppliedDate( DateUtil.convertDateToDateString(objCardsRenewalDto.getUpdatedDate())); appCardsList.add(objRenewalBatchProcessSuccess); } } } catch (Exception e) { logger.error(new Object(), e); System.out.println("Exception on card number generation " + e); } } // insert into batch if (successApps.size() > 0) { CardBatchDto objBatchDto = new CardBatchDto(); if (totalApps == count) { objBatchDto.setStatus(CommonCodes.BATCH_COMPLETED); } else { objBatchDto.setStatus(CommonCodes.BATCH_COMPLETED_PARTIAl); } objBatchDto.setBatchId(objForm.getBatchId()); objBatchDto.setNoOfCardsGenerated(cardCount); objBatchDto.setErrorMsg(""); objBatchDto.setAuthorizedBy(objForm.getAuthUserId()); objBatchDto.setAuthorizedDate(new Date()); objBatchDto.setUpdateddBy(objForm.getUserId()); objBatchDto.setUpdatedDate(new Date()); boolean overallSuccess = objCardBatchProcessManager.addBatch(objBatchDto); if (overallSuccess) { objForm.setSuccessAppsPrimaryList(appCardsList); objForm.setAppIds( genAppsIds.toString().substring(0, (genAppsIds.toString().length() - 1))); objForm.setNewCardNos( newCardsNos.toString().substring(0, (newCardsNos.toString().length() - 1))); return mapping.findForward("reportpage"); } } else { Collection applicationsList = objCardBatchProcessManager.listRenewalCardApps(issuerId, pageNo); objForm.setAppList(applicationsList); int totApps = objCardBatchProcessManager.getTotalRenewalCardsApps(issuerId); objForm.setTotalNoOfApps(String.valueOf(totApps)); request.setAttribute("SEARCHLIST", applicationsList); request.setAttribute("PAGENO", new Integer(pageNo).toString()); errors.add("Error", new ActionError("error.batchprocessfailed")); saveErrors(request, errors); } } } catch (Exception e) { logger.error(new Object(), e); System.out.println(e); Collection applicationsList = objCardBatchProcessManager.listRenewalCardApps(issuerId, pageNo); objForm.setAppList(applicationsList); int totApps = objCardBatchProcessManager.getTotalRenewalCardsApps(issuerId); objForm.setTotalNoOfApps(String.valueOf(totApps)); request.setAttribute("SEARCHLIST", applicationsList); request.setAttribute("PAGENO", new Integer(pageNo).toString()); errors.add("Error", new ActionError("error.applicationerror")); saveErrors(request, errors); } return mapping.findForward("success"); }