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;
}
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;
}
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;
}
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;
}
}
}
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);
}
}
Aggregations