public List<SelectItem> getCustomerClassList() { if (customerClassList == null) { customerClassList = new ArrayList<SelectItem>(); customerClassList.add(new SelectItem("", "--select--")); for (CustomerClass customerClass : CustomerClass.values()) { customerClassList.add(new SelectItem(customerClass.name(), customerClass.name())); } } return customerClassList; }
public String next() { try { if (this.fieldsAreValid()) { getRegInfo().getCustomer().setTitle(selectedTitle); getRegInfo().getCustomer().setGender(Gender.valueOf(selectedGender)); getRegInfo().getCustomer().setMaritalStatus(MaritalStatus.valueOf(selectedMaritalStatus)); getRegInfo().getCustomer().setCustomerClass(CustomerClass.valueOf(selectedCustomerClass)); getRegInfo() .getCustomer() .setDateOfBirth(DateUtil.convertToXMLGregorianCalendar(dateOfBirth)); getRegInfo() .getCustomer() .setNationalId(StringUtil.formatNationalId(getRegInfo().getCustomer().getNationalId())); getRegInfo().getCustomer().setCustomerAutoRegStatus(CustomerAutoRegStatus.NEVER); Profile profile = super.getProfileService().getProfileByUserName(super.getJaasUserName()); if (profile == null || profile.getId() == null) { super.setErrorMessage("You are not logged in. Log in first."); return "failure"; } getRegInfo().getMobileProfileList().clear(); getRegInfo().getCustomer().setBranchId(profile.getBranchId()); /* * Uncomment this later */ getRegInfo().getCustomer().setCustomerLastBranch(profile.getBranchId()); if (profile1.getMobileNumber() != null && !profile1.getMobileNumber().trim().equals("")) { profile1.setNetwork(MobileNetworkOperator.valueOf(selectedNetwork1)); profile1.setPrimary(true); /* * Uncomment later */ profile1.setMobileProfileEditBranch(profile.getBranchId()); getRegInfo().getMobileProfileList().add(profile1); } LOG.debug("1 number pf mobileprofile list ....." + regInfo.getMobileProfileList().size()); if (profile2.getMobileNumber() != null && !profile2.getMobileNumber().trim().equals("")) { profile2.setNetwork(MobileNetworkOperator.valueOf(selectedNetwork2)); profile2.setMobileProfileEditBranch(profile.getBranchId()); getRegInfo().getMobileProfileList().add(profile2); } LOG.debug("2 number pf mobileprofile list ....." + regInfo.getMobileProfileList().size()); if (profile3.getMobileNumber() != null && !profile3.getMobileNumber().trim().equals("")) { profile3.setNetwork(MobileNetworkOperator.valueOf(selectedNetwork3)); profile3.setMobileProfileEditBranch(profile.getBranchId()); getRegInfo().getMobileProfileList().add(profile3); } LOG.debug(" number pf mobileprofile list ....." + regInfo.getMobileProfileList().size()); for (MobileProfile mobileProfile : regInfo.getMobileProfileList()) { // format mobile number LOG.debug(" number pf mobileprofile list ....." + regInfo.getMobileProfileList().size()); LOG.debug("mobilr number>>>>>>>>>>>>>>>>>>>>>>>>>>>" + mobileProfile.getMobileNumber()); try { mobileProfile.setMobileNumber( NumberUtil.formatMobileNumber(mobileProfile.getMobileNumber())); // check existence MobileProfile mobileCheck = super.getCustomerService() .getMobileProfileByMobileNumber(mobileProfile.getMobileNumber()); if (mobileCheck != null && mobileCheck.getMobileNumber() != null && !mobileCheck .getStatus() .toString() .equalsIgnoreCase(MobileProfileStatus.DELETED.toString())) { super.setErrorMessage( "Mobile Number " + mobileProfile.getMobileNumber() + " is already registered."); return "failure"; } /*if (super.getCustomerService().getMobileProfileByMobileNumber(mobileProfile.getMobileNumber()) != null) { super.setErrorMessage("Mobile Number " + mobileProfile.getMobileNumber() + " is already registered."); return "failure"; }*/ if (validateMobileAndNetwork(mobileProfile)) { // valid } else { // Network and number do not match return super.setErrorMessage( "Mobile Number " + mobileProfile.getMobileNumber() + " not in the " + mobileProfile.getNetwork().name() + " network."); return "failure"; } } catch (Exception e) { super.setErrorMessage("Mobile Number is not in correct format."); return "failure"; } if (referralCode != null && !referralCode.trim().equals("")) { Referral referral = super.getReferralService() .getReferralByReferredMobileAndCode( mobileProfile.getMobileNumber(), Integer.parseInt(referralCode)); if (referral != null && referral.getId() != null) { getRegInfo().setReferral(referral); } } } // process referral // String referralCode = getRegInfo().getMobileProfile().getReferralCode(); // String mobileNumber = getRegInfo().getMobileProfile().getMobileNumber(); // if (referralCode != null) { // Referral referral = referralService.getReferralByReferredMobileAndCode(mobileNumber, // Integer.parseInt(referralCode)); // if (referral != null) { // if (!referral.getStatus().equals(ReferralStatus.NEW)) { // super.setErrorMessage("Referral Code is in an invalid state: " + // referral.getStatus().name()); // return "failure"; // } // } else { // super.setErrorMessage("ERROR: Referral Code does not exist."); // return "failure"; // } // } this.putVariablesInSessionScope(); } else { return "failure"; } } catch (Exception e) { e.printStackTrace(); super.setErrorMessage(PageCodeBase.ERROR_MESSAGE); return "failure"; } gotoPage("/csr/registerCustomer2.jspx"); return "next"; }