use of io.clownfish.clownfish.dbentities.CfSitedatasourcePK in project Clownfish by rawdog71.
the class SiteTreeBean method onChange.
public void onChange(ActionEvent actionEvent) {
if (null != selectedSite) {
if (null != selectedStylesheet) {
selectedSite.setStylesheetref(BigInteger.valueOf(selectedStylesheet.getId().intValue()));
} else {
selectedSite.setStylesheetref(null);
}
if (null != selectedTemplate) {
selectedSite.setTemplateref(BigInteger.valueOf(selectedTemplate.getId().intValue()));
} else {
selectedSite.setTemplateref(null);
}
if (null != selectedJavascript) {
selectedSite.setJavascriptref(BigInteger.valueOf(selectedJavascript.getId().intValue()));
} else {
selectedSite.setJavascriptref(null);
}
// Delete siteresources first
List<CfSitedatasource> sitedatasourceList = cfsitedatasourceService.findBySiteref(selectedSite.getId());
for (CfSitedatasource sitedatasource : sitedatasourceList) {
cfsitedatasourceService.delete(sitedatasource);
}
// Add selected siteresources
if (!selectedDatasources.isEmpty()) {
for (CfDatasource datasource : selectedDatasources) {
CfSitedatasource sitedatasource = new CfSitedatasource();
CfSitedatasourcePK cfsitedatasourcePK = new CfSitedatasourcePK();
cfsitedatasourcePK.setSiteref(selectedSite.getId());
cfsitedatasourcePK.setDatasourceref(datasource.getId());
sitedatasource.setCfSitedatasourcePK(cfsitedatasourcePK);
cfsitedatasourceService.create(sitedatasource);
}
}
// Delete sitelists first
List<CfSitelist> sitelists = cfsitelistService.findBySiteref(selectedSite.getId());
for (CfSitelist sitelist : sitelists) {
cfsitelistService.delete(sitelist);
}
// Add selected sitelists
if (!selectedContentlist.isEmpty()) {
for (CfList contentList : selectedContentlist) {
CfSitelist sitelist = new CfSitelist();
CfSitelistPK cfsitelistPK = new CfSitelistPK();
cfsitelistPK.setSiteref(selectedSite.getId());
cfsitelistPK.setListref(contentList.getId());
sitelist.setCfSitelistPK(cfsitelistPK);
cfsitelistService.create(sitelist);
}
}
// Delete sitecontent first
List<CfSitecontent> contentlists = cfsitecontentService.findBySiteref(selectedSite.getId());
for (CfSitecontent content : contentlists) {
cfsitecontentService.delete(content);
}
// Add selected sitecontent
if (!selectedClasscontentlist.isEmpty()) {
for (CfClasscontent content : selectedClasscontentlist) {
CfSitecontent sitecontent = new CfSitecontent();
CfSitecontentPK cfsitecontentPK = new CfSitecontentPK();
cfsitecontentPK.setSiteref(selectedSite.getId());
cfsitecontentPK.setClasscontentref(content.getId());
sitecontent.setCfSitecontentPK(cfsitecontentPK);
cfsitecontentService.create(sitecontent);
}
}
// Delete siteassetlist first
List<CfSiteassetlist> siteassetlists = cfsiteassetlistService.findBySiteref(selectedSite.getId());
for (CfSiteassetlist assetList : siteassetlists) {
cfsiteassetlistService.delete(assetList);
}
// Add selected sitecontent
if (!selectedAssetlist.isEmpty()) {
for (CfAssetlist content : selectedAssetlist) {
CfSiteassetlist siteassetlist = new CfSiteassetlist();
CfSiteassetlistPK cfsitecontentPK = new CfSiteassetlistPK();
cfsitecontentPK.setSiteref(selectedSite.getId());
cfsitecontentPK.setAssetlistref(content.getId());
siteassetlist.setCfSiteassetlistPK(cfsitecontentPK);
cfsiteassetlistService.create(siteassetlist);
}
}
// Delete sitekeywordlist first
List<CfSitekeywordlist> sitekeywordlists = cfsitekeywordlistService.findBySiteref(selectedSite.getId());
for (CfSitekeywordlist keywordList : sitekeywordlists) {
cfsitekeywordlistService.delete(keywordList);
}
// Add selected sitecontent
if (!selectedKeywordlist.isEmpty()) {
for (CfKeywordlist content : selectedKeywordlist) {
CfSitekeywordlist sitekeywordlist = new CfSitekeywordlist();
CfSitekeywordlistPK cfsitecontentPK = new CfSitekeywordlistPK();
cfsitecontentPK.setSiteref(selectedSite.getId());
cfsitecontentPK.setKeywordlistref(content.getId());
sitekeywordlist.setCfSitekeywordlistPK(cfsitecontentPK);
cfsitekeywordlistService.create(sitekeywordlist);
}
}
selectedSite.setName(siteName);
selectedSite.setHtmlcompression(sitehtmlcompression);
selectedSite.setCharacterencoding(characterEncoding);
selectedSite.setContenttype(contentType);
selectedSite.setLocale(locale);
selectedSite.setAliaspath(aliaspath);
selectedSite.setTitle(siteTitle);
selectedSite.setDescription(siteDescription);
selectedSite.setJob(sitejob);
selectedSite.setSearchrelevant(sitesearchrelevant);
selectedSite.setSitemap(sitemap);
selectedSite.setStaticsite(sitestatic);
cfsiteService.edit(selectedSite);
loadTree();
FacesMessage message = new FacesMessage("Changed " + selectedSite.getName());
FacesContext.getCurrentInstance().addMessage(null, message);
}
}
Aggregations