Long siteProfileClassId = form.getSiteProfileClassId();
User user = adminBean.getUser();
Iterator<?> iterator = homePage.getHomePageLanguages().iterator();
boolean found = false;
HomePageLanguage homePageLanguage = null;
while (iterator.hasNext()) {
homePageLanguage = (HomePageLanguage) iterator.next();
if (homePageLanguage.getSiteProfileClass().getSiteProfileClassId().equals(siteProfileClassId)) {
found = true;
break;
}
}
if (!found) {
homePageLanguage = new HomePageLanguage();
homePageLanguage.setRecCreateBy(user.getUserId());
homePageLanguage.setRecCreateDatetime(new Date(System.currentTimeMillis()));
SiteProfileClass siteProfileClass = (SiteProfileClass) em.find(SiteProfileClass.class, siteProfileClassId);
homePageLanguage.setSiteProfileClass(siteProfileClass);
homePageLanguage.setHomePage(homePage);
}
if (form.isPageTitleLangFlag()) {
homePageLanguage.setHomePageTitle(form.getPageTitleLang());
}
else {
homePageLanguage.setHomePageTitle(null);
}
if (form.isMetaKeywordsLangFlag()) {
homePageLanguage.setMetaKeywords(form.getMetaKeywords());
}
else {
homePageLanguage.setMetaKeywords(null);
}
if (form.isMetaDescriptionLangFlag()) {
homePageLanguage.setMetaDescription(form.getMetaDescriptionLang());
}
else {
homePageLanguage.setMetaDescription(null);
}
homePageLanguage.setRecUpdateBy(user.getUserId());
homePageLanguage.setRecUpdateDatetime(new Date(System.currentTimeMillis()));
if (!found) {
em.persist(homePageLanguage);
}
}