EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
Long siteProfileClassId = form.getSiteProfileClassId();
User user = adminBean.getUser();
Iterator<?> iterator = tax.getTaxLanguages().iterator();
boolean found = false;
TaxLanguage taxLanguage = null;
while (iterator.hasNext()) {
taxLanguage = (TaxLanguage) iterator.next();
if (taxLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
found = true;
break;
}
}
if (!found) {
taxLanguage = new TaxLanguage();
taxLanguage.setRecCreateBy(user.getUserId());
taxLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
SiteProfileClass siteProfileClass = (SiteProfileClass) em.find(SiteProfileClass.class, siteProfileClassId);
taxLanguage.setSiteProfileClass(siteProfileClass);
taxLanguage.setTax(tax);
}
if (form.isTaxCodeLangFlag()) {
taxLanguage.setTaxCode(form.getTaxCodeLang());
}
else {
taxLanguage.setTaxCode(null);
}
if (form.isTaxNameLangFlag()) {
taxLanguage.setTaxName(form.getTaxNameLang());
}
else {
taxLanguage.setTaxName(null);
}
taxLanguage.setRecUpdateBy(user.getUserId());
taxLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
em.persist(taxLanguage);
}