use of io.clownfish.clownfish.dbentities.CfClasscontentkeyword 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.CfClasscontentkeyword in project Clownfish by rawdog71.
the class RestKeywordContent method deleteKeywordContent.
private RestKeywordContentParameter deleteKeywordContent(RestKeywordContentParameter iklp) {
try {
String token = iklp.getToken();
if (authtokenlist.checkValidToken(token)) {
String apikey = iklp.getApikey();
if (apikeyutil.checkApiKey(apikey, "RestService")) {
try {
CfClasscontentkeyword contentkeyword = cfclasscontentkeywordService.findByClasscontentRefAndKeywordRef(iklp.getContentref(), iklp.getKeywordref());
cfclasscontentkeywordService.delete(contentkeyword);
iklp.setReturncode("OK");
} catch (javax.persistence.NoResultException ex) {
LOGGER.warn("ContentKeyword not found");
iklp.setReturncode("ContentKeyword not found");
}
} else {
iklp.setReturncode("Wrong API KEY");
}
} else {
iklp.setReturncode("Invalid token");
}
} catch (javax.persistence.NoResultException ex) {
LOGGER.error("NoResultException");
iklp.setReturncode("NoResultException");
}
return iklp;
}
use of io.clownfish.clownfish.dbentities.CfClasscontentkeyword in project Clownfish by rawdog71.
the class CfClasscontentKeywordDAOImpl method findByKeywordRef.
@Override
public List<CfClasscontentkeyword> findByKeywordRef(Long id) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery query = (TypedQuery) session.getNamedQuery("CfClasscontentkeyword.findByKeywordref");
query.setParameter("keywordref", id);
List<CfClasscontentkeyword> cfcontentkeywordlist = query.getResultList();
return cfcontentkeywordlist;
}
use of io.clownfish.clownfish.dbentities.CfClasscontentkeyword in project Clownfish by rawdog71.
the class CfClasscontentKeywordDAOImpl method findAll.
@Override
public List<CfClasscontentkeyword> findAll() {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery query = (TypedQuery) session.getNamedQuery("CfClasscontentkeyword.findAll");
List<CfClasscontentkeyword> cfcontentkeywordlist = query.getResultList();
return cfcontentkeywordlist;
}
use of io.clownfish.clownfish.dbentities.CfClasscontentkeyword in project Clownfish by rawdog71.
the class CfClasscontentKeywordDAOImpl method findByClassContentRef.
@Override
public List<CfClasscontentkeyword> findByClassContentRef(Long id) {
Session session = this.sessionFactory.getCurrentSession();
TypedQuery query = (TypedQuery) session.getNamedQuery("CfClasscontentkeyword.findByClasscontentref");
query.setParameter("classcontentref", id);
List<CfClasscontentkeyword> cfcontentkeywordlist = query.getResultList();
return cfcontentkeywordlist;
}
Aggregations