Search in sources :

Example 6 with ForumThreadReply

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;
    }
}
Also used : ForumThreadReply(fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply)

Example 7 with ForumThreadReply

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);
}
Also used : ForumThreadReply(fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply)

Example 8 with ForumThreadReply

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();
}
Also used : WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity) ForumAreaGroup(fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup) ForumThread(fi.otavanopisto.muikku.plugins.forum.model.ForumThread) ForumArea(fi.otavanopisto.muikku.plugins.forum.model.ForumArea) EnvironmentForumArea(fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea) WorkspaceForumArea(fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea) ForumThreadReply(fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Example 9 with ForumThreadReply

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();
}
Also used : ForumThreadReply(fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) RESTPermit(fi.otavanopisto.security.rest.RESTPermit)

Example 10 with ForumThreadReply

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();
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) EntityManager(javax.persistence.EntityManager) ForumThreadReply(fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply)

Aggregations

ForumThreadReply (fi.otavanopisto.muikku.plugins.forum.model.ForumThreadReply)21 RESTPermit (fi.otavanopisto.security.rest.RESTPermit)12 Path (javax.ws.rs.Path)12 ForumArea (fi.otavanopisto.muikku.plugins.forum.model.ForumArea)11 ForumThread (fi.otavanopisto.muikku.plugins.forum.model.ForumThread)11 WorkspaceForumArea (fi.otavanopisto.muikku.plugins.forum.model.WorkspaceForumArea)7 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)6 EnvironmentForumArea (fi.otavanopisto.muikku.plugins.forum.model.EnvironmentForumArea)6 EntityManager (javax.persistence.EntityManager)4 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)4 DELETE (javax.ws.rs.DELETE)4 GET (javax.ws.rs.GET)4 ForumAreaGroup (fi.otavanopisto.muikku.plugins.forum.model.ForumAreaGroup)2 POST (javax.ws.rs.POST)2 PUT (javax.ws.rs.PUT)2