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