CustomAttributeOptionDisplayForm optionForm = form.getCustomAttribOptions()[i];
CustomAttributeOption customAttributeOption = null;
Long customAttribOptionId = Format.getLong(optionForm.getCustomAttribOptionId());
customAttributeOption = CustomAttributeOptionDAO.load(adminBean.getSite().getSiteId(), customAttribOptionId);
boolean exist = true;
CustomAttributeOptionCurrency customAttributeOptionCurrency = null;
for (CustomAttributeOptionCurrency optionCurr : customAttributeOption.getCustomAttributeOptionCurrencies()) {
if (optionCurr.getSiteCurrencyClass().getSiteCurrencyClassId().equals(siteCurrencyClassId)) {
customAttributeOptionCurrency = optionCurr;
}
}
if (customAttributeOptionCurrency == null) {
customAttributeOptionCurrency = new CustomAttributeOptionCurrency();
exist = false;
customAttributeOptionCurrency.setRecCreateBy(user.getUserId());
customAttributeOptionCurrency.setRecCreateDatetime(new Date(System.currentTimeMillis()));
SiteCurrencyClass siteCurrencyClass = (SiteCurrencyClass) em.find(SiteCurrencyClass.class, siteCurrencyClassId);
customAttributeOptionCurrency.setSiteCurrencyClass(siteCurrencyClass);
customAttributeOptionCurrency.setCustomAttributeOption(customAttributeOption);
customAttributeOption.getCustomAttributeOptionCurrencies().add(customAttributeOptionCurrency);
}
if (form.isCustomAttribOptionCurrFlag()) {
customAttributeOptionCurrency.setCustomAttribValue(optionForm.getCustomAttribValueCurr());
}
else {
customAttributeOptionCurrency.setCustomAttribValue(null);
}
customAttributeOptionCurrency.setRecUpdateBy(user.getUserId());
customAttributeOptionCurrency.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
if (!exist) {
em.persist(customAttributeOptionCurrency);
}
optionForm.setCustomAttribValueCurrFlag(form.isCustomAttribOptionCurrFlag());
}