Search in sources :

Example 1 with CfListcontent

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

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

the class RestDatalist method deleteDatalist.

private RestDatalistParameter deleteDatalist(RestDatalistParameter idp) {
    try {
        String token = idp.getToken();
        if (authtokenlist.checkValidToken(token)) {
            String apikey = idp.getApikey();
            if (apikeyutil.checkApiKey(apikey, "RestService")) {
                try {
                    CfList list = cflistService.findByName(idp.getListname());
                    List<CfListcontent> listcontentList = cflistcontentService.findByListref(list.getId());
                    for (CfListcontent listcontent : listcontentList) {
                        cflistcontentService.delete(listcontent);
                    }
                    cflistService.delete(list);
                    idp.setReturncode("OK");
                } catch (javax.persistence.NoResultException ex) {
                    idp.setReturncode("Datalist not found");
                }
            } else {
                idp.setReturncode("Wrong API KEY");
            }
        } else {
            idp.setReturncode("Invalid token");
        }
    } catch (javax.persistence.NoResultException ex) {
        idp.setReturncode("NoResultException");
    }
    return idp;
}
Also used : CfList(io.clownfish.clownfish.dbentities.CfList) CfListcontent(io.clownfish.clownfish.dbentities.CfListcontent)

Example 3 with CfListcontent

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

the class CfListcontentDAOImpl method findByListref.

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

Example 4 with CfListcontent

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

the class SiteTreeBean method onSelectLayoutDatalist.

/**
 * Selects a Datalist
 * @param event
 */
public void onSelectLayoutDatalist(SelectEvent event) {
    CfList selected_datalist = (CfList) event.getObject();
    previewDatalistOutput = "";
    for (CfListcontent datalistcontent : cflistcontentService.findByListref(selected_datalist.getId())) {
        CfClasscontent cc = cfclasscontentService.findById(datalistcontent.getCfListcontentPK().getClasscontentref());
        String template = templateUtility.getVersion(cc.getClassref().getTemplateref().getId(), cftemplateversionService.findMaxVersion(cc.getClassref().getTemplateref().getId()));
        if (null != cc) {
            attributcontentlist = cfattributcontentService.findByClasscontentref(cc);
            // String output = cc.getClassref().getTemplateref().getContent();
            for (CfAttributcontent attributcontent : attributcontentlist) {
                template = template.replaceAll("#" + attributcontent.getAttributref().getName() + "#", attributcontent.toString());
            }
            previewDatalistOutput += template;
        }
    }
}
Also used : CfList(io.clownfish.clownfish.dbentities.CfList) CfAttributcontent(io.clownfish.clownfish.dbentities.CfAttributcontent) CfListcontent(io.clownfish.clownfish.dbentities.CfListcontent) CfClasscontent(io.clownfish.clownfish.dbentities.CfClasscontent)

Example 5 with CfListcontent

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

Aggregations

CfListcontent (io.clownfish.clownfish.dbentities.CfListcontent)28 CfClasscontent (io.clownfish.clownfish.dbentities.CfClasscontent)22 CfList (io.clownfish.clownfish.dbentities.CfList)19 CfAttributcontent (io.clownfish.clownfish.dbentities.CfAttributcontent)14 ArrayList (java.util.ArrayList)13 Map (java.util.Map)13 HashMap (java.util.HashMap)12 Gson (com.google.gson.Gson)11 List (java.util.List)10 Session (org.hibernate.Session)9 CfClass (io.clownfish.clownfish.dbentities.CfClass)7 CfClassService (io.clownfish.clownfish.serviceinterface.CfClassService)7 CfClasscontentKeywordService (io.clownfish.clownfish.serviceinterface.CfClasscontentKeywordService)7 CfClasscontentService (io.clownfish.clownfish.serviceinterface.CfClasscontentService)7 CfKeywordService (io.clownfish.clownfish.serviceinterface.CfKeywordService)7 CfListService (io.clownfish.clownfish.serviceinterface.CfListService)7 CfListcontentService (io.clownfish.clownfish.serviceinterface.CfListcontentService)7 IOException (java.io.IOException)7 Query (org.hibernate.query.Query)7 Logger (org.slf4j.Logger)7