em.persist(contactUsLanguage);
}
private void saveLanguage(ContactUs contactUs, ContactUsMaintActionForm form, AdminBean adminBean) throws Exception {
EntityManager em = JpaConnection.getInstance().getCurrentEntityManager();
ContactUsLanguage contactUsLanguage = null;
User user = adminBean.getUser();
Long siteProfileClassId = form.getSiteProfileClassId();
boolean found = false;
Iterator<?> iterator = contactUs.getContactUsLanguages().iterator();
while (iterator.hasNext()) {
contactUsLanguage = (ContactUsLanguage) iterator.next();
if (contactUsLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
found = true;
break;
}
}
if (!found) {
contactUsLanguage = new ContactUsLanguage();
contactUsLanguage.setRecCreateBy(user.getUserId());
contactUsLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
SiteProfileClass siteProfileClass = em.find(SiteProfileClass.class, siteProfileClassId);
contactUsLanguage.setSiteProfileClass(siteProfileClass);
contactUs.getContactUsLanguages().add(contactUsLanguage);
}
if (form.isContactUsNameLangFlag()) {
contactUsLanguage.setContactUsName(form.getContactUsNameLang());
}
else {
contactUsLanguage.setContactUsName(null);
}
if (form.isContactUsDescLangFlag()) {
contactUsLanguage.setContactUsDesc(form.getContactUsDescLang());
}
else {
contactUsLanguage.setContactUsDesc(null);
}
contactUsLanguage.setRecUpdateBy(user.getUserId());
contactUsLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
em.persist(contactUsLanguage);
}