Search in sources :

Example 1 with CfSitecontent

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

the class RestContent method destroyContent.

private RestContentParameter destroyContent(RestContentParameter ucp) {
    try {
        String token = ucp.getToken();
        if (authtokenlist.checkValidToken(token)) {
            String apikey = ucp.getApikey();
            if (apikeyutil.checkApiKey(apikey, "RestService")) {
                CfClass clazz = cfclassService.findByName(ucp.getClassname());
                try {
                    CfClasscontent classcontent = cfclasscontentService.findByName(ucp.getContentname());
                    // Delete corresponding attributcontent entries
                    List<CfAttributcontent> attributcontentlistdummy = cfattributcontentService.findByClasscontentref(classcontent);
                    for (CfAttributcontent attributcontent : attributcontentlistdummy) {
                        cfattributcontentService.delete(attributcontent);
                    }
                    // Delete corresponding listcontent entries
                    List<CfListcontent> selectedcontent = cflistcontentService.findByClasscontentref(classcontent.getId());
                    for (CfListcontent listcontent : selectedcontent) {
                        cflistcontentService.delete(listcontent);
                    }
                    // Delete corresponding keywordcontent entries
                    List<CfClasscontentkeyword> keywordcontentdummy = cfclasscontentkeywordService.findByClassContentRef(classcontent.getId());
                    for (CfClasscontentkeyword keywordcontent : keywordcontentdummy) {
                        cfclasscontentkeywordService.delete(keywordcontent);
                    }
                    // Delete corresponding sitecontent entries
                    List<CfSitecontent> sitecontentdummy = cfsitecontentService.findByClasscontentref(classcontent.getId());
                    for (CfSitecontent sitecontent : sitecontentdummy) {
                        cfsitecontentService.delete(sitecontent);
                    }
                    cfclasscontentService.delete(classcontent);
                    try {
                        hibernateUtil.deleteContent(classcontent);
                    } catch (javax.persistence.NoResultException ex) {
                        LOGGER.warn(ex.getMessage());
                    }
                    ucp.setReturncode("OK");
                } catch (javax.persistence.NoResultException ex) {
                    ucp.setReturncode("Classcontent not found");
                }
            } else {
                ucp.setReturncode("Wrong API KEY");
            }
        } else {
            ucp.setReturncode("Invalid token");
        }
    } catch (javax.persistence.NoResultException ex) {
        ucp.setReturncode("NoResultException");
    }
    return ucp;
}
Also used : CfClasscontentkeyword(io.clownfish.clownfish.dbentities.CfClasscontentkeyword) CfClass(io.clownfish.clownfish.dbentities.CfClass) CfSitecontent(io.clownfish.clownfish.dbentities.CfSitecontent) CfListcontent(io.clownfish.clownfish.dbentities.CfListcontent) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent) CfAttributcontent(io.clownfish.clownfish.dbentities.CfAttributcontent)

Example 2 with CfSitecontent

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

the class CfSitecontentDAOImpl method findBySiteref.

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

Example 3 with CfSitecontent

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

the class CfSitecontentDAOImpl method findAll.

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

Example 4 with CfSitecontent

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

the class ScrapyardList method onDeleteContent.

public void onDeleteContent(ActionEvent actionEvent) {
    if (selectedContent != null) {
        // Delete corresponding attributcontent entries
        List<CfAttributcontent> attributcontentlistdummy = cfattributcontentService.findByClasscontentref(selectedContent);
        for (CfAttributcontent attributcontent : attributcontentlistdummy) {
            cfattributcontentService.delete(attributcontent);
        }
        // Delete corresponding listcontent entries
        List<CfListcontent> selectedcontent = cflistcontentService.findByClasscontentref(selectedContent.getId());
        for (CfListcontent listcontent : selectedcontent) {
            cflistcontentService.delete(listcontent);
        }
        // Delete corresponding keywordcontent entries
        List<CfClasscontentkeyword> keywordcontentdummy = cfclasscontentkeywordService.findByClassContentRef(selectedContent.getId());
        for (CfClasscontentkeyword keywordcontent : keywordcontentdummy) {
            cfclasscontentkeywordService.delete(keywordcontent);
        }
        // Delete corresponding sitecontent entries
        List<CfSitecontent> sitecontentdummy = cfsitecontentService.findByClasscontentref(selectedContent.getId());
        for (CfSitecontent sitecontent : sitecontentdummy) {
            cfsitecontentService.delete(sitecontent);
        }
        cfclasscontentService.delete(selectedContent);
        try {
            hibernateUtil.deleteContent(selectedContent);
        } catch (javax.persistence.NoResultException ex) {
            LOGGER.warn(ex.getMessage());
        }
        classcontentlist = cfclasscontentService.findByScrapped(true);
    }
}
Also used : CfClasscontentkeyword(io.clownfish.clownfish.dbentities.CfClasscontentkeyword) CfSitecontent(io.clownfish.clownfish.dbentities.CfSitecontent) CfAttributcontent(io.clownfish.clownfish.dbentities.CfAttributcontent) CfListcontent(io.clownfish.clownfish.dbentities.CfListcontent)

Example 5 with CfSitecontent

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

the class SiteUtil method getSitecontentmapList.

public Map getSitecontentmapList(List<CfSitecontent> sitecontentlist) {
    Map sitecontentmapdummy = new LinkedHashMap();
    for (CfSitecontent sitecontent : sitecontentlist) {
        CfClasscontent classcontent = cfclasscontentService.findById(sitecontent.getCfSitecontentPK().getClasscontentref());
        if (null != classcontent) {
            List<CfAttributcontent> attributcontentlist = new ArrayList<>();
            attributcontentlist.addAll(cfattributcontentService.findByClasscontentref(classcontent));
            if (0 == useHibernate) {
                sitecontentmapdummy.put(classcontent.getName(), classutil.getattributmap(classcontent));
            } else {
                sitecontentmapdummy.put(classcontent.getName(), hibernateutil.getContent(classcontent.getClassref().getName(), classcontent.getId()));
            }
        } else {
            LOGGER.warn("CLASSCONTENT NOT FOUND (deleted or on scrapyard): " + sitecontent.getCfSitecontentPK().getClasscontentref());
        }
    }
    return sitecontentmapdummy;
}
Also used : CfSitecontent(io.clownfish.clownfish.dbentities.CfSitecontent) ArrayList(java.util.ArrayList) CfAttributcontent(io.clownfish.clownfish.dbentities.CfAttributcontent) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

CfSitecontent (io.clownfish.clownfish.dbentities.CfSitecontent)9 CfClasscontent (io.clownfish.clownfish.dbentities.CfClasscontent)5 CfAttributcontent (io.clownfish.clownfish.dbentities.CfAttributcontent)3 CfClasscontentkeyword (io.clownfish.clownfish.dbentities.CfClasscontentkeyword)3 CfListcontent (io.clownfish.clownfish.dbentities.CfListcontent)3 CfAssetlist (io.clownfish.clownfish.dbentities.CfAssetlist)2 CfClass (io.clownfish.clownfish.dbentities.CfClass)2 CfDatasource (io.clownfish.clownfish.dbentities.CfDatasource)2 CfKeywordlist (io.clownfish.clownfish.dbentities.CfKeywordlist)2 CfList (io.clownfish.clownfish.dbentities.CfList)2 CfSiteassetlist (io.clownfish.clownfish.dbentities.CfSiteassetlist)2 CfSitedatasource (io.clownfish.clownfish.dbentities.CfSitedatasource)2 CfSitekeywordlist (io.clownfish.clownfish.dbentities.CfSitekeywordlist)2 CfSitelist (io.clownfish.clownfish.dbentities.CfSitelist)2 FacesMessage (javax.faces.application.FacesMessage)2 TypedQuery (javax.persistence.TypedQuery)2 Session (org.hibernate.Session)2 PropertyList (io.clownfish.clownfish.beans.PropertyList)1 CfDiv (io.clownfish.clownfish.datamodels.CfDiv)1 CfLayout (io.clownfish.clownfish.datamodels.CfLayout)1