/** * Determines if topic is code review * * @return true if code review, otherwise false */ public boolean isCodeReview() { return type != null && type.equals(TopicTypeName.CODE_REVIEW.getName()); }
/** * Determines if this draft is draft for code review * * @return true if code review, otherwise false */ public boolean isCodeReview() { return Objects.equals(topicType, TopicTypeName.CODE_REVIEW.getName()); }
/** * Determines if this draft is draft for provided by plugin topic. * NOTE: currently jcommune provides two topic types: "Code review" and "Discussion" all other * topic types are provided by plugins * * @return true if topic is provided by plugin otherwise false */ public boolean isPlugable() { return topicType != null && !(this.isCodeReview() || topicType.equals(TopicTypeName.DISCUSSION.getName())); } }
/** * Determines if topic is provided by plugin. * NOTE: currently jcommune provides two topic types: "Code review" and "Discussion" all other * topic types are provided by plugins * * @return true if topic is provided by plugin otherwise false */ public boolean isPlugable() { return type != null && !(this.isCodeReview() || type.equals(TopicTypeName.DISCUSSION.getName())); }
final Topic topic = topicDto.getTopic(); topic.setBranch(branch); topic.setType(TopicTypeName.CODE_REVIEW.getName());
/** * Shows page with form for new topic * * @param branchId {@link Branch} branch, where topic will be created * @return {@code ModelAndView} object with "newTopic" view, new {@link TopicDto} and branch id * @throws NotFoundException when branch was not found */ @RequestMapping(value = "/topics/new", method = RequestMethod.GET) public ModelAndView showNewTopicPage(@RequestParam(BRANCH_ID) Long branchId) throws NotFoundException { TopicDraft topicDraft = ObjectUtils.defaultIfNull( topicDraftService.getDraft(), new TopicDraft()); TopicDto dto = new TopicDto(topicDraft); Branch branch = branchService.get(branchId); dto.getTopic().setBranch(branch); dto.getTopic().setType(TopicTypeName.DISCUSSION.getName()); return new ModelAndView(TOPIC_VIEW) .addObject(TOPIC_DTO, dto) .addObject(TOPIC_DRAFT, topicDraft) .addObject(BRANCH_ID, branchId) .addObject(SUBMIT_URL, "/topics/new?branchId=" + branchId) .addObject(BREADCRUMB_LIST, breadcrumbBuilder.getNewTopicBreadcrumb(branch)); }
/** * Shows page with form for new code review * * @param branchId {@link Branch} branch, where code review will be created * @return {@code ModelAndView} object with "codeReviewForm" view, new {@link TopicDto} and branch id * @throws NotFoundException when branch was not found */ @RequestMapping(value = "/reviews/new", method = RequestMethod.GET) public ModelAndView showNewCodeReviewPage(@RequestParam(BRANCH_ID) Long branchId) throws NotFoundException { TopicDraft draft = ObjectUtils.defaultIfNull( topicDraftService.getDraft(), new TopicDraft()); TopicDto dto = new TopicDto(draft); Branch branch = branchService.get(branchId); dto.getTopic().setBranch(branch); dto.getTopic().setType(TopicTypeName.CODE_REVIEW.getName()); return new ModelAndView(CODE_REVIEW_VIEW) .addObject(TOPIC_DTO, dto) .addObject(TOPIC_DRAFT, draft) .addObject(BRANCH_ID, branchId) .addObject(SUBMIT_URL, "/reviews/new?branchId=" + branchId) .addObject(BREADCRUMB_LIST, breadcrumbBuilder.getNewTopicBreadcrumb(branch)); }
topicDto.getTopic().setType(TopicTypeName.DISCUSSION.getName());
public static TopicDraft getDefaultTopicDraft() { TopicDraft draft = new TopicDraft(getDefaultUser(), RandomStringUtils.random(5), RandomStringUtils.random(15)); draft.setPollTitle(RandomStringUtils.random(5)); draft.setPollItemsValue(RandomStringUtils.random(5) + "\n" + RandomStringUtils.random(5)); draft.setTopicType(TopicTypeName.DISCUSSION.getName()); draft.setBranchId(1L); return draft; }
public static TopicDraft getDefaultTopicDraft() { JCUser user = persist(ObjectsFactory.getDefaultUser()); Branch branch = persist(ObjectsFactory.getDefaultBranch()); TopicDraft newTopicDraft = new TopicDraft(user, RandomStringUtils.random(5), RandomStringUtils.random(15)); newTopicDraft.setTopicType(TopicTypeName.DISCUSSION.getName()); newTopicDraft.setBranchId(branch.getId()); persist(newTopicDraft); return newTopicDraft; }