CustomAttributeOptionDisplayForm optionForm = form.getCustomAttribOptions()[i];
CustomAttributeOption customAttributeOption = null;
Long customAttribOptionId = Format.getLong(optionForm.getCustomAttribOptionId());
customAttributeOption = CustomAttributeOptionDAO.load(adminBean.getSite().getSiteId(), customAttribOptionId);
boolean exist = true;
CustomAttributeOptionLanguage customAttributeOptionLanguage = null;
for (CustomAttributeOptionLanguage optionLang : customAttributeOption.getCustomAttributeOptionLanguages()) {
if (optionLang.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
customAttributeOptionLanguage = optionLang;
}
}
if (customAttributeOptionLanguage == null) {
customAttributeOptionLanguage = new CustomAttributeOptionLanguage();
exist = false;
customAttributeOptionLanguage.setRecCreateBy(user.getUserId());
customAttributeOptionLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
SiteProfileClass siteProfileClass = (SiteProfileClass) em.find(SiteProfileClass.class, siteProfileClassId);
customAttributeOptionLanguage.setSiteProfileClass(siteProfileClass);
customAttributeOptionLanguage.setCustomAttributeOption(customAttributeOption);
customAttributeOption.getCustomAttributeOptionLanguages().add(customAttributeOptionLanguage);
}
if (form.isCustomAttribOptionLangFlag()) {
customAttributeOptionLanguage.setCustomAttribValue(optionForm.getCustomAttribValueLang());
}
else {
customAttributeOptionLanguage.setCustomAttribValue(null);
}
customAttributeOptionLanguage.setRecUpdateBy(user.getUserId());
customAttributeOptionLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
if (!exist) {
em.persist(customAttributeOptionLanguage);
}
optionForm.setCustomAttribValueLangFlag(form.isCustomAttribOptionLangFlag());
}