Query query = em.createQuery("from SiteCurrencyClass siteCurrencyClass where siteCurrencyClass.site.siteId = :siteId");
query.setParameter("siteId", site.getSiteId());
Iterator<?> iterator = query.getResultList().iterator();
while (iterator.hasNext()) {
SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) iterator.next();
if (specialPrice != null) {
ItemPriceSearch itemPriceSearch = new ItemPriceSearch();
ItemPriceCurrency itemPriceCurrency = null;
for (ItemPriceCurrency currency : item.getItemPriceCurrencies()) {
if (currency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_SPECIAL) {
continue;
}
if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClass.getSiteCurrencyClassId())) {
itemPriceCurrency = currency;
break;
}
}
if (itemPriceCurrency == null || itemPriceCurrency.getItemPrice() == null) {
itemPriceSearch.setItemPrice(specialPrice.getItemPrice());
itemPriceSearch.setExchangeFactor(Integer.valueOf(1));
}
else {
itemPriceSearch.setItemPrice(itemPriceCurrency.getItemPrice());
itemPriceSearch.setExchangeFactor(Integer.valueOf(0));
}
itemPriceSearch.setItemPricePublishOn(specialPrice.getItemPricePublishOn());
itemPriceSearch.setItemPriceExpireOn(specialPrice.getItemPriceExpireOn());
itemPriceSearch.setRecUpdateBy(adminBean.getUser().getUserId());
itemPriceSearch.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
itemPriceSearch.setRecCreateBy(adminBean.getUser().getUserId());
itemPriceSearch.setRecCreateDatetime(new Date(System.currentTimeMillis()));
itemPriceSearch.setSiteCurrencyClass(siteCurrencyClass);
em.persist(itemPriceSearch);
master.getItemPriceSearches().add(itemPriceSearch);
}
ItemPriceCurrency itemPriceCurrency = null;
for (ItemPriceCurrency currency : item.getItemPriceCurrencies()) {
if (currency.getItemPriceTypeCode() != Constants.ITEM_PRICE_TYPE_CODE_REGULAR) {
continue;
}
if (currency.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClass.getSiteCurrencyClassId())) {
itemPriceCurrency = currency;
break;
}
}
ItemPriceSearch itemPriceSearch = new ItemPriceSearch();