Search in sources :

Example 1 with CfSitedatasourcePK

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);
    }
}
Also used : CfSitedatasource(io.clownfish.clownfish.dbentities.CfSitedatasource) CfKeywordlist(io.clownfish.clownfish.dbentities.CfKeywordlist) CfSitedatasourcePK(io.clownfish.clownfish.dbentities.CfSitedatasourcePK) CfSitelistPK(io.clownfish.clownfish.dbentities.CfSitelistPK) CfSiteassetlistPK(io.clownfish.clownfish.dbentities.CfSiteassetlistPK) CfSitecontent(io.clownfish.clownfish.dbentities.CfSitecontent) CfSitelist(io.clownfish.clownfish.dbentities.CfSitelist) CfDatasource(io.clownfish.clownfish.dbentities.CfDatasource) CfSiteassetlist(io.clownfish.clownfish.dbentities.CfSiteassetlist) CfAssetlist(io.clownfish.clownfish.dbentities.CfAssetlist) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent) CfSitecontentPK(io.clownfish.clownfish.dbentities.CfSitecontentPK) CfSitekeywordlistPK(io.clownfish.clownfish.dbentities.CfSitekeywordlistPK) CfSitekeywordlist(io.clownfish.clownfish.dbentities.CfSitekeywordlist) CfList(io.clownfish.clownfish.dbentities.CfList) FacesMessage(javax.faces.application.FacesMessage)

Aggregations

CfAssetlist (io.clownfish.clownfish.dbentities.CfAssetlist)1 CfClasscontent (io.clownfish.clownfish.dbentities.CfClasscontent)1 CfDatasource (io.clownfish.clownfish.dbentities.CfDatasource)1 CfKeywordlist (io.clownfish.clownfish.dbentities.CfKeywordlist)1 CfList (io.clownfish.clownfish.dbentities.CfList)1 CfSiteassetlist (io.clownfish.clownfish.dbentities.CfSiteassetlist)1 CfSiteassetlistPK (io.clownfish.clownfish.dbentities.CfSiteassetlistPK)1 CfSitecontent (io.clownfish.clownfish.dbentities.CfSitecontent)1 CfSitecontentPK (io.clownfish.clownfish.dbentities.CfSitecontentPK)1 CfSitedatasource (io.clownfish.clownfish.dbentities.CfSitedatasource)1 CfSitedatasourcePK (io.clownfish.clownfish.dbentities.CfSitedatasourcePK)1 CfSitekeywordlist (io.clownfish.clownfish.dbentities.CfSitekeywordlist)1 CfSitekeywordlistPK (io.clownfish.clownfish.dbentities.CfSitekeywordlistPK)1 CfSitelist (io.clownfish.clownfish.dbentities.CfSitelist)1 CfSitelistPK (io.clownfish.clownfish.dbentities.CfSitelistPK)1 FacesMessage (javax.faces.application.FacesMessage)1