Package org.jtalks.jcommune.model.entity

Examples of org.jtalks.jcommune.model.entity.Branch


     */
    @Override
    public void fillStatisticInfo(List<org.jtalks.common.model.entity.Branch> branches) {

        for (org.jtalks.common.model.entity.Branch commonBranch : branches) {
            Branch jcommuneBranch = (Branch) commonBranch;
            int postsCount = getDao().getCountPostsInBranch(jcommuneBranch);
            jcommuneBranch.setPostsCount(postsCount);
            int topicsCount = topicDao.countTopics(jcommuneBranch);
            jcommuneBranch.setTopicsCount(topicsCount);
            if (jcommuneBranch.getLastPost() == null) {
                lastPostService.refreshLastPostInBranch(jcommuneBranch);
            }
            //TODO Was removed till milestone 2 due to performance issues
//            JCUser user = userService.getCurrentUser();
//            if (!user.isAnonymous()) {
View Full Code Here


    /**
     * {@inheritDoc}
     */
    @Override
    public Branch deleteAllTopics(long branchId) throws NotFoundException {
        Branch branch = get(branchId);

        // Create tmp list to avoid ConcurrentModificationException
        List<Topic> loopList = new ArrayList<>(branch.getTopics());
        for (Topic topic : loopList) {
            topicService.deleteTopicSilent(topic.getId());
        }

        logger.info("All topics for branch \"{}\" were deleted. " +
                "Branch id: {}", branch.getName(), branch.getId());
        return branch;
    }
View Full Code Here

     */
    @Override
    @PreAuthorize("hasPermission(#componentId, 'COMPONENT', 'GeneralPermission.ADMIN')")
    public void changeBranchInfo(long componentId, long branchId, String title, String description)
            throws NotFoundException {
        Branch branch = get(branchId);
        branch.setName(title);
        branch.setDescription(description);
        getDao().saveOrUpdate(branch);
    }
View Full Code Here

     */
    @Override
    @PreAuthorize("hasPermission(#componentId, 'COMPONENT', 'GeneralPermission.ADMIN')")
    public void createNewBranch(long componentId, long sectionId, String title, String description) {
        Section section = sectionDao.get(sectionId);
        Branch branch = new Branch(title, description);
        branch.setSection(section);
        section.addOrUpdateBranch(branch);
        sectionDao.saveOrUpdate(section);
        //add default permission to view topics (for group Registered users)
        Group registeredUsersGroup = groupDao.getGroupByName(AdministrationGroup.USER.getName());
        Collection<Group> groups = Arrays.asList(registeredUsersGroup);
View Full Code Here

        branchLastPostService = new TransactionalBranchLastPostService(postDao, branchDao);
    }

    @Test
    public void testUpdateLastPostInBranchWhenPostDeletedIsLastPost() {
        Branch branchOfDeletedPost = new Branch(BRANCH_NAME, BRANCH_DESCRIPTION);
        Post expectedNewLastPost = new Post(null, null);
        when(postDao.getLastPostFor(branchOfDeletedPost))
                .thenReturn(expectedNewLastPost);

        branchLastPostService.refreshLastPostInBranch(branchOfDeletedPost);
        Post actualNewLastPost = branchOfDeletedPost.getLastPost();

        assertEquals(actualNewLastPost, expectedNewLastPost, "Incorrect last post was setted.");
        verify(branchDao).saveOrUpdate(branchOfDeletedPost);
        verify(postDao).getLastPostFor(branchOfDeletedPost);
    }
View Full Code Here

     */
    @Override
    @PreAuthorize("hasPermission(#componentId, 'COMPONENT', 'GeneralPermission.ADMIN')")
    public void changeBranchPermissions(long componentId, long branchId, boolean allowed, PermissionChanges changes)
            throws NotFoundException {
        Branch branch = get(branchId);
        if (allowed) {
            permissionService.changeGrants(branch, changes);
        } else {
            permissionService.changeRestrictions(branch, changes);
        }
View Full Code Here

            throws NotFoundException{
        VelocityEngine engine = new VelocityEngine(getProperties());
        engine.init();
        Map<String, Object> data = getDefaultModel(request);
        if (result.hasErrors()) {
            Branch branch = TransactionalPluginBranchService.getInstance().get(branchId);
            topicDto.getTopic().setBranch(branch);
            data.put("breadcrumbList", breadcrumbBuilder.getForumBreadcrumb(topicDto.getTopic()));
            data.put("topicDto", topicDto);
            data.put("result", result);
            model.addAttribute("content", VelocityEngineUtils.mergeTemplateIntoString(engine,
View Full Code Here

    @RequestMapping(value = "new", method = RequestMethod.GET)
    public String showNewQuestionPage(@RequestParam(BRANCH_ID) Long branchId, Model model, HttpServletRequest request)
            throws NotFoundException {
        VelocityEngine engine = new VelocityEngine(getProperties());
        engine.init();
        Branch branch = TransactionalPluginBranchService.getInstance().get(branchId);
        Topic topic = new Topic();
        topic.setBranch(branch);
        TopicDto dto = new TopicDto(topic);
        Map<String, Object> data = getDefaultModel(request);
        data.put("breadcrumbList", breadcrumbBuilder.getForumBreadcrumb(topic));
View Full Code Here

    @BeforeMethod
    public void setUp() {
        initMocks(this);
        service = new TransactionalSubscriptionService(userService, branchDao, topicDao, codeReviewDao);
        branch = new Branch("name", "description");
        topic = new Topic(user, "title");
        codeReview = new CodeReview();
        topic.setCodeReview(codeReview);
        codeReview.setTopic(topic);
        when(userService.getCurrentUser()).thenReturn(user);
View Full Code Here

    public void deletePost(Post post) {
        JCUser user = post.getUserCreated();
        user.setPostCount(user.getPostCount() - 1);
        Topic topic = post.getTopic();
        topic.removePost(post);
        Branch branch = topic.getBranch();
        boolean deletedPostIsLastPostInBranch = branch.isLastPost(post);
        if (deletedPostIsLastPostInBranch) {
            branch.clearLastPost();
        }

        if (post.getCreationDate().equals(topic.getModificationDate())) {
            topic.recalculateModificationDate();
        }
View Full Code Here

TOP

Related Classes of org.jtalks.jcommune.model.entity.Branch

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.