/** * For special phone numbers: id:# or # | name. * * @return true, if the phone number was successfully processed. */ private boolean processPhoneNumber() { final String phoneNumber = form.getPhoneNumber(); if (StringUtils.isNotEmpty(phoneNumber) == true) { if (phoneNumber.startsWith("id:") == true && phoneNumber.length() > 3) { final Integer id = NumberHelper.parseInteger(phoneNumber.substring(3)); if (id != null) { form.setPhoneNumber(""); final AddressDO address = addressDao.getById(id); if (address != null) { form.setAddress(address); final String no = getFirstPhoneNumber(); if (StringUtils.isNotEmpty(no) == true) { setPhoneNumber(no, true); } } } return true; } else if (phoneNumber.indexOf(SEPARATOR) >= 0) { final int pos = phoneNumber.indexOf(SEPARATOR); final String rest = phoneNumber.substring(pos + SEPARATOR.length()); final int numberPos = rest.indexOf('#'); form.setPhoneNumber(phoneNumber.substring(0, pos)); if (numberPos > 0) { final Integer id = NumberHelper.parseInteger(rest.substring(numberPos + 1)); if (id != null) { final AddressDO address = addressDao.getById(id); if (address != null) { form.setAddress(address); } } else { form.setAddress(null); } } else { form.setAddress(null); } return true; } } return false; }
public void setAddressId(final Integer addressId) { if (addressId != null) { final AddressDO address = addressDao.getById(addressId); form.address = address; } }