"left join taxRegion.site site " +
"where site.siteId = :siteId";
Query query = em.createQuery(sql);
query.setParameter("siteId", contentBean.getSiteDomain().getSite().getSiteId());
boolean found = false;
TaxRegion tr = null;
Vector<TaxRegion> vector = new Vector<TaxRegion>();
Iterator<?> iterator = query.getResultList().iterator();
while (iterator.hasNext()) {
tr = (TaxRegion) iterator.next();
if (tr.getPublished() != Constants.VALUE_YES) {
continue;
}
Iterator<?> iteratorCountry = null;
iteratorCountry = tr.getCountries().iterator();
while (iteratorCountry.hasNext()) {
Country country = (Country) iteratorCountry.next();
if (country.getCountryId().equals(shippingAddress.getCountry().getCountryId())) {
vector.add(tr);
break;
}
}
if (!found) {
if (shippingAddress.getState() != null) {
Iterator<?> iteratorState = null;
iteratorState = tr.getStates().iterator();
while (iteratorState.hasNext()) {
State state = (State) iteratorState.next();
if (state.getStateId().equals(shippingAddress.getState().getStateId())) {
vector.add(tr);
break;
}
}
}
}
String zipCode = shippingAddress.getCustZipCode();
if (!found && !Format.isNullOrEmpty(zipCode)) {
Iterator<?> iteratorZipCode = tr.getZipCodes().iterator();
while (iteratorZipCode.hasNext()) {
TaxRegionZip trZip = (TaxRegionZip) iteratorZipCode.next();
if (zipCode.compareTo(trZip.getZipCodeStart()) >= 0 &&
zipCode.compareTo(trZip.getZipCodeEnd()) <= 0) {
vector.add(tr);