use of fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply in project muikku by otavanopisto.
the class ForumController method createForumThreadReply.
public ForumThreadReply createForumThreadReply(ForumThread thread, String message, ForumThreadReply parentReply) {
if (thread.getLocked()) {
logger.severe("Tried to create a forum thread reply for locked thread");
return null;
} else {
ForumThreadReply reply = forumThreadReplyDAO.create(thread.getForumArea(), thread, clean(message), sessionController.getLoggedUserEntity(), parentReply);
forumThreadDAO.updateThreadUpdated(thread, reply.getCreated());
return reply;
}
}
use of fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply in project muikku by otavanopisto.
the class ForumController method deleteThread.
public void deleteThread(ForumThread thread) {
List<ForumThreadReply> replies = forumThreadReplyDAO.listByForumThread(thread);
for (ForumThreadReply reply : replies) {
forumThreadReplyDAO.updateParentReply(reply, null);
}
for (ForumThreadReply reply : replies) {
forumThreadReplyDAO.delete(reply);
}
forumThreadDAO.delete(thread);
}
use of fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply in project muikku by otavanopisto.
the class AcceptanceTestsRESTService method deleteWorkspaceDiscussion.
@DELETE
@Path("/workspaces/{WORKSPACEENTITYID}/discussiongroups/{GROUPID}/discussions/{DISCUSSIONID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteWorkspaceDiscussion(@PathParam("WORKSPACEENTITYID") Long workspaceEntityId, @PathParam("GROUPID") Long groupId, @PathParam("DISCUSSIONID") Long discussionId) {
WorkspaceEntity workspaceEntity = workspaceEntityController.findWorkspaceEntityById(workspaceEntityId);
if (workspaceEntity == null) {
return Response.status(Status.NOT_FOUND).entity("WorkspaceEntity not found").build();
}
ForumAreaGroup group = forumController.findForumAreaGroup(groupId);
if (group == null) {
return Response.status(Status.NOT_FOUND).entity("Group not found").build();
}
ForumArea forumArea = forumController.getForumArea(discussionId);
if (forumArea == null) {
return Response.status(Status.NOT_FOUND).entity("Discussion not found").build();
}
List<ForumThread> threads = forumController.listForumThreads(forumArea, 0, Integer.MAX_VALUE, true);
for (ForumThread thread : threads) {
List<ForumThreadReply> replies = forumController.listForumThreadReplies(thread, 0, Integer.MAX_VALUE, true);
for (ForumThreadReply reply : replies) {
forumController.deleteReply(reply);
}
forumController.deleteThread(thread);
}
forumController.deleteArea(forumArea);
return Response.noContent().build();
}
use of fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply in project muikku by otavanopisto.
the class ForumAcceptanceTestsRESTService method deleteForumThreadReply.
@DELETE
@Path("/areas/{AREAID}/threads/{THREADID}/replies/{REPLYID}")
@RESTPermit(handling = Handling.UNSECURED)
public Response deleteForumThreadReply(@PathParam("AREAID") Long forumAreaId, @PathParam("THREADID") Long forumThreadId, @PathParam("REPLYID") Long forumThreadReplyId) {
ForumThreadReply forumThreadReply = forumController.getForumThreadReply(forumThreadReplyId);
if (forumThreadReply == null) {
return Response.status(Status.NOT_FOUND).entity("ForumThreadReply not found").build();
}
forumController.deleteReply(forumThreadReply);
return Response.noContent().build();
}
use of fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply in project muikku by otavanopisto.
the class ForumThreadReplyDAO method countByThread.
public Long countByThread(ForumThread thread) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<Long> criteria = criteriaBuilder.createQuery(Long.class);
Root<ForumThreadReply> root = criteria.from(ForumThreadReply.class);
criteria.select(criteriaBuilder.count(root));
criteria.where(criteriaBuilder.and(criteriaBuilder.equal(root.get(ForumThreadReply_.thread), thread), criteriaBuilder.equal(root.get(ForumThreadReply_.archived), Boolean.FALSE)));
return entityManager.createQuery(criteria).getSingleResult();
}
Aggregations