Search in sources :

Example 1 with CfSitelist

use of io.clownfish.clownfish.dbentities.CfSitelist in project Clownfish by rawdog71.

the class SiteUtil method getSitelist_list.

public Map getSitelist_list(CfSite cfsite, Map sitecontentmap) {
    List<CfSitelist> sitelist_list = new ArrayList<>();
    sitelist_list.addAll(cfsitelistService.findBySiteref(cfsite.getId()));
    if (!sitelist_list.isEmpty()) {
        for (CfSitelist sitelist : sitelist_list) {
            CfList cflist = cflistService.findById(sitelist.getCfSitelistPK().getListref());
            Map listcontentmap = new LinkedHashMap();
            List<CfListcontent> contentlist = cflistcontentService.findByListref(cflist.getId());
            for (CfListcontent listcontent : contentlist) {
                CfClasscontent classcontent = cfclasscontentService.findById(listcontent.getCfListcontentPK().getClasscontentref());
                cfclassService.findById(classcontent.getClassref().getId());
                List<CfAttributcontent> attributcontentlist = new ArrayList<>();
                attributcontentlist.addAll(cfattributcontentService.findByClasscontentref(classcontent));
                if (0 == useHibernate) {
                    listcontentmap.put(classcontent.getName(), classutil.getattributmap(classcontent));
                } else {
                    listcontentmap.put(classcontent.getName(), hibernateutil.getContent(classcontent.getClassref().getName(), classcontent.getId()));
                }
            }
            sitecontentmap.put(cflist.getName(), listcontentmap);
        }
    }
    return sitecontentmap;
}
Also used : CfList(io.clownfish.clownfish.dbentities.CfList) CfSitelist(io.clownfish.clownfish.dbentities.CfSitelist) ArrayList(java.util.ArrayList) CfAttributcontent(io.clownfish.clownfish.dbentities.CfAttributcontent) CfListcontent(io.clownfish.clownfish.dbentities.CfListcontent) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent) LinkedHashMap(java.util.LinkedHashMap)

Example 2 with CfSitelist

use of io.clownfish.clownfish.dbentities.CfSitelist in project Clownfish by rawdog71.

the class SiteTreeBean method onSelect.

public void onSelect(NodeSelectEvent event) {
    selectedNode = event.getTreeNode();
    selectedSite = (CfSite) selectedNode.getData();
    classcontentlist = cfclasscontentService.findByMaintenance(true);
    if (null != selectedSite.getTemplateref()) {
        CfTemplate template = cftemplateService.findById(selectedSite.getTemplateref().longValue());
        int idx = templatelist.getTemplateListe().indexOf(template);
        selectedTemplate = templatelist.getTemplateListe().get(idx);
        iframeurl = selectedSite.getName() + "?preview=true";
        selectedDiv = null;
        showContent = false;
        showDatalist = false;
        showAsset = false;
        showAssetLibrary = false;
        showKeywordLibrary = false;
        if (template.isLayout()) {
            contenteditable = true;
            FacesMessage message = new FacesMessage("LAYOUT TEMPLATE");
            FacesContext.getCurrentInstance().addMessage(null, message);
            // List<CfLayoutcontent> layoutcontent = cflayoutcontentService.findBySiteref(selectedSite.getId());
            layout = new CfLayout(template.getName());
            Document doc = Jsoup.parse(template.getContent());
            Elements divs = doc.getElementsByAttribute("template");
            for (Element div : divs) {
                String contents = div.attr("contents");
                String datalists = div.attr("datalists");
                String assets = div.attr("assets");
                String assetlists = div.attr("assetlists");
                String keywordlists = div.attr("keywordlists");
                CfDiv cfdiv = new CfDiv();
                cfdiv.setId(div.attr("id"));
                cfdiv.setName(div.attr("template"));
                if (!contents.isEmpty()) {
                    cfdiv.getContentArray().addAll(ClownfishUtil.toList(contents.split(",")));
                }
                if (!datalists.isEmpty()) {
                    cfdiv.getContentlistArray().addAll(ClownfishUtil.toList(datalists.split(",")));
                }
                if (!assets.isEmpty()) {
                    cfdiv.getAssetArray().addAll(ClownfishUtil.toList(assets.split(",")));
                }
                if (!assetlists.isEmpty()) {
                    cfdiv.getAssetlistArray().addAll(ClownfishUtil.toList(assetlists.split(",")));
                }
                if (!keywordlists.isEmpty()) {
                    cfdiv.getKeywordlistArray().addAll(ClownfishUtil.toList(keywordlists.split(",")));
                }
                layout.getDivArray().put(div.attr("id"), cfdiv);
            }
        } else {
            contenteditable = false;
            selected_contentclass = null;
            selected_datalisttclass = null;
            selected_asset = null;
            selected_assetlist = null;
            selected_keywordlist = null;
        }
    } else {
        selectedTemplate = null;
    }
    if (null != selectedSite.getStylesheetref()) {
        CfStylesheet styleshet = cfstylesheetService.findById(selectedSite.getStylesheetref().longValue());
        int idx = stylesheetlist.getStylesheetListe().indexOf(styleshet);
        selectedStylesheet = stylesheetlist.getStylesheetListe().get(idx);
    } else {
        selectedStylesheet = null;
    }
    if (null != selectedSite.getJavascriptref()) {
        CfJavascript javascript = cfjavascriptService.findById(selectedSite.getJavascriptref().longValue());
        int idx = javascriptlist.getJavascriptListe().indexOf(javascript);
        selectedJavascript = javascriptlist.getJavascriptListe().get(idx);
    } else {
        selectedJavascript = null;
    }
    selectedDatasources.clear();
    List<CfSitedatasource> selectedSiteDatasources = cfsitedatasourceService.findBySiteref(selectedSite.getId());
    for (CfSitedatasource sitedatasource : selectedSiteDatasources) {
        CfDatasource ds = cfdatasourceService.findById(sitedatasource.getCfSitedatasourcePK().getDatasourceref());
        selectedDatasources.add(ds);
    }
    selectedContentlist.clear();
    List<CfSitelist> selectedSitecontentlist = cfsitelistService.findBySiteref(selectedSite.getId());
    for (CfSitelist sitelist : selectedSitecontentlist) {
        CfList cl = cflistService.findById(sitelist.getCfSitelistPK().getListref());
        selectedContentlist.add(cl);
    }
    selectedClasscontentlist.clear();
    List<CfSitecontent> selectedClasscontentliste = cfsitecontentService.findBySiteref(selectedSite.getId());
    for (CfSitecontent sitecontent : selectedClasscontentliste) {
        CfClasscontent cc = cfclasscontentService.findById(sitecontent.getCfSitecontentPK().getClasscontentref());
        selectedClasscontentlist.add(cc);
    }
    selectedAssetlist.clear();
    List<CfSiteassetlist> selectedAssetliste = cfsiteassetlistService.findBySiteref(selectedSite.getId());
    for (CfSiteassetlist siteassetlist : selectedAssetliste) {
        CfAssetlist csa = cfassetlistService.findById(siteassetlist.getCfSiteassetlistPK().getAssetlistref());
        selectedAssetlist.add(csa);
    }
    selectedKeywordlist.clear();
    List<CfSitekeywordlist> selectedKeywordliste = cfsitekeywordlistService.findBySiteref(selectedSite.getId());
    for (CfSitekeywordlist sitekeywordlist : selectedKeywordliste) {
        CfKeywordlist kwl = cfkeywordlistService.findById(sitekeywordlist.getCfSitekeywordlistPK().getKeywordlistref());
        selectedKeywordlist.add(kwl);
    }
    siteName = selectedSite.getName();
    siteTitle = selectedSite.getTitle();
    siteDescription = selectedSite.getDescription();
    sitejob = selectedSite.isJob();
    sitesearchrelevant = selectedSite.isSearchrelevant();
    sitemap = selectedSite.isSitemap();
    sitestatic = selectedSite.isStaticsite();
    aliaspath = selectedSite.getAliaspath();
    sitehtmlcompression = selectedSite.getHtmlcompression();
    characterEncoding = selectedSite.getCharacterencoding();
    contentType = selectedSite.getContenttype();
    locale = selectedSite.getLocale();
    saprfclist = cfsitesaprfcService.findBySiteref(selectedSite.getId());
    newButtonDisabled = true;
    FacesMessage message = new FacesMessage("Selected " + selectedSite.getName());
    FacesContext.getCurrentInstance().addMessage(null, message);
}
Also used : CfSitedatasource(io.clownfish.clownfish.dbentities.CfSitedatasource) Element(org.jsoup.nodes.Element) CfDatasource(io.clownfish.clownfish.dbentities.CfDatasource) CfSiteassetlist(io.clownfish.clownfish.dbentities.CfSiteassetlist) CfAssetlist(io.clownfish.clownfish.dbentities.CfAssetlist) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent) CfTemplate(io.clownfish.clownfish.dbentities.CfTemplate) CfDiv(io.clownfish.clownfish.datamodels.CfDiv) CfSitekeywordlist(io.clownfish.clownfish.dbentities.CfSitekeywordlist) CfList(io.clownfish.clownfish.dbentities.CfList) CfJavascript(io.clownfish.clownfish.dbentities.CfJavascript) CfKeywordlist(io.clownfish.clownfish.dbentities.CfKeywordlist) CfLayout(io.clownfish.clownfish.datamodels.CfLayout) CfSitecontent(io.clownfish.clownfish.dbentities.CfSitecontent) CfSitelist(io.clownfish.clownfish.dbentities.CfSitelist) CfStylesheet(io.clownfish.clownfish.dbentities.CfStylesheet) FacesMessage(javax.faces.application.FacesMessage)

Example 3 with CfSitelist

use of io.clownfish.clownfish.dbentities.CfSitelist 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)

Example 4 with CfSitelist

use of io.clownfish.clownfish.dbentities.CfSitelist in project Clownfish by rawdog71.

the class CfSitelistDAOImpl method findAll.

@Override
public List<CfSitelist> findAll() {
    Session session = this.sessionFactory.getCurrentSession();
    TypedQuery query = (TypedQuery) session.getNamedQuery("CfSitelist.findAll");
    List<CfSitelist> cfsitelistlist = query.getResultList();
    return cfsitelistlist;
}
Also used : TypedQuery(javax.persistence.TypedQuery) CfSitelist(io.clownfish.clownfish.dbentities.CfSitelist) Session(org.hibernate.Session)

Example 5 with CfSitelist

use of io.clownfish.clownfish.dbentities.CfSitelist in project Clownfish by rawdog71.

the class CfSitelistDAOImpl method findByListref.

@Override
public List<CfSitelist> findByListref(Long ref) {
    Session session = this.sessionFactory.getCurrentSession();
    TypedQuery query = (TypedQuery) session.getNamedQuery("CfSitelist.findByListref");
    query.setParameter("listref", ref);
    List<CfSitelist> cfsitelistlist = query.getResultList();
    return cfsitelistlist;
}
Also used : TypedQuery(javax.persistence.TypedQuery) CfSitelist(io.clownfish.clownfish.dbentities.CfSitelist) Session(org.hibernate.Session)

Aggregations

CfSitelist (io.clownfish.clownfish.dbentities.CfSitelist)6 CfClasscontent (io.clownfish.clownfish.dbentities.CfClasscontent)3 CfList (io.clownfish.clownfish.dbentities.CfList)3 TypedQuery (javax.persistence.TypedQuery)3 Session (org.hibernate.Session)3 CfAssetlist (io.clownfish.clownfish.dbentities.CfAssetlist)2 CfDatasource (io.clownfish.clownfish.dbentities.CfDatasource)2 CfKeywordlist (io.clownfish.clownfish.dbentities.CfKeywordlist)2 CfSiteassetlist (io.clownfish.clownfish.dbentities.CfSiteassetlist)2 CfSitecontent (io.clownfish.clownfish.dbentities.CfSitecontent)2 CfSitedatasource (io.clownfish.clownfish.dbentities.CfSitedatasource)2 CfSitekeywordlist (io.clownfish.clownfish.dbentities.CfSitekeywordlist)2 FacesMessage (javax.faces.application.FacesMessage)2 CfDiv (io.clownfish.clownfish.datamodels.CfDiv)1 CfLayout (io.clownfish.clownfish.datamodels.CfLayout)1 CfAttributcontent (io.clownfish.clownfish.dbentities.CfAttributcontent)1 CfJavascript (io.clownfish.clownfish.dbentities.CfJavascript)1 CfListcontent (io.clownfish.clownfish.dbentities.CfListcontent)1 CfSiteassetlistPK (io.clownfish.clownfish.dbentities.CfSiteassetlistPK)1 CfSitecontentPK (io.clownfish.clownfish.dbentities.CfSitecontentPK)1