Search in sources :

Example 6 with CfKeywordlist

use of io.clownfish.clownfish.dbentities.CfKeywordlist 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 7 with CfKeywordlist

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

the class KeywordContentList method onCreate.

public void onCreate(ActionEvent actionEvent) {
    try {
        keywordlistname = keywordlistname.trim().replaceAll("\\s+", "_");
        cfkeywordlistService.findByName(keywordlistname);
    } catch (NoResultException ex) {
        CfKeywordlist newkeywordlist = new CfKeywordlist();
        newkeywordlist.setName(keywordlistname);
        cfkeywordlistService.create(newkeywordlist);
        keywordlist = cfkeywordlistService.findAll();
        keywords = cfkeywordService.findAll();
    } catch (ConstraintViolationException ex) {
        LOGGER.error(ex.getMessage());
    }
}
Also used : CfKeywordlist(io.clownfish.clownfish.dbentities.CfKeywordlist) ConstraintViolationException(jakarta.validation.ConstraintViolationException) NoResultException(javax.persistence.NoResultException)

Example 8 with CfKeywordlist

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

the class CfKeywordlistDAOImpl method findByName.

@Override
public CfKeywordlist findByName(String name) {
    Session session = this.sessionFactory.getCurrentSession();
    TypedQuery query = (TypedQuery) session.getNamedQuery("CfKeywordlist.findByName");
    query.setParameter("name", name);
    CfKeywordlist cfkeywordlist = (CfKeywordlist) query.getSingleResult();
    return cfkeywordlist;
}
Also used : CfKeywordlist(io.clownfish.clownfish.dbentities.CfKeywordlist) TypedQuery(javax.persistence.TypedQuery) Session(org.hibernate.Session)

Example 9 with CfKeywordlist

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

the class CfKeywordlistDAOImpl method findById.

@Override
public CfKeywordlist findById(Long id) {
    Session session = this.sessionFactory.getCurrentSession();
    TypedQuery query = (TypedQuery) session.getNamedQuery("CfKeywordlist.findById");
    query.setParameter("id", id);
    CfKeywordlist cfkeywordlist = (CfKeywordlist) query.getSingleResult();
    return cfkeywordlist;
}
Also used : CfKeywordlist(io.clownfish.clownfish.dbentities.CfKeywordlist) TypedQuery(javax.persistence.TypedQuery) Session(org.hibernate.Session)

Example 10 with CfKeywordlist

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

the class CfKeywordlistDAOImpl method findAll.

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

Aggregations

CfKeywordlist (io.clownfish.clownfish.dbentities.CfKeywordlist)11 CfKeywordlistcontent (io.clownfish.clownfish.dbentities.CfKeywordlistcontent)4 CfKeyword (io.clownfish.clownfish.dbentities.CfKeyword)3 CfSitekeywordlist (io.clownfish.clownfish.dbentities.CfSitekeywordlist)3 ArrayList (java.util.ArrayList)3 TypedQuery (javax.persistence.TypedQuery)3 Session (org.hibernate.Session)3 CfAssetlist (io.clownfish.clownfish.dbentities.CfAssetlist)2 CfClasscontent (io.clownfish.clownfish.dbentities.CfClasscontent)2 CfDatasource (io.clownfish.clownfish.dbentities.CfDatasource)2 CfList (io.clownfish.clownfish.dbentities.CfList)2 CfSiteassetlist (io.clownfish.clownfish.dbentities.CfSiteassetlist)2 CfSitecontent (io.clownfish.clownfish.dbentities.CfSitecontent)2 CfSitedatasource (io.clownfish.clownfish.dbentities.CfSitedatasource)2 CfSitelist (io.clownfish.clownfish.dbentities.CfSitelist)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 FacesMessage (javax.faces.application.FacesMessage)2 Gson (com.google.gson.Gson)1 CfDiv (io.clownfish.clownfish.datamodels.CfDiv)1