Query query = em.createQuery("from country in class Country where country.siteId = :siteId order by country.countryName");
query.setParameter("siteId", siteId);
Iterator<?> iterator = query.getResultList().iterator();
Vector<LabelValueBean> vector = new Vector<LabelValueBean>();
while (iterator.hasNext()) {
Country country = (Country) iterator.next();
LabelValueBean bean = new LabelValueBean(country.getCountryName(), country.getCountryCode());
vector.add(bean);
}
LabelValueBean countries[] = new LabelValueBean[vector.size()];
vector.copyInto(countries);
form.setCountries(countries);
String sql = "from CreditCard credit_card where siteId = :siteId order by seqNum";
query = em.createQuery(sql);
query.setParameter("siteId", siteId);
iterator = query.getResultList().iterator();
vector = new Vector<LabelValueBean>();
while (iterator.hasNext()) {
CreditCard creditCard = (CreditCard) iterator.next();
LabelValueBean bean = new LabelValueBean(creditCard.getCreditCardDesc(), creditCard.getCreditCardId().toString());
vector.add(bean);
}
LabelValueBean creditCards[] = new LabelValueBean[vector.size()];
vector.copyInto(creditCards);
form.setCreditCards(creditCards);
LabelValueBean expiryMonths[] = {new LabelValueBean("01", "01"),
new LabelValueBean("02", "02"),
new LabelValueBean("03", "03"),
new LabelValueBean("04", "04"),
new LabelValueBean("05", "05"),
new LabelValueBean("06", "06"),
new LabelValueBean("07", "07"),
new LabelValueBean("08", "08"),
new LabelValueBean("09", "09"),
new LabelValueBean("10", "10"),
new LabelValueBean("11", "11"),
new LabelValueBean("12", "12")};
LabelValueBean expiryYears[] = {new LabelValueBean("2011", "2011"),
new LabelValueBean("2012", "2012"),
new LabelValueBean("2013", "2013"),
new LabelValueBean("2014", "2014"),
new LabelValueBean("2015", "2015"),
new LabelValueBean("2016", "2016"),
new LabelValueBean("2017", "2017"),
new LabelValueBean("2018", "2018"),
new LabelValueBean("2019", "2019"),
new LabelValueBean("2020", "2020"),
new LabelValueBean("2021", "2021"),
new LabelValueBean("2022", "2022"),
new LabelValueBean("2023", "2023"),
new LabelValueBean("2024", "2024"),
new LabelValueBean("2025", "2025"),
new LabelValueBean("2026", "2026"),
new LabelValueBean("2027", "2027"),
new LabelValueBean("2028", "2028"),
new LabelValueBean("2029", "2029"),
};
form.setExpiryMonths(expiryMonths);
form.setExpiryYears(expiryYears);
Country estimateCountry = CountryDAO.loadByCountryCode(siteId, form.getEstimateCountryCode());
Vector<LabelValueBean> estimateStateVector = new Vector<LabelValueBean>();
if (estimateCountry != null) {
for (State state : estimateCountry.getStates()) {
LabelValueBean bean = new LabelValueBean(state.getStateName(), state.getStateCode());
estimateStateVector.add(bean);
}
LabelValueBean states[] = new LabelValueBean[estimateStateVector.size()];
estimateStateVector.copyInto(states);
form.setEstimateStates(states);
}
else {
LabelValueBean states[] = {};
form.setEstimateStates(states);
}
Country custCountry = CountryDAO.loadByCountryCode(siteId, form.getCustCountryCode());
Vector<LabelValueBean> stateVector = new Vector<LabelValueBean>();
if (custCountry != null) {
for (State state : custCountry.getStates()) {
LabelValueBean bean = new LabelValueBean(state.getStateName(), state.getStateCode());
stateVector.add(bean);
}
LabelValueBean states[] = new LabelValueBean[stateVector.size()];
stateVector.copyInto(states);
form.setCustStates(states);
}
else {
LabelValueBean states[] = {};
form.setCustStates(states);
}
custCountry = CountryDAO.loadByCountryCode(siteId, form.getBillingCustCountryCode());
stateVector = new Vector<LabelValueBean>();
if (custCountry != null) {
for (State state : custCountry.getStates()) {
LabelValueBean bean = new LabelValueBean(state.getStateName(), state.getStateCode());
stateVector.add(bean);
}
LabelValueBean states[] = new LabelValueBean[stateVector.size()];
stateVector.copyInto(states);
form.setBillingCustStates(states);
}
else {
LabelValueBean states[] = {};
form.setBillingCustStates(states);
}
custCountry = CountryDAO.loadByCountryCode(siteId, form.getShippingCustCountryCode());
stateVector = new Vector<LabelValueBean>();
if (custCountry != null) {
for (State state : custCountry.getStates()) {
LabelValueBean bean = new LabelValueBean(state.getStateName(), state.getStateCode());
stateVector.add(bean);
}
LabelValueBean states[] = new LabelValueBean[stateVector.size()];
stateVector.copyInto(states);